@next-bricks/nav 1.18.4 → 1.19.0

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/types.json CHANGED
@@ -593,6 +593,19 @@
593
593
  "events": [],
594
594
  "methods": []
595
595
  },
596
+ "eo-sidebar-menu": {
597
+ "properties": [
598
+ {
599
+ "name": "menuCollapsed",
600
+ "annotation": {
601
+ "type": "keyword",
602
+ "value": "boolean"
603
+ }
604
+ }
605
+ ],
606
+ "events": [],
607
+ "methods": []
608
+ },
596
609
  "eo-sidebar-menu-submenu": {
597
610
  "properties": [
598
611
  {
@@ -630,19 +643,6 @@
630
643
  "events": [],
631
644
  "methods": []
632
645
  },
633
- "eo-sidebar-menu": {
634
- "properties": [
635
- {
636
- "name": "menuCollapsed",
637
- "annotation": {
638
- "type": "keyword",
639
- "value": "boolean"
640
- }
641
- }
642
- ],
643
- "events": [],
644
- "methods": []
645
- },
646
646
  "eo-directory-tree-internal-node": {
647
647
  "properties": [
648
648
  {
@@ -1384,92 +1384,6 @@
1384
1384
  ],
1385
1385
  "methods": []
1386
1386
  },
1387
- "nav.poll-announce": {
1388
- "properties": [
1389
- {
1390
- "name": "pollEnabled",
1391
- "annotation": {
1392
- "type": "keyword",
1393
- "value": "boolean"
1394
- }
1395
- },
1396
- {
1397
- "name": "realTimeMessage",
1398
- "annotation": {
1399
- "type": "reference",
1400
- "typeName": {
1401
- "type": "identifier",
1402
- "name": "Message"
1403
- }
1404
- }
1405
- }
1406
- ],
1407
- "events": [
1408
- {
1409
- "name": "notification.close",
1410
- "detail": {
1411
- "annotation": {
1412
- "type": "keyword",
1413
- "value": "void"
1414
- }
1415
- }
1416
- },
1417
- {
1418
- "name": "notification.open",
1419
- "detail": {
1420
- "annotation": {
1421
- "type": "keyword",
1422
- "value": "void"
1423
- }
1424
- }
1425
- }
1426
- ],
1427
- "methods": [],
1428
- "types": [
1429
- {
1430
- "type": "interface",
1431
- "name": "Message",
1432
- "body": [
1433
- {
1434
- "type": "propertySignature",
1435
- "key": {
1436
- "type": "identifier",
1437
- "name": "title"
1438
- },
1439
- "annotation": {
1440
- "type": "keyword",
1441
- "value": "string"
1442
- },
1443
- "computed": false
1444
- },
1445
- {
1446
- "type": "propertySignature",
1447
- "key": {
1448
- "type": "identifier",
1449
- "name": "data"
1450
- },
1451
- "annotation": {
1452
- "type": "keyword",
1453
- "value": "string"
1454
- },
1455
- "computed": false
1456
- },
1457
- {
1458
- "type": "propertySignature",
1459
- "key": {
1460
- "type": "identifier",
1461
- "name": "instanceId"
1462
- },
1463
- "annotation": {
1464
- "type": "keyword",
1465
- "value": "string"
1466
- },
1467
- "computed": false
1468
- }
1469
- ]
1470
- }
1471
- ]
1472
- },
1473
1387
  "nav.get-menu-config-options": {
1474
1388
  "type": "provider",
1475
1389
  "params": [
@@ -1859,6 +1773,92 @@
1859
1773
  }
1860
1774
  ]
1861
1775
  },
1776
+ "nav.poll-announce": {
1777
+ "properties": [
1778
+ {
1779
+ "name": "pollEnabled",
1780
+ "annotation": {
1781
+ "type": "keyword",
1782
+ "value": "boolean"
1783
+ }
1784
+ },
1785
+ {
1786
+ "name": "realTimeMessage",
1787
+ "annotation": {
1788
+ "type": "reference",
1789
+ "typeName": {
1790
+ "type": "identifier",
1791
+ "name": "Message"
1792
+ }
1793
+ }
1794
+ }
1795
+ ],
1796
+ "events": [
1797
+ {
1798
+ "name": "notification.close",
1799
+ "detail": {
1800
+ "annotation": {
1801
+ "type": "keyword",
1802
+ "value": "void"
1803
+ }
1804
+ }
1805
+ },
1806
+ {
1807
+ "name": "notification.open",
1808
+ "detail": {
1809
+ "annotation": {
1810
+ "type": "keyword",
1811
+ "value": "void"
1812
+ }
1813
+ }
1814
+ }
1815
+ ],
1816
+ "methods": [],
1817
+ "types": [
1818
+ {
1819
+ "type": "interface",
1820
+ "name": "Message",
1821
+ "body": [
1822
+ {
1823
+ "type": "propertySignature",
1824
+ "key": {
1825
+ "type": "identifier",
1826
+ "name": "title"
1827
+ },
1828
+ "annotation": {
1829
+ "type": "keyword",
1830
+ "value": "string"
1831
+ },
1832
+ "computed": false
1833
+ },
1834
+ {
1835
+ "type": "propertySignature",
1836
+ "key": {
1837
+ "type": "identifier",
1838
+ "name": "data"
1839
+ },
1840
+ "annotation": {
1841
+ "type": "keyword",
1842
+ "value": "string"
1843
+ },
1844
+ "computed": false
1845
+ },
1846
+ {
1847
+ "type": "propertySignature",
1848
+ "key": {
1849
+ "type": "identifier",
1850
+ "name": "instanceId"
1851
+ },
1852
+ "annotation": {
1853
+ "type": "keyword",
1854
+ "value": "string"
1855
+ },
1856
+ "computed": false
1857
+ }
1858
+ ]
1859
+ }
1860
+ ]
1861
+ },
1862
1862
  "eo-directory-tree": {
1863
1863
  "properties": [
1864
1864
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-bricks/nav",
3
- "version": "1.18.4",
3
+ "version": "1.19.0",
4
4
  "homepage": "https://github.com/easyops-cn/next-bricks/tree/master/bricks/nav",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,5 +43,5 @@
43
43
  "@next-bricks/form": "*",
44
44
  "@next-bricks/icons": "*"
45
45
  },
46
- "gitHead": "61f7df5abe941b15ae1fed6a231764fedb105db7"
46
+ "gitHead": "a48b628dc9f3b8c24d8b54f194acab0ebd3f1deb"
47
47
  }
@@ -1,2 +0,0 @@
1
- "use strict";(globalThis.webpackChunk_next_bricks_nav=globalThis.webpackChunk_next_bricks_nav||[]).push([[2133],{2133:(e,t,n)=>{n.d(t,{fm:()=>M,ir:()=>_,pU:()=>O,sZ:()=>T});var s=n(8769),r=n(1230),i=n(3289),o=n(4612),a=n(4864),c=n(9393),p=n(3346),l=n(7296),u=n(2824),d=n(2887),m=n(8406);const f=10,h=10;var I,g=n(6659),y=n(1030);async function v(){return(await(0,l.K)({page:1,pageSize:f},{interceptorParams:{ignoreLoadingBar:!0},noAbortOnRouteChange:!0})).list}function w(e,t){return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)?e:null}function k(e,t){return e.id.toLowerCase().includes(t)||e.name.toLowerCase().includes(t)||e.description&&e.description.toLowerCase().includes(t)?e:null}const b=`launchpad-recent-visits:${null===(I=i.auth.getAuth())||void 0===I?void 0:I.org}`,A=new o.G(localStorage);let F=[],C=new Map,S=new Map,B=!1,P=[],x=!1,E=[],L=!1;const _=new a.x((async()=>{({menuGroups:F,microAppsById:C,customLinksById:S}=await async function(){const e=await(0,p.i)({},{interceptorParams:{ignoreLoadingBar:!0},noAbortOnRouteChange:!0}),t=new Map;for(const n of e.storyboards){const e=n.app;e.localeName=(0,g.F)(e.locales,e.name),t.set(e.id,e)}const n=[],s=new Map;for(const r of e.desktops){const e=[];for(const n of r.items)switch(n.type){case"app":{const s=t.get(n.id);s&&e.push({...n,name:s.localeName,url:s.homepage,menuIcon:s.menuIcon});break}case"custom":e.push(n),s.set(n.id,n);break;case"dir":{const r=[];for(const e of n.items)if("app"===e.type){const n=t.get(e.id);n&&r.push({...e,name:n.localeName,url:n.homepage,menuIcon:n.menuIcon})}else"custom"===e.type&&(r.push(e),s.set(e.id,e));r.length>0&&e.push({...n,items:r});break}}e.length>0&&n.push({...r,items:e})}return{menuGroups:n,microAppsById:t,customLinksById:s}}()),B=!0})),M=new a.x((async()=>{P=await async function(){const e=await v(),t=[];for(const n of e)if("microApp"===n.type){const e=n.relatedApp;e.localeName=(0,g.F)(e.locales,e.name),t.push({favoriteId:n.instanceId,type:"app",name:e.localeName,id:e.appId,url:e.homepage,instanceId:e.instanceId,menuIcon:e.menuIcon})}else if("customItem"===n.type){const e=n.relatedCustomItem;t.push({favoriteId:n.instanceId,type:"custom",name:e.name,id:e.id,url:e.url,menuIcon:e.menuIcon})}else"link"===n.type&&t.push({favoriteId:n.instanceId,type:"link",name:n.name,url:n.link,menuIcon:n.icon});return t}(),x=!0})),O=new a.x((async()=>{E=await async function(){const e=(await(0,m.y)("MICRO_APP_CATEGORY@EASYOPS",{fields:["id","type","name","icon","order","platformApps.appId","platformApps.name","platformApps.homepage","platformApps.description","platformApps.menuIcon","platformApps.locales","platformApps._object_id","platformApps.@.order","platformItems.id","platformItems.name","platformItems.url","platformItems.description","platformItems.menuIcon","platformItems._object_id","platformItems.@.order"],page:1,page_size:300,query:{type:"platform"}})).list,t=null==e?void 0:e.map((e=>{const t=e.platformApps.map((e=>{var t;return{type:"app",name:(0,g.F)(e.locales,e.name),id:e.appId,url:e.homepage,menuIcon:e.menuIcon,description:e.description,instanceId:e.instanceId,order:null===(t=e["@"])||void 0===t?void 0:t.order}})),n=e.platformItems.map((e=>{var t;return{type:"custom",name:e.name,id:e.id,url:e.url,menuIcon:e.menuIcon,description:e.description,instanceId:e.instanceId,order:null===(t=e["@"])||void 0===t?void 0:t.order}})),s=(0,y.sortBy)([...t,...n],"order");return{instanceId:e.instanceId,id:e.id,name:e.name,icon:e.icon,order:e.order,items:s}}));return[{id:"#all",name:"全部",icon:{lib:"easyops",category:"second-menu",icon:"sprint-planning-second-menu"},items:[]},...(0,y.sortBy)(t,"order")]}(),L=!0})),N=e=>(0,c.Ds)({type:"error",message:(0,r.httpErrorToString)(e)});function T(e){const[t,n]=(0,s.useState)(F),[i,o]=(0,s.useState)(C),[a,p]=(0,s.useState)(S),[l,m]=(0,s.useState)(""),[I,g]=(0,s.useState)(!B),[y,T]=(0,s.useState)(!x),[R,j]=(0,s.useState)(!L),[q,z]=(0,s.useState)([]),[D,J]=(0,s.useState)([]),[V,Y]=(0,s.useState)(P),[$,H]=(0,s.useState)(E);(0,s.useEffect)((()=>{e&&!I&&(n(F),o(C),p(S))}),[e,I]),(0,s.useEffect)((()=>{e&&!y&&Y(P)}),[e,y]),(0,s.useEffect)((()=>{e&&!R&&H(E)}),[e,R]),(0,s.useEffect)((()=>{var t;e&&z(null!==(t=A.getItem(b))&&void 0!==t?t:[])}),[e]),(0,s.useEffect)((()=>{e&&(async()=>{try{await _.fetch(),g(!1)}catch(e){(0,r.handleHttpError)(e)}})()}),[e]),(0,s.useEffect)((()=>{e&&(async()=>{try{await M.fetch(),T(!1)}catch(e){T(!1),N(e)}})()}),[e]),(0,s.useEffect)((()=>{var t;e&&null!==(t=(0,r.getRuntime)())&&void 0!==t&&t.getFeatureFlags()["launchpad-show-platform-category"]&&(async()=>{try{await O.fetch(),j(!1)}catch(e){j(!1),N(e)}})()}),[e]),(0,s.useEffect)((()=>{if(I)return;const e=q.map((e=>{if("app"===e.type){const t=i.get(e.id);return t?{type:"app",name:t.localeName,id:t.id,url:t.homepage,instanceId:t.instanceId,menuIcon:t.menuIcon}:null}return a.get(e.id)})).filter(Boolean);J(e)}),[a,I,i,q]);const K=(0,s.useCallback)((e=>{var t;let{type:n,id:s}=e;const r=null!==(t=A.getItem(b))&&void 0!==t?t:[],i=r.findIndex((e=>e.type===n&&e.id===s));i>-1&&r.splice(i,1),r.unshift({type:n,id:s}),r.length>h&&r.pop(),A.setItem(b,r)}),[]),Q=(0,s.useCallback)((e=>V.some((t=>G(e,t)))),[V]),U=(0,s.useCallback)((e=>{const t=V.findIndex((t=>"link"===e.type?t.favoriteId===e.favoriteId:G(e,t)));let n;if(t>-1){const e=V[t];n=V.slice(0,t).concat(V.slice(t+1)),async function(e){return e.favoriteId?(0,d.r)(e.favoriteId):v().then((t=>{var n;const s=null===(n=t.find((t=>{var n,s;return"app"===e.type?"microApp"===t.type&&(null===(n=t.relatedApp)||void 0===n?void 0:n.appId)===e.id:"custom"===e.type&&(null===(s=t.relatedCustomItem)||void 0===s?void 0:s.id)===e.id})))||void 0===n?void 0:n.instanceId;if(s)return(0,d.r)(s);console.error("Menu item to unstar not found:",e)}))}(e).catch(N)}else{if(V.length>=f)return void(0,c.ui)({type:"warn",title:"收藏数量已达上限",content:`当前收藏链接数量已达上限(${f}个),请删除部分收藏后再添加。`});const t={...e};n=V.concat(t),async function(e){return(0,u.k)({type:"app"===e.type?"microApp":"customItem",relatedInstanceId:e.instanceId},{interceptorParams:{ignoreLoadingBar:!0}})}(e).then((e=>{e&&(t.favoriteId=e.instanceId)}),N)}Y(n),P=n}),[V]),Z=(0,s.useMemo)((()=>function(e,t){if(!t)return e;const n=t.toLowerCase();return e.map((e=>({...e,items:e.items.map((e=>{switch(e.type){case"app":return w(e,n);case"custom":return k(e,n);case"dir":{const t=e.items.map((e=>"app"===e.type?w(e,n):"custom"===e.type?k(e,n):null)).filter(Boolean);return t.length>0?{...e,items:t}:null}}})).filter(Boolean)}))).filter((e=>e.items.length>0))}(t,l)),[t,l]),W=(0,s.useMemo)((()=>function(e,t){if(!t)return e;const n=t.toLowerCase();return e.map((e=>({...e,items:e.items.map((e=>{switch(e.type){case"app":return w(e,n);case"custom":return k(e,n)}})).filter(Boolean)})))}($,l)),[$,l]);return{loading:I,q:l,setQ:m,menuGroups:Z,loadingFavorites:y,loadingPlatformCategories:R,favorites:V,recentVisits:D,pushRecentVisit:K,isStarred:Q,toggleStar:U,platformCategories:W}}function G(e,t){return e.instanceId&&t.instanceId?t.instanceId===e.instanceId:t.type===e.type&&t.id===e.id}},9393:(e,t,n)=>{n.d(t,{Bj:()=>i,Ds:()=>c,EM:()=>o,ui:()=>a});var s=n(3049),r=n(6878);const i=(0,s.wrapBrick)("eo-icon"),o=(0,s.wrapBrick)("eo-link"),a=(0,r.unwrapProvider)("basic.show-dialog"),c=(0,r.unwrapProvider)("basic.show-notification")},4864:(e,t,n)=>{n.d(t,{x:()=>r});var s=n(4586);class r{constructor(e){(0,s.A)(this,"preFetchId",null),(0,s.A)(this,"preFetchScheduled",!1),(0,s.A)(this,"firstFetchPromise",null),(0,s.A)(this,"isFetching",!1),(0,s.A)(this,"task",void 0),this.task=e}schedulePrefetch(){if(!this.preFetchScheduled){this.preFetchScheduled=!0;const e=async()=>{this.preFetchId=null,this.fetch()};"function"==typeof window.requestIdleCallback?this.preFetchId=window.requestIdleCallback(e):this.preFetchId=setTimeout(e)}}fetch(e){let t;return this.preFetchId&&("function"==typeof window.cancelIdleCallback?cancelIdleCallback(this.preFetchId):clearTimeout(this.preFetchId),this.preFetchId=null),this.isFetching&&!e||(this.isFetching=!0,t=this.task(),t.catch((e=>{console.error(e),this.firstFetchPromise=null})).finally((()=>{this.isFetching=!1})),this.firstFetchPromise||(this.firstFetchPromise=t),!e)?this.firstFetchPromise:t}}},6659:(e,t,n)=>{n.d(t,{F:()=>r});var s=n(413);function r(e,t){var n;if(!e)return t;const r=Object.fromEntries(Object.entries(e).filter((e=>{let[t,n]=e;return n.name})).map((e=>{let[t,n]=e;return[t,n.name]})));return null!==(n=(0,s.i18nText)(r))&&void 0!==n?n:t}},4612:(e,t,n)=>{n.d(t,{G:()=>s});class s{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"brick-next-";this.storage=e,this.prefix=t}setItem(e,t){this.storage.setItem(this.prefix+e,JSON.stringify(t))}getItem(e){return JSON.parse(this.storage.getItem(this.prefix+e))}removeItem(e){return this.storage.removeItem(this.prefix+e)}clear(){return this.storage.clear()}}}}]);
2
- //# sourceMappingURL=2133.e6a6cbd3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chunks/2133.e6a6cbd3.js","mappings":"+RAAO,MAAMA,EAAkB,GAClBC,EAAsB,G,0BCiGnCC,eAAeC,IACb,aACQC,EAAAA,EAAAA,GACJ,CAAEC,KAAM,EAAGC,SAAUN,GACrB,CACEO,kBAAmB,CAAEC,kBAAkB,GACvCC,sBAAsB,KAG1BC,IACJ,CC5BA,SAASC,EAAiBC,EAAuBC,GAC/C,OAAOD,EAAKE,GAAGC,cAAcC,SAASH,IACpCD,EAAKK,KAAKF,cAAcC,SAASH,IAChCD,EAAKM,aAAeN,EAAKM,YAAYH,cAAcC,SAASH,GAC3DD,EACA,IACN,CAEA,SAASO,EAAoBP,EAA0BC,GACrD,OAAOD,EAAKE,GAAGC,cAAcC,SAASH,IACpCD,EAAKK,KAAKF,cAAcC,SAASH,IAChCD,EAAKM,aAAeN,EAAKM,YAAYH,cAAcC,SAASH,GAC3D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AWhC,KAAKyB,OAASlM,EAC/C,CAEA0M,KAAAA,GACE,OAAOjC,KAAKjK,QAAQkM,OACtB,E","sources":["webpack:///./src/launchpad-button-v2/constants.ts","webpack:///./src/launchpad-button-v2/api.ts","webpack:///./src/launchpad-button-v2/search.ts","webpack:///./src/launchpad-button-v2/useLaunchpadInfo.ts","webpack:///./src/launchpad-button-v2/wrapped-bricks.ts","webpack:///./src/shared/DeferredService.ts","webpack:///./src/shared/getLocaleName.ts","webpack:///../../src/JsonStorage.ts"],"sourcesContent":["export const FAVORITES_LIMIT = 10;\nexport const RECENT_VISITS_LIMIT = 10;\n","import type { Storyboard } from \"@next-core/types\";\nimport { LaunchpadApi_getLaunchpadInfo } from \"@next-api-sdk/micro-app-standalone-sdk\";\nimport {\n LaunchpadApi_createCollectionV2,\n LaunchpadApi_deleteCollectionV2,\n LaunchpadApi_listCollectionV2,\n} from \"@next-api-sdk/user-service-sdk\";\nimport { InstanceApi_postSearchV3 } from \"@next-api-sdk/cmdb-sdk\";\nimport type {\n FavMenuItem,\n MenuGroupData,\n MenuItemData,\n MenuItemDataApp,\n MenuItemDataCustom,\n MenuItemDataDir,\n MenuItemDataNormal,\n MicroAppWithInstanceId,\n PlatformCategoryItem,\n} from \"./interfaces\";\nimport { FAVORITES_LIMIT } from \"./constants\";\nimport { getAppLocaleName } from \"../shared/getLocaleName\";\nimport { sortBy } from \"lodash\";\n\nexport async function fetchLaunchpadInfo() {\n const launchpadInfo = await LaunchpadApi_getLaunchpadInfo(\n {},\n {\n interceptorParams: { ignoreLoadingBar: true },\n noAbortOnRouteChange: true,\n }\n );\n\n const microAppsById = new Map<string, MicroAppWithInstanceId>();\n for (const storyboard of launchpadInfo.storyboards as Storyboard[]) {\n const app = storyboard.app as unknown as MicroAppWithInstanceId;\n app.localeName = getAppLocaleName(app.locales, app.name);\n microAppsById.set(app.id, app);\n }\n\n const menuGroups: MenuGroupData[] = [];\n const customLinksById = new Map<string, MenuItemDataCustom>();\n\n for (const group of launchpadInfo.desktops as unknown as MenuGroupData[]) {\n const items: MenuItemData[] = [];\n for (const item of group.items) {\n switch (item.type) {\n case \"app\": {\n const app = microAppsById.get(item.id);\n if (app) {\n items.push({\n ...item,\n name: app.localeName,\n url: app.homepage,\n menuIcon: app.menuIcon,\n } as MenuItemDataApp);\n }\n break;\n }\n case \"custom\":\n items.push(item);\n customLinksById.set(item.id, item);\n break;\n case \"dir\": {\n const subItems: MenuItemDataNormal[] = [];\n for (const subItem of item.items) {\n if (subItem.type === \"app\") {\n const app = microAppsById.get(subItem.id);\n if (app) {\n subItems.push({\n ...subItem,\n name: app.localeName,\n url: app.homepage,\n menuIcon: app.menuIcon,\n } as MenuItemDataApp);\n }\n } else if (subItem.type === \"custom\") {\n subItems.push(subItem as MenuItemDataCustom);\n customLinksById.set(subItem.id, subItem);\n }\n }\n if (subItems.length > 0) {\n items.push({\n ...item,\n items: subItems,\n } as MenuItemDataDir);\n }\n break;\n }\n }\n }\n if (items.length > 0) {\n menuGroups.push({ ...group, items });\n }\n }\n\n return { menuGroups, microAppsById, customLinksById };\n}\n\nasync function fetchRawFavorites() {\n return (\n await LaunchpadApi_listCollectionV2(\n { page: 1, pageSize: FAVORITES_LIMIT },\n {\n interceptorParams: { ignoreLoadingBar: true },\n noAbortOnRouteChange: true,\n }\n )\n ).list;\n}\n\nexport async function fetchFavorites() {\n const list = await fetchRawFavorites();\n const stored: FavMenuItem[] = [];\n for (const fav of list) {\n if (fav.type === \"microApp\") {\n const app = fav.relatedApp as Omit<MicroAppWithInstanceId, \"id\"> & {\n appId: string;\n };\n app.localeName = getAppLocaleName(app.locales, app.name);\n stored.push({\n favoriteId: fav.instanceId,\n type: \"app\",\n name: app.localeName,\n id: app.appId,\n url: app.homepage,\n instanceId: app.instanceId,\n menuIcon: app.menuIcon,\n } as FavMenuItem);\n } else if (fav.type === \"customItem\") {\n const customItem = fav.relatedCustomItem!;\n stored.push({\n favoriteId: fav.instanceId,\n type: \"custom\",\n name: customItem.name,\n id: customItem.id,\n url: customItem.url,\n menuIcon: customItem.menuIcon,\n } as FavMenuItem);\n } else if (fav.type === \"link\") {\n stored.push({\n favoriteId: fav.instanceId,\n type: \"link\",\n name: fav.name,\n // id: fav.id,\n url: fav.link,\n menuIcon: fav.icon,\n } as FavMenuItem);\n }\n }\n return stored;\n}\n\nexport async function favorite(\n item: MenuItemDataNormal\n): Promise<{ instanceId?: string }> {\n return LaunchpadApi_createCollectionV2(\n {\n type: item.type === \"app\" ? \"microApp\" : \"customItem\",\n relatedInstanceId: item.instanceId,\n },\n {\n interceptorParams: { ignoreLoadingBar: true },\n }\n );\n}\n\nexport async function undoFavorite(item: FavMenuItem) {\n if (item.favoriteId) {\n return LaunchpadApi_deleteCollectionV2(item.favoriteId);\n }\n\n return fetchRawFavorites().then((list) => {\n const foundId = list.find((fav) =>\n item.type === \"app\"\n ? fav.type === \"microApp\" && fav.relatedApp?.appId === item.id\n : item.type === \"custom\" && fav.relatedCustomItem?.id === item.id\n )?.instanceId;\n\n if (foundId) {\n return LaunchpadApi_deleteCollectionV2(foundId);\n }\n // eslint-disable-next-line no-console\n console.error(\"Menu item to unstar not found:\", item);\n });\n}\n\nexport async function fetchPlatformCategories(): Promise<\n PlatformCategoryItem[]\n> {\n const categories = (\n await InstanceApi_postSearchV3(\"MICRO_APP_CATEGORY@EASYOPS\", {\n fields: [\n \"id\",\n \"type\",\n \"name\",\n \"icon\",\n \"order\",\n \"platformApps.appId\",\n \"platformApps.name\",\n \"platformApps.homepage\",\n \"platformApps.description\",\n \"platformApps.menuIcon\",\n \"platformApps.locales\",\n \"platformApps._object_id\",\n \"platformApps.@.order\",\n \"platformItems.id\",\n \"platformItems.name\",\n \"platformItems.url\",\n \"platformItems.description\",\n \"platformItems.menuIcon\",\n \"platformItems._object_id\",\n \"platformItems.@.order\",\n ],\n page: 1,\n page_size: 300,\n query: {\n type: \"platform\",\n },\n })\n ).list;\n\n const _categories = categories?.map((category) => {\n const apps = category.platformApps.map((app: Record<string, any>) => {\n return {\n type: \"app\",\n name: getAppLocaleName(app.locales, app.name),\n id: app.appId,\n url: app.homepage,\n menuIcon: app.menuIcon,\n description: app.description,\n instanceId: app.instanceId,\n order: app[\"@\"]?.order,\n };\n }) as MenuItemDataApp[];\n const customItems = category.platformItems.map(\n (item: Record<string, any>) => {\n return {\n type: \"custom\",\n name: item.name,\n id: item.id,\n url: item.url,\n menuIcon: item.menuIcon,\n description: item.description,\n instanceId: item.instanceId,\n order: item[\"@\"]?.order,\n };\n }\n ) as MenuItemDataCustom[];\n\n const items = sortBy([...apps, ...customItems], \"order\");\n return {\n instanceId: category.instanceId,\n id: category.id,\n name: category.name,\n icon: category.icon,\n order: category.order,\n items,\n } as PlatformCategoryItem;\n });\n\n return [\n {\n id: \"#all\",\n name: \"全部\",\n icon: {\n lib: \"easyops\",\n category: \"second-menu\",\n icon: \"sprint-planning-second-menu\",\n },\n items: [],\n },\n ...sortBy(_categories, \"order\"),\n ];\n}\n","import type {\n MenuGroupData,\n MenuItemData,\n MenuItemDataApp,\n MenuItemDataCustom,\n MenuItemDataNormal,\n PlatformCategoryItem,\n} from \"./interfaces\";\n\nexport function search(\n allMenuGroups: MenuGroupData[],\n q: string\n): MenuGroupData[] {\n if (!q) {\n return allMenuGroups;\n }\n const lowerQ = q.toLowerCase();\n const groups: MenuGroupData[] = allMenuGroups\n .map((group) => ({\n ...group,\n items: group.items\n .map((item) => {\n switch (item.type) {\n case \"app\":\n return matchMenuItemApp(item, lowerQ);\n case \"custom\":\n return matchMenuItemCustom(item, lowerQ);\n case \"dir\": {\n const filteredSubItems = item.items\n .map((sub) =>\n sub.type === \"app\"\n ? matchMenuItemApp(sub, lowerQ)\n : sub.type === \"custom\"\n ? matchMenuItemCustom(sub, lowerQ)\n : null\n )\n .filter(Boolean) as MenuItemData[];\n return filteredSubItems.length > 0\n ? {\n ...item,\n items: filteredSubItems,\n }\n : null;\n }\n }\n })\n // Ignore not matched items\n .filter(Boolean) as MenuItemData[],\n }))\n // ignore empty desktops\n .filter((group) => group.items.length > 0);\n return groups;\n}\n\nexport function searchCategories(\n categories: PlatformCategoryItem[],\n q: string\n): PlatformCategoryItem[] {\n if (!q) {\n return categories;\n }\n\n const lowerQ = q.toLowerCase();\n const _categories = categories.map((category) => ({\n ...category,\n items: category.items\n .map((item) => {\n switch (item.type) {\n case \"app\":\n return matchMenuItemApp(item, lowerQ);\n case \"custom\":\n return matchMenuItemCustom(item, lowerQ);\n }\n })\n // Ignore not matched items\n .filter(Boolean) as MenuItemDataNormal[],\n }));\n return _categories;\n}\n\nfunction matchMenuItemApp(item: MenuItemDataApp, lowerQ: string) {\n return item.id.toLowerCase().includes(lowerQ) ||\n item.name.toLowerCase().includes(lowerQ) ||\n (item.description && item.description.toLowerCase().includes(lowerQ))\n ? item\n : null;\n}\n\nfunction matchMenuItemCustom(item: MenuItemDataCustom, lowerQ: string) {\n return item.id.toLowerCase().includes(lowerQ) ||\n item.name.toLowerCase().includes(lowerQ) ||\n (item.description && item.description.toLowerCase().includes(lowerQ))\n ? item\n : null;\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport {\n getRuntime,\n handleHttpError,\n httpErrorToString,\n} from \"@next-core/runtime\";\nimport { auth } from \"@next-core/easyops-runtime\";\nimport { JsonStorage } from \"@next-shared/general/JsonStorage\";\nimport { DeferredService } from \"../shared/DeferredService\";\nimport { showDialog, showNotification } from \"./wrapped-bricks\";\nimport type {\n FavMenuItem,\n MenuGroupData,\n MenuItemDataCustom,\n MenuItemDataLink,\n MenuItemDataNormal,\n MicroAppWithInstanceId,\n PlatformCategoryItem,\n StoredMenuItem,\n} from \"./interfaces\";\nimport {\n favorite,\n fetchFavorites,\n fetchLaunchpadInfo,\n fetchPlatformCategories,\n undoFavorite,\n} from \"./api\";\nimport { search, searchCategories } from \"./search\";\nimport { FAVORITES_LIMIT, RECENT_VISITS_LIMIT } from \"./constants\";\n\nconst storageKey = `launchpad-recent-visits:${(\n auth.getAuth() as Record<string, string>\n)?.org}`;\nconst storage = new JsonStorage(localStorage);\n\nlet candidateDesktops: MenuGroupData[] = [];\nlet candidateMicroAppsById = new Map<string, MicroAppWithInstanceId>();\nlet candidateCustomLinksById = new Map<string, MenuItemDataCustom>();\nlet preLoaded = false;\n\nlet candidateFavorites: FavMenuItem[] = [];\nlet preLoadedFavorites = false;\n\nlet candidatePlatformCategories: PlatformCategoryItem[] = [];\nlet preLoadedPlatformCategories = false;\n\nexport const deferredLaunchpadInfo = new DeferredService(async () => {\n ({\n menuGroups: candidateDesktops,\n microAppsById: candidateMicroAppsById,\n customLinksById: candidateCustomLinksById,\n } = await fetchLaunchpadInfo());\n preLoaded = true;\n});\n\nexport const deferredFavorites = new DeferredService(async () => {\n candidateFavorites = await fetchFavorites();\n preLoadedFavorites = true;\n});\n\nexport const deferredPlatformCategories = new DeferredService(async () => {\n candidatePlatformCategories = await fetchPlatformCategories();\n preLoadedPlatformCategories = true;\n});\n\nconst showErrorAsNotification = (error: unknown) =>\n showNotification({\n type: \"error\",\n message: httpErrorToString(error),\n });\n\n/**\n * - 页面初始化时预加载 launchpad 信息。\n * - 每次打开 launchpad 都发起请求,但该请求的数据只在下次打开 launchpad 时使用。\n * 即每次打开 launchpad 使用的都是上一次获取的数据,以便达到两个效果:\n * - 每次打开 launchpad 都能立即显示菜单列表;\n * - 同时当用户在 launchpad 上操作时,不会出现数据突然更新(新数据请求完成)。\n */\nexport function useLaunchpadInfo(active?: boolean) {\n const [desktops, setDesktops] = useState(candidateDesktops);\n const [microAppsById, setMicroAppsById] = useState(candidateMicroAppsById);\n const [customLinksById, setCustomLinksById] = useState(\n candidateCustomLinksById\n );\n\n const [q, setQ] = useState(\"\");\n\n const [loading, setLoading] = useState(!preLoaded);\n const [loadingFavorites, setLoadingFavorites] = useState(!preLoadedFavorites);\n const [loadingPlatformCategories, setLoadingPlatformCategories] = useState(\n !preLoadedPlatformCategories\n );\n\n const [storedRecentVisits, setStoredRecentVisits] = useState<\n StoredMenuItem[]\n >([]);\n\n const [recentVisits, setRecentVisits] = useState<MenuItemDataNormal[]>([]);\n\n const [favorites, setFavorites] = useState<FavMenuItem[]>(candidateFavorites);\n const [platformCategories, setPlatformCategories] = useState<\n PlatformCategoryItem[]\n >(candidatePlatformCategories);\n\n useEffect(() => {\n // 仅当首次加载完成或重新打开 launchpad 时更新一次数据。\n if (active && !loading) {\n setDesktops(candidateDesktops);\n setMicroAppsById(candidateMicroAppsById);\n setCustomLinksById(candidateCustomLinksById);\n }\n }, [active, loading]);\n\n useEffect(() => {\n if (active && !loadingFavorites) {\n setFavorites(candidateFavorites);\n }\n }, [active, loadingFavorites]);\n\n useEffect(() => {\n if (active && !loadingPlatformCategories) {\n setPlatformCategories(candidatePlatformCategories);\n }\n }, [active, loadingPlatformCategories]);\n\n useEffect(() => {\n if (active) {\n setStoredRecentVisits(storage.getItem(storageKey) ?? []);\n }\n }, [active]);\n\n useEffect(() => {\n if (active) {\n const startFetchLaunchpadInfo = async (): Promise<void> => {\n try {\n await deferredLaunchpadInfo.fetch();\n setLoading(false);\n } catch (error) {\n handleHttpError(error);\n }\n };\n startFetchLaunchpadInfo();\n }\n }, [active]);\n\n useEffect(() => {\n if (active) {\n const startFetchFavorites = async (): Promise<void> => {\n try {\n await deferredFavorites.fetch();\n setLoadingFavorites(false);\n } catch (error) {\n setLoadingFavorites(false);\n showErrorAsNotification(error);\n }\n };\n startFetchFavorites();\n }\n }, [active]);\n\n useEffect(() => {\n if (\n active &&\n getRuntime()?.getFeatureFlags()[\"launchpad-show-platform-category\"]\n ) {\n const startFetchPlatformCategories = async (): Promise<void> => {\n try {\n await deferredPlatformCategories.fetch();\n setLoadingPlatformCategories(false);\n } catch (error) {\n setLoadingPlatformCategories(false);\n showErrorAsNotification(error);\n }\n };\n startFetchPlatformCategories();\n }\n }, [active]);\n\n useEffect(() => {\n if (loading) {\n return;\n }\n const visits = storedRecentVisits\n .map((item) => {\n // Remembered recent visits maybe no longer existed in launchpad\n if (item.type === \"app\") {\n const app = microAppsById.get(item.id);\n return app\n ? {\n type: \"app\",\n name: app.localeName,\n id: app.id,\n url: app.homepage,\n instanceId: app.instanceId,\n menuIcon: app.menuIcon,\n }\n : null;\n }\n return customLinksById.get(item.id);\n })\n .filter(Boolean) as MenuItemDataNormal[];\n setRecentVisits(visits);\n }, [customLinksById, loading, microAppsById, storedRecentVisits]);\n\n const pushRecentVisit = useCallback(({ type, id }: StoredMenuItem) => {\n const visits: StoredMenuItem[] = storage.getItem(storageKey) ?? [];\n const index = visits.findIndex(\n (visit) => visit.type === type && visit.id === id\n );\n if (index > -1) {\n visits.splice(index, 1);\n }\n visits.unshift({ type, id });\n if (visits.length > RECENT_VISITS_LIMIT) {\n visits.pop();\n }\n // setStoredRecentVisits(visits);\n storage.setItem(storageKey, visits);\n }, []);\n\n const isStarred = useCallback(\n (item: MenuItemDataNormal) =>\n favorites.some((fav) => matchFavorite(item, fav)),\n [favorites]\n );\n\n const toggleStar = useCallback(\n (item: MenuItemDataNormal | MenuItemDataLink) => {\n const index = favorites.findIndex((fav) =>\n item.type === \"link\"\n ? fav.favoriteId === item.favoriteId\n : matchFavorite(item, fav)\n );\n let newFavorites: FavMenuItem[];\n if (index > -1) {\n const removed = favorites[index];\n newFavorites = favorites\n .slice(0, index)\n .concat(favorites.slice(index + 1));\n undoFavorite(removed).catch(showErrorAsNotification);\n } else {\n if (favorites.length >= FAVORITES_LIMIT) {\n showDialog({\n type: \"warn\",\n title: \"收藏数量已达上限\",\n content: `当前收藏链接数量已达上限(${FAVORITES_LIMIT}个),请删除部分收藏后再添加。`,\n });\n return;\n }\n // Assert: no link item\n const fav: FavMenuItem = { ...(item as MenuItemDataNormal) };\n newFavorites = favorites.concat(fav);\n favorite(item as MenuItemDataNormal).then((result) => {\n if (result) {\n fav.favoriteId = result.instanceId;\n }\n }, showErrorAsNotification);\n }\n setFavorites(newFavorites);\n candidateFavorites = newFavorites;\n },\n [favorites]\n );\n\n const menuGroups: MenuGroupData[] = useMemo(\n () => search(desktops, q),\n [desktops, q]\n );\n\n const filteredPlatformCategories: PlatformCategoryItem[] = useMemo(\n () => searchCategories(platformCategories, q),\n [platformCategories, q]\n );\n\n return {\n loading,\n q,\n setQ,\n menuGroups,\n loadingFavorites,\n loadingPlatformCategories,\n favorites,\n recentVisits,\n pushRecentVisit,\n isStarred,\n toggleStar,\n platformCategories: filteredPlatformCategories,\n };\n}\n\nexport function matchFavorite(item: MenuItemDataNormal, fav: FavMenuItem) {\n return item.instanceId && fav.instanceId\n ? fav.instanceId === item.instanceId\n : fav.type === item.type && fav.id === item.id;\n}\n","import { wrapBrick } from \"@next-core/react-element\";\nimport { unwrapProvider } from \"@next-core/utils/general\";\nimport type {\n GeneralIcon,\n GeneralIconProps,\n} from \"@next-bricks/icons/general-icon\";\nimport type { Link, LinkProps } from \"@next-bricks/basic/link\";\nimport type { showDialog as _showDialog } from \"@next-bricks/basic/data-providers/show-dialog/show-dialog\";\nimport type { showNotification as _showNotification } from \"@next-bricks/basic/data-providers/show-notification/show-notification\";\n\nexport const WrappedIcon = wrapBrick<GeneralIcon, GeneralIconProps>(\"eo-icon\");\nexport const WrappedLink = wrapBrick<Link, LinkProps>(\"eo-link\");\n\n// Use `unwrapProvider` to get the original function of a provider\nexport const showDialog =\n unwrapProvider<typeof _showDialog>(\"basic.show-dialog\");\n\nexport const showNotification = unwrapProvider<typeof _showNotification>(\n \"basic.show-notification\"\n);\n","export class DeferredService {\n private preFetchId: number | null = null;\n private preFetchScheduled = false;\n private firstFetchPromise: Promise<unknown> | null = null;\n private isFetching = false;\n private readonly task: () => Promise<unknown>;\n\n constructor(task: () => Promise<unknown>) {\n this.task = task;\n }\n\n schedulePrefetch(): void {\n if (!this.preFetchScheduled) {\n this.preFetchScheduled = true;\n const preFetchLaunchpadInfo = async (): Promise<void> => {\n this.preFetchId = null;\n this.fetch();\n };\n // istanbul ignore if\n if (typeof window.requestIdleCallback === \"function\") {\n this.preFetchId = window.requestIdleCallback(preFetchLaunchpadInfo);\n } else {\n this.preFetchId = setTimeout(\n preFetchLaunchpadInfo\n ) as unknown as number;\n }\n }\n }\n\n fetch(eager?: boolean): Promise<unknown> {\n if (this.preFetchId) {\n // istanbul ignore if\n if (typeof window.cancelIdleCallback === \"function\") {\n cancelIdleCallback(this.preFetchId);\n } else {\n clearTimeout(this.preFetchId);\n }\n this.preFetchId = null;\n }\n\n let promise: Promise<unknown>;\n if (!this.isFetching || eager) {\n this.isFetching = true;\n promise = this.task();\n promise\n .catch((error) => {\n // eslint-disable-next-line no-console\n console.error(error);\n this.firstFetchPromise = null;\n })\n .finally(() => {\n this.isFetching = false;\n });\n if (!this.firstFetchPromise) {\n this.firstFetchPromise = promise;\n }\n if (eager) {\n return promise;\n }\n }\n return this.firstFetchPromise!;\n }\n}\n","import { i18nText } from \"@next-core/i18n\";\nimport type { AppLocales, I18nData } from \"@next-core/types\";\n\nexport function getAppLocaleName(\n locales: AppLocales | undefined,\n name: string\n) {\n if (!locales) {\n return name;\n }\n const i18nData = Object.fromEntries(\n Object.entries(locales)\n .filter(([_lang, resources]) => resources.name)\n .map(([lang, resources]) => [lang, resources.name])\n ) as I18nData;\n return i18nText(i18nData) ?? name;\n}\n","export class JsonStorage {\n constructor(\n private storage: Storage,\n private prefix: string = \"brick-next-\"\n ) {}\n\n setItem<T = any>(name: string, value: T): void {\n this.storage.setItem(this.prefix + name, JSON.stringify(value));\n }\n\n getItem<T = any>(name: string): T {\n return JSON.parse(this.storage.getItem(this.prefix + name) as string) as T;\n }\n\n removeItem(name: string): void {\n return this.storage.removeItem(this.prefix + name);\n }\n\n clear(): void {\n return this.storage.clear();\n }\n}\n"],"names":["FAVORITES_LIMIT","RECENT_VISITS_LIMIT","async","fetchRawFavorites","LaunchpadApi_listCollectionV2","page","pageSize","interceptorParams","ignoreLoadingBar","noAbortOnRouteChange","list","matchMenuItemApp","item","lowerQ","id","toLowerCase","includes","name","description","matchMenuItemCustom","storageKey","_auth$getAuth","auth","getAuth","org","storage","JsonStorage","localStorage","candidateDesktops","candidateMicroAppsById","Map","candidateCustomLinksById","preLoaded","candidateFavorites","preLoadedFavorites","candidatePlatformCategories","preLoadedPlatformCategories","deferredLaunchpadInfo","DeferredService","menuGroups","microAppsById","customLinksById","launchpadInfo","LaunchpadApi_getLaunchpadInfo","storyboard","storyboards","app","localeName","getAppLocaleName","locales","set","group","desktops","items","type","get","push","url","homepage","menuIcon","subItems","subItem","length","fetchLaunchpadInfo","deferredFavorites","stored","fav","relatedApp","favoriteId","instanceId","appId","customItem","relatedCustomItem","link","icon","fetchFavorites","deferredPlatformCategories","categories","InstanceApi_postSearchV3","fields","page_size","query","_categories","map","category","apps","platformApps","_app$","order","customItems","platformItems","_item$","sortBy","lib","fetchPlatformCategories","showErrorAsNotification","error","showNotification","message","httpErrorToString","useLaunchpadInfo","active","setDesktops","useState","setMicroAppsById","setCustomLinksById","q","setQ","loading","setLoading","loadingFavorites","setLoadingFavorites","loadingPlatformCategories","setLoadingPlatformCategories","storedRecentVisits","setStoredRecentVisits","recentVisits","setRecentVisits","favorites","setFavorites","platformCategories","setPlatformCategories","useEffect","_storage$getItem","getItem","fetch","handleHttpError","startFetchLaunchpadInfo","startFetchFavorites","_getRuntime","getRuntime","getFeatureFlags","startFetchPlatformCategories","visits","filter","Boolean","pushRecentVisit","useCallback","_ref","_storage$getItem2","index","findIndex","visit","splice","unshift","pop","setItem","isStarred","some","matchFavorite","toggleStar","newFavorites","removed","slice","concat","LaunchpadApi_deleteCollectionV2","then","_list$find","foundId","find","_fav$relatedApp","_fav$relatedCustomIte","console","undoFavorite","catch","showDialog","title","content","LaunchpadApi_createCollectionV2","relatedInstanceId","favorite","result","useMemo","allMenuGroups","filteredSubItems","sub","search","filteredPlatformCategories","searchCategories","WrappedIcon","wrapBrick","WrappedLink","unwrapProvider","constructor","task","_defineProperty","this","schedulePrefetch","preFetchScheduled","preFetchLaunchpadInfo","preFetchId","window","requestIdleCallback","setTimeout","eager","promise","cancelIdleCallback","clearTimeout","isFetching","firstFetchPromise","finally","_i18nText","i18nData","Object","fromEntries","entries","_lang","resources","_ref2","lang","i18nText","prefix","arguments","undefined","value","JSON","stringify","parse","removeItem","clear"],"sourceRoot":""}