decocms 2.302.7 → 2.303.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/client/assets/{AlertCircle-CG9syR30.js → AlertCircle-vEsirhNa.js} +1 -1
- package/dist/client/assets/{ArrowNarrowLeft-BoVSDn9e.js → ArrowNarrowLeft-DZv_aYqP.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-BdaniATT.js → ArrowUpRight-gnKwWbdS.js} +1 -1
- package/dist/client/assets/{CheckCircle-DenMuCVF.js → CheckCircle-CG65sxv8.js} +1 -1
- package/dist/client/assets/{ChevronDown-C3Ygm425.js → ChevronDown-ClwyYcv4.js} +1 -1
- package/dist/client/assets/{ChevronRight-ZWCM92t_.js → ChevronRight-C0UgsndQ.js} +1 -1
- package/dist/client/assets/{ChevronUp-D2rVf06n.js → ChevronUp-0O0O_hLq.js} +1 -1
- package/dist/client/assets/{Container-D7Azh5xu.js → Container-D1_FRS1u.js} +1 -1
- package/dist/client/assets/{DotsVertical-CLHEpDSq.js → DotsVertical-BdLY0G_d.js} +1 -1
- package/dist/client/assets/{LinkExternal01-DxXEJ52C.js → LinkExternal01-C0RHT0gp.js} +1 -1
- package/dist/client/assets/{Lock01-BguDy0uh.js → Lock01-CJP_L01s.js} +1 -1
- package/dist/client/assets/{Palette-BYEIR3m2.js → Palette-DTaJJ6eW.js} +1 -1
- package/dist/client/assets/{Play-Bwjd77ev.js → Play-wg-GRHFk.js} +1 -1
- package/dist/client/assets/{Plus-DTn86Odk.js → Plus-Ukcu1-Za.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-BHf_tfWd.js → RefreshCcw01-i1Q8uoB-.js} +1 -1
- package/dist/client/assets/{SearchMd-a6724p0Y.js → SearchMd-CaU1opgI.js} +1 -1
- package/dist/client/assets/{Settings02-CrnanDsL.js → Settings02-sn7Sw6YT.js} +1 -1
- package/dist/client/assets/{Shield01-DtxRf8Qj.js → Shield01-BV1qTPTH.js} +1 -1
- package/dist/client/assets/{Star01-BFmiet3n.js → Star01-BRRUiVRZ.js} +1 -1
- package/dist/client/assets/{Sun-CRJFmy5s.js → Sun-xRqcyI3R.js} +1 -1
- package/dist/client/assets/{Tool01-9otovhMh.js → Tool01-Baq41T_m.js} +1 -1
- package/dist/client/assets/{Trash01-re7YiF5g.js → Trash01-vBGY9tLb.js} +1 -1
- package/dist/client/assets/{User01-BgnyFNdJ.js → User01-Dt3HpnQa.js} +1 -1
- package/dist/client/assets/{Users03-BPGIuPOi.js → Users03-DXg5Ltjv.js} +1 -1
- package/dist/client/assets/{X-DlTdh5jK.js → X-cgiyE3ZM.js} +1 -1
- package/dist/client/assets/{XCircle-BE4LAsf8.js → XCircle-pfcw5bLn.js} +1 -1
- package/dist/client/assets/{XClose-CDyDeDuF.js → XClose-BddCxuhK.js} +1 -1
- package/dist/client/assets/{Zap-DE6pD70D.js → Zap-Csq8iSdS.js} +1 -1
- package/dist/client/assets/{ZapSquare-FWH2wtfn.js → ZapSquare-BcZ9bNOI.js} +1 -1
- package/dist/client/assets/{accordion-BubDFUkM.js → accordion-6lnK-4_B.js} +1 -1
- package/dist/client/assets/{agent-icon-DzVM2Y3D.js → agent-icon-BdKQ6n0b.js} +1 -1
- package/dist/client/assets/{agents-list-ClVNGy3h.js → agents-list-CQCT4ln6.js} +1 -1
- package/dist/client/assets/ai-providers-GeW9mIp3.js +1 -0
- package/dist/client/assets/{alert-dialog-Cp4KelsS.js → alert-dialog-eUvHx9LP.js} +1 -1
- package/dist/client/assets/{auth-catchall-DAjGP-X3.js → auth-catchall-DTPgUDmr.js} +1 -1
- package/dist/client/assets/{automation-list-row-DP5TESrt.js → automation-list-row-Dr5sNKYc.js} +1 -1
- package/dist/client/assets/{automations-BKKclzI8.js → automations-C3gcgD_I.js} +1 -1
- package/dist/client/assets/{avatar-D56WFjQj.js → avatar-DYHAtJIn.js} +1 -1
- package/dist/client/assets/{badge-Brrebgj_.js → badge-CbBFj3dT.js} +1 -1
- package/dist/client/assets/{brand-context-B9KleYrA.js → brand-context-CH3a97ud.js} +1 -1
- package/dist/client/assets/{card-CbtqsNyF.js → card-KdWbX1xC.js} +1 -1
- package/dist/client/assets/{chat-context-D8pNmIoM.js → chat-context-CyOREmRE.js} +1 -1
- package/dist/client/assets/{checkbox-A-1sOL7a.js → checkbox-L6ow9OAH.js} +1 -1
- package/dist/client/assets/{collection-detail-BiV7gm_U.js → collection-detail-BNa0DV-E.js} +1 -1
- package/dist/client/assets/{collection-display-button-hDD2VNh1.js → collection-display-button-Cd1AAuzE.js} +1 -1
- package/dist/client/assets/{collection-search-BtNt6NZG.js → collection-search-C_3BuKbi.js} +1 -1
- package/dist/client/assets/{collection-search-TTX5BBhb.js → collection-search-DKaMJpI1.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-RDfR0u8g.js → collection-table-wrapper-BZMY30r-.js} +1 -1
- package/dist/client/assets/{collection-tabs-BYirFRax.js → collection-tabs-CKmdw5ye.js} +1 -1
- package/dist/client/assets/{collections-DY4I1w_a.js → collections-JCMKBQvX.js} +1 -1
- package/dist/client/assets/{command-DzkZTofz.js → command-CiVqeZK9.js} +1 -1
- package/dist/client/assets/{connection-card-iSBKdQg9.js → connection-card-BGoNyj1I.js} +1 -1
- package/dist/client/assets/{connection-detail-DeALevd5.js → connection-detail-DgOZE4hQ.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-Cad-A9NK.js → connection-form-helpers-DiXDE6He.js} +1 -1
- package/dist/client/assets/{connections-BhCBByIk.js → connections-BHvbqlLg.js} +1 -1
- package/dist/client/assets/{constants-9TBj0Gaa.js → constants-BOiLyn9k.js} +1 -1
- package/dist/client/assets/{constants-BXUJyD1c.js → constants-CxLUc4t1.js} +1 -1
- package/dist/client/assets/{dialog-DpgNnjBX.js → dialog-B24YZzA9.js} +1 -1
- package/dist/client/assets/{domain-settings-CfEXVZxs.js → domain-settings-WXCddaP7.js} +1 -1
- package/dist/client/assets/{drawer-LAm5-sL1.js → drawer-CGPAKRwg.js} +1 -1
- package/dist/client/assets/{dropdown-menu-CSBZWMuU.js → dropdown-menu-D3k5KxvY.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-YqPG32No.js → dynamic-plugin-layout-B06IMDFS.js} +1 -1
- package/dist/client/assets/{empty-state-D8Ji8JRa.js → empty-state-CI0GC98R.js} +1 -1
- package/dist/client/assets/{empty-state-C3GO5RSf.js → empty-state-Wp7TaLly.js} +1 -1
- package/dist/client/assets/{extract-connection-data-cbAHcCfh.js → extract-connection-data-C8BcpMzg.js} +1 -1
- package/dist/client/assets/{features-D_II3j_j.js → features-Dm0-VLa6.js} +1 -1
- package/dist/client/assets/{form-DFO_5Fzm.js → form-FasOp70m.js} +1 -1
- package/dist/client/assets/{general-By1woa8E.js → general-B7DIS0Ue.js} +1 -1
- package/dist/client/assets/{index-DF5x0d60.js → index-22XZTMRU.js} +1 -1
- package/dist/client/assets/{index-ImhE7zFL.js → index-B2vavj0S.js} +1 -1
- package/dist/client/assets/{index-XLC4yiSV.js → index-C6uOB0Y4.js} +1 -1
- package/dist/client/assets/{index-CHNVhIMp.js → index-CFi3i8-6.js} +1 -1
- package/dist/client/assets/{index-C4QwSWi9.js → index-CGc8iCsx.js} +1 -1
- package/dist/client/assets/{index-D2mitOSe.js → index-CHehLkTl.js} +4 -4
- package/dist/client/assets/index-CHk8-d41.js +1 -0
- package/dist/client/assets/{index-swcvm5Z1.js → index-CJ0MPowS.js} +1 -1
- package/dist/client/assets/{index-DYIl7M2a.js → index-CLPpVsE7.js} +1 -1
- package/dist/client/assets/{index-B2vPEOVc.js → index-CLgan7xr.js} +1 -1
- package/dist/client/assets/{index-tSJy2IW6.js → index-CmoaTI3v.js} +1 -1
- package/dist/client/assets/{index-2dOrl4x0.js → index-CnMcjZ2J.js} +1 -1
- package/dist/client/assets/{index-DSoRyzSx.js → index-DSDywrQr.js} +1 -1
- package/dist/client/assets/{index-CQ4D5GAP.js → index-DgPBaKAA.js} +2 -2
- package/dist/client/assets/{index-r9i7ABND.js → index-UUkaa4t8.js} +1 -1
- package/dist/client/assets/{index-Br3d5-Cj.js → index-Uci3t_4k.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-CxkHF-jm.js → infiniteQueryObserver-BNzmdrsE.js} +1 -1
- package/dist/client/assets/{input-6Sf2hB_F.js → input-s7yMiYrQ.js} +1 -1
- package/dist/client/assets/{integration-icon-8lhkAaq5.js → integration-icon-BTFNSNVv.js} +1 -1
- package/dist/client/assets/{label-DoJDMV6i.js → label-DdmR-9sj.js} +1 -1
- package/dist/client/assets/{layout-BHQ_c4RM.js → layout-b284SHuQ.js} +1 -1
- package/dist/client/assets/{lean-canvas-recruit-modal-CDcr9qCt.js → lean-canvas-recruit-modal-DajQAG70.js} +1 -1
- package/dist/client/assets/{login-Am3HfZgi.js → login-B1PDG9tU.js} +1 -1
- package/dist/client/assets/{members-yGwdGYMP.js → members-BzR5JdQ2.js} +1 -1
- package/dist/client/assets/{monaco-editor-CglgsbP6.js → monaco-editor-CI3jdnZr.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-C64ix0dR.js → monitoring-stats-row-DhMQIkbL.js} +1 -1
- package/dist/client/assets/{oauth-callback-YaQtgy3B.js → oauth-callback-BnQ8HZqD.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-DXuTlaTS.js → oauth-callback-ai-provider-CRSRr_xb.js} +1 -1
- package/dist/client/assets/{onboarding-WnwwsOhD.js → onboarding-D_M2p9DV.js} +1 -1
- package/dist/client/assets/{org-layout-DCXUX3EB.js → org-layout-D2xtXfus.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-Dsb_WQsm.js → org-plugin-layout-DZaqttiB.js} +1 -1
- package/dist/client/assets/{pair-B01JdgFS.js → pair-DipmF7bC.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-D3CO3AdB.js → plugin-empty-state-Buoq-fSV.js} +1 -1
- package/dist/client/assets/{plugin-header-aeJUAm2h.js → plugin-header-BYnPGK02.js} +1 -1
- package/dist/client/assets/{plugin-layout-CP1Bb1gU.js → plugin-layout-CN3nu4uU.js} +1 -1
- package/dist/client/assets/{popover-BajibMdr.js → popover-BO9bGsCV.js} +1 -1
- package/dist/client/assets/{profile-DDe57pOS.js → profile-KMr1dQ-Q.js} +1 -1
- package/dist/client/assets/{project-app-view-AKSh-WqN.js → project-app-view-BUlVlC-x.js} +1 -1
- package/dist/client/assets/registry-BQuAXDX3.js +2 -0
- package/dist/client/assets/{registry-layout-QiSXnsNM.js → registry-layout-BUJ3AeXk.js} +1 -1
- package/dist/client/assets/{required-auth-layout-jdQgts2c.js → required-auth-layout-23LI14IJ.js} +1 -1
- package/dist/client/assets/{reset-password-BN5V7l8r.js → reset-password-D1P-Z7nY.js} +1 -1
- package/dist/client/assets/{roles-HeW5UUYX.js → roles-C76lzhHm.js} +1 -1
- package/dist/client/assets/{scroll-area-SGeY9dE-.js → scroll-area-BYgy2rRU.js} +1 -1
- package/dist/client/assets/{search-input-D6oau9hI.js → search-input-DouvVIAY.js} +1 -1
- package/dist/client/assets/{select-model-Di1os-Ub.js → select-model-BwlI7XmT.js} +1 -1
- package/dist/client/assets/{select-DeRvPFq1.js → select-tWER34RX.js} +1 -1
- package/dist/client/assets/{settings-layout-Ds_Ffodp.js → settings-layout-DM8Inkwn.js} +1 -1
- package/dist/client/assets/{settings-section-RBLHL8gf.js → settings-section-Dr0LUAWl.js} +1 -1
- package/dist/client/assets/{shell-layout-BBGXUnLn.js → shell-layout-RjvCJ64C.js} +1 -1
- package/dist/client/assets/{skeleton-BAo1ij7j.js → skeleton-CUpGn6FE.js} +1 -1
- package/dist/client/assets/{sso-CKN-2e5M.js → sso-BIwBaU8W.js} +1 -1
- package/dist/client/assets/{store-hnD4E6ii.js → store-DxMzTKYE.js} +1 -1
- package/dist/client/assets/store-registry-4KpCoRMs.js +2 -0
- package/dist/client/assets/{switch-BGrAKUyr.js → switch-DEvD95wE.js} +1 -1
- package/dist/client/assets/{table-0gEoBFzX.js → table-C3UVFCYb.js} +1 -1
- package/dist/client/assets/{tabs-ChLvcDIf.js → tabs-BVEP2lWJ.js} +1 -1
- package/dist/client/assets/{task-status-B0G255I6.js → task-status-CGfLBMZl.js} +1 -1
- package/dist/client/assets/{textarea-CDageIb2.js → textarea-D7sU3_M1.js} +1 -1
- package/dist/client/assets/{toggle-group-BUN1pnfF.js → toggle-group-V7Yt1Ex8.js} +1 -1
- package/dist/client/assets/{tools-list-DIvrgoIa.js → tools-list-CABaXV8v.js} +1 -1
- package/dist/client/assets/{tooltip-pBgOajzM.js → tooltip-apD1iSo_.js} +1 -1
- package/dist/client/assets/{types-wSZC8rz7.js → types-CD5tpm5b.js} +1 -1
- package/dist/client/assets/{use-ai-providers-DVEz2NmK.js → use-ai-providers-CGTNouwr.js} +1 -1
- package/dist/client/assets/{use-collections-DV5bwdGb.js → use-collections-DFWGNuJR.js} +1 -1
- package/dist/client/assets/{use-connection-fs-HjrZ7.js → use-connection-C-BvdB1r.js} +1 -1
- package/dist/client/assets/{use-copy-lIGig9yc.js → use-copy-DefGD5Vz.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-Bz4IDcO1.js → use-create-virtual-mcp-CBpUnMCs.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-B38OLSFm.js → use-decopilot-events-ltSQJ_A7.js} +1 -1
- package/dist/client/assets/{use-delete-connection-CORGK4Oi.js → use-delete-connection-DpaPpzHo.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-C0wp7W5X.js → use-infinite-scroll-BQ-INmUl.js} +1 -1
- package/dist/client/assets/{use-list-state-DWVI_yIs.js → use-list-state-D1F4t091.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-C-hABbHm.js → use-mcp-tools-BrbjMOtH.js} +1 -1
- package/dist/client/assets/{use-members-DbWcRqMH.js → use-members-b-HHyQxx.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-37f-6W2B.js → use-navigate-to-agent-vkB0KE5O.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-5_rgl0KN.js → use-org-auth-client-DpMUudQp.js} +1 -1
- package/dist/client/assets/{use-org-sso-CFxSE_n9.js → use-org-sso-B1ThBRct.js} +1 -1
- package/dist/client/assets/{use-organization-roles-Cy74Gv9v.js → use-organization-roles-CBMuGkFt.js} +1 -1
- package/dist/client/assets/{use-organization-settings-B3AsJEWq.js → use-organization-settings-8KaGxc8P.js} +1 -1
- package/dist/client/assets/{use-registry-connections-C9X2yrii.js → use-registry-connections-q8kr-T41.js} +1 -1
- package/dist/client/assets/{use-status-sounds-DuT0KslZ.js → use-status-sounds-C19SUHpW.js} +1 -1
- package/dist/client/assets/{use-tasks-Bg4m_k7S.js → use-tasks-CKR5m1e3.js} +1 -1
- package/dist/client/assets/{use-view-mode-_U7GAKYn.js → use-view-mode-C6IKAuZR.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-CwGnYHPH.js → use-virtual-mcp-DqIUOY7O.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-eU5lg-Wu.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-ddH3lLnG.js +1 -0
- package/dist/client/assets/{user-CpC285Qu.js → user-CaH0b_KG.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-zrlQPSP1.js → view-mode-toggle-D-dHPCyZ.js} +1 -1
- package/dist/client/assets/{workflow-D77PbtT7.js → workflow-BivIt-Ky.js} +1 -1
- package/dist/client/assets/workflow-detail-Df9rIeG5.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +88 -45
- package/dist/server/node_modules/get-east-asian-width/index.d.ts +60 -0
- package/dist/server/node_modules/get-east-asian-width/index.js +30 -0
- package/dist/server/node_modules/get-east-asian-width/lookup-data.js +18 -0
- package/dist/server/node_modules/get-east-asian-width/lookup.js +135 -0
- package/dist/server/node_modules/get-east-asian-width/package.json +71 -0
- package/dist/server/node_modules/get-east-asian-width/readme.md +65 -0
- package/dist/server/node_modules/get-east-asian-width/utilities.js +24 -0
- package/dist/server/server.js +87 -44
- package/package.json +1 -1
- package/dist/client/assets/ai-providers-CCNzjFxx.js +0 -1
- package/dist/client/assets/index-B13jh3-s.js +0 -1
- package/dist/client/assets/registry-BEeKP9Pe.js +0 -2
- package/dist/client/assets/store-registry-s8CHypuf.js +0 -2
- package/dist/client/assets/useInfiniteQuery-DGrk4ASG.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-cV09mkra.js +0 -1
- package/dist/client/assets/workflow-detail-DAtCF7t1.js +0 -1
- package/dist/server/node_modules/is-fullwidth-code-point/index.d.ts +0 -17
- package/dist/server/node_modules/is-fullwidth-code-point/index.js +0 -12
- package/dist/server/node_modules/is-fullwidth-code-point/package.json +0 -53
- package/dist/server/node_modules/is-fullwidth-code-point/readme.md +0 -31
- package/dist/server/node_modules/mimic-fn/index.d.ts +0 -54
- package/dist/server/node_modules/mimic-fn/index.js +0 -13
- package/dist/server/node_modules/mimic-fn/license +0 -9
- package/dist/server/node_modules/mimic-fn/package.json +0 -42
- package/dist/server/node_modules/mimic-fn/readme.md +0 -69
- package/dist/server/node_modules/onetime/index.d.ts +0 -64
- package/dist/server/node_modules/onetime/index.js +0 -44
- package/dist/server/node_modules/onetime/license +0 -9
- package/dist/server/node_modules/onetime/package.json +0 -43
- package/dist/server/node_modules/onetime/readme.md +0 -94
- package/dist/server/node_modules/pg-int8/LICENSE +0 -13
- package/dist/server/node_modules/pg-int8/README.md +0 -16
- package/dist/server/node_modules/pg-int8/index.js +0 -100
- package/dist/server/node_modules/pg-int8/package.json +0 -24
- package/dist/server/node_modules/postgres-array/index.d.ts +0 -4
- package/dist/server/node_modules/postgres-array/index.js +0 -97
- package/dist/server/node_modules/postgres-array/license +0 -21
- package/dist/server/node_modules/postgres-array/package.json +0 -35
- package/dist/server/node_modules/postgres-array/readme.md +0 -43
- package/dist/server/node_modules/postgres-bytea/index.js +0 -33
- package/dist/server/node_modules/postgres-bytea/license +0 -21
- package/dist/server/node_modules/postgres-bytea/package.json +0 -34
- package/dist/server/node_modules/postgres-bytea/readme.md +0 -34
- package/dist/server/node_modules/postgres-date/index.js +0 -116
- package/dist/server/node_modules/postgres-date/license +0 -21
- package/dist/server/node_modules/postgres-date/package.json +0 -33
- package/dist/server/node_modules/postgres-date/readme.md +0 -49
- package/dist/server/node_modules/postgres-interval/index.d.ts +0 -20
- package/dist/server/node_modules/postgres-interval/index.js +0 -125
- package/dist/server/node_modules/postgres-interval/license +0 -21
- package/dist/server/node_modules/postgres-interval/package.json +0 -36
- package/dist/server/node_modules/postgres-interval/readme.md +0 -48
- package/dist/server/node_modules/split2/LICENSE +0 -13
- package/dist/server/node_modules/split2/README.md +0 -85
- package/dist/server/node_modules/split2/bench.js +0 -27
- package/dist/server/node_modules/split2/index.js +0 -141
- package/dist/server/node_modules/split2/package.json +0 -39
- package/dist/server/node_modules/split2/test.js +0 -409
- package/dist/server/node_modules/string-width/index.d.ts +0 -39
- package/dist/server/node_modules/string-width/index.js +0 -82
- package/dist/server/node_modules/string-width/license +0 -9
- package/dist/server/node_modules/string-width/package.json +0 -64
- package/dist/server/node_modules/string-width/readme.md +0 -66
- /package/dist/server/node_modules/{is-fullwidth-code-point → get-east-asian-width}/license +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type WidthType = 'fullwidth' | 'halfwidth' | 'wide' | 'narrow' | 'neutral' | 'ambiguous';
|
|
2
|
+
|
|
3
|
+
export type Options = {
|
|
4
|
+
/**
|
|
5
|
+
Whether to treat an `'ambiguous'` character as wide.
|
|
6
|
+
|
|
7
|
+
@default true
|
|
8
|
+
|
|
9
|
+
@example
|
|
10
|
+
```
|
|
11
|
+
import {eastAsianWidth} from 'get-east-asian-width';
|
|
12
|
+
|
|
13
|
+
const codePoint = '⛣'.codePointAt(0);
|
|
14
|
+
|
|
15
|
+
console.log(eastAsianWidth(codePoint));
|
|
16
|
+
//=> 1
|
|
17
|
+
|
|
18
|
+
console.log(eastAsianWidth(codePoint, {ambiguousAsWide: true}));
|
|
19
|
+
//=> 2
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
> Ambiguous characters behave like wide or narrow characters depending on the context (language tag, script identification, associated font, source of data, or explicit markup; all can provide the context). __If the context cannot be established reliably, they should be treated as narrow characters by default.__
|
|
23
|
+
> - http://www.unicode.org/reports/tr11/
|
|
24
|
+
*/
|
|
25
|
+
readonly ambiguousAsWide?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
Returns the width as a number for the given code point.
|
|
30
|
+
|
|
31
|
+
@param codePoint - A Unicode code point.
|
|
32
|
+
|
|
33
|
+
@example
|
|
34
|
+
```
|
|
35
|
+
import {eastAsianWidth} from 'get-east-asian-width';
|
|
36
|
+
|
|
37
|
+
const codePoint = '字'.codePointAt(0);
|
|
38
|
+
|
|
39
|
+
console.log(eastAsianWidth(codePoint));
|
|
40
|
+
//=> 2
|
|
41
|
+
```
|
|
42
|
+
*/
|
|
43
|
+
export function eastAsianWidth(codePoint: number, options?: Options): 1 | 2;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
Returns the type of “East Asian Width” for the given code point.
|
|
47
|
+
|
|
48
|
+
@param codePoint - A Unicode code point.
|
|
49
|
+
|
|
50
|
+
@example
|
|
51
|
+
```
|
|
52
|
+
import {eastAsianWidthType} from 'get-east-asian-width';
|
|
53
|
+
|
|
54
|
+
const codePoint = '字'.codePointAt(0);
|
|
55
|
+
|
|
56
|
+
console.log(eastAsianWidthType(codePoint));
|
|
57
|
+
//=> 'wide'
|
|
58
|
+
```
|
|
59
|
+
*/
|
|
60
|
+
export function eastAsianWidthType(codePoint: number): WidthType;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {getCategory, isAmbiguous, isFullWidth, isWide} from './lookup.js';
|
|
2
|
+
|
|
3
|
+
function validate(codePoint) {
|
|
4
|
+
if (!Number.isSafeInteger(codePoint)) {
|
|
5
|
+
throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function eastAsianWidthType(codePoint) {
|
|
10
|
+
validate(codePoint);
|
|
11
|
+
|
|
12
|
+
return getCategory(codePoint);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function eastAsianWidth(codePoint, {ambiguousAsWide = false} = {}) {
|
|
16
|
+
validate(codePoint);
|
|
17
|
+
|
|
18
|
+
if (
|
|
19
|
+
isFullWidth(codePoint)
|
|
20
|
+
|| isWide(codePoint)
|
|
21
|
+
|| (ambiguousAsWide && isAmbiguous(codePoint))
|
|
22
|
+
) {
|
|
23
|
+
return 2;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Private exports for https://github.com/sindresorhus/is-fullwidth-code-point
|
|
30
|
+
export {isFullWidth as _isFullWidth, isWide as _isWide} from './lookup.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Generated by scripts/build.js
|
|
2
|
+
|
|
3
|
+
// prettier-ignore
|
|
4
|
+
const ambiguousRanges = [161, 161, 164, 164, 167, 168, 170, 170, 173, 174, 176, 180, 182, 186, 188, 191, 198, 198, 208, 208, 215, 216, 222, 225, 230, 230, 232, 234, 236, 237, 240, 240, 242, 243, 247, 250, 252, 252, 254, 254, 257, 257, 273, 273, 275, 275, 283, 283, 294, 295, 299, 299, 305, 307, 312, 312, 319, 322, 324, 324, 328, 331, 333, 333, 338, 339, 358, 359, 363, 363, 462, 462, 464, 464, 466, 466, 468, 468, 470, 470, 472, 472, 474, 474, 476, 476, 593, 593, 609, 609, 708, 708, 711, 711, 713, 715, 717, 717, 720, 720, 728, 731, 733, 733, 735, 735, 768, 879, 913, 929, 931, 937, 945, 961, 963, 969, 1025, 1025, 1040, 1103, 1105, 1105, 8208, 8208, 8211, 8214, 8216, 8217, 8220, 8221, 8224, 8226, 8228, 8231, 8240, 8240, 8242, 8243, 8245, 8245, 8251, 8251, 8254, 8254, 8308, 8308, 8319, 8319, 8321, 8324, 8364, 8364, 8451, 8451, 8453, 8453, 8457, 8457, 8467, 8467, 8470, 8470, 8481, 8482, 8486, 8486, 8491, 8491, 8531, 8532, 8539, 8542, 8544, 8555, 8560, 8569, 8585, 8585, 8592, 8601, 8632, 8633, 8658, 8658, 8660, 8660, 8679, 8679, 8704, 8704, 8706, 8707, 8711, 8712, 8715, 8715, 8719, 8719, 8721, 8721, 8725, 8725, 8730, 8730, 8733, 8736, 8739, 8739, 8741, 8741, 8743, 8748, 8750, 8750, 8756, 8759, 8764, 8765, 8776, 8776, 8780, 8780, 8786, 8786, 8800, 8801, 8804, 8807, 8810, 8811, 8814, 8815, 8834, 8835, 8838, 8839, 8853, 8853, 8857, 8857, 8869, 8869, 8895, 8895, 8978, 8978, 9312, 9449, 9451, 9547, 9552, 9587, 9600, 9615, 9618, 9621, 9632, 9633, 9635, 9641, 9650, 9651, 9654, 9655, 9660, 9661, 9664, 9665, 9670, 9672, 9675, 9675, 9678, 9681, 9698, 9701, 9711, 9711, 9733, 9734, 9737, 9737, 9742, 9743, 9756, 9756, 9758, 9758, 9792, 9792, 9794, 9794, 9824, 9825, 9827, 9829, 9831, 9834, 9836, 9837, 9839, 9839, 9886, 9887, 9919, 9919, 9926, 9933, 9935, 9939, 9941, 9953, 9955, 9955, 9960, 9961, 9963, 9969, 9972, 9972, 9974, 9977, 9979, 9980, 9982, 9983, 10045, 10045, 10102, 10111, 11094, 11097, 12872, 12879, 57344, 63743, 65024, 65039, 65533, 65533, 127232, 127242, 127248, 127277, 127280, 127337, 127344, 127373, 127375, 127376, 127387, 127404, 917760, 917999, 983040, 1048573, 1048576, 1114109];
|
|
5
|
+
|
|
6
|
+
// prettier-ignore
|
|
7
|
+
const fullwidthRanges = [12288, 12288, 65281, 65376, 65504, 65510];
|
|
8
|
+
|
|
9
|
+
// prettier-ignore
|
|
10
|
+
const halfwidthRanges = [8361, 8361, 65377, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65512, 65518];
|
|
11
|
+
|
|
12
|
+
// prettier-ignore
|
|
13
|
+
const narrowRanges = [32, 126, 162, 163, 165, 166, 172, 172, 175, 175, 10214, 10221, 10629, 10630];
|
|
14
|
+
|
|
15
|
+
// prettier-ignore
|
|
16
|
+
const wideRanges = [4352, 4447, 8986, 8987, 9001, 9002, 9193, 9196, 9200, 9200, 9203, 9203, 9725, 9726, 9748, 9749, 9776, 9783, 9800, 9811, 9855, 9855, 9866, 9871, 9875, 9875, 9889, 9889, 9898, 9899, 9917, 9918, 9924, 9925, 9934, 9934, 9940, 9940, 9962, 9962, 9970, 9971, 9973, 9973, 9978, 9978, 9981, 9981, 9989, 9989, 9994, 9995, 10024, 10024, 10060, 10060, 10062, 10062, 10067, 10069, 10071, 10071, 10133, 10135, 10160, 10160, 10175, 10175, 11035, 11036, 11088, 11088, 11093, 11093, 11904, 11929, 11931, 12019, 12032, 12245, 12272, 12287, 12289, 12350, 12353, 12438, 12441, 12543, 12549, 12591, 12593, 12686, 12688, 12773, 12783, 12830, 12832, 12871, 12880, 42124, 42128, 42182, 43360, 43388, 44032, 55203, 63744, 64255, 65040, 65049, 65072, 65106, 65108, 65126, 65128, 65131, 94176, 94180, 94192, 94198, 94208, 101589, 101631, 101662, 101760, 101874, 110576, 110579, 110581, 110587, 110589, 110590, 110592, 110882, 110898, 110898, 110928, 110930, 110933, 110933, 110948, 110951, 110960, 111355, 119552, 119638, 119648, 119670, 126980, 126980, 127183, 127183, 127374, 127374, 127377, 127386, 127488, 127490, 127504, 127547, 127552, 127560, 127568, 127569, 127584, 127589, 127744, 127776, 127789, 127797, 127799, 127868, 127870, 127891, 127904, 127946, 127951, 127955, 127968, 127984, 127988, 127988, 127992, 128062, 128064, 128064, 128066, 128252, 128255, 128317, 128331, 128334, 128336, 128359, 128378, 128378, 128405, 128406, 128420, 128420, 128507, 128591, 128640, 128709, 128716, 128716, 128720, 128722, 128725, 128728, 128732, 128735, 128747, 128748, 128756, 128764, 128992, 129003, 129008, 129008, 129292, 129338, 129340, 129349, 129351, 129535, 129648, 129660, 129664, 129674, 129678, 129734, 129736, 129736, 129741, 129756, 129759, 129770, 129775, 129784, 131072, 196605, 196608, 262141];
|
|
17
|
+
|
|
18
|
+
export {ambiguousRanges, fullwidthRanges, halfwidthRanges, narrowRanges, wideRanges};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ambiguousRanges,
|
|
3
|
+
fullwidthRanges,
|
|
4
|
+
halfwidthRanges,
|
|
5
|
+
narrowRanges,
|
|
6
|
+
wideRanges,
|
|
7
|
+
} from './lookup-data.js';
|
|
8
|
+
import {isInRange} from './utilities.js';
|
|
9
|
+
|
|
10
|
+
const minimumAmbiguousCodePoint = ambiguousRanges[0];
|
|
11
|
+
const maximumAmbiguousCodePoint = ambiguousRanges.at(-1);
|
|
12
|
+
const minimumFullWidthCodePoint = fullwidthRanges[0];
|
|
13
|
+
const maximumFullWidthCodePoint = fullwidthRanges.at(-1);
|
|
14
|
+
const minimumHalfWidthCodePoint = halfwidthRanges[0];
|
|
15
|
+
const maximumHalfWidthCodePoint = halfwidthRanges.at(-1);
|
|
16
|
+
const minimumNarrowCodePoint = narrowRanges[0];
|
|
17
|
+
const maximumNarrowCodePoint = narrowRanges.at(-1);
|
|
18
|
+
const minimumWideCodePoint = wideRanges[0];
|
|
19
|
+
const maximumWideCodePoint = wideRanges.at(-1);
|
|
20
|
+
|
|
21
|
+
const commonCjkCodePoint = 0x4E_00;
|
|
22
|
+
const [wideFastPathStart, wideFastPathEnd] = findWideFastPathRange(wideRanges);
|
|
23
|
+
|
|
24
|
+
// Use a hot-path range so common `isWide` calls can skip binary search.
|
|
25
|
+
// The range containing U+4E00 covers common CJK ideographs;
|
|
26
|
+
// fallback to the largest range for resilience to Unicode table changes.
|
|
27
|
+
function findWideFastPathRange(ranges) {
|
|
28
|
+
let fastPathStart = ranges[0];
|
|
29
|
+
let fastPathEnd = ranges[1];
|
|
30
|
+
|
|
31
|
+
for (let index = 0; index < ranges.length; index += 2) {
|
|
32
|
+
const start = ranges[index];
|
|
33
|
+
const end = ranges[index + 1];
|
|
34
|
+
|
|
35
|
+
if (
|
|
36
|
+
commonCjkCodePoint >= start
|
|
37
|
+
&& commonCjkCodePoint <= end
|
|
38
|
+
) {
|
|
39
|
+
return [start, end];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if ((end - start) > (fastPathEnd - fastPathStart)) {
|
|
43
|
+
fastPathStart = start;
|
|
44
|
+
fastPathEnd = end;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return [fastPathStart, fastPathEnd];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export const isAmbiguous = codePoint => {
|
|
52
|
+
if (
|
|
53
|
+
codePoint < minimumAmbiguousCodePoint
|
|
54
|
+
|| codePoint > maximumAmbiguousCodePoint
|
|
55
|
+
) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return isInRange(ambiguousRanges, codePoint);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const isFullWidth = codePoint => {
|
|
63
|
+
if (
|
|
64
|
+
codePoint < minimumFullWidthCodePoint
|
|
65
|
+
|| codePoint > maximumFullWidthCodePoint
|
|
66
|
+
) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return isInRange(fullwidthRanges, codePoint);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const isHalfWidth = codePoint => {
|
|
74
|
+
if (
|
|
75
|
+
codePoint < minimumHalfWidthCodePoint
|
|
76
|
+
|| codePoint > maximumHalfWidthCodePoint
|
|
77
|
+
) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return isInRange(halfwidthRanges, codePoint);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const isNarrow = codePoint => {
|
|
85
|
+
if (
|
|
86
|
+
codePoint < minimumNarrowCodePoint
|
|
87
|
+
|| codePoint > maximumNarrowCodePoint
|
|
88
|
+
) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return isInRange(narrowRanges, codePoint);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const isWide = codePoint => {
|
|
96
|
+
if (
|
|
97
|
+
codePoint >= wideFastPathStart
|
|
98
|
+
&& codePoint <= wideFastPathEnd
|
|
99
|
+
) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (
|
|
104
|
+
codePoint < minimumWideCodePoint
|
|
105
|
+
|| codePoint > maximumWideCodePoint
|
|
106
|
+
) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return isInRange(wideRanges, codePoint);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export function getCategory(codePoint) {
|
|
114
|
+
if (isAmbiguous(codePoint)) {
|
|
115
|
+
return 'ambiguous';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (isFullWidth(codePoint)) {
|
|
119
|
+
return 'fullwidth';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (isHalfWidth(codePoint)) {
|
|
123
|
+
return 'halfwidth';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (isNarrow(codePoint)) {
|
|
127
|
+
return 'narrow';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (isWide(codePoint)) {
|
|
131
|
+
return 'wide';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return 'neutral';
|
|
135
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "get-east-asian-width",
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "Determine the East Asian Width of a Unicode character",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "sindresorhus/get-east-asian-width",
|
|
7
|
+
"funding": "https://github.com/sponsors/sindresorhus",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Sindre Sorhus",
|
|
10
|
+
"email": "sindresorhus@gmail.com",
|
|
11
|
+
"url": "https://sindresorhus.com"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
"types": "./index.d.ts",
|
|
16
|
+
"default": "./index.js"
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "xo && ava && tsc index.d.ts",
|
|
24
|
+
"build": "node scripts/build.js",
|
|
25
|
+
"prepublish": "npm run build"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"index.js",
|
|
29
|
+
"index.d.ts",
|
|
30
|
+
"lookup.js",
|
|
31
|
+
"lookup-data.js",
|
|
32
|
+
"utilities.js"
|
|
33
|
+
],
|
|
34
|
+
"keywords": [
|
|
35
|
+
"unicode",
|
|
36
|
+
"east-asian-width",
|
|
37
|
+
"eastasianwidth",
|
|
38
|
+
"character",
|
|
39
|
+
"string",
|
|
40
|
+
"width",
|
|
41
|
+
"text",
|
|
42
|
+
"layout",
|
|
43
|
+
"alignment",
|
|
44
|
+
"fullwidth",
|
|
45
|
+
"halfwidth",
|
|
46
|
+
"ambiguous",
|
|
47
|
+
"narrow",
|
|
48
|
+
"wide",
|
|
49
|
+
"neutral",
|
|
50
|
+
"typography",
|
|
51
|
+
"japanese",
|
|
52
|
+
"chinese",
|
|
53
|
+
"korean",
|
|
54
|
+
"codepoint",
|
|
55
|
+
"text-processing",
|
|
56
|
+
"i18n",
|
|
57
|
+
"l10n"
|
|
58
|
+
],
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"ava": "^5.3.1",
|
|
61
|
+
"outdent": "^0.8.0",
|
|
62
|
+
"simplify-ranges": "^0.1.0",
|
|
63
|
+
"typescript": "^5.2.2",
|
|
64
|
+
"xo": "^0.56.0"
|
|
65
|
+
},
|
|
66
|
+
"xo": {
|
|
67
|
+
"ignores": [
|
|
68
|
+
"lookup-data.js"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# get-east-asian-width
|
|
2
|
+
|
|
3
|
+
> Determine the [East Asian Width](https://unicode.org/reports/tr11/) of a Unicode character
|
|
4
|
+
|
|
5
|
+
> East Asian Width categorizes Unicode characters based on their occupied space in East Asian typography, which helps in text layout and alignment, particularly in languages like Japanese, Chinese, and Korean.
|
|
6
|
+
|
|
7
|
+
Unlike other similar packages, this package uses the latest Unicode data (which changes each year).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install get-east-asian-width
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import {eastAsianWidth, eastAsianWidthType} from 'get-east-asian-width';
|
|
19
|
+
|
|
20
|
+
const codePoint = '字'.codePointAt(0);
|
|
21
|
+
|
|
22
|
+
console.log(eastAsianWidth(codePoint));
|
|
23
|
+
//=> 2
|
|
24
|
+
|
|
25
|
+
console.log(eastAsianWidthType(codePoint));
|
|
26
|
+
//=> 'wide'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## `eastAsianWidth(codePoint: number, options?: object): 1 | 2`
|
|
30
|
+
|
|
31
|
+
Returns the width as a number for the given code point.
|
|
32
|
+
|
|
33
|
+
### options
|
|
34
|
+
|
|
35
|
+
Type: `object`
|
|
36
|
+
|
|
37
|
+
#### ambiguousAsWide
|
|
38
|
+
|
|
39
|
+
Type: `boolean`\
|
|
40
|
+
Default: `false`
|
|
41
|
+
|
|
42
|
+
Whether to treat an `'ambiguous'` character as wide.
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
import {eastAsianWidth} from 'get-east-asian-width';
|
|
46
|
+
|
|
47
|
+
const codePoint = '⛣'.codePointAt(0);
|
|
48
|
+
|
|
49
|
+
console.log(eastAsianWidth(codePoint));
|
|
50
|
+
//=> 1
|
|
51
|
+
|
|
52
|
+
console.log(eastAsianWidth(codePoint, {ambiguousAsWide: true}));
|
|
53
|
+
//=> 2
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
> Ambiguous characters behave like wide or narrow characters depending on the context (language tag, script identification, associated font, source of data, or explicit markup; all can provide the context). **If the context cannot be established reliably, they should be treated as narrow characters by default.**
|
|
57
|
+
> - http://www.unicode.org/reports/tr11/
|
|
58
|
+
|
|
59
|
+
## `eastAsianWidthType(codePoint: number): 'fullwidth' | 'halfwidth' | 'wide' | 'narrow' | 'neutral' | 'ambiguous'`
|
|
60
|
+
|
|
61
|
+
Returns the type of “East Asian Width” for the given code point.
|
|
62
|
+
|
|
63
|
+
## Related
|
|
64
|
+
|
|
65
|
+
- [string-width](https://github.com/sindresorhus/string-width) - Get the visual width of a string
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Binary search on a sorted flat array of [start, end] pairs.
|
|
3
|
+
|
|
4
|
+
@param {number[]} ranges - Flat array of inclusive [start, end] range pairs, e.g. [0, 5, 10, 20].
|
|
5
|
+
@param {number} codePoint - The value to search for.
|
|
6
|
+
@returns {boolean} Whether the value falls within any of the ranges.
|
|
7
|
+
*/
|
|
8
|
+
export const isInRange = (ranges, codePoint) => {
|
|
9
|
+
let low = 0;
|
|
10
|
+
let high = Math.floor(ranges.length / 2) - 1;
|
|
11
|
+
while (low <= high) {
|
|
12
|
+
const mid = Math.floor((low + high) / 2);
|
|
13
|
+
const i = mid * 2;
|
|
14
|
+
if (codePoint < ranges[i]) {
|
|
15
|
+
high = mid - 1;
|
|
16
|
+
} else if (codePoint > ranges[i + 1]) {
|
|
17
|
+
low = mid + 1;
|
|
18
|
+
} else {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return false;
|
|
24
|
+
};
|
package/dist/server/server.js
CHANGED
|
@@ -3938,9 +3938,10 @@ var gitSync2 = (args, opts) => gitSync(["-c", "safe.directory=*", ...args], opts
|
|
|
3938
3938
|
class BranchStatusMonitor {
|
|
3939
3939
|
config;
|
|
3940
3940
|
broadcaster;
|
|
3941
|
-
last =
|
|
3941
|
+
last = { kind: "initializing" };
|
|
3942
3942
|
timer = null;
|
|
3943
3943
|
watcher = null;
|
|
3944
|
+
pollFallback = null;
|
|
3944
3945
|
constructor(config, broadcaster) {
|
|
3945
3946
|
this.config = config;
|
|
3946
3947
|
this.broadcaster = broadcaster;
|
|
@@ -3948,35 +3949,66 @@ class BranchStatusMonitor {
|
|
|
3948
3949
|
getLast() {
|
|
3949
3950
|
return this.last;
|
|
3950
3951
|
}
|
|
3951
|
-
|
|
3952
|
+
setPhase(next) {
|
|
3953
|
+
if (this.equal(this.last, next))
|
|
3954
|
+
return;
|
|
3955
|
+
this.last = next;
|
|
3956
|
+
this.broadcast(next);
|
|
3957
|
+
}
|
|
3958
|
+
markReady() {
|
|
3952
3959
|
const next = this.compute();
|
|
3953
3960
|
if (!next)
|
|
3954
3961
|
return;
|
|
3955
|
-
if (this.
|
|
3962
|
+
if (this.equal(this.last, next))
|
|
3956
3963
|
return;
|
|
3957
|
-
}
|
|
3958
3964
|
this.last = next;
|
|
3965
|
+
this.broadcast(next);
|
|
3966
|
+
this.ensureWatch();
|
|
3967
|
+
}
|
|
3968
|
+
stop() {
|
|
3969
|
+
if (this.timer) {
|
|
3970
|
+
clearTimeout(this.timer);
|
|
3971
|
+
this.timer = null;
|
|
3972
|
+
}
|
|
3973
|
+
if (this.watcher) {
|
|
3974
|
+
this.watcher.close();
|
|
3975
|
+
this.watcher = null;
|
|
3976
|
+
}
|
|
3977
|
+
if (this.pollFallback) {
|
|
3978
|
+
clearInterval(this.pollFallback);
|
|
3979
|
+
this.pollFallback = null;
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
broadcast(s) {
|
|
3959
3983
|
this.broadcaster.broadcastEvent("branch-status", {
|
|
3960
3984
|
type: "branch-status",
|
|
3961
|
-
...
|
|
3985
|
+
...s
|
|
3962
3986
|
});
|
|
3963
3987
|
}
|
|
3988
|
+
equal(a, b) {
|
|
3989
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
3990
|
+
}
|
|
3964
3991
|
schedule() {
|
|
3965
3992
|
if (this.timer)
|
|
3966
3993
|
return;
|
|
3967
3994
|
this.timer = setTimeout(() => {
|
|
3968
3995
|
this.timer = null;
|
|
3969
|
-
this.
|
|
3996
|
+
if (this.last.kind === "ready")
|
|
3997
|
+
this.markReady();
|
|
3970
3998
|
}, 250);
|
|
3971
3999
|
}
|
|
3972
|
-
|
|
3973
|
-
if (this.watcher)
|
|
4000
|
+
ensureWatch() {
|
|
4001
|
+
if (this.watcher || this.pollFallback)
|
|
3974
4002
|
return;
|
|
3975
4003
|
const gitDir = \`\${this.config.appRoot}/.git\`;
|
|
3976
4004
|
try {
|
|
3977
4005
|
this.watcher = fs2.watch(gitDir, { recursive: true }, () => this.schedule());
|
|
4006
|
+
this.watcher.on("error", () => {});
|
|
3978
4007
|
} catch {
|
|
3979
|
-
setInterval(() =>
|
|
4008
|
+
this.pollFallback = setInterval(() => {
|
|
4009
|
+
if (this.last.kind === "ready")
|
|
4010
|
+
this.markReady();
|
|
4011
|
+
}, 5000);
|
|
3980
4012
|
}
|
|
3981
4013
|
}
|
|
3982
4014
|
compute() {
|
|
@@ -4017,6 +4049,7 @@ class BranchStatusMonitor {
|
|
|
4017
4049
|
}
|
|
4018
4050
|
const headSha = run(["rev-parse", branchRef]);
|
|
4019
4051
|
return {
|
|
4052
|
+
kind: "ready",
|
|
4020
4053
|
branch,
|
|
4021
4054
|
base,
|
|
4022
4055
|
workingTreeDirty: dirty,
|
|
@@ -5330,9 +5363,7 @@ function makeSseStream(deps) {
|
|
|
5330
5363
|
...deps.getAppStatus()
|
|
5331
5364
|
})));
|
|
5332
5365
|
const lastBranch = deps.getLastBranchStatus();
|
|
5333
|
-
|
|
5334
|
-
c.enqueue(sseFormat("branch-status", JSON.stringify({ type: "branch-status", ...lastBranch })));
|
|
5335
|
-
}
|
|
5366
|
+
c.enqueue(sseFormat("branch-status", JSON.stringify({ type: "branch-status", ...lastBranch })));
|
|
5336
5367
|
deps.broadcaster.register(controller);
|
|
5337
5368
|
keepAlive = setInterval(() => {
|
|
5338
5369
|
try {
|
|
@@ -6127,19 +6158,33 @@ class SetupOrchestrator {
|
|
|
6127
6158
|
return;
|
|
6128
6159
|
const cloneUrl = config.git?.repository?.cloneUrl;
|
|
6129
6160
|
if (cloneUrl && !isResume(config.repoDir)) {
|
|
6161
|
+
this.deps.branchStatus.setPhase({ kind: "cloning" });
|
|
6130
6162
|
const cloneTaskId = this.deps.phaseManager?.begin("clone");
|
|
6131
6163
|
const cloneLogPath = appLogPath(this.deps.logsDir, "clone");
|
|
6132
6164
|
try {
|
|
6133
6165
|
unlinkSync3(cloneLogPath);
|
|
6134
6166
|
} catch {}
|
|
6135
6167
|
const cloneTee = new LogTee(cloneLogPath, INSTALL_LOG_MAX_BYTES);
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6168
|
+
let code;
|
|
6169
|
+
try {
|
|
6170
|
+
code = await spawnClone({
|
|
6171
|
+
config,
|
|
6172
|
+
onChunk: (_src, data) => {
|
|
6173
|
+
this.chunk(data);
|
|
6174
|
+
cloneTee.write(data);
|
|
6175
|
+
}
|
|
6176
|
+
});
|
|
6177
|
+
} catch (e) {
|
|
6178
|
+
cloneTee.close();
|
|
6179
|
+
const error = e.message;
|
|
6180
|
+
this.chunk(\`\\r
|
|
6181
|
+
[orchestrator] clone failed: \${error}\\r
|
|
6182
|
+
\`);
|
|
6183
|
+
if (cloneTaskId)
|
|
6184
|
+
this.deps.phaseManager?.fail(cloneTaskId, error);
|
|
6185
|
+
this.deps.branchStatus.setPhase({ kind: "clone-failed", error });
|
|
6186
|
+
return;
|
|
6187
|
+
}
|
|
6143
6188
|
cloneTee.close();
|
|
6144
6189
|
if (code !== 0) {
|
|
6145
6190
|
this.chunk(\`\\r
|
|
@@ -6147,6 +6192,10 @@ class SetupOrchestrator {
|
|
|
6147
6192
|
\`);
|
|
6148
6193
|
if (cloneTaskId)
|
|
6149
6194
|
this.deps.phaseManager?.fail(cloneTaskId, \`exit \${code}\`);
|
|
6195
|
+
this.deps.branchStatus.setPhase({
|
|
6196
|
+
kind: "clone-failed",
|
|
6197
|
+
error: \`exit \${code}\`
|
|
6198
|
+
});
|
|
6150
6199
|
return;
|
|
6151
6200
|
}
|
|
6152
6201
|
if (cloneTaskId)
|
|
@@ -6156,6 +6205,7 @@ class SetupOrchestrator {
|
|
|
6156
6205
|
\`);
|
|
6157
6206
|
}
|
|
6158
6207
|
await this.gitSetup(config);
|
|
6208
|
+
this.deps.branchStatus.markReady();
|
|
6159
6209
|
if (config.application?.intent === "running") {
|
|
6160
6210
|
const installed = await this.runInstall();
|
|
6161
6211
|
if (installed)
|
|
@@ -6171,6 +6221,7 @@ class SetupOrchestrator {
|
|
|
6171
6221
|
if (!config)
|
|
6172
6222
|
return;
|
|
6173
6223
|
await this.gitSetup(config);
|
|
6224
|
+
this.deps.branchStatus.markReady();
|
|
6174
6225
|
if (config.application?.intent === "running") {
|
|
6175
6226
|
if (!this.deps.installState.isInstalledFor(config, this.currentBranchHead)) {
|
|
6176
6227
|
const ok = await this.runInstall();
|
|
@@ -6186,15 +6237,19 @@ class SetupOrchestrator {
|
|
|
6186
6237
|
await this.deps.appService.stop();
|
|
6187
6238
|
this.chunk(\`[orchestrator] checking out branch: \${to}\\r
|
|
6188
6239
|
\`);
|
|
6240
|
+
this.deps.branchStatus.setPhase({ kind: "checking-out", to });
|
|
6189
6241
|
try {
|
|
6190
6242
|
await this.checkoutBranch(to);
|
|
6191
6243
|
} catch (e) {
|
|
6244
|
+
const error = e.message;
|
|
6192
6245
|
this.chunk(\`\\r
|
|
6193
|
-
[orchestrator] branch-change failed: \${
|
|
6246
|
+
[orchestrator] branch-change failed: \${error}\\r
|
|
6194
6247
|
\`);
|
|
6248
|
+
this.deps.branchStatus.setPhase({ kind: "checkout-failed", error });
|
|
6195
6249
|
return;
|
|
6196
6250
|
}
|
|
6197
6251
|
this.refreshBranchHead();
|
|
6252
|
+
this.deps.branchStatus.markReady();
|
|
6198
6253
|
const ok = await this.runInstall();
|
|
6199
6254
|
if (ok)
|
|
6200
6255
|
await this.startIfReady();
|
|
@@ -6538,6 +6593,14 @@ var appService = new ApplicationService({
|
|
|
6538
6593
|
\`);
|
|
6539
6594
|
}
|
|
6540
6595
|
});
|
|
6596
|
+
var branchStatus = new BranchStatusMonitor({
|
|
6597
|
+
appRoot: bootConfig.appRoot,
|
|
6598
|
+
repoDir: bootConfig.repoDir,
|
|
6599
|
+
daemonToken: bootConfig.daemonToken,
|
|
6600
|
+
daemonBootId: bootConfig.daemonBootId,
|
|
6601
|
+
proxyPort: bootConfig.proxyPort,
|
|
6602
|
+
dropPrivileges: false
|
|
6603
|
+
}, broadcaster);
|
|
6541
6604
|
var orchestrator = new SetupOrchestrator({
|
|
6542
6605
|
bootConfig: { appRoot: bootConfig.appRoot, repoDir: bootConfig.repoDir },
|
|
6543
6606
|
store,
|
|
@@ -6545,9 +6608,9 @@ var orchestrator = new SetupOrchestrator({
|
|
|
6545
6608
|
broadcaster,
|
|
6546
6609
|
installState,
|
|
6547
6610
|
logsDir: TMP_DIR,
|
|
6548
|
-
phaseManager
|
|
6611
|
+
phaseManager,
|
|
6612
|
+
branchStatus
|
|
6549
6613
|
});
|
|
6550
|
-
var branchStatus = null;
|
|
6551
6614
|
var discoveredScripts = null;
|
|
6552
6615
|
var lastWrittenProxyPort;
|
|
6553
6616
|
var origEvent = broadcaster.broadcastEvent.bind(broadcaster);
|
|
@@ -6559,27 +6622,7 @@ broadcaster.broadcastEvent = (event, data) => {
|
|
|
6559
6622
|
};
|
|
6560
6623
|
store.subscribe((event) => {
|
|
6561
6624
|
orchestrator.handle(event.transition);
|
|
6562
|
-
if (event.transition.kind === "first-bootstrap") {
|
|
6563
|
-
refreshBranchStatusMonitor();
|
|
6564
|
-
}
|
|
6565
6625
|
});
|
|
6566
|
-
function refreshBranchStatusMonitor() {
|
|
6567
|
-
const enriched = store.read();
|
|
6568
|
-
if (!enriched) {
|
|
6569
|
-
branchStatus = null;
|
|
6570
|
-
return;
|
|
6571
|
-
}
|
|
6572
|
-
const config = {
|
|
6573
|
-
...enriched,
|
|
6574
|
-
daemonToken: bootConfig.daemonToken,
|
|
6575
|
-
daemonBootId: bootConfig.daemonBootId,
|
|
6576
|
-
proxyPort: bootConfig.proxyPort,
|
|
6577
|
-
appRoot: bootConfig.appRoot,
|
|
6578
|
-
repoDir: bootConfig.repoDir,
|
|
6579
|
-
dropPrivileges: false
|
|
6580
|
-
};
|
|
6581
|
-
branchStatus = new BranchStatusMonitor(config, broadcaster);
|
|
6582
|
-
}
|
|
6583
6626
|
var excludeFromDiscovery = new Set([bootConfig.proxyPort]);
|
|
6584
6627
|
var getDiscoveredPorts = () => {
|
|
6585
6628
|
const pids = [];
|
|
@@ -6668,7 +6711,7 @@ var eventsH = makeEventsHandler({
|
|
|
6668
6711
|
getDiscoveredScripts: () => discoveredScripts,
|
|
6669
6712
|
getActiveTasks,
|
|
6670
6713
|
getAppStatus: () => appService.snapshot(),
|
|
6671
|
-
getLastBranchStatus: () => branchStatus
|
|
6714
|
+
getLastBranchStatus: () => branchStatus.getLast()
|
|
6672
6715
|
});
|
|
6673
6716
|
var idleH = makeIdleHandler();
|
|
6674
6717
|
var proxyH = makeProxyHandler({ broadcaster, getDevPort });
|
|
@@ -6705,7 +6748,6 @@ function hydrate() {
|
|
|
6705
6748
|
if (!initial)
|
|
6706
6749
|
return;
|
|
6707
6750
|
store.hydrate(initial);
|
|
6708
|
-
refreshBranchStatusMonitor();
|
|
6709
6751
|
const transitionKind = isResume(bootConfig.repoDir) ? "resume" : "first-bootstrap";
|
|
6710
6752
|
orchestrator.handle({ kind: transitionKind, config: initial });
|
|
6711
6753
|
if (diskOutcome.kind !== "valid") {
|
|
@@ -6814,6 +6856,7 @@ Bun.serve({
|
|
|
6814
6856
|
process.on("SIGTERM", () => {
|
|
6815
6857
|
taskManager.shutdown();
|
|
6816
6858
|
appService.shutdown();
|
|
6859
|
+
branchStatus.stop();
|
|
6817
6860
|
const branch = store.read()?.git?.repository?.branch;
|
|
6818
6861
|
if (branch) {
|
|
6819
6862
|
try {
|