@nldd/design-system 0.20.0 → 0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +361 -10
- package/dist/cdn/autoloader.js +181 -0
- package/dist/cdn/chunks/activity-indicator-JglZJ8dh.js +356 -0
- package/dist/cdn/chunks/activity-indicator.i18n-D7mCy6d2.js +3 -0
- package/dist/cdn/chunks/avatar-ASqePVhU.js +308 -0
- package/dist/cdn/chunks/avatar-group-GinEMPm9.js +338 -0
- package/dist/cdn/chunks/avatar-group.i18n-BYw_9wt_.js +7 -0
- package/dist/cdn/chunks/avatar.i18n-CMwQjBkS.js +7 -0
- package/dist/cdn/chunks/badge-Cc2Nufoc.js +323 -0
- package/dist/cdn/chunks/badge.i18n-DqW7hLQj.js +3 -0
- package/dist/cdn/chunks/banner-BLVKM07M.js +325 -0
- package/dist/cdn/chunks/banner.i18n-BOCM9rGN.js +3 -0
- package/dist/cdn/chunks/bar-split-view-Clbg-p9H.js +259 -0
- package/dist/cdn/chunks/base-CfuoYRhN.js +3 -0
- package/dist/cdn/chunks/blockquote-BoOqbGdm.js +189 -0
- package/dist/cdn/chunks/box-WkhyjQVy.js +88 -0
- package/dist/cdn/chunks/breadcrumbs-D9YxZzRj.js +162 -0
- package/dist/cdn/chunks/breadcrumbs.i18n-zmO8jaTO.js +3 -0
- package/dist/cdn/chunks/breakpoints-Cwor8TRP.js +15 -0
- package/dist/cdn/chunks/button-DO90Lo6q.js +863 -0
- package/dist/cdn/chunks/button-bar-Bxgdbyh3.js +225 -0
- package/dist/cdn/chunks/button-group-BYGPPLmZ.js +205 -0
- package/dist/{components/button.i18n-DiDGynnq.js → cdn/chunks/button.i18n-BGFt7Z9u.js} +2 -2
- package/dist/cdn/chunks/card-BP0jfOkS.js +262 -0
- package/dist/cdn/chunks/card.i18n-CpafLm3i.js +8 -0
- package/dist/cdn/chunks/carried-context-DlMSujiJ.js +37 -0
- package/dist/cdn/chunks/cell-BRD2ilQh.js +144 -0
- package/dist/cdn/chunks/checkbox-Cazx8CQn.js +296 -0
- package/dist/cdn/chunks/checkbox-field-DDZ-B6vH.js +157 -0
- package/dist/cdn/chunks/class-map-CXSdNjt8.js +26 -0
- package/dist/cdn/chunks/code-editor-D6Q55oaY.js +286 -0
- package/dist/cdn/chunks/code-viewer-DspLH2T1.js +766 -0
- package/dist/cdn/chunks/code-viewer.i18n-BHfSDRbK.js +13 -0
- package/dist/cdn/chunks/codemirror-input-Db65x22n.js +1232 -0
- package/dist/cdn/chunks/collection-NVtkvDls.js +396 -0
- package/dist/cdn/chunks/collection.i18n-DqWPGnZO.js +8 -0
- package/dist/cdn/chunks/combo-box-OywRKaWj.js +512 -0
- package/dist/cdn/chunks/combo-box.i18n-BorzYnJ2.js +6 -0
- package/dist/cdn/chunks/container-rrbwk0z4.js +602 -0
- package/dist/cdn/chunks/custom-element-BW8Ua4c7.js +7 -0
- package/dist/cdn/chunks/custom-element-q6NzoL5b.js +301 -0
- package/dist/cdn/chunks/custom-font-size-D7KNr84p.js +57 -0
- package/dist/cdn/chunks/date-field-vmZLo80s.js +662 -0
- package/dist/cdn/chunks/date-field.i18n-BTzc0E9a.js +15 -0
- package/dist/cdn/chunks/date-picker-CXDzSBoL.js +993 -0
- package/dist/cdn/chunks/date-picker.i18n-Dsc_M5QK.js +82 -0
- package/dist/cdn/chunks/decorate-TduJMFD_.js +280 -0
- package/dist/cdn/chunks/defer-focus-F73ud2D9.js +9 -0
- package/dist/cdn/chunks/described-by-mixin-daRE7orX.js +32 -0
- package/dist/cdn/chunks/description-cell-CQwOj_rN.js +166 -0
- package/dist/cdn/chunks/dev-checks-zW_W-hnh.js +2695 -0
- package/dist/cdn/chunks/directive-CwRgozUW.js +27 -0
- package/dist/cdn/chunks/dismiss-from-title-bar-C6mP7sWP.js +5 -0
- package/dist/cdn/chunks/dist-3C80SZN9.js +849 -0
- package/dist/cdn/chunks/dist-A7_1pHX0.js +379 -0
- package/dist/cdn/chunks/dist-BEfLdOvy.js +1346 -0
- package/dist/cdn/chunks/dist-BTUxFM2V.js +268 -0
- package/dist/cdn/chunks/dist-CP3G1pSK.js +1037 -0
- package/dist/cdn/chunks/dist-C_dGY6zR.js +468 -0
- package/dist/{components/dist-B9YBOGFW.js → cdn/chunks/dist-ChmCRv39.js} +109 -153
- package/dist/{components/dist-CJm4tkNC.js → cdn/chunks/dist-D2qap2OY.js} +23 -31
- package/dist/cdn/chunks/dist-DPUBF0MZ.js +1593 -0
- package/dist/{components/dist-4g23YHP0.js → cdn/chunks/dist-DrTzvgE7.js} +291 -404
- package/dist/cdn/chunks/dist-EM4MWLQq.js +385 -0
- package/dist/cdn/chunks/dist-EgIBI-FG.js +293 -0
- package/dist/{components/dist-Bf823YyL.js → cdn/chunks/dist-Rm6FvrSR.js} +272 -551
- package/dist/cdn/chunks/divider-CCNbnplA.js +53 -0
- package/dist/cdn/chunks/document-tab-bar-A2DFWrP9.js +973 -0
- package/dist/cdn/chunks/document-tab-bar.i18n-DKrA9TnB.js +9 -0
- package/dist/cdn/chunks/drag-handle-cell-CbzDYebG.js +206 -0
- package/dist/cdn/chunks/drag-handle-cell.i18n-CKUrbm2q.js +3 -0
- package/dist/cdn/chunks/dropdown-DZTZtkm5.js +350 -0
- package/dist/cdn/chunks/element-state-B-44fVqq.js +20 -0
- package/dist/cdn/chunks/file-field-DQ52qq5L.js +1484 -0
- package/dist/cdn/chunks/file-field.i18n-pDM7Utud.js +40 -0
- package/dist/cdn/chunks/floating-ui.dom-B8J1rV2c.js +753 -0
- package/dist/cdn/chunks/focus-target-DSLGcCWq.js +24 -0
- package/dist/cdn/chunks/form-actions-C_7hINq-.js +90 -0
- package/dist/cdn/chunks/form-associated-mixin--GIbl98p.js +62 -0
- package/dist/cdn/chunks/form-field--4nWJ_DK.js +364 -0
- package/dist/cdn/chunks/form-hXLgy_tY.js +84 -0
- package/dist/cdn/chunks/form-section-By-D4un0.js +64 -0
- package/dist/cdn/chunks/full-bleed-section-Dg4sIJG1.js +161 -0
- package/dist/cdn/chunks/gherkin-eseYvsxh.js +29 -0
- package/dist/cdn/chunks/hero-CQQMNCT_.js +761 -0
- package/dist/{components/icon-_Eox7ZfO.js → cdn/chunks/icon-BORlalt0.js} +298 -308
- package/dist/cdn/chunks/icon-button-rKiIHs7A.js +632 -0
- package/dist/{components/icon-button.i18n-1_N-wN6x.js → cdn/chunks/icon-button.i18n-DpZOfIS4.js} +2 -4
- package/dist/cdn/chunks/icon-cell-rk4NQid2.js +156 -0
- package/dist/cdn/chunks/identity-BLXecYsZ.js +187 -0
- package/dist/cdn/chunks/if-defined-CaKKERku.js +4 -0
- package/dist/cdn/chunks/image-DZMW6JgL.js +659 -0
- package/dist/cdn/chunks/image.i18n-ONcm1h7o.js +3 -0
- package/dist/cdn/chunks/implicit-submission-Csbcor_E.js +27 -0
- package/dist/cdn/chunks/inline-dialog-WlqtPBPJ.js +259 -0
- package/dist/cdn/chunks/input-modality-XE0B7yCn.js +42 -0
- package/dist/cdn/chunks/just-in-time-education-DRcb5g7x.js +611 -0
- package/dist/cdn/chunks/just-in-time-education.i18n-CW_dsaxf.js +6 -0
- package/dist/cdn/chunks/kanban-Ca_mfqsA.js +400 -0
- package/dist/cdn/chunks/kanban-column-fgIMc7pw.js +375 -0
- package/dist/cdn/chunks/kanban.i18n-CWqc3e0B.js +11 -0
- package/dist/cdn/chunks/keyboard-shortcut-EknnW7Ub.js +267 -0
- package/dist/cdn/chunks/languages-yKikVFv_.js +8893 -0
- package/dist/cdn/chunks/link-FBSAJ3UC.js +229 -0
- package/dist/cdn/chunks/link-group-90qVfKa0.js +111 -0
- package/dist/cdn/chunks/link-hint-KFhgr5Ng.js +24 -0
- package/dist/cdn/chunks/link-rel-DvrTEfVT.js +8 -0
- package/dist/cdn/chunks/link.i18n-DJPobGmu.js +8 -0
- package/dist/cdn/chunks/list-CaWl3q0Z.js +880 -0
- package/dist/cdn/chunks/list-item-Cagnf6eG.js +802 -0
- package/dist/cdn/chunks/list-item-segment-BRzBF1y_.js +315 -0
- package/dist/cdn/chunks/list-item-segment.i18n-DHnrQL4V.js +8 -0
- package/dist/{components/list-item.i18n-89uqlBMK.js → cdn/chunks/list-item.i18n-Br6J5Ev9.js} +2 -2
- package/dist/cdn/chunks/list-items-Du0RCWsY.js +6 -0
- package/dist/{components/list.i18n-CKqbhFQ_.js → cdn/chunks/list.i18n-C40ltgdI.js} +2 -2
- package/dist/cdn/chunks/loading-tags-DtUr-DR7.js +3 -0
- package/dist/cdn/chunks/menu-BtxzRedh.js +719 -0
- package/dist/cdn/chunks/menu-bar-BU3Hjk1b.js +253 -0
- package/dist/cdn/chunks/menu-bar-item-C7LQ0NI_.js +365 -0
- package/dist/cdn/chunks/menu-bar.i18n-BoMu4Eoz.js +3 -0
- package/dist/cdn/chunks/menu-divider-CLLRgMll.js +15 -0
- package/dist/cdn/chunks/menu-group-BL24ChpR.js +23 -0
- package/dist/cdn/chunks/menu-item-CooKfrFa.js +140 -0
- package/dist/cdn/chunks/menu.i18n-C6uYJsG3.js +10 -0
- package/dist/cdn/chunks/menu.template-C6rbfI-u.js +642 -0
- package/dist/cdn/chunks/modal-dialog-BrUMP4Jm.js +240 -0
- package/dist/cdn/chunks/multi-line-text-field-D7hXhyOn.js +318 -0
- package/dist/cdn/chunks/navigation-split-view-B2ZQhxEb.js +621 -0
- package/dist/cdn/chunks/nl.generated-D6T41jG3.js +112 -0
- package/dist/cdn/chunks/notification-DSGP14d1.js +492 -0
- package/dist/cdn/chunks/notification.i18n-BKUSLN5c.js +6 -0
- package/dist/cdn/chunks/number-field-B8op14Y_.js +301 -0
- package/dist/cdn/chunks/number-field.i18n-BS0bINWY.js +7 -0
- package/dist/cdn/chunks/one-half-one-half-section-ZYmHYf4Q.js +213 -0
- package/dist/cdn/chunks/one-third-two-thirds-section-Ds10K6AS.js +213 -0
- package/dist/cdn/chunks/one-time-code-field-Cgy_tTS4.js +693 -0
- package/dist/cdn/chunks/open-when-rendered-CW_2_WUZ.js +20 -0
- package/dist/cdn/chunks/owned-attribute-x9OCTy_4.js +6 -0
- package/dist/cdn/chunks/owner-form-Cq8tT7ac.js +7 -0
- package/dist/cdn/chunks/page-CBf_Decp.js +431 -0
- package/dist/cdn/chunks/page-footer-CSv1dU7M.js +396 -0
- package/dist/cdn/chunks/page-footer.i18n-pbdr4lN3.js +3 -0
- package/dist/cdn/chunks/page-section-mixin-Dp6X8GKd.js +132 -0
- package/dist/cdn/chunks/pagination-CMUcFB53.js +485 -0
- package/dist/cdn/chunks/pagination.i18n-QQMx14CQ.js +9 -0
- package/dist/cdn/chunks/password-field-C76Vm3rm.js +368 -0
- package/dist/cdn/chunks/password-field.i18n-CzdBn-1b.js +8 -0
- package/dist/cdn/chunks/popover-CGbeEv_-.js +334 -0
- package/dist/cdn/chunks/popover-target-B25dxnmt.js +10 -0
- package/dist/cdn/chunks/popover.i18n-DmFBHUvB.js +3 -0
- package/dist/cdn/chunks/popup-anchor-controller-VZw0bXf2.js +30 -0
- package/dist/cdn/chunks/progress-bar-BLiHaRUS.js +674 -0
- package/dist/cdn/chunks/progress-bar.i18n-Cr5miGTx.js +8 -0
- package/dist/cdn/chunks/progress-circle-CjkovRbL.js +667 -0
- package/dist/cdn/chunks/progress-circle.i18n-CRrXuY4V.js +8 -0
- package/dist/cdn/chunks/query-ChDzi9FQ.js +28 -0
- package/dist/cdn/chunks/radio-button-GHyO-GQB.js +338 -0
- package/dist/cdn/chunks/radio-button-field-C-Z6Lnd4.js +192 -0
- package/dist/cdn/chunks/radio-button-group-ChTqBCnQ.js +118 -0
- package/dist/cdn/chunks/radio-position-CXWYAjaz.js +10 -0
- package/dist/cdn/chunks/reflect-non-default-Bu3rpCvg.js +9 -0
- package/dist/cdn/chunks/render-marked-DX_5ISZE.js +37 -0
- package/dist/cdn/chunks/repeat-Ch_5OsXE.js +76 -0
- package/dist/cdn/chunks/return-focus-BzZWhXhc.js +57 -0
- package/dist/cdn/chunks/rich-text-CQ2uwMSp.js +47 -0
- package/dist/cdn/chunks/rich-text.i18n-BlJ68YuU.js +3 -0
- package/dist/cdn/chunks/row-header-mixin-CgqvREoV.js +16 -0
- package/dist/cdn/chunks/sanitize-url-CBuGmY0W.js +7 -0
- package/dist/cdn/chunks/scroll-mode-controller-COUD1-3P.js +42 -0
- package/dist/cdn/chunks/search-field-BGNfERhn.js +396 -0
- package/dist/cdn/chunks/search-field.i18n-B_Oc7hc-.js +6 -0
- package/dist/cdn/chunks/segmented-control-BYAG4VRp.js +671 -0
- package/dist/cdn/chunks/shadow-resets-6SToDsPu.js +12 -0
- package/dist/cdn/chunks/sheet-CqN7ViYV.js +340 -0
- package/dist/cdn/chunks/shell-C9rds_D9.js +146 -0
- package/dist/cdn/chunks/shell-DmJOYhyF.js +108 -0
- package/dist/cdn/chunks/side-by-side-split-view-C5oX4c6Z.js +166 -0
- package/dist/cdn/chunks/sidebar-section-CFPBdETU.js +353 -0
- package/dist/cdn/chunks/sidebar-section.i18n-BuGfRMpD.js +6 -0
- package/dist/cdn/chunks/simple-section-qrCqXeBa.js +192 -0
- package/dist/cdn/chunks/skip-link-DWh4W6-J.js +161 -0
- package/dist/cdn/chunks/skip-link.i18n--PbEdAmJ.js +3 -0
- package/dist/cdn/chunks/slider--hODfOwh.js +772 -0
- package/dist/cdn/chunks/slider.i18n-DVw0c8AG.js +6 -0
- package/dist/cdn/chunks/slot-content-BLuPqVXw.js +13 -0
- package/dist/cdn/chunks/spacer-CFzq_JCh.js +237 -0
- package/dist/cdn/chunks/spacer-cell-DuVOgIj8.js +68 -0
- package/dist/cdn/chunks/spacing-scale-SufIjHeN.js +28 -0
- package/dist/cdn/chunks/split-button-DH19p8So.js +268 -0
- package/dist/cdn/chunks/split-button.i18n-DtClSMga.js +3 -0
- package/dist/cdn/chunks/split-view-divider-jzcPmnMh.js +100 -0
- package/dist/cdn/chunks/split-view-pane-BLsZz263.js +128 -0
- package/dist/cdn/chunks/stacked-split-view-CcOR8LrJ.js +157 -0
- package/dist/cdn/chunks/static-html-Cf4ccUIg.js +26 -0
- package/dist/cdn/chunks/status-bar-CINbOihq.js +284 -0
- package/dist/cdn/chunks/status-bar-change-CR9l0Gyk.js +3 -0
- package/dist/cdn/chunks/step-bar-6FvZL1Ti.js +474 -0
- package/dist/cdn/chunks/step-bar.i18n-DocExlD7.js +9 -0
- package/dist/cdn/chunks/step-cell-CejRisgS.js +287 -0
- package/dist/cdn/chunks/stepper-CY2rJWOJ.js +223 -0
- package/dist/cdn/chunks/stepper.i18n-COOAkaBl.js +7 -0
- package/dist/cdn/chunks/style-map-DsIw6lkq.js +29 -0
- package/dist/cdn/chunks/style-mod-DGMhzWuk.js +1583 -0
- package/dist/cdn/chunks/swatch-picker-BY3DBIl6.js +430 -0
- package/dist/cdn/chunks/swatch-picker.i18n-_G0nmnGe.js +22 -0
- package/dist/cdn/chunks/switch-DDSsZFwK.js +275 -0
- package/dist/cdn/chunks/switch-field-CMoM9I38.js +137 -0
- package/dist/cdn/chunks/tab-bar-CA8K1XjU.js +697 -0
- package/dist/cdn/chunks/tab-bar.i18n-Crsc7ShA.js +3 -0
- package/dist/cdn/chunks/table-DwXjCSD5.js +308 -0
- package/dist/cdn/chunks/table.i18n-Bmb_uw_w.js +3 -0
- package/dist/cdn/chunks/tag-DM3APy3B.js +306 -0
- package/dist/cdn/chunks/text-B1CatNR1.js +421 -0
- package/dist/cdn/chunks/text-cell-BkEsGI3g.js +299 -0
- package/dist/cdn/chunks/text-editor-BvTiMeNV.js +3743 -0
- package/dist/cdn/chunks/text-editor.i18n-sJKiRQ4i.js +17 -0
- package/dist/cdn/chunks/text-field-CUyh1-V8.js +398 -0
- package/dist/cdn/chunks/time-field--5K0YTcr.js +607 -0
- package/dist/cdn/chunks/time-field.i18n-CLH5vmS7.js +11 -0
- package/dist/cdn/chunks/time-picker-W0xYXLy8.js +508 -0
- package/dist/cdn/chunks/time-picker.i18n-BilOCXlS.js +7 -0
- package/dist/cdn/chunks/title-BuT7tWqN.js +437 -0
- package/dist/cdn/chunks/title-bar-label-controller-DSxdKZOg.js +24 -0
- package/dist/cdn/chunks/title-cell-8d8psUBX.js +327 -0
- package/dist/cdn/chunks/toggle-button-DNXWXZpE.js +528 -0
- package/dist/cdn/chunks/toggle-button-group-ByowJYgs.js +156 -0
- package/dist/cdn/chunks/token-CnkEB3hB.js +266 -0
- package/dist/cdn/chunks/token-field-BpyxOGmU.js +664 -0
- package/dist/cdn/chunks/token-field.i18n-BclzoR8F.js +9 -0
- package/dist/cdn/chunks/token.i18n-RGD5zAtl.js +7 -0
- package/dist/cdn/chunks/toml-w97zZfFO.js +27 -0
- package/dist/cdn/chunks/toolbar-C24LqAzK.js +408 -0
- package/dist/cdn/chunks/toolbar-item-DpPfPxCi.js +50 -0
- package/dist/cdn/chunks/toolbar-title-KBMpfL9d.js +84 -0
- package/dist/cdn/chunks/toolbar.i18n-QwS37CBC.js +8 -0
- package/dist/cdn/chunks/toolbar.styles-BQkG4gVc.js +383 -0
- package/dist/cdn/chunks/tooltip-BsAHJjci.js +325 -0
- package/dist/cdn/chunks/top-navigation-bar-C_kLPVKD.js +925 -0
- package/dist/cdn/chunks/top-navigation-bar.i18n-C-lcH1nB.js +10 -0
- package/dist/cdn/chunks/top-title-bar-iNFB2zQL.js +344 -0
- package/dist/cdn/chunks/translations-wxBSz213.js +8 -0
- package/dist/cdn/chunks/two-thirds-one-third-section-D-UANbHC.js +213 -0
- package/dist/cdn/chunks/validation-list-C5BhHZIG.js +202 -0
- package/dist/cdn/chunks/validation-list.i18n-CM6In8zD.js +12 -0
- package/dist/cdn/chunks/visibility-mixin-COAZ9pON.js +74 -0
- package/dist/cdn/chunks/visually-hidden-BPgATaH0.js +43 -0
- package/dist/cdn/chunks/window-CxV6ELE9.js +227 -0
- package/dist/cdn/chunks/window.i18n-CsEnUPAk.js +3 -0
- package/dist/cdn/chunks/with-translations-XX14GKFh.js +16 -0
- package/dist/components/actions/menu/menu-item.d.ts +6 -2
- package/dist/components/actions/menu/menu-item.d.ts.map +1 -1
- package/dist/components/actions/menu/menu-item.js +12 -1
- package/dist/components/actions/menu/menu-item.js.map +1 -1
- package/dist/components/actions/menu/menu.js +1 -1
- package/dist/components/actions/menu/menu.js.map +1 -1
- package/dist/components/actions/menu/menu.template.d.ts.map +1 -1
- package/dist/components/actions/menu/menu.template.js +2 -1
- package/dist/components/actions/menu/menu.template.js.map +1 -1
- package/dist/components/content/blockquote/blockquote.d.ts +1 -0
- package/dist/components/content/blockquote/blockquote.d.ts.map +1 -1
- package/dist/components/content/blockquote/blockquote.js +1 -0
- package/dist/components/content/blockquote/blockquote.js.map +1 -1
- package/dist/components/content/identity/identity.d.ts +1 -0
- package/dist/components/content/identity/identity.d.ts.map +1 -1
- package/dist/components/content/identity/identity.js +1 -0
- package/dist/components/content/identity/identity.js.map +1 -1
- package/dist/components/content/image/image.d.ts +1 -0
- package/dist/components/content/image/image.d.ts.map +1 -1
- package/dist/components/content/image/image.js +1 -0
- package/dist/components/content/image/image.js.map +1 -1
- package/dist/components/content/rich-text/rich-text.d.ts +1 -0
- package/dist/components/content/rich-text/rich-text.d.ts.map +1 -1
- package/dist/components/content/rich-text/rich-text.js +1 -0
- package/dist/components/content/rich-text/rich-text.js.map +1 -1
- package/dist/components/content/text/text.d.ts +1 -0
- package/dist/components/content/text/text.d.ts.map +1 -1
- package/dist/components/content/text/text.js +1 -0
- package/dist/components/content/text/text.js.map +1 -1
- package/dist/components/content/title/title.d.ts +1 -0
- package/dist/components/content/title/title.d.ts.map +1 -1
- package/dist/components/content/title/title.js +1 -0
- package/dist/components/content/title/title.js.map +1 -1
- package/dist/components/forms/form/form.d.ts.map +1 -1
- package/dist/components/forms/form/form.js +1 -0
- package/dist/components/forms/form/form.js.map +1 -1
- package/dist/components/forms/form-field/form-field.d.ts +1 -0
- package/dist/components/forms/form-field/form-field.d.ts.map +1 -1
- package/dist/components/forms/form-field/form-field.js +1 -0
- package/dist/components/forms/form-field/form-field.js.map +1 -1
- package/dist/components/inputs/date-field/date-field.d.ts +9 -4
- package/dist/components/inputs/date-field/date-field.d.ts.map +1 -1
- package/dist/components/inputs/date-field/date-field.js +20 -7
- package/dist/components/inputs/date-field/date-field.js.map +1 -1
- package/dist/components/inputs/date-field/date-field.template.d.ts.map +1 -1
- package/dist/components/inputs/date-field/date-field.template.js +1 -0
- package/dist/components/inputs/date-field/date-field.template.js.map +1 -1
- package/dist/components/inputs/dropdown/dropdown.d.ts +23 -2
- package/dist/components/inputs/dropdown/dropdown.d.ts.map +1 -1
- package/dist/components/inputs/dropdown/dropdown.js +68 -11
- package/dist/components/inputs/dropdown/dropdown.js.map +1 -1
- package/dist/components/inputs/time-field/time-field.d.ts +4 -0
- package/dist/components/inputs/time-field/time-field.d.ts.map +1 -1
- package/dist/components/inputs/time-field/time-field.js +17 -2
- package/dist/components/inputs/time-field/time-field.js.map +1 -1
- package/dist/components/inputs/time-field/time-field.template.d.ts.map +1 -1
- package/dist/components/inputs/time-field/time-field.template.js +1 -0
- package/dist/components/inputs/time-field/time-field.template.js.map +1 -1
- package/dist/components/layout/container/container.d.ts +15 -2
- package/dist/components/layout/container/container.d.ts.map +1 -1
- package/dist/components/layout/container/container.js +38 -3
- package/dist/components/layout/container/container.js.map +1 -1
- package/dist/components/layout/container/container.styles.js +1 -1
- package/dist/components/layout/container/container.template.js +1 -1
- package/dist/components/layout/container/container.template.js.map +1 -1
- package/dist/components/layout/page-sections/hero/hero.d.ts +1 -0
- package/dist/components/layout/page-sections/hero/hero.d.ts.map +1 -1
- package/dist/components/layout/page-sections/hero/hero.js +1 -0
- package/dist/components/layout/page-sections/hero/hero.js.map +1 -1
- package/dist/components/layout/popover/popover.d.ts.map +1 -1
- package/dist/components/layout/popover/popover.js +4 -2
- package/dist/components/layout/popover/popover.js.map +1 -1
- package/dist/components/lists-and-tables/list-item/list-item.d.ts +7 -0
- package/dist/components/lists-and-tables/list-item/list-item.d.ts.map +1 -1
- package/dist/components/lists-and-tables/list-item/list-item.js +13 -3
- package/dist/components/lists-and-tables/list-item/list-item.js.map +1 -1
- package/dist/components/lists-and-tables/list-item-segment/list-item-segment.d.ts +11 -1
- package/dist/components/lists-and-tables/list-item-segment/list-item-segment.d.ts.map +1 -1
- package/dist/components/lists-and-tables/list-item-segment/list-item-segment.js +19 -3
- package/dist/components/lists-and-tables/list-item-segment/list-item-segment.js.map +1 -1
- package/dist/nldd.min.js +729 -727
- package/dist/types/react.d.ts +3323 -0
- package/dist/types/vue.d.ts +11 -3
- package/dist/utilities/autoloader.d.ts +33 -0
- package/dist/utilities/autoloader.d.ts.map +1 -0
- package/dist/utilities/autoloader.generated.d.ts +3 -0
- package/dist/utilities/autoloader.generated.d.ts.map +1 -0
- package/dist/utilities/autoloader.generated.js +141 -0
- package/dist/utilities/autoloader.generated.js.map +1 -0
- package/dist/utilities/autoloader.js +94 -0
- package/dist/utilities/autoloader.js.map +1 -0
- package/dist/utilities/dev-checks.d.ts +9 -0
- package/dist/utilities/dev-checks.d.ts.map +1 -1
- package/dist/utilities/dev-checks.js +45 -3
- package/dist/utilities/dev-checks.js.map +1 -1
- package/dist/utilities/dev-rules.generated.d.ts.map +1 -1
- package/dist/utilities/dev-rules.generated.js +12 -2
- package/dist/utilities/dev-rules.generated.js.map +1 -1
- package/dist/utilities/loading-tags.d.ts +7 -0
- package/dist/utilities/loading-tags.d.ts.map +1 -0
- package/dist/utilities/loading-tags.js +7 -0
- package/dist/utilities/loading-tags.js.map +1 -0
- package/dist/utilities/owner-form.d.ts +3 -3
- package/dist/utilities/owner-form.d.ts.map +1 -1
- package/dist/utilities/owner-form.js +6 -3
- package/dist/utilities/owner-form.js.map +1 -1
- package/dist/utilities/return-focus.d.ts +14 -0
- package/dist/utilities/return-focus.d.ts.map +1 -1
- package/dist/utilities/return-focus.js +26 -8
- package/dist/utilities/return-focus.js.map +1 -1
- package/lint/data.generated.json +1 -1
- package/lint/engine.js +53 -1
- package/lint/format.js +6 -5
- package/lint/frontends.js +224 -16
- package/lint/linter.js +5 -3
- package/lint/main.js +36 -9
- package/lint/project.js +73 -4
- package/lint/rule-data.js +17 -2
- package/lint/tree.js +3 -0
- package/package.json +50 -11
- package/dist/components/breakpoints-DtL62nLI.js +0 -45
- package/dist/components/components.js +0 -68243
- package/dist/components/decorate-DD7uUxHb.js +0 -51
- package/dist/components/defer-focus-dzorHsCQ.js +0 -176
- package/dist/components/dev-checks-CLB9G43h.js +0 -2711
- package/dist/components/dist-245LaK9m.js +0 -1479
- package/dist/components/dist-BFZM0YsR.js +0 -15772
- package/dist/components/dist-BNkeFjc3.js +0 -1180
- package/dist/components/dist-CSC1dG3L.js +0 -365
- package/dist/components/dist-CeMOOqgP.js +0 -1509
- package/dist/components/dist-DFjwTlJV.js +0 -624
- package/dist/components/dist-DHhnz3Gv.js +0 -381
- package/dist/components/dist-PeUX4vPq.js +0 -2857
- package/dist/components/dist-m70B83qb.js +0 -463
- package/dist/components/element-state-BnarBv0M.js +0 -42
- package/dist/components/gherkin-DzYbEwDO.js +0 -107
- package/dist/components/icon-button-8gvQCwCW.js +0 -2305
- package/dist/components/input-modality-D_CY185R.js +0 -48
- package/dist/components/just-in-time-education.i18n-BqU1ImP4.js +0 -423
- package/dist/components/nl.generated-DzZkOgnP.js +0 -64
- package/dist/components/rolldown-runtime-D8jQpDG7.js +0 -12
- package/dist/components/shadow-resets-BwOyyZFH.js +0 -60
- package/dist/components/shell-Dh5IwHd-.js +0 -222
- package/dist/components/toml-D0Pix_8Q.js +0 -58
- package/dist/components/visibility-mixin-Dzn48SL8.js +0 -153
|
@@ -1,2857 +0,0 @@
|
|
|
1
|
-
// node_modules/style-mod/src/style-mod.js
|
|
2
|
-
var C = "ͼ";
|
|
3
|
-
var COUNT = typeof Symbol == "undefined" ? "__ͼ" : Symbol.for(C);
|
|
4
|
-
var SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
|
|
5
|
-
var top = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : {};
|
|
6
|
-
var StyleModule = class {
|
|
7
|
-
constructor(spec, options) {
|
|
8
|
-
this.rules = [];
|
|
9
|
-
let { finish } = options || {};
|
|
10
|
-
function splitSelector(selector) {
|
|
11
|
-
return /^@/.test(selector) ? [selector] : selector.split(/,\s*/);
|
|
12
|
-
}
|
|
13
|
-
function render(selectors, spec, target, isKeyframes) {
|
|
14
|
-
let local = [], isAt = /^@(\w+)\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == "keyframes";
|
|
15
|
-
if (isAt && spec == null) return target.push(selectors[0] + ";");
|
|
16
|
-
for (let prop in spec) {
|
|
17
|
-
let value = spec[prop];
|
|
18
|
-
if (/&/.test(prop)) render(prop.split(/,\s*/).map((part) => selectors.map((sel) => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)), value, target);
|
|
19
|
-
else if (value && typeof value == "object") {
|
|
20
|
-
if (!isAt) throw new RangeError("The value of a property (" + prop + ") should be a primitive value.");
|
|
21
|
-
render(splitSelector(prop), value, local, keyframes);
|
|
22
|
-
} else if (value != null) local.push(prop.replace(/_.*/, "").replace(/[A-Z]/g, (l) => "-" + l.toLowerCase()) + ": " + value + ";");
|
|
23
|
-
}
|
|
24
|
-
if (local.length || keyframes) target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(", ") + " {" + local.join(" ") + "}");
|
|
25
|
-
}
|
|
26
|
-
for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules);
|
|
27
|
-
}
|
|
28
|
-
getRules() {
|
|
29
|
-
return this.rules.join("\n");
|
|
30
|
-
}
|
|
31
|
-
static newName() {
|
|
32
|
-
let id = top[COUNT] || 1;
|
|
33
|
-
top[COUNT] = id + 1;
|
|
34
|
-
return C + id.toString(36);
|
|
35
|
-
}
|
|
36
|
-
static mount(root, modules, options) {
|
|
37
|
-
let set = root[SET], nonce = options && options.nonce;
|
|
38
|
-
if (!set) set = new StyleSet(root, nonce);
|
|
39
|
-
else if (nonce) set.setNonce(nonce);
|
|
40
|
-
set.mount(Array.isArray(modules) ? modules : [modules], root);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
var adoptedSet = /* @__PURE__ */ new Map();
|
|
44
|
-
var StyleSet = class {
|
|
45
|
-
constructor(root, nonce) {
|
|
46
|
-
let doc = root.ownerDocument || root, win = doc.defaultView;
|
|
47
|
-
if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {
|
|
48
|
-
let adopted = adoptedSet.get(doc);
|
|
49
|
-
if (adopted) return root[SET] = adopted;
|
|
50
|
-
this.sheet = new win.CSSStyleSheet();
|
|
51
|
-
adoptedSet.set(doc, this);
|
|
52
|
-
} else {
|
|
53
|
-
this.styleTag = doc.createElement("style");
|
|
54
|
-
if (nonce) this.styleTag.setAttribute("nonce", nonce);
|
|
55
|
-
}
|
|
56
|
-
this.modules = [];
|
|
57
|
-
root[SET] = this;
|
|
58
|
-
}
|
|
59
|
-
mount(modules, root) {
|
|
60
|
-
let sheet = this.sheet;
|
|
61
|
-
let pos = 0, j = 0;
|
|
62
|
-
for (let i = 0; i < modules.length; i++) {
|
|
63
|
-
let mod = modules[i], index = this.modules.indexOf(mod);
|
|
64
|
-
if (index < j && index > -1) {
|
|
65
|
-
this.modules.splice(index, 1);
|
|
66
|
-
j--;
|
|
67
|
-
index = -1;
|
|
68
|
-
}
|
|
69
|
-
if (index == -1) {
|
|
70
|
-
this.modules.splice(j++, 0, mod);
|
|
71
|
-
if (sheet) for (let k = 0; k < mod.rules.length; k++) sheet.insertRule(mod.rules[k], pos++);
|
|
72
|
-
} else {
|
|
73
|
-
while (j < index) pos += this.modules[j++].rules.length;
|
|
74
|
-
pos += mod.rules.length;
|
|
75
|
-
j++;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (sheet) {
|
|
79
|
-
if (root.adoptedStyleSheets.indexOf(this.sheet) < 0) root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets];
|
|
80
|
-
} else {
|
|
81
|
-
let text = "";
|
|
82
|
-
for (let i = 0; i < this.modules.length; i++) text += this.modules[i].getRules() + "\n";
|
|
83
|
-
this.styleTag.textContent = text;
|
|
84
|
-
let target = root.head || root;
|
|
85
|
-
if (this.styleTag.parentNode != target) target.insertBefore(this.styleTag, target.firstChild);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
setNonce(nonce) {
|
|
89
|
-
if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce) this.styleTag.setAttribute("nonce", nonce);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
// node_modules/@lezer/common/dist/index.js
|
|
93
|
-
/**
|
|
94
|
-
The default maximum length of a `TreeBuffer` node.
|
|
95
|
-
*/
|
|
96
|
-
var DefaultBufferLength = 1024;
|
|
97
|
-
var nextPropID = 0;
|
|
98
|
-
var Range = class {
|
|
99
|
-
constructor(from, to) {
|
|
100
|
-
this.from = from;
|
|
101
|
-
this.to = to;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
Each [node type](#common.NodeType) or [individual tree](#common.Tree)
|
|
106
|
-
can have metadata associated with it in props. Instances of this
|
|
107
|
-
class represent prop names.
|
|
108
|
-
*/
|
|
109
|
-
var NodeProp = class {
|
|
110
|
-
/**
|
|
111
|
-
Create a new node prop type.
|
|
112
|
-
*/
|
|
113
|
-
constructor(config = {}) {
|
|
114
|
-
this.id = nextPropID++;
|
|
115
|
-
this.perNode = !!config.perNode;
|
|
116
|
-
this.deserialize = config.deserialize || (() => {
|
|
117
|
-
throw new Error("This node type doesn't define a deserialize function");
|
|
118
|
-
});
|
|
119
|
-
this.combine = config.combine || null;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
This is meant to be used with
|
|
123
|
-
[`NodeSet.extend`](#common.NodeSet.extend) or
|
|
124
|
-
[`LRParser.configure`](#lr.ParserConfig.props) to compute
|
|
125
|
-
prop values for each node type in the set. Takes a [match
|
|
126
|
-
object](#common.NodeType^match) or function that returns undefined
|
|
127
|
-
if the node type doesn't get this prop, and the prop's value if
|
|
128
|
-
it does.
|
|
129
|
-
*/
|
|
130
|
-
add(match) {
|
|
131
|
-
if (this.perNode) throw new RangeError("Can't add per-node props to node types");
|
|
132
|
-
if (typeof match != "function") match = NodeType.match(match);
|
|
133
|
-
return (type) => {
|
|
134
|
-
let result = match(type);
|
|
135
|
-
return result === void 0 ? null : [this, result];
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
Prop that is used to describe matching delimiters. For opening
|
|
141
|
-
delimiters, this holds an array of node names (written as a
|
|
142
|
-
space-separated string when declaring this prop in a grammar)
|
|
143
|
-
for the node types of closing delimiters that match it.
|
|
144
|
-
*/
|
|
145
|
-
NodeProp.closedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
|
|
146
|
-
/**
|
|
147
|
-
The inverse of [`closedBy`](#common.NodeProp^closedBy). This is
|
|
148
|
-
attached to closing delimiters, holding an array of node names
|
|
149
|
-
of types of matching opening delimiters.
|
|
150
|
-
*/
|
|
151
|
-
NodeProp.openedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
|
|
152
|
-
/**
|
|
153
|
-
Used to assign node types to groups (for example, all node
|
|
154
|
-
types that represent an expression could be tagged with an
|
|
155
|
-
`"Expression"` group).
|
|
156
|
-
*/
|
|
157
|
-
NodeProp.group = new NodeProp({ deserialize: (str) => str.split(" ") });
|
|
158
|
-
/**
|
|
159
|
-
Attached to nodes to indicate these should be
|
|
160
|
-
[displayed](https://codemirror.net/docs/ref/#language.syntaxTree)
|
|
161
|
-
in a bidirectional text isolate, so that direction-neutral
|
|
162
|
-
characters on their sides don't incorrectly get associated with
|
|
163
|
-
surrounding text. You'll generally want to set this for nodes
|
|
164
|
-
that contain arbitrary text, like strings and comments, and for
|
|
165
|
-
nodes that appear _inside_ arbitrary text, like HTML tags. When
|
|
166
|
-
not given a value, in a grammar declaration, defaults to
|
|
167
|
-
`"auto"`.
|
|
168
|
-
*/
|
|
169
|
-
NodeProp.isolate = new NodeProp({ deserialize: (value) => {
|
|
170
|
-
if (value && value != "rtl" && value != "ltr" && value != "auto") throw new RangeError("Invalid value for isolate: " + value);
|
|
171
|
-
return value || "auto";
|
|
172
|
-
} });
|
|
173
|
-
/**
|
|
174
|
-
The hash of the [context](#lr.ContextTracker.constructor)
|
|
175
|
-
that the node was parsed in, if any. Used to limit reuse of
|
|
176
|
-
contextual nodes.
|
|
177
|
-
*/
|
|
178
|
-
NodeProp.contextHash = new NodeProp({ perNode: true });
|
|
179
|
-
/**
|
|
180
|
-
The distance beyond the end of the node that the tokenizer
|
|
181
|
-
looked ahead for any of the tokens inside the node. (The LR
|
|
182
|
-
parser only stores this when it is larger than 25, for
|
|
183
|
-
efficiency reasons.)
|
|
184
|
-
*/
|
|
185
|
-
NodeProp.lookAhead = new NodeProp({ perNode: true });
|
|
186
|
-
/**
|
|
187
|
-
This per-node prop is used to replace a given node, or part of a
|
|
188
|
-
node, with another tree. This is useful to include trees from
|
|
189
|
-
different languages in mixed-language parsers.
|
|
190
|
-
*/
|
|
191
|
-
NodeProp.mounted = new NodeProp({ perNode: true });
|
|
192
|
-
/**
|
|
193
|
-
A mounted tree, which can be [stored](#common.NodeProp^mounted) on
|
|
194
|
-
a tree node to indicate that parts of its content are
|
|
195
|
-
represented by another tree.
|
|
196
|
-
*/
|
|
197
|
-
var MountedTree = class {
|
|
198
|
-
constructor(tree, overlay, parser, bracketed = false) {
|
|
199
|
-
this.tree = tree;
|
|
200
|
-
this.overlay = overlay;
|
|
201
|
-
this.parser = parser;
|
|
202
|
-
this.bracketed = bracketed;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
@internal
|
|
206
|
-
*/
|
|
207
|
-
static get(tree) {
|
|
208
|
-
return tree && tree.props && tree.props[NodeProp.mounted.id];
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
var noProps = Object.create(null);
|
|
212
|
-
/**
|
|
213
|
-
Each node in a syntax tree has a node type associated with it.
|
|
214
|
-
*/
|
|
215
|
-
var NodeType = class NodeType {
|
|
216
|
-
/**
|
|
217
|
-
@internal
|
|
218
|
-
*/
|
|
219
|
-
constructor(name, props, id, flags = 0) {
|
|
220
|
-
this.name = name;
|
|
221
|
-
this.props = props;
|
|
222
|
-
this.id = id;
|
|
223
|
-
this.flags = flags;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
Define a node type.
|
|
227
|
-
*/
|
|
228
|
-
static define(spec) {
|
|
229
|
-
let props = spec.props && spec.props.length ? Object.create(null) : noProps;
|
|
230
|
-
let flags = (spec.top ? 1 : 0) | (spec.skipped ? 2 : 0) | (spec.error ? 4 : 0) | (spec.name == null ? 8 : 0);
|
|
231
|
-
let type = new NodeType(spec.name || "", props, spec.id, flags);
|
|
232
|
-
if (spec.props) for (let src of spec.props) {
|
|
233
|
-
if (!Array.isArray(src)) src = src(type);
|
|
234
|
-
if (src) {
|
|
235
|
-
if (src[0].perNode) throw new RangeError("Can't store a per-node prop on a node type");
|
|
236
|
-
props[src[0].id] = src[1];
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return type;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
Retrieves a node prop for this type. Will return `undefined` if
|
|
243
|
-
the prop isn't present on this node.
|
|
244
|
-
*/
|
|
245
|
-
prop(prop) {
|
|
246
|
-
return this.props[prop.id];
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
True when this is the top node of a grammar.
|
|
250
|
-
*/
|
|
251
|
-
get isTop() {
|
|
252
|
-
return (this.flags & 1) > 0;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
True when this node is produced by a skip rule.
|
|
256
|
-
*/
|
|
257
|
-
get isSkipped() {
|
|
258
|
-
return (this.flags & 2) > 0;
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
Indicates whether this is an error node.
|
|
262
|
-
*/
|
|
263
|
-
get isError() {
|
|
264
|
-
return (this.flags & 4) > 0;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
When true, this node type doesn't correspond to a user-declared
|
|
268
|
-
named node, for example because it is used to cache repetition.
|
|
269
|
-
*/
|
|
270
|
-
get isAnonymous() {
|
|
271
|
-
return (this.flags & 8) > 0;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
Returns true when this node's name or one of its
|
|
275
|
-
[groups](#common.NodeProp^group) matches the given string.
|
|
276
|
-
*/
|
|
277
|
-
is(name) {
|
|
278
|
-
if (typeof name == "string") {
|
|
279
|
-
if (this.name == name) return true;
|
|
280
|
-
let group = this.prop(NodeProp.group);
|
|
281
|
-
return group ? group.indexOf(name) > -1 : false;
|
|
282
|
-
}
|
|
283
|
-
return this.id == name;
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
Create a function from node types to arbitrary values by
|
|
287
|
-
specifying an object whose property names are node or
|
|
288
|
-
[group](#common.NodeProp^group) names. Often useful with
|
|
289
|
-
[`NodeProp.add`](#common.NodeProp.add). You can put multiple
|
|
290
|
-
names, separated by spaces, in a single property name to map
|
|
291
|
-
multiple node names to a single value.
|
|
292
|
-
*/
|
|
293
|
-
static match(map) {
|
|
294
|
-
let direct = Object.create(null);
|
|
295
|
-
for (let prop in map) for (let name of prop.split(" ")) direct[name] = map[prop];
|
|
296
|
-
return (node) => {
|
|
297
|
-
for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {
|
|
298
|
-
let found = direct[i < 0 ? node.name : groups[i]];
|
|
299
|
-
if (found) return found;
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
/**
|
|
305
|
-
An empty dummy node type to use when no actual type is available.
|
|
306
|
-
*/
|
|
307
|
-
NodeType.none = new NodeType("", Object.create(null), 0, 8);
|
|
308
|
-
/**
|
|
309
|
-
A node set holds a collection of node types. It is used to
|
|
310
|
-
compactly represent trees by storing their type ids, rather than a
|
|
311
|
-
full pointer to the type object, in a numeric array. Each parser
|
|
312
|
-
[has](#lr.LRParser.nodeSet) a node set, and [tree
|
|
313
|
-
buffers](#common.TreeBuffer) can only store collections of nodes
|
|
314
|
-
from the same set. A set can have a maximum of 2**16 (65536) node
|
|
315
|
-
types in it, so that the ids fit into 16-bit typed array slots.
|
|
316
|
-
*/
|
|
317
|
-
var NodeSet = class NodeSet {
|
|
318
|
-
/**
|
|
319
|
-
Create a set with the given types. The `id` property of each
|
|
320
|
-
type should correspond to its position within the array.
|
|
321
|
-
*/
|
|
322
|
-
constructor(types) {
|
|
323
|
-
this.types = types;
|
|
324
|
-
for (let i = 0; i < types.length; i++) if (types[i].id != i) throw new RangeError("Node type ids should correspond to array positions when creating a node set");
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
Create a copy of this set with some node properties added. The
|
|
328
|
-
arguments to this method can be created with
|
|
329
|
-
[`NodeProp.add`](#common.NodeProp.add).
|
|
330
|
-
*/
|
|
331
|
-
extend(...props) {
|
|
332
|
-
let newTypes = [];
|
|
333
|
-
for (let type of this.types) {
|
|
334
|
-
let newProps = null;
|
|
335
|
-
for (let source of props) {
|
|
336
|
-
let add = source(type);
|
|
337
|
-
if (add) {
|
|
338
|
-
if (!newProps) newProps = Object.assign({}, type.props);
|
|
339
|
-
let value = add[1], prop = add[0];
|
|
340
|
-
if (prop.combine && prop.id in newProps) value = prop.combine(newProps[prop.id], value);
|
|
341
|
-
newProps[prop.id] = value;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
|
|
345
|
-
}
|
|
346
|
-
return new NodeSet(newTypes);
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
var CachedNode = /* @__PURE__ */ new WeakMap();
|
|
350
|
-
var CachedInnerNode = /* @__PURE__ */ new WeakMap();
|
|
351
|
-
/**
|
|
352
|
-
Options that control iteration. Can be combined with the `|`
|
|
353
|
-
operator to enable multiple ones.
|
|
354
|
-
*/
|
|
355
|
-
var IterMode;
|
|
356
|
-
(function(IterMode) {
|
|
357
|
-
/**
|
|
358
|
-
When enabled, iteration will only visit [`Tree`](#common.Tree)
|
|
359
|
-
objects, not nodes packed into
|
|
360
|
-
[`TreeBuffer`](#common.TreeBuffer)s.
|
|
361
|
-
*/
|
|
362
|
-
IterMode[IterMode["ExcludeBuffers"] = 1] = "ExcludeBuffers";
|
|
363
|
-
/**
|
|
364
|
-
Enable this to make iteration include anonymous nodes (such as
|
|
365
|
-
the nodes that wrap repeated grammar constructs into a balanced
|
|
366
|
-
tree).
|
|
367
|
-
*/
|
|
368
|
-
IterMode[IterMode["IncludeAnonymous"] = 2] = "IncludeAnonymous";
|
|
369
|
-
/**
|
|
370
|
-
By default, regular [mounted](#common.NodeProp^mounted) nodes
|
|
371
|
-
replace their base node in iteration. Enable this to ignore them
|
|
372
|
-
instead.
|
|
373
|
-
*/
|
|
374
|
-
IterMode[IterMode["IgnoreMounts"] = 4] = "IgnoreMounts";
|
|
375
|
-
/**
|
|
376
|
-
This option only applies in
|
|
377
|
-
[`enter`](#common.SyntaxNode.enter)-style methods. It tells the
|
|
378
|
-
library to not enter mounted overlays if one covers the given
|
|
379
|
-
position.
|
|
380
|
-
*/
|
|
381
|
-
IterMode[IterMode["IgnoreOverlays"] = 8] = "IgnoreOverlays";
|
|
382
|
-
/**
|
|
383
|
-
When set, positions on the boundary of a mounted overlay tree
|
|
384
|
-
that has its [`bracketed`](#common.NestedParse.bracketed) flag
|
|
385
|
-
set will enter that tree regardless of side. Only supported in
|
|
386
|
-
[`enter`](#common.SyntaxNode.enter), not in cursors.
|
|
387
|
-
*/
|
|
388
|
-
IterMode[IterMode["EnterBracketed"] = 16] = "EnterBracketed";
|
|
389
|
-
})(IterMode || (IterMode = {}));
|
|
390
|
-
/**
|
|
391
|
-
A piece of syntax tree. There are two ways to approach these
|
|
392
|
-
trees: the way they are actually stored in memory, and the
|
|
393
|
-
convenient way.
|
|
394
|
-
|
|
395
|
-
Syntax trees are stored as a tree of `Tree` and `TreeBuffer`
|
|
396
|
-
objects. By packing detail information into `TreeBuffer` leaf
|
|
397
|
-
nodes, the representation is made a lot more memory-efficient.
|
|
398
|
-
|
|
399
|
-
However, when you want to actually work with tree nodes, this
|
|
400
|
-
representation is very awkward, so most client code will want to
|
|
401
|
-
use the [`TreeCursor`](#common.TreeCursor) or
|
|
402
|
-
[`SyntaxNode`](#common.SyntaxNode) interface instead, which provides
|
|
403
|
-
a view on some part of this data structure, and can be used to
|
|
404
|
-
move around to adjacent nodes.
|
|
405
|
-
*/
|
|
406
|
-
var Tree = class Tree {
|
|
407
|
-
/**
|
|
408
|
-
Construct a new tree. See also [`Tree.build`](#common.Tree^build).
|
|
409
|
-
*/
|
|
410
|
-
constructor(type, children, positions, length, props) {
|
|
411
|
-
this.type = type;
|
|
412
|
-
this.children = children;
|
|
413
|
-
this.positions = positions;
|
|
414
|
-
this.length = length;
|
|
415
|
-
/**
|
|
416
|
-
@internal
|
|
417
|
-
*/
|
|
418
|
-
this.props = null;
|
|
419
|
-
if (props && props.length) {
|
|
420
|
-
this.props = Object.create(null);
|
|
421
|
-
for (let [prop, value] of props) this.props[typeof prop == "number" ? prop : prop.id] = value;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
@internal
|
|
426
|
-
*/
|
|
427
|
-
toString() {
|
|
428
|
-
let mounted = MountedTree.get(this);
|
|
429
|
-
if (mounted && !mounted.overlay) return mounted.tree.toString();
|
|
430
|
-
let children = "";
|
|
431
|
-
for (let ch of this.children) {
|
|
432
|
-
let str = ch.toString();
|
|
433
|
-
if (str) {
|
|
434
|
-
if (children) children += ",";
|
|
435
|
-
children += str;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
return !this.type.name ? children : (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "");
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
Get a [tree cursor](#common.TreeCursor) positioned at the top of
|
|
442
|
-
the tree. Mode can be used to [control](#common.IterMode) which
|
|
443
|
-
nodes the cursor visits.
|
|
444
|
-
*/
|
|
445
|
-
cursor(mode = 0) {
|
|
446
|
-
return new TreeCursor(this.topNode, mode);
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
Get a [tree cursor](#common.TreeCursor) pointing into this tree
|
|
450
|
-
at the given position and side (see
|
|
451
|
-
[`moveTo`](#common.TreeCursor.moveTo).
|
|
452
|
-
*/
|
|
453
|
-
cursorAt(pos, side = 0, mode = 0) {
|
|
454
|
-
let cursor = new TreeCursor(CachedNode.get(this) || this.topNode);
|
|
455
|
-
cursor.moveTo(pos, side);
|
|
456
|
-
CachedNode.set(this, cursor._tree);
|
|
457
|
-
return cursor;
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
Get a [syntax node](#common.SyntaxNode) object for the top of the
|
|
461
|
-
tree.
|
|
462
|
-
*/
|
|
463
|
-
get topNode() {
|
|
464
|
-
return new TreeNode(this, 0, 0, null);
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
Get the [syntax node](#common.SyntaxNode) at the given position.
|
|
468
|
-
If `side` is -1, this will move into nodes that end at the
|
|
469
|
-
position. If 1, it'll move into nodes that start at the
|
|
470
|
-
position. With 0, it'll only enter nodes that cover the position
|
|
471
|
-
from both sides.
|
|
472
|
-
|
|
473
|
-
Note that this will not enter
|
|
474
|
-
[overlays](#common.MountedTree.overlay), and you often want
|
|
475
|
-
[`resolveInner`](#common.Tree.resolveInner) instead.
|
|
476
|
-
*/
|
|
477
|
-
resolve(pos, side = 0) {
|
|
478
|
-
let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
|
|
479
|
-
CachedNode.set(this, node);
|
|
480
|
-
return node;
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
Like [`resolve`](#common.Tree.resolve), but will enter
|
|
484
|
-
[overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
|
|
485
|
-
pointing into the innermost overlaid tree at the given position
|
|
486
|
-
(with parent links going through all parent structure, including
|
|
487
|
-
the host trees).
|
|
488
|
-
*/
|
|
489
|
-
resolveInner(pos, side = 0) {
|
|
490
|
-
let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
|
|
491
|
-
CachedInnerNode.set(this, node);
|
|
492
|
-
return node;
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
In some situations, it can be useful to iterate through all
|
|
496
|
-
nodes around a position, including those in overlays that don't
|
|
497
|
-
directly cover the position. This method gives you an iterator
|
|
498
|
-
that will produce all nodes, from small to big, around the given
|
|
499
|
-
position.
|
|
500
|
-
*/
|
|
501
|
-
resolveStack(pos, side = 0) {
|
|
502
|
-
return stackIterator(this, pos, side);
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
Iterate over the tree and its children, calling `enter` for any
|
|
506
|
-
node that touches the `from`/`to` region (if given) before
|
|
507
|
-
running over such a node's children, and `leave` (if given) when
|
|
508
|
-
leaving the node. When `enter` returns `false`, that node will
|
|
509
|
-
not have its children iterated over (or `leave` called).
|
|
510
|
-
*/
|
|
511
|
-
iterate(spec) {
|
|
512
|
-
let { enter, leave, from = 0, to = this.length } = spec;
|
|
513
|
-
let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
|
|
514
|
-
for (let c = this.cursor(mode | IterMode.IncludeAnonymous);;) {
|
|
515
|
-
let entered = false;
|
|
516
|
-
if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
|
|
517
|
-
if (c.firstChild()) continue;
|
|
518
|
-
entered = true;
|
|
519
|
-
}
|
|
520
|
-
for (;;) {
|
|
521
|
-
if (entered && leave && (anon || !c.type.isAnonymous)) leave(c);
|
|
522
|
-
if (c.nextSibling()) break;
|
|
523
|
-
if (!c.parent()) return;
|
|
524
|
-
entered = true;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
Get the value of the given [node prop](#common.NodeProp) for this
|
|
530
|
-
node. Works with both per-node and per-type props.
|
|
531
|
-
*/
|
|
532
|
-
prop(prop) {
|
|
533
|
-
return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : void 0;
|
|
534
|
-
}
|
|
535
|
-
/**
|
|
536
|
-
Returns the node's [per-node props](#common.NodeProp.perNode) in a
|
|
537
|
-
format that can be passed to the [`Tree`](#common.Tree)
|
|
538
|
-
constructor.
|
|
539
|
-
*/
|
|
540
|
-
get propValues() {
|
|
541
|
-
let result = [];
|
|
542
|
-
if (this.props) for (let id in this.props) result.push([+id, this.props[id]]);
|
|
543
|
-
return result;
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
Balance the direct children of this tree, producing a copy of
|
|
547
|
-
which may have children grouped into subtrees with type
|
|
548
|
-
[`NodeType.none`](#common.NodeType^none).
|
|
549
|
-
*/
|
|
550
|
-
balance(config = {}) {
|
|
551
|
-
return this.children.length <= 8 ? this : balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length)));
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
Build a tree from a postfix-ordered buffer of node information,
|
|
555
|
-
or a cursor over such a buffer.
|
|
556
|
-
*/
|
|
557
|
-
static build(data) {
|
|
558
|
-
return buildTree(data);
|
|
559
|
-
}
|
|
560
|
-
};
|
|
561
|
-
/**
|
|
562
|
-
The empty tree
|
|
563
|
-
*/
|
|
564
|
-
Tree.empty = new Tree(NodeType.none, [], [], 0);
|
|
565
|
-
var FlatBufferCursor = class FlatBufferCursor {
|
|
566
|
-
constructor(buffer, index) {
|
|
567
|
-
this.buffer = buffer;
|
|
568
|
-
this.index = index;
|
|
569
|
-
}
|
|
570
|
-
get id() {
|
|
571
|
-
return this.buffer[this.index - 4];
|
|
572
|
-
}
|
|
573
|
-
get start() {
|
|
574
|
-
return this.buffer[this.index - 3];
|
|
575
|
-
}
|
|
576
|
-
get end() {
|
|
577
|
-
return this.buffer[this.index - 2];
|
|
578
|
-
}
|
|
579
|
-
get size() {
|
|
580
|
-
return this.buffer[this.index - 1];
|
|
581
|
-
}
|
|
582
|
-
get pos() {
|
|
583
|
-
return this.index;
|
|
584
|
-
}
|
|
585
|
-
next() {
|
|
586
|
-
this.index -= 4;
|
|
587
|
-
}
|
|
588
|
-
fork() {
|
|
589
|
-
return new FlatBufferCursor(this.buffer, this.index);
|
|
590
|
-
}
|
|
591
|
-
};
|
|
592
|
-
/**
|
|
593
|
-
Tree buffers contain (type, start, end, endIndex) quads for each
|
|
594
|
-
node. In such a buffer, nodes are stored in prefix order (parents
|
|
595
|
-
before children, with the endIndex of the parent indicating which
|
|
596
|
-
children belong to it).
|
|
597
|
-
*/
|
|
598
|
-
var TreeBuffer = class TreeBuffer {
|
|
599
|
-
/**
|
|
600
|
-
Create a tree buffer.
|
|
601
|
-
*/
|
|
602
|
-
constructor(buffer, length, set) {
|
|
603
|
-
this.buffer = buffer;
|
|
604
|
-
this.length = length;
|
|
605
|
-
this.set = set;
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
@internal
|
|
609
|
-
*/
|
|
610
|
-
get type() {
|
|
611
|
-
return NodeType.none;
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
@internal
|
|
615
|
-
*/
|
|
616
|
-
toString() {
|
|
617
|
-
let result = [];
|
|
618
|
-
for (let index = 0; index < this.buffer.length;) {
|
|
619
|
-
result.push(this.childString(index));
|
|
620
|
-
index = this.buffer[index + 3];
|
|
621
|
-
}
|
|
622
|
-
return result.join(",");
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
@internal
|
|
626
|
-
*/
|
|
627
|
-
childString(index) {
|
|
628
|
-
let id = this.buffer[index], endIndex = this.buffer[index + 3];
|
|
629
|
-
let type = this.set.types[id], result = type.name;
|
|
630
|
-
if (/\W/.test(result) && !type.isError) result = JSON.stringify(result);
|
|
631
|
-
index += 4;
|
|
632
|
-
if (endIndex == index) return result;
|
|
633
|
-
let children = [];
|
|
634
|
-
while (index < endIndex) {
|
|
635
|
-
children.push(this.childString(index));
|
|
636
|
-
index = this.buffer[index + 3];
|
|
637
|
-
}
|
|
638
|
-
return result + "(" + children.join(",") + ")";
|
|
639
|
-
}
|
|
640
|
-
/**
|
|
641
|
-
@internal
|
|
642
|
-
*/
|
|
643
|
-
findChild(startIndex, endIndex, dir, pos, side) {
|
|
644
|
-
let { buffer } = this, pick = -1;
|
|
645
|
-
for (let i = startIndex; i != endIndex; i = buffer[i + 3]) if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
|
|
646
|
-
pick = i;
|
|
647
|
-
if (dir > 0) break;
|
|
648
|
-
}
|
|
649
|
-
return pick;
|
|
650
|
-
}
|
|
651
|
-
/**
|
|
652
|
-
@internal
|
|
653
|
-
*/
|
|
654
|
-
slice(startI, endI, from) {
|
|
655
|
-
let b = this.buffer;
|
|
656
|
-
let copy = new Uint16Array(endI - startI), len = 0;
|
|
657
|
-
for (let i = startI, j = 0; i < endI;) {
|
|
658
|
-
copy[j++] = b[i++];
|
|
659
|
-
copy[j++] = b[i++] - from;
|
|
660
|
-
let to = copy[j++] = b[i++] - from;
|
|
661
|
-
copy[j++] = b[i++] - startI;
|
|
662
|
-
len = Math.max(len, to);
|
|
663
|
-
}
|
|
664
|
-
return new TreeBuffer(copy, len, this.set);
|
|
665
|
-
}
|
|
666
|
-
};
|
|
667
|
-
function checkSide(side, pos, from, to) {
|
|
668
|
-
switch (side) {
|
|
669
|
-
case -2: return from < pos;
|
|
670
|
-
case -1: return to >= pos && from < pos;
|
|
671
|
-
case 0: return from < pos && to > pos;
|
|
672
|
-
case 1: return from <= pos && to > pos;
|
|
673
|
-
case 2: return to > pos;
|
|
674
|
-
case 4: return true;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
function resolveNode(node, pos, side, overlays) {
|
|
678
|
-
var _a;
|
|
679
|
-
while (node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos)) {
|
|
680
|
-
let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
|
|
681
|
-
if (!parent) return node;
|
|
682
|
-
node = parent;
|
|
683
|
-
}
|
|
684
|
-
let mode = overlays ? 0 : IterMode.IgnoreOverlays;
|
|
685
|
-
if (overlays) {
|
|
686
|
-
for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from) node = parent;
|
|
687
|
-
}
|
|
688
|
-
for (;;) {
|
|
689
|
-
let inner = node.enter(pos, side, mode);
|
|
690
|
-
if (!inner) return node;
|
|
691
|
-
node = inner;
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
var BaseNode = class {
|
|
695
|
-
cursor(mode = 0) {
|
|
696
|
-
return new TreeCursor(this, mode);
|
|
697
|
-
}
|
|
698
|
-
getChild(type, before = null, after = null) {
|
|
699
|
-
let r = getChildren(this, type, before, after);
|
|
700
|
-
return r.length ? r[0] : null;
|
|
701
|
-
}
|
|
702
|
-
getChildren(type, before = null, after = null) {
|
|
703
|
-
return getChildren(this, type, before, after);
|
|
704
|
-
}
|
|
705
|
-
resolve(pos, side = 0) {
|
|
706
|
-
return resolveNode(this, pos, side, false);
|
|
707
|
-
}
|
|
708
|
-
resolveInner(pos, side = 0) {
|
|
709
|
-
return resolveNode(this, pos, side, true);
|
|
710
|
-
}
|
|
711
|
-
matchContext(context) {
|
|
712
|
-
return matchNodeContext(this.parent, context);
|
|
713
|
-
}
|
|
714
|
-
enterUnfinishedNodesBefore(pos) {
|
|
715
|
-
let scan = this.childBefore(pos), node = this;
|
|
716
|
-
while (scan) {
|
|
717
|
-
let last = scan.lastChild;
|
|
718
|
-
if (!last || last.to != scan.to) break;
|
|
719
|
-
if (last.type.isError && last.from == last.to) {
|
|
720
|
-
node = scan;
|
|
721
|
-
scan = last.prevSibling;
|
|
722
|
-
} else scan = last;
|
|
723
|
-
}
|
|
724
|
-
return node;
|
|
725
|
-
}
|
|
726
|
-
get node() {
|
|
727
|
-
return this;
|
|
728
|
-
}
|
|
729
|
-
get next() {
|
|
730
|
-
return this.parent;
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
var TreeNode = class TreeNode extends BaseNode {
|
|
734
|
-
constructor(_tree, from, index, _parent) {
|
|
735
|
-
super();
|
|
736
|
-
this._tree = _tree;
|
|
737
|
-
this.from = from;
|
|
738
|
-
this.index = index;
|
|
739
|
-
this._parent = _parent;
|
|
740
|
-
}
|
|
741
|
-
get type() {
|
|
742
|
-
return this._tree.type;
|
|
743
|
-
}
|
|
744
|
-
get name() {
|
|
745
|
-
return this._tree.type.name;
|
|
746
|
-
}
|
|
747
|
-
get to() {
|
|
748
|
-
return this.from + this._tree.length;
|
|
749
|
-
}
|
|
750
|
-
nextChild(i, dir, pos, side, mode = 0) {
|
|
751
|
-
for (let parent = this;;) {
|
|
752
|
-
for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
|
|
753
|
-
let next = children[i], start = positions[i] + parent.from, mounted;
|
|
754
|
-
if (!(mode & IterMode.EnterBracketed && next instanceof Tree && (mounted = MountedTree.get(next)) && !mounted.overlay && mounted.bracketed && pos >= start && pos <= start + next.length) && !checkSide(side, pos, start, start + next.length)) continue;
|
|
755
|
-
if (next instanceof TreeBuffer) {
|
|
756
|
-
if (mode & IterMode.ExcludeBuffers) continue;
|
|
757
|
-
let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
|
|
758
|
-
if (index > -1) return new BufferNode(new BufferContext(parent, next, i, start), null, index);
|
|
759
|
-
} else if (mode & IterMode.IncludeAnonymous || !next.type.isAnonymous || hasChild(next)) {
|
|
760
|
-
let mounted;
|
|
761
|
-
if (!(mode & IterMode.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay) return new TreeNode(mounted.tree, start, i, parent);
|
|
762
|
-
let inner = new TreeNode(next, start, i, parent);
|
|
763
|
-
return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side, mode);
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous) return null;
|
|
767
|
-
if (parent.index >= 0) i = parent.index + dir;
|
|
768
|
-
else i = dir < 0 ? -1 : parent._parent._tree.children.length;
|
|
769
|
-
parent = parent._parent;
|
|
770
|
-
if (!parent) return null;
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
get firstChild() {
|
|
774
|
-
return this.nextChild(0, 1, 0, 4);
|
|
775
|
-
}
|
|
776
|
-
get lastChild() {
|
|
777
|
-
return this.nextChild(this._tree.children.length - 1, -1, 0, 4);
|
|
778
|
-
}
|
|
779
|
-
childAfter(pos) {
|
|
780
|
-
return this.nextChild(0, 1, pos, 2);
|
|
781
|
-
}
|
|
782
|
-
childBefore(pos) {
|
|
783
|
-
return this.nextChild(this._tree.children.length - 1, -1, pos, -2);
|
|
784
|
-
}
|
|
785
|
-
prop(prop) {
|
|
786
|
-
return this._tree.prop(prop);
|
|
787
|
-
}
|
|
788
|
-
enter(pos, side, mode = 0) {
|
|
789
|
-
let mounted;
|
|
790
|
-
if (!(mode & IterMode.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {
|
|
791
|
-
let rPos = pos - this.from, enterBracketed = mode & IterMode.EnterBracketed && mounted.bracketed;
|
|
792
|
-
for (let { from, to } of mounted.overlay) if ((side > 0 || enterBracketed ? from <= rPos : from < rPos) && (side < 0 || enterBracketed ? to >= rPos : to > rPos)) return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
|
|
793
|
-
}
|
|
794
|
-
return this.nextChild(0, 1, pos, side, mode);
|
|
795
|
-
}
|
|
796
|
-
nextSignificantParent() {
|
|
797
|
-
let val = this;
|
|
798
|
-
while (val.type.isAnonymous && val._parent) val = val._parent;
|
|
799
|
-
return val;
|
|
800
|
-
}
|
|
801
|
-
get parent() {
|
|
802
|
-
return this._parent ? this._parent.nextSignificantParent() : null;
|
|
803
|
-
}
|
|
804
|
-
get nextSibling() {
|
|
805
|
-
return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4) : null;
|
|
806
|
-
}
|
|
807
|
-
get prevSibling() {
|
|
808
|
-
return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4) : null;
|
|
809
|
-
}
|
|
810
|
-
get tree() {
|
|
811
|
-
return this._tree;
|
|
812
|
-
}
|
|
813
|
-
toTree() {
|
|
814
|
-
return this._tree;
|
|
815
|
-
}
|
|
816
|
-
/**
|
|
817
|
-
@internal
|
|
818
|
-
*/
|
|
819
|
-
toString() {
|
|
820
|
-
return this._tree.toString();
|
|
821
|
-
}
|
|
822
|
-
};
|
|
823
|
-
function getChildren(node, type, before, after) {
|
|
824
|
-
let cur = node.cursor(), result = [];
|
|
825
|
-
if (!cur.firstChild()) return result;
|
|
826
|
-
if (before != null) for (let found = false; !found;) {
|
|
827
|
-
found = cur.type.is(before);
|
|
828
|
-
if (!cur.nextSibling()) return result;
|
|
829
|
-
}
|
|
830
|
-
for (;;) {
|
|
831
|
-
if (after != null && cur.type.is(after)) return result;
|
|
832
|
-
if (cur.type.is(type)) result.push(cur.node);
|
|
833
|
-
if (!cur.nextSibling()) return after == null ? result : [];
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
function matchNodeContext(node, context, i = context.length - 1) {
|
|
837
|
-
for (let p = node; i >= 0; p = p.parent) {
|
|
838
|
-
if (!p) return false;
|
|
839
|
-
if (!p.type.isAnonymous) {
|
|
840
|
-
if (context[i] && context[i] != p.name) return false;
|
|
841
|
-
i--;
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
return true;
|
|
845
|
-
}
|
|
846
|
-
var BufferContext = class {
|
|
847
|
-
constructor(parent, buffer, index, start) {
|
|
848
|
-
this.parent = parent;
|
|
849
|
-
this.buffer = buffer;
|
|
850
|
-
this.index = index;
|
|
851
|
-
this.start = start;
|
|
852
|
-
}
|
|
853
|
-
};
|
|
854
|
-
var BufferNode = class BufferNode extends BaseNode {
|
|
855
|
-
get name() {
|
|
856
|
-
return this.type.name;
|
|
857
|
-
}
|
|
858
|
-
get from() {
|
|
859
|
-
return this.context.start + this.context.buffer.buffer[this.index + 1];
|
|
860
|
-
}
|
|
861
|
-
get to() {
|
|
862
|
-
return this.context.start + this.context.buffer.buffer[this.index + 2];
|
|
863
|
-
}
|
|
864
|
-
constructor(context, _parent, index) {
|
|
865
|
-
super();
|
|
866
|
-
this.context = context;
|
|
867
|
-
this._parent = _parent;
|
|
868
|
-
this.index = index;
|
|
869
|
-
this.type = context.buffer.set.types[context.buffer.buffer[index]];
|
|
870
|
-
}
|
|
871
|
-
child(dir, pos, side) {
|
|
872
|
-
let { buffer } = this.context;
|
|
873
|
-
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
|
|
874
|
-
return index < 0 ? null : new BufferNode(this.context, this, index);
|
|
875
|
-
}
|
|
876
|
-
get firstChild() {
|
|
877
|
-
return this.child(1, 0, 4);
|
|
878
|
-
}
|
|
879
|
-
get lastChild() {
|
|
880
|
-
return this.child(-1, 0, 4);
|
|
881
|
-
}
|
|
882
|
-
childAfter(pos) {
|
|
883
|
-
return this.child(1, pos, 2);
|
|
884
|
-
}
|
|
885
|
-
childBefore(pos) {
|
|
886
|
-
return this.child(-1, pos, -2);
|
|
887
|
-
}
|
|
888
|
-
prop(prop) {
|
|
889
|
-
return this.type.prop(prop);
|
|
890
|
-
}
|
|
891
|
-
enter(pos, side, mode = 0) {
|
|
892
|
-
if (mode & IterMode.ExcludeBuffers) return null;
|
|
893
|
-
let { buffer } = this.context;
|
|
894
|
-
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
|
|
895
|
-
return index < 0 ? null : new BufferNode(this.context, this, index);
|
|
896
|
-
}
|
|
897
|
-
get parent() {
|
|
898
|
-
return this._parent || this.context.parent.nextSignificantParent();
|
|
899
|
-
}
|
|
900
|
-
externalSibling(dir) {
|
|
901
|
-
return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4);
|
|
902
|
-
}
|
|
903
|
-
get nextSibling() {
|
|
904
|
-
let { buffer } = this.context;
|
|
905
|
-
let after = buffer.buffer[this.index + 3];
|
|
906
|
-
if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length)) return new BufferNode(this.context, this._parent, after);
|
|
907
|
-
return this.externalSibling(1);
|
|
908
|
-
}
|
|
909
|
-
get prevSibling() {
|
|
910
|
-
let { buffer } = this.context;
|
|
911
|
-
let parentStart = this._parent ? this._parent.index + 4 : 0;
|
|
912
|
-
if (this.index == parentStart) return this.externalSibling(-1);
|
|
913
|
-
return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4));
|
|
914
|
-
}
|
|
915
|
-
get tree() {
|
|
916
|
-
return null;
|
|
917
|
-
}
|
|
918
|
-
toTree() {
|
|
919
|
-
let children = [], positions = [];
|
|
920
|
-
let { buffer } = this.context;
|
|
921
|
-
let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
|
|
922
|
-
if (endI > startI) {
|
|
923
|
-
let from = buffer.buffer[this.index + 1];
|
|
924
|
-
children.push(buffer.slice(startI, endI, from));
|
|
925
|
-
positions.push(0);
|
|
926
|
-
}
|
|
927
|
-
return new Tree(this.type, children, positions, this.to - this.from);
|
|
928
|
-
}
|
|
929
|
-
/**
|
|
930
|
-
@internal
|
|
931
|
-
*/
|
|
932
|
-
toString() {
|
|
933
|
-
return this.context.buffer.childString(this.index);
|
|
934
|
-
}
|
|
935
|
-
};
|
|
936
|
-
function iterStack(heads) {
|
|
937
|
-
if (!heads.length) return null;
|
|
938
|
-
let pick = 0, picked = heads[0];
|
|
939
|
-
for (let i = 1; i < heads.length; i++) {
|
|
940
|
-
let node = heads[i];
|
|
941
|
-
if (node.from > picked.from || node.to < picked.to) {
|
|
942
|
-
picked = node;
|
|
943
|
-
pick = i;
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;
|
|
947
|
-
let newHeads = heads.slice();
|
|
948
|
-
if (next) newHeads[pick] = next;
|
|
949
|
-
else newHeads.splice(pick, 1);
|
|
950
|
-
return new StackIterator(newHeads, picked);
|
|
951
|
-
}
|
|
952
|
-
var StackIterator = class {
|
|
953
|
-
constructor(heads, node) {
|
|
954
|
-
this.heads = heads;
|
|
955
|
-
this.node = node;
|
|
956
|
-
}
|
|
957
|
-
get next() {
|
|
958
|
-
return iterStack(this.heads);
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
function stackIterator(tree, pos, side) {
|
|
962
|
-
let inner = tree.resolveInner(pos, side), layers = null;
|
|
963
|
-
for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) if (scan.index < 0) {
|
|
964
|
-
let parent = scan.parent;
|
|
965
|
-
(layers || (layers = [inner])).push(parent.resolve(pos, side));
|
|
966
|
-
scan = parent;
|
|
967
|
-
} else {
|
|
968
|
-
let mount = MountedTree.get(scan.tree);
|
|
969
|
-
if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {
|
|
970
|
-
let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, -1, scan);
|
|
971
|
-
(layers || (layers = [inner])).push(resolveNode(root, pos, side, false));
|
|
972
|
-
}
|
|
973
|
-
}
|
|
974
|
-
return layers ? iterStack(layers) : inner;
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
A tree cursor object focuses on a given node in a syntax tree, and
|
|
978
|
-
allows you to move to adjacent nodes.
|
|
979
|
-
*/
|
|
980
|
-
var TreeCursor = class {
|
|
981
|
-
/**
|
|
982
|
-
Shorthand for `.type.name`.
|
|
983
|
-
*/
|
|
984
|
-
get name() {
|
|
985
|
-
return this.type.name;
|
|
986
|
-
}
|
|
987
|
-
/**
|
|
988
|
-
@internal
|
|
989
|
-
*/
|
|
990
|
-
constructor(node, mode = 0) {
|
|
991
|
-
/**
|
|
992
|
-
@internal
|
|
993
|
-
*/
|
|
994
|
-
this.buffer = null;
|
|
995
|
-
this.stack = [];
|
|
996
|
-
/**
|
|
997
|
-
@internal
|
|
998
|
-
*/
|
|
999
|
-
this.index = 0;
|
|
1000
|
-
this.bufferNode = null;
|
|
1001
|
-
this.mode = mode & ~IterMode.EnterBracketed;
|
|
1002
|
-
if (node instanceof TreeNode) this.yieldNode(node);
|
|
1003
|
-
else {
|
|
1004
|
-
this._tree = node.context.parent;
|
|
1005
|
-
this.buffer = node.context;
|
|
1006
|
-
for (let n = node._parent; n; n = n._parent) this.stack.unshift(n.index);
|
|
1007
|
-
this.bufferNode = node;
|
|
1008
|
-
this.yieldBuf(node.index);
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
yieldNode(node) {
|
|
1012
|
-
if (!node) return false;
|
|
1013
|
-
this._tree = node;
|
|
1014
|
-
this.type = node.type;
|
|
1015
|
-
this.from = node.from;
|
|
1016
|
-
this.to = node.to;
|
|
1017
|
-
return true;
|
|
1018
|
-
}
|
|
1019
|
-
yieldBuf(index, type) {
|
|
1020
|
-
this.index = index;
|
|
1021
|
-
let { start, buffer } = this.buffer;
|
|
1022
|
-
this.type = type || buffer.set.types[buffer.buffer[index]];
|
|
1023
|
-
this.from = start + buffer.buffer[index + 1];
|
|
1024
|
-
this.to = start + buffer.buffer[index + 2];
|
|
1025
|
-
return true;
|
|
1026
|
-
}
|
|
1027
|
-
/**
|
|
1028
|
-
@internal
|
|
1029
|
-
*/
|
|
1030
|
-
yield(node) {
|
|
1031
|
-
if (!node) return false;
|
|
1032
|
-
if (node instanceof TreeNode) {
|
|
1033
|
-
this.buffer = null;
|
|
1034
|
-
return this.yieldNode(node);
|
|
1035
|
-
}
|
|
1036
|
-
this.buffer = node.context;
|
|
1037
|
-
return this.yieldBuf(node.index, node.type);
|
|
1038
|
-
}
|
|
1039
|
-
/**
|
|
1040
|
-
@internal
|
|
1041
|
-
*/
|
|
1042
|
-
toString() {
|
|
1043
|
-
return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
@internal
|
|
1047
|
-
*/
|
|
1048
|
-
enterChild(dir, pos, side) {
|
|
1049
|
-
if (!this.buffer) return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
|
|
1050
|
-
let { buffer } = this.buffer;
|
|
1051
|
-
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
|
|
1052
|
-
if (index < 0) return false;
|
|
1053
|
-
this.stack.push(this.index);
|
|
1054
|
-
return this.yieldBuf(index);
|
|
1055
|
-
}
|
|
1056
|
-
/**
|
|
1057
|
-
Move the cursor to this node's first child. When this returns
|
|
1058
|
-
false, the node has no child, and the cursor has not been moved.
|
|
1059
|
-
*/
|
|
1060
|
-
firstChild() {
|
|
1061
|
-
return this.enterChild(1, 0, 4);
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
Move the cursor to this node's last child.
|
|
1065
|
-
*/
|
|
1066
|
-
lastChild() {
|
|
1067
|
-
return this.enterChild(-1, 0, 4);
|
|
1068
|
-
}
|
|
1069
|
-
/**
|
|
1070
|
-
Move the cursor to the first child that ends after `pos`.
|
|
1071
|
-
*/
|
|
1072
|
-
childAfter(pos) {
|
|
1073
|
-
return this.enterChild(1, pos, 2);
|
|
1074
|
-
}
|
|
1075
|
-
/**
|
|
1076
|
-
Move to the last child that starts before `pos`.
|
|
1077
|
-
*/
|
|
1078
|
-
childBefore(pos) {
|
|
1079
|
-
return this.enterChild(-1, pos, -2);
|
|
1080
|
-
}
|
|
1081
|
-
/**
|
|
1082
|
-
Move the cursor to the child around `pos`. If side is -1 the
|
|
1083
|
-
child may end at that position, when 1 it may start there. This
|
|
1084
|
-
will also enter [overlaid](#common.MountedTree.overlay)
|
|
1085
|
-
[mounted](#common.NodeProp^mounted) trees unless `overlays` is
|
|
1086
|
-
set to false.
|
|
1087
|
-
*/
|
|
1088
|
-
enter(pos, side, mode = this.mode) {
|
|
1089
|
-
if (!this.buffer) return this.yield(this._tree.enter(pos, side, mode));
|
|
1090
|
-
return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
|
|
1091
|
-
}
|
|
1092
|
-
/**
|
|
1093
|
-
Move to the node's parent node, if this isn't the top node.
|
|
1094
|
-
*/
|
|
1095
|
-
parent() {
|
|
1096
|
-
if (!this.buffer) return this.yieldNode(this.mode & IterMode.IncludeAnonymous ? this._tree._parent : this._tree.parent);
|
|
1097
|
-
if (this.stack.length) return this.yieldBuf(this.stack.pop());
|
|
1098
|
-
let parent = this.mode & IterMode.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
|
|
1099
|
-
this.buffer = null;
|
|
1100
|
-
return this.yieldNode(parent);
|
|
1101
|
-
}
|
|
1102
|
-
/**
|
|
1103
|
-
@internal
|
|
1104
|
-
*/
|
|
1105
|
-
sibling(dir) {
|
|
1106
|
-
if (!this.buffer) return !this._tree._parent ? false : this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4, this.mode));
|
|
1107
|
-
let { buffer } = this.buffer, d = this.stack.length - 1;
|
|
1108
|
-
if (dir < 0) {
|
|
1109
|
-
let parentStart = d < 0 ? 0 : this.stack[d] + 4;
|
|
1110
|
-
if (this.index != parentStart) return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4));
|
|
1111
|
-
} else {
|
|
1112
|
-
let after = buffer.buffer[this.index + 3];
|
|
1113
|
-
if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3])) return this.yieldBuf(after);
|
|
1114
|
-
}
|
|
1115
|
-
return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4, this.mode)) : false;
|
|
1116
|
-
}
|
|
1117
|
-
/**
|
|
1118
|
-
Move to this node's next sibling, if any.
|
|
1119
|
-
*/
|
|
1120
|
-
nextSibling() {
|
|
1121
|
-
return this.sibling(1);
|
|
1122
|
-
}
|
|
1123
|
-
/**
|
|
1124
|
-
Move to this node's previous sibling, if any.
|
|
1125
|
-
*/
|
|
1126
|
-
prevSibling() {
|
|
1127
|
-
return this.sibling(-1);
|
|
1128
|
-
}
|
|
1129
|
-
atLastNode(dir) {
|
|
1130
|
-
let index, parent, { buffer } = this;
|
|
1131
|
-
if (buffer) {
|
|
1132
|
-
if (dir > 0) {
|
|
1133
|
-
if (this.index < buffer.buffer.buffer.length) return false;
|
|
1134
|
-
} else for (let i = 0; i < this.index; i++) if (buffer.buffer.buffer[i + 3] < this.index) return false;
|
|
1135
|
-
({index, parent} = buffer);
|
|
1136
|
-
} else ({index, _parent: parent} = this._tree);
|
|
1137
|
-
for (; parent; {index, _parent: parent} = parent) if (index > -1) for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
|
|
1138
|
-
let child = parent._tree.children[i];
|
|
1139
|
-
if (this.mode & IterMode.IncludeAnonymous || child instanceof TreeBuffer || !child.type.isAnonymous || hasChild(child)) return false;
|
|
1140
|
-
}
|
|
1141
|
-
return true;
|
|
1142
|
-
}
|
|
1143
|
-
move(dir, enter) {
|
|
1144
|
-
if (enter && this.enterChild(dir, 0, 4)) return true;
|
|
1145
|
-
for (;;) {
|
|
1146
|
-
if (this.sibling(dir)) return true;
|
|
1147
|
-
if (this.atLastNode(dir) || !this.parent()) return false;
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
/**
|
|
1151
|
-
Move to the next node in a
|
|
1152
|
-
[pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
|
|
1153
|
-
traversal, going from a node to its first child or, if the
|
|
1154
|
-
current node is empty or `enter` is false, its next sibling or
|
|
1155
|
-
the next sibling of the first parent node that has one.
|
|
1156
|
-
*/
|
|
1157
|
-
next(enter = true) {
|
|
1158
|
-
return this.move(1, enter);
|
|
1159
|
-
}
|
|
1160
|
-
/**
|
|
1161
|
-
Move to the next node in a last-to-first pre-order traversal. A
|
|
1162
|
-
node is followed by its last child or, if it has none, its
|
|
1163
|
-
previous sibling or the previous sibling of the first parent
|
|
1164
|
-
node that has one.
|
|
1165
|
-
*/
|
|
1166
|
-
prev(enter = true) {
|
|
1167
|
-
return this.move(-1, enter);
|
|
1168
|
-
}
|
|
1169
|
-
/**
|
|
1170
|
-
Move the cursor to the innermost node that covers `pos`. If
|
|
1171
|
-
`side` is -1, it will enter nodes that end at `pos`. If it is 1,
|
|
1172
|
-
it will enter nodes that start at `pos`.
|
|
1173
|
-
*/
|
|
1174
|
-
moveTo(pos, side = 0) {
|
|
1175
|
-
while (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos)) if (!this.parent()) break;
|
|
1176
|
-
while (this.enterChild(1, pos, side));
|
|
1177
|
-
return this;
|
|
1178
|
-
}
|
|
1179
|
-
/**
|
|
1180
|
-
Get a [syntax node](#common.SyntaxNode) at the cursor's current
|
|
1181
|
-
position.
|
|
1182
|
-
*/
|
|
1183
|
-
get node() {
|
|
1184
|
-
if (!this.buffer) return this._tree;
|
|
1185
|
-
let cache = this.bufferNode, result = null, depth = 0;
|
|
1186
|
-
if (cache && cache.context == this.buffer) scan: for (let index = this.index, d = this.stack.length; d >= 0;) {
|
|
1187
|
-
for (let c = cache; c; c = c._parent) if (c.index == index) {
|
|
1188
|
-
if (index == this.index) return c;
|
|
1189
|
-
result = c;
|
|
1190
|
-
depth = d + 1;
|
|
1191
|
-
break scan;
|
|
1192
|
-
}
|
|
1193
|
-
index = this.stack[--d];
|
|
1194
|
-
}
|
|
1195
|
-
for (let i = depth; i < this.stack.length; i++) result = new BufferNode(this.buffer, result, this.stack[i]);
|
|
1196
|
-
return this.bufferNode = new BufferNode(this.buffer, result, this.index);
|
|
1197
|
-
}
|
|
1198
|
-
/**
|
|
1199
|
-
Get the [tree](#common.Tree) that represents the current node, if
|
|
1200
|
-
any. Will return null when the node is in a [tree
|
|
1201
|
-
buffer](#common.TreeBuffer).
|
|
1202
|
-
*/
|
|
1203
|
-
get tree() {
|
|
1204
|
-
return this.buffer ? null : this._tree._tree;
|
|
1205
|
-
}
|
|
1206
|
-
/**
|
|
1207
|
-
Iterate over the current node and all its descendants, calling
|
|
1208
|
-
`enter` when entering a node and `leave`, if given, when leaving
|
|
1209
|
-
one. When `enter` returns `false`, any children of that node are
|
|
1210
|
-
skipped, and `leave` isn't called for it.
|
|
1211
|
-
*/
|
|
1212
|
-
iterate(enter, leave) {
|
|
1213
|
-
for (let depth = 0;;) {
|
|
1214
|
-
let mustLeave = false;
|
|
1215
|
-
if (this.type.isAnonymous || enter(this) !== false) {
|
|
1216
|
-
if (this.firstChild()) {
|
|
1217
|
-
depth++;
|
|
1218
|
-
continue;
|
|
1219
|
-
}
|
|
1220
|
-
if (!this.type.isAnonymous) mustLeave = true;
|
|
1221
|
-
}
|
|
1222
|
-
for (;;) {
|
|
1223
|
-
if (mustLeave && leave) leave(this);
|
|
1224
|
-
mustLeave = this.type.isAnonymous;
|
|
1225
|
-
if (!depth) return;
|
|
1226
|
-
if (this.nextSibling()) break;
|
|
1227
|
-
this.parent();
|
|
1228
|
-
depth--;
|
|
1229
|
-
mustLeave = true;
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
/**
|
|
1234
|
-
Test whether the current node matches a given context—a sequence
|
|
1235
|
-
of direct parent node names. Empty strings in the context array
|
|
1236
|
-
are treated as wildcards.
|
|
1237
|
-
*/
|
|
1238
|
-
matchContext(context) {
|
|
1239
|
-
if (!this.buffer) return matchNodeContext(this.node.parent, context);
|
|
1240
|
-
let { buffer } = this.buffer, { types } = buffer.set;
|
|
1241
|
-
for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
|
|
1242
|
-
if (d < 0) return matchNodeContext(this._tree, context, i);
|
|
1243
|
-
let type = types[buffer.buffer[this.stack[d]]];
|
|
1244
|
-
if (!type.isAnonymous) {
|
|
1245
|
-
if (context[i] && context[i] != type.name) return false;
|
|
1246
|
-
i--;
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
return true;
|
|
1250
|
-
}
|
|
1251
|
-
};
|
|
1252
|
-
function hasChild(tree) {
|
|
1253
|
-
return tree.children.some((ch) => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
|
|
1254
|
-
}
|
|
1255
|
-
function buildTree(data) {
|
|
1256
|
-
var _a;
|
|
1257
|
-
let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
|
|
1258
|
-
let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
|
|
1259
|
-
let types = nodeSet.types;
|
|
1260
|
-
let contextHash = 0, lookAhead = 0;
|
|
1261
|
-
function takeNode(parentStart, minPos, children, positions, inRepeat, depth) {
|
|
1262
|
-
let { id, start, end, size } = cursor;
|
|
1263
|
-
let lookAheadAtStart = lookAhead, contextAtStart = contextHash;
|
|
1264
|
-
if (size < 0) {
|
|
1265
|
-
cursor.next();
|
|
1266
|
-
if (size == -1) {
|
|
1267
|
-
let node = reused[id];
|
|
1268
|
-
children.push(node);
|
|
1269
|
-
positions.push(start - parentStart);
|
|
1270
|
-
return;
|
|
1271
|
-
} else if (size == -3) {
|
|
1272
|
-
contextHash = id;
|
|
1273
|
-
return;
|
|
1274
|
-
} else if (size == -4) {
|
|
1275
|
-
lookAhead = id;
|
|
1276
|
-
return;
|
|
1277
|
-
} else throw new RangeError(`Unrecognized record size: ${size}`);
|
|
1278
|
-
}
|
|
1279
|
-
let type = types[id], node, buffer;
|
|
1280
|
-
let startPos = start - parentStart;
|
|
1281
|
-
if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {
|
|
1282
|
-
let data = new Uint16Array(buffer.size - buffer.skip);
|
|
1283
|
-
let endPos = cursor.pos - buffer.size, index = data.length;
|
|
1284
|
-
while (cursor.pos > endPos) index = copyToBuffer(buffer.start, data, index);
|
|
1285
|
-
node = new TreeBuffer(data, end - buffer.start, nodeSet);
|
|
1286
|
-
startPos = buffer.start - parentStart;
|
|
1287
|
-
} else {
|
|
1288
|
-
let endPos = cursor.pos - size;
|
|
1289
|
-
cursor.next();
|
|
1290
|
-
let localChildren = [], localPositions = [];
|
|
1291
|
-
let localInRepeat = id >= minRepeatType ? id : -1;
|
|
1292
|
-
let lastGroup = 0, lastEnd = end;
|
|
1293
|
-
while (cursor.pos > endPos) if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
|
|
1294
|
-
if (cursor.end <= lastEnd - maxBufferLength) {
|
|
1295
|
-
makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
|
|
1296
|
-
lastGroup = localChildren.length;
|
|
1297
|
-
lastEnd = cursor.end;
|
|
1298
|
-
}
|
|
1299
|
-
cursor.next();
|
|
1300
|
-
} else if (depth > 2500) takeFlatNode(start, endPos, localChildren, localPositions);
|
|
1301
|
-
else takeNode(start, endPos, localChildren, localPositions, localInRepeat, depth + 1);
|
|
1302
|
-
if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length) makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart, contextAtStart);
|
|
1303
|
-
localChildren.reverse();
|
|
1304
|
-
localPositions.reverse();
|
|
1305
|
-
if (localInRepeat > -1 && lastGroup > 0) {
|
|
1306
|
-
let make = makeBalanced(type, contextAtStart);
|
|
1307
|
-
node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
|
|
1308
|
-
} else node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end, contextAtStart);
|
|
1309
|
-
}
|
|
1310
|
-
children.push(node);
|
|
1311
|
-
positions.push(startPos);
|
|
1312
|
-
}
|
|
1313
|
-
function takeFlatNode(parentStart, minPos, children, positions) {
|
|
1314
|
-
let nodes = [];
|
|
1315
|
-
let nodeCount = 0, stopAt = -1;
|
|
1316
|
-
while (cursor.pos > minPos) {
|
|
1317
|
-
let { id, start, end, size } = cursor;
|
|
1318
|
-
if (size > 4) cursor.next();
|
|
1319
|
-
else if (stopAt > -1 && start < stopAt) break;
|
|
1320
|
-
else {
|
|
1321
|
-
if (stopAt < 0) stopAt = end - maxBufferLength;
|
|
1322
|
-
nodes.push(id, start, end);
|
|
1323
|
-
nodeCount++;
|
|
1324
|
-
cursor.next();
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
if (nodeCount) {
|
|
1328
|
-
let buffer = new Uint16Array(nodeCount * 4);
|
|
1329
|
-
let start = nodes[nodes.length - 2];
|
|
1330
|
-
for (let i = nodes.length - 3, j = 0; i >= 0; i -= 3) {
|
|
1331
|
-
buffer[j++] = nodes[i];
|
|
1332
|
-
buffer[j++] = nodes[i + 1] - start;
|
|
1333
|
-
buffer[j++] = nodes[i + 2] - start;
|
|
1334
|
-
buffer[j++] = j;
|
|
1335
|
-
}
|
|
1336
|
-
children.push(new TreeBuffer(buffer, nodes[2] - start, nodeSet));
|
|
1337
|
-
positions.push(start - parentStart);
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
function makeBalanced(type, contextHash) {
|
|
1341
|
-
return (children, positions, length) => {
|
|
1342
|
-
let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;
|
|
1343
|
-
if (lastI >= 0 && (last = children[lastI]) instanceof Tree) {
|
|
1344
|
-
if (!lastI && last.type == type && last.length == length) return last;
|
|
1345
|
-
if (lookAheadProp = last.prop(NodeProp.lookAhead)) lookAhead = positions[lastI] + last.length + lookAheadProp;
|
|
1346
|
-
}
|
|
1347
|
-
return makeTree(type, children, positions, length, lookAhead, contextHash);
|
|
1348
|
-
};
|
|
1349
|
-
}
|
|
1350
|
-
function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead, contextHash) {
|
|
1351
|
-
let localChildren = [], localPositions = [];
|
|
1352
|
-
while (children.length > i) {
|
|
1353
|
-
localChildren.push(children.pop());
|
|
1354
|
-
localPositions.push(positions.pop() + base - from);
|
|
1355
|
-
}
|
|
1356
|
-
children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to, contextHash));
|
|
1357
|
-
positions.push(from - base);
|
|
1358
|
-
}
|
|
1359
|
-
function makeTree(type, children, positions, length, lookAhead, contextHash, props) {
|
|
1360
|
-
if (contextHash) {
|
|
1361
|
-
let pair = [NodeProp.contextHash, contextHash];
|
|
1362
|
-
props = props ? [pair].concat(props) : [pair];
|
|
1363
|
-
}
|
|
1364
|
-
if (lookAhead > 25) {
|
|
1365
|
-
let pair = [NodeProp.lookAhead, lookAhead];
|
|
1366
|
-
props = props ? [pair].concat(props) : [pair];
|
|
1367
|
-
}
|
|
1368
|
-
return new Tree(type, children, positions, length, props);
|
|
1369
|
-
}
|
|
1370
|
-
function findBufferSize(maxSize, inRepeat) {
|
|
1371
|
-
let fork = cursor.fork();
|
|
1372
|
-
let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
|
|
1373
|
-
let result = {
|
|
1374
|
-
size: 0,
|
|
1375
|
-
start: 0,
|
|
1376
|
-
skip: 0
|
|
1377
|
-
};
|
|
1378
|
-
scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {
|
|
1379
|
-
let nodeSize = fork.size;
|
|
1380
|
-
if (fork.id == inRepeat && nodeSize >= 0) {
|
|
1381
|
-
result.size = size;
|
|
1382
|
-
result.start = start;
|
|
1383
|
-
result.skip = skip;
|
|
1384
|
-
skip += 4;
|
|
1385
|
-
size += 4;
|
|
1386
|
-
fork.next();
|
|
1387
|
-
continue;
|
|
1388
|
-
}
|
|
1389
|
-
let startPos = fork.pos - nodeSize;
|
|
1390
|
-
if (nodeSize < 0 || startPos < minPos || fork.start < minStart) break;
|
|
1391
|
-
let localSkipped = fork.id >= minRepeatType ? 4 : 0;
|
|
1392
|
-
let nodeStart = fork.start;
|
|
1393
|
-
fork.next();
|
|
1394
|
-
while (fork.pos > startPos) {
|
|
1395
|
-
if (fork.size < 0) {
|
|
1396
|
-
if (fork.size == -3 || fork.size == -4) localSkipped += 4;
|
|
1397
|
-
else break scan;
|
|
1398
|
-
} else if (fork.id >= minRepeatType) localSkipped += 4;
|
|
1399
|
-
fork.next();
|
|
1400
|
-
}
|
|
1401
|
-
start = nodeStart;
|
|
1402
|
-
size += nodeSize;
|
|
1403
|
-
skip += localSkipped;
|
|
1404
|
-
}
|
|
1405
|
-
if (inRepeat < 0 || size == maxSize) {
|
|
1406
|
-
result.size = size;
|
|
1407
|
-
result.start = start;
|
|
1408
|
-
result.skip = skip;
|
|
1409
|
-
}
|
|
1410
|
-
return result.size > 4 ? result : void 0;
|
|
1411
|
-
}
|
|
1412
|
-
function copyToBuffer(bufferStart, buffer, index) {
|
|
1413
|
-
let { id, start, end, size } = cursor;
|
|
1414
|
-
cursor.next();
|
|
1415
|
-
if (size >= 0 && id < minRepeatType) {
|
|
1416
|
-
let startIndex = index;
|
|
1417
|
-
if (size > 4) {
|
|
1418
|
-
let endPos = cursor.pos - (size - 4);
|
|
1419
|
-
while (cursor.pos > endPos) index = copyToBuffer(bufferStart, buffer, index);
|
|
1420
|
-
}
|
|
1421
|
-
buffer[--index] = startIndex;
|
|
1422
|
-
buffer[--index] = end - bufferStart;
|
|
1423
|
-
buffer[--index] = start - bufferStart;
|
|
1424
|
-
buffer[--index] = id;
|
|
1425
|
-
} else if (size == -3) contextHash = id;
|
|
1426
|
-
else if (size == -4) lookAhead = id;
|
|
1427
|
-
return index;
|
|
1428
|
-
}
|
|
1429
|
-
let children = [], positions = [];
|
|
1430
|
-
while (cursor.pos > 0) takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1, 0);
|
|
1431
|
-
let length = (_a = data.length) !== null && _a !== void 0 ? _a : children.length ? positions[0] + children[0].length : 0;
|
|
1432
|
-
return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
|
|
1433
|
-
}
|
|
1434
|
-
var nodeSizeCache = /* @__PURE__ */ new WeakMap();
|
|
1435
|
-
function nodeSize(balanceType, node) {
|
|
1436
|
-
if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType) return 1;
|
|
1437
|
-
let size = nodeSizeCache.get(node);
|
|
1438
|
-
if (size == null) {
|
|
1439
|
-
size = 1;
|
|
1440
|
-
for (let child of node.children) {
|
|
1441
|
-
if (child.type != balanceType || !(child instanceof Tree)) {
|
|
1442
|
-
size = 1;
|
|
1443
|
-
break;
|
|
1444
|
-
}
|
|
1445
|
-
size += nodeSize(balanceType, child);
|
|
1446
|
-
}
|
|
1447
|
-
nodeSizeCache.set(node, size);
|
|
1448
|
-
}
|
|
1449
|
-
return size;
|
|
1450
|
-
}
|
|
1451
|
-
function balanceRange(balanceType, children, positions, from, to, start, length, mkTop, mkTree) {
|
|
1452
|
-
let total = 0;
|
|
1453
|
-
for (let i = from; i < to; i++) total += nodeSize(balanceType, children[i]);
|
|
1454
|
-
let maxChild = Math.ceil(total * 1.5 / 8);
|
|
1455
|
-
let localChildren = [], localPositions = [];
|
|
1456
|
-
function divide(children, positions, from, to, offset) {
|
|
1457
|
-
for (let i = from; i < to;) {
|
|
1458
|
-
let groupFrom = i, groupStart = positions[i], groupSize = nodeSize(balanceType, children[i]);
|
|
1459
|
-
i++;
|
|
1460
|
-
for (; i < to; i++) {
|
|
1461
|
-
let nextSize = nodeSize(balanceType, children[i]);
|
|
1462
|
-
if (groupSize + nextSize >= maxChild) break;
|
|
1463
|
-
groupSize += nextSize;
|
|
1464
|
-
}
|
|
1465
|
-
if (i == groupFrom + 1) {
|
|
1466
|
-
if (groupSize > maxChild) {
|
|
1467
|
-
let only = children[groupFrom];
|
|
1468
|
-
divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);
|
|
1469
|
-
continue;
|
|
1470
|
-
}
|
|
1471
|
-
localChildren.push(children[groupFrom]);
|
|
1472
|
-
} else {
|
|
1473
|
-
let length = positions[i - 1] + children[i - 1].length - groupStart;
|
|
1474
|
-
localChildren.push(balanceRange(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));
|
|
1475
|
-
}
|
|
1476
|
-
localPositions.push(groupStart + offset - start);
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
divide(children, positions, from, to, 0);
|
|
1480
|
-
return (mkTop || mkTree)(localChildren, localPositions, length);
|
|
1481
|
-
}
|
|
1482
|
-
/**
|
|
1483
|
-
Provides a way to associate values with pieces of trees. As long
|
|
1484
|
-
as that part of the tree is reused, the associated values can be
|
|
1485
|
-
retrieved from an updated tree.
|
|
1486
|
-
*/
|
|
1487
|
-
var NodeWeakMap = class {
|
|
1488
|
-
constructor() {
|
|
1489
|
-
this.map = /* @__PURE__ */ new WeakMap();
|
|
1490
|
-
}
|
|
1491
|
-
setBuffer(buffer, index, value) {
|
|
1492
|
-
let inner = this.map.get(buffer);
|
|
1493
|
-
if (!inner) this.map.set(buffer, inner = /* @__PURE__ */ new Map());
|
|
1494
|
-
inner.set(index, value);
|
|
1495
|
-
}
|
|
1496
|
-
getBuffer(buffer, index) {
|
|
1497
|
-
let inner = this.map.get(buffer);
|
|
1498
|
-
return inner && inner.get(index);
|
|
1499
|
-
}
|
|
1500
|
-
/**
|
|
1501
|
-
Set the value for this syntax node.
|
|
1502
|
-
*/
|
|
1503
|
-
set(node, value) {
|
|
1504
|
-
if (node instanceof BufferNode) this.setBuffer(node.context.buffer, node.index, value);
|
|
1505
|
-
else if (node instanceof TreeNode) this.map.set(node.tree, value);
|
|
1506
|
-
}
|
|
1507
|
-
/**
|
|
1508
|
-
Retrieve value for this syntax node, if it exists in the map.
|
|
1509
|
-
*/
|
|
1510
|
-
get(node) {
|
|
1511
|
-
return node instanceof BufferNode ? this.getBuffer(node.context.buffer, node.index) : node instanceof TreeNode ? this.map.get(node.tree) : void 0;
|
|
1512
|
-
}
|
|
1513
|
-
/**
|
|
1514
|
-
Set the value for the node that a cursor currently points to.
|
|
1515
|
-
*/
|
|
1516
|
-
cursorSet(cursor, value) {
|
|
1517
|
-
if (cursor.buffer) this.setBuffer(cursor.buffer.buffer, cursor.index, value);
|
|
1518
|
-
else this.map.set(cursor.tree, value);
|
|
1519
|
-
}
|
|
1520
|
-
/**
|
|
1521
|
-
Retrieve the value for the node that a cursor currently points
|
|
1522
|
-
to.
|
|
1523
|
-
*/
|
|
1524
|
-
cursorGet(cursor) {
|
|
1525
|
-
return cursor.buffer ? this.getBuffer(cursor.buffer.buffer, cursor.index) : this.map.get(cursor.tree);
|
|
1526
|
-
}
|
|
1527
|
-
};
|
|
1528
|
-
/**
|
|
1529
|
-
Tree fragments are used during [incremental
|
|
1530
|
-
parsing](#common.Parser.startParse) to track parts of old trees
|
|
1531
|
-
that can be reused in a new parse. An array of fragments is used
|
|
1532
|
-
to track regions of an old tree whose nodes might be reused in new
|
|
1533
|
-
parses. Use the static
|
|
1534
|
-
[`applyChanges`](#common.TreeFragment^applyChanges) method to
|
|
1535
|
-
update fragments for document changes.
|
|
1536
|
-
*/
|
|
1537
|
-
var TreeFragment = class TreeFragment {
|
|
1538
|
-
/**
|
|
1539
|
-
Construct a tree fragment. You'll usually want to use
|
|
1540
|
-
[`addTree`](#common.TreeFragment^addTree) and
|
|
1541
|
-
[`applyChanges`](#common.TreeFragment^applyChanges) instead of
|
|
1542
|
-
calling this directly.
|
|
1543
|
-
*/
|
|
1544
|
-
constructor(from, to, tree, offset, openStart = false, openEnd = false) {
|
|
1545
|
-
this.from = from;
|
|
1546
|
-
this.to = to;
|
|
1547
|
-
this.tree = tree;
|
|
1548
|
-
this.offset = offset;
|
|
1549
|
-
this.open = (openStart ? 1 : 0) | (openEnd ? 2 : 0);
|
|
1550
|
-
}
|
|
1551
|
-
/**
|
|
1552
|
-
Whether the start of the fragment represents the start of a
|
|
1553
|
-
parse, or the end of a change. (In the second case, it may not
|
|
1554
|
-
be safe to reuse some nodes at the start, depending on the
|
|
1555
|
-
parsing algorithm.)
|
|
1556
|
-
*/
|
|
1557
|
-
get openStart() {
|
|
1558
|
-
return (this.open & 1) > 0;
|
|
1559
|
-
}
|
|
1560
|
-
/**
|
|
1561
|
-
Whether the end of the fragment represents the end of a
|
|
1562
|
-
full-document parse, or the start of a change.
|
|
1563
|
-
*/
|
|
1564
|
-
get openEnd() {
|
|
1565
|
-
return (this.open & 2) > 0;
|
|
1566
|
-
}
|
|
1567
|
-
/**
|
|
1568
|
-
Create a set of fragments from a freshly parsed tree, or update
|
|
1569
|
-
an existing set of fragments by replacing the ones that overlap
|
|
1570
|
-
with a tree with content from the new tree. When `partial` is
|
|
1571
|
-
true, the parse is treated as incomplete, and the resulting
|
|
1572
|
-
fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
|
|
1573
|
-
true.
|
|
1574
|
-
*/
|
|
1575
|
-
static addTree(tree, fragments = [], partial = false) {
|
|
1576
|
-
let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];
|
|
1577
|
-
for (let f of fragments) if (f.to > tree.length) result.push(f);
|
|
1578
|
-
return result;
|
|
1579
|
-
}
|
|
1580
|
-
/**
|
|
1581
|
-
Apply a set of edits to an array of fragments, removing or
|
|
1582
|
-
splitting fragments as necessary to remove edited ranges, and
|
|
1583
|
-
adjusting offsets for fragments that moved.
|
|
1584
|
-
*/
|
|
1585
|
-
static applyChanges(fragments, changes, minGap = 128) {
|
|
1586
|
-
if (!changes.length) return fragments;
|
|
1587
|
-
let result = [];
|
|
1588
|
-
let fI = 1, nextF = fragments.length ? fragments[0] : null;
|
|
1589
|
-
for (let cI = 0, pos = 0, off = 0;; cI++) {
|
|
1590
|
-
let nextC = cI < changes.length ? changes[cI] : null;
|
|
1591
|
-
let nextPos = nextC ? nextC.fromA : 1e9;
|
|
1592
|
-
if (nextPos - pos >= minGap) while (nextF && nextF.from < nextPos) {
|
|
1593
|
-
let cut = nextF;
|
|
1594
|
-
if (pos >= cut.from || nextPos <= cut.to || off) {
|
|
1595
|
-
let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;
|
|
1596
|
-
cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);
|
|
1597
|
-
}
|
|
1598
|
-
if (cut) result.push(cut);
|
|
1599
|
-
if (nextF.to > nextPos) break;
|
|
1600
|
-
nextF = fI < fragments.length ? fragments[fI++] : null;
|
|
1601
|
-
}
|
|
1602
|
-
if (!nextC) break;
|
|
1603
|
-
pos = nextC.toA;
|
|
1604
|
-
off = nextC.toA - nextC.toB;
|
|
1605
|
-
}
|
|
1606
|
-
return result;
|
|
1607
|
-
}
|
|
1608
|
-
};
|
|
1609
|
-
/**
|
|
1610
|
-
A superclass that parsers should extend.
|
|
1611
|
-
*/
|
|
1612
|
-
var Parser = class {
|
|
1613
|
-
/**
|
|
1614
|
-
Start a parse, returning a [partial parse](#common.PartialParse)
|
|
1615
|
-
object. [`fragments`](#common.TreeFragment) can be passed in to
|
|
1616
|
-
make the parse incremental.
|
|
1617
|
-
|
|
1618
|
-
By default, the entire input is parsed. You can pass `ranges`,
|
|
1619
|
-
which should be a sorted array of non-empty, non-overlapping
|
|
1620
|
-
ranges, to parse only those ranges. The tree returned in that
|
|
1621
|
-
case will start at `ranges[0].from`.
|
|
1622
|
-
*/
|
|
1623
|
-
startParse(input, fragments, ranges) {
|
|
1624
|
-
if (typeof input == "string") input = new StringInput(input);
|
|
1625
|
-
ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map((r) => new Range(r.from, r.to)) : [new Range(0, 0)];
|
|
1626
|
-
return this.createParse(input, fragments || [], ranges);
|
|
1627
|
-
}
|
|
1628
|
-
/**
|
|
1629
|
-
Run a full parse, returning the resulting tree.
|
|
1630
|
-
*/
|
|
1631
|
-
parse(input, fragments, ranges) {
|
|
1632
|
-
let parse = this.startParse(input, fragments, ranges);
|
|
1633
|
-
for (;;) {
|
|
1634
|
-
let done = parse.advance();
|
|
1635
|
-
if (done) return done;
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
};
|
|
1639
|
-
var StringInput = class {
|
|
1640
|
-
constructor(string) {
|
|
1641
|
-
this.string = string;
|
|
1642
|
-
}
|
|
1643
|
-
get length() {
|
|
1644
|
-
return this.string.length;
|
|
1645
|
-
}
|
|
1646
|
-
chunk(from) {
|
|
1647
|
-
return this.string.slice(from);
|
|
1648
|
-
}
|
|
1649
|
-
get lineChunks() {
|
|
1650
|
-
return false;
|
|
1651
|
-
}
|
|
1652
|
-
read(from, to) {
|
|
1653
|
-
return this.string.slice(from, to);
|
|
1654
|
-
}
|
|
1655
|
-
};
|
|
1656
|
-
/**
|
|
1657
|
-
Create a parse wrapper that, after the inner parse completes,
|
|
1658
|
-
scans its tree for mixed language regions with the `nest`
|
|
1659
|
-
function, runs the resulting [inner parses](#common.NestedParse),
|
|
1660
|
-
and then [mounts](#common.NodeProp^mounted) their results onto the
|
|
1661
|
-
tree.
|
|
1662
|
-
*/
|
|
1663
|
-
function parseMixed(nest) {
|
|
1664
|
-
return (parse, input, fragments, ranges) => new MixedParse(parse, nest, input, fragments, ranges);
|
|
1665
|
-
}
|
|
1666
|
-
var InnerParse = class {
|
|
1667
|
-
constructor(parser, parse, overlay, bracketed, target, from) {
|
|
1668
|
-
this.parser = parser;
|
|
1669
|
-
this.parse = parse;
|
|
1670
|
-
this.overlay = overlay;
|
|
1671
|
-
this.bracketed = bracketed;
|
|
1672
|
-
this.target = target;
|
|
1673
|
-
this.from = from;
|
|
1674
|
-
}
|
|
1675
|
-
};
|
|
1676
|
-
function checkRanges(ranges) {
|
|
1677
|
-
if (!ranges.length || ranges.some((r) => r.from >= r.to)) throw new RangeError("Invalid inner parse ranges given: " + JSON.stringify(ranges));
|
|
1678
|
-
}
|
|
1679
|
-
var ActiveOverlay = class {
|
|
1680
|
-
constructor(parser, predicate, mounts, index, start, bracketed, target, prev) {
|
|
1681
|
-
this.parser = parser;
|
|
1682
|
-
this.predicate = predicate;
|
|
1683
|
-
this.mounts = mounts;
|
|
1684
|
-
this.index = index;
|
|
1685
|
-
this.start = start;
|
|
1686
|
-
this.bracketed = bracketed;
|
|
1687
|
-
this.target = target;
|
|
1688
|
-
this.prev = prev;
|
|
1689
|
-
this.depth = 0;
|
|
1690
|
-
this.ranges = [];
|
|
1691
|
-
}
|
|
1692
|
-
};
|
|
1693
|
-
var stoppedInner = new NodeProp({ perNode: true });
|
|
1694
|
-
var MixedParse = class {
|
|
1695
|
-
constructor(base, nest, input, fragments, ranges) {
|
|
1696
|
-
this.nest = nest;
|
|
1697
|
-
this.input = input;
|
|
1698
|
-
this.fragments = fragments;
|
|
1699
|
-
this.ranges = ranges;
|
|
1700
|
-
this.inner = [];
|
|
1701
|
-
this.innerDone = 0;
|
|
1702
|
-
this.baseTree = null;
|
|
1703
|
-
this.stoppedAt = null;
|
|
1704
|
-
this.baseParse = base;
|
|
1705
|
-
}
|
|
1706
|
-
advance() {
|
|
1707
|
-
if (this.baseParse) {
|
|
1708
|
-
let done = this.baseParse.advance();
|
|
1709
|
-
if (!done) return null;
|
|
1710
|
-
this.baseParse = null;
|
|
1711
|
-
this.baseTree = done;
|
|
1712
|
-
this.startInner();
|
|
1713
|
-
if (this.stoppedAt != null) for (let inner of this.inner) inner.parse.stopAt(this.stoppedAt);
|
|
1714
|
-
}
|
|
1715
|
-
if (this.innerDone == this.inner.length) {
|
|
1716
|
-
let result = this.baseTree;
|
|
1717
|
-
if (this.stoppedAt != null) result = new Tree(result.type, result.children, result.positions, result.length, result.propValues.concat([[stoppedInner, this.stoppedAt]]));
|
|
1718
|
-
return result;
|
|
1719
|
-
}
|
|
1720
|
-
let inner = this.inner[this.innerDone], done = inner.parse.advance();
|
|
1721
|
-
if (done) {
|
|
1722
|
-
this.innerDone++;
|
|
1723
|
-
let props = Object.assign(Object.create(null), inner.target.props);
|
|
1724
|
-
props[NodeProp.mounted.id] = new MountedTree(done, inner.overlay, inner.parser, inner.bracketed);
|
|
1725
|
-
inner.target.props = props;
|
|
1726
|
-
}
|
|
1727
|
-
return null;
|
|
1728
|
-
}
|
|
1729
|
-
get parsedPos() {
|
|
1730
|
-
if (this.baseParse) return 0;
|
|
1731
|
-
let pos = this.input.length;
|
|
1732
|
-
for (let i = this.innerDone; i < this.inner.length; i++) if (this.inner[i].from < pos) pos = Math.min(pos, this.inner[i].parse.parsedPos);
|
|
1733
|
-
return pos;
|
|
1734
|
-
}
|
|
1735
|
-
stopAt(pos) {
|
|
1736
|
-
this.stoppedAt = pos;
|
|
1737
|
-
if (this.baseParse) this.baseParse.stopAt(pos);
|
|
1738
|
-
else for (let i = this.innerDone; i < this.inner.length; i++) this.inner[i].parse.stopAt(pos);
|
|
1739
|
-
}
|
|
1740
|
-
startInner() {
|
|
1741
|
-
let fragmentCursor = new FragmentCursor(this.fragments);
|
|
1742
|
-
let overlay = null;
|
|
1743
|
-
let covered = null;
|
|
1744
|
-
let cursor = new TreeCursor(new TreeNode(this.baseTree, this.ranges[0].from, 0, null), IterMode.IncludeAnonymous | IterMode.IgnoreMounts);
|
|
1745
|
-
scan: for (let nest, isCovered;;) {
|
|
1746
|
-
let enter = true, range;
|
|
1747
|
-
if (this.stoppedAt != null && cursor.from >= this.stoppedAt) enter = false;
|
|
1748
|
-
else if (fragmentCursor.hasNode(cursor)) {
|
|
1749
|
-
if (overlay) {
|
|
1750
|
-
let match = overlay.mounts.find((m) => m.frag.from <= cursor.from && m.frag.to >= cursor.to && m.mount.overlay);
|
|
1751
|
-
if (match) for (let r of match.mount.overlay) {
|
|
1752
|
-
let from = r.from + match.pos, to = r.to + match.pos;
|
|
1753
|
-
if (from >= cursor.from && to <= cursor.to && !overlay.ranges.some((r) => r.from < to && r.to > from)) overlay.ranges.push({
|
|
1754
|
-
from,
|
|
1755
|
-
to
|
|
1756
|
-
});
|
|
1757
|
-
}
|
|
1758
|
-
}
|
|
1759
|
-
enter = false;
|
|
1760
|
-
} else if (covered && (isCovered = checkCover(covered.ranges, cursor.from, cursor.to))) enter = isCovered != 2;
|
|
1761
|
-
else if (!cursor.type.isAnonymous && (nest = this.nest(cursor, this.input)) && (cursor.from < cursor.to || !nest.overlay)) {
|
|
1762
|
-
if (!cursor.tree) {
|
|
1763
|
-
materialize(cursor);
|
|
1764
|
-
if (overlay) overlay.depth++;
|
|
1765
|
-
if (covered) covered.depth++;
|
|
1766
|
-
}
|
|
1767
|
-
let oldMounts = fragmentCursor.findMounts(cursor.from, nest.parser);
|
|
1768
|
-
if (typeof nest.overlay == "function") overlay = new ActiveOverlay(nest.parser, nest.overlay, oldMounts, this.inner.length, cursor.from, !!nest.bracketed, cursor.tree, overlay);
|
|
1769
|
-
else {
|
|
1770
|
-
let ranges = punchRanges(this.ranges, nest.overlay || (cursor.from < cursor.to ? [new Range(cursor.from, cursor.to)] : []));
|
|
1771
|
-
if (ranges.length) checkRanges(ranges);
|
|
1772
|
-
if (ranges.length || !nest.overlay) this.inner.push(new InnerParse(nest.parser, ranges.length ? nest.parser.startParse(this.input, enterFragments(oldMounts, ranges), ranges) : nest.parser.startParse(""), nest.overlay ? nest.overlay.map((r) => new Range(r.from - cursor.from, r.to - cursor.from)) : null, !!nest.bracketed, cursor.tree, ranges.length ? ranges[0].from : cursor.from));
|
|
1773
|
-
if (!nest.overlay) enter = false;
|
|
1774
|
-
else if (ranges.length) covered = {
|
|
1775
|
-
ranges,
|
|
1776
|
-
depth: 0,
|
|
1777
|
-
prev: covered
|
|
1778
|
-
};
|
|
1779
|
-
}
|
|
1780
|
-
} else if (overlay && (range = overlay.predicate(cursor))) {
|
|
1781
|
-
if (range === true) range = new Range(cursor.from, cursor.to);
|
|
1782
|
-
if (range.from < range.to) {
|
|
1783
|
-
let last = overlay.ranges.length - 1;
|
|
1784
|
-
if (last >= 0 && overlay.ranges[last].to == range.from) overlay.ranges[last] = {
|
|
1785
|
-
from: overlay.ranges[last].from,
|
|
1786
|
-
to: range.to
|
|
1787
|
-
};
|
|
1788
|
-
else overlay.ranges.push(range);
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
if (enter && cursor.firstChild()) {
|
|
1792
|
-
if (overlay) overlay.depth++;
|
|
1793
|
-
if (covered) covered.depth++;
|
|
1794
|
-
} else for (;;) {
|
|
1795
|
-
if (cursor.nextSibling()) break;
|
|
1796
|
-
if (!cursor.parent()) break scan;
|
|
1797
|
-
if (overlay && !--overlay.depth) {
|
|
1798
|
-
let ranges = punchRanges(this.ranges, overlay.ranges);
|
|
1799
|
-
if (ranges.length) {
|
|
1800
|
-
checkRanges(ranges);
|
|
1801
|
-
this.inner.splice(overlay.index, 0, new InnerParse(overlay.parser, overlay.parser.startParse(this.input, enterFragments(overlay.mounts, ranges), ranges), overlay.ranges.map((r) => new Range(r.from - overlay.start, r.to - overlay.start)), overlay.bracketed, overlay.target, ranges[0].from));
|
|
1802
|
-
}
|
|
1803
|
-
overlay = overlay.prev;
|
|
1804
|
-
}
|
|
1805
|
-
if (covered && !--covered.depth) covered = covered.prev;
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
};
|
|
1810
|
-
function checkCover(covered, from, to) {
|
|
1811
|
-
for (let range of covered) {
|
|
1812
|
-
if (range.from >= to) break;
|
|
1813
|
-
if (range.to > from) return range.from <= from && range.to >= to ? 2 : 1;
|
|
1814
|
-
}
|
|
1815
|
-
return 0;
|
|
1816
|
-
}
|
|
1817
|
-
function sliceBuf(buf, startI, endI, nodes, positions, off) {
|
|
1818
|
-
if (startI < endI) {
|
|
1819
|
-
let from = buf.buffer[startI + 1];
|
|
1820
|
-
nodes.push(buf.slice(startI, endI, from));
|
|
1821
|
-
positions.push(from - off);
|
|
1822
|
-
}
|
|
1823
|
-
}
|
|
1824
|
-
function materialize(cursor) {
|
|
1825
|
-
let { node } = cursor, stack = [];
|
|
1826
|
-
let buffer = node.context.buffer;
|
|
1827
|
-
do {
|
|
1828
|
-
stack.push(cursor.index);
|
|
1829
|
-
cursor.parent();
|
|
1830
|
-
} while (!cursor.tree);
|
|
1831
|
-
let base = cursor.tree, i = base.children.indexOf(buffer);
|
|
1832
|
-
let buf = base.children[i], b = buf.buffer, newStack = [i];
|
|
1833
|
-
function split(startI, endI, type, innerOffset, length, stackPos) {
|
|
1834
|
-
let targetI = stack[stackPos];
|
|
1835
|
-
let children = [], positions = [];
|
|
1836
|
-
sliceBuf(buf, startI, targetI, children, positions, innerOffset);
|
|
1837
|
-
let from = b[targetI + 1], to = b[targetI + 2];
|
|
1838
|
-
newStack.push(children.length);
|
|
1839
|
-
let child = stackPos ? split(targetI + 4, b[targetI + 3], buf.set.types[b[targetI]], from, to - from, stackPos - 1) : node.toTree();
|
|
1840
|
-
children.push(child);
|
|
1841
|
-
positions.push(from - innerOffset);
|
|
1842
|
-
sliceBuf(buf, b[targetI + 3], endI, children, positions, innerOffset);
|
|
1843
|
-
return new Tree(type, children, positions, length);
|
|
1844
|
-
}
|
|
1845
|
-
base.children[i] = split(0, b.length, NodeType.none, 0, buf.length, stack.length - 1);
|
|
1846
|
-
for (let index of newStack) {
|
|
1847
|
-
let tree = cursor.tree.children[index], pos = cursor.tree.positions[index];
|
|
1848
|
-
cursor.yield(new TreeNode(tree, pos + cursor.from, index, cursor._tree));
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
var StructureCursor = class {
|
|
1852
|
-
constructor(root, offset) {
|
|
1853
|
-
this.offset = offset;
|
|
1854
|
-
this.done = false;
|
|
1855
|
-
this.cursor = root.cursor(IterMode.IncludeAnonymous | IterMode.IgnoreMounts);
|
|
1856
|
-
}
|
|
1857
|
-
moveTo(pos) {
|
|
1858
|
-
let { cursor } = this, p = pos - this.offset;
|
|
1859
|
-
while (!this.done && cursor.from < p) if (cursor.to >= pos && cursor.enter(p, 1, IterMode.IgnoreOverlays | IterMode.ExcludeBuffers));
|
|
1860
|
-
else if (cursor.to <= pos) {
|
|
1861
|
-
if (!cursor.next(false)) this.done = true;
|
|
1862
|
-
} else break;
|
|
1863
|
-
}
|
|
1864
|
-
hasNode(cursor) {
|
|
1865
|
-
this.moveTo(cursor.from);
|
|
1866
|
-
if (!this.done && this.cursor.from + this.offset == cursor.from && this.cursor.tree) for (let tree = this.cursor.tree;;) {
|
|
1867
|
-
if (tree == cursor.tree) return true;
|
|
1868
|
-
if (tree.children.length && tree.positions[0] == 0 && tree.children[0] instanceof Tree) tree = tree.children[0];
|
|
1869
|
-
else break;
|
|
1870
|
-
}
|
|
1871
|
-
return false;
|
|
1872
|
-
}
|
|
1873
|
-
};
|
|
1874
|
-
var FragmentCursor = class {
|
|
1875
|
-
constructor(fragments) {
|
|
1876
|
-
var _a;
|
|
1877
|
-
this.fragments = fragments;
|
|
1878
|
-
this.curTo = 0;
|
|
1879
|
-
this.fragI = 0;
|
|
1880
|
-
if (fragments.length) {
|
|
1881
|
-
let first = this.curFrag = fragments[0];
|
|
1882
|
-
this.curTo = (_a = first.tree.prop(stoppedInner)) !== null && _a !== void 0 ? _a : first.to;
|
|
1883
|
-
this.inner = new StructureCursor(first.tree, -first.offset);
|
|
1884
|
-
} else this.curFrag = this.inner = null;
|
|
1885
|
-
}
|
|
1886
|
-
hasNode(node) {
|
|
1887
|
-
while (this.curFrag && node.from >= this.curTo) this.nextFrag();
|
|
1888
|
-
return this.curFrag && this.curFrag.from <= node.from && this.curTo >= node.to && this.inner.hasNode(node);
|
|
1889
|
-
}
|
|
1890
|
-
nextFrag() {
|
|
1891
|
-
var _a;
|
|
1892
|
-
this.fragI++;
|
|
1893
|
-
if (this.fragI == this.fragments.length) this.curFrag = this.inner = null;
|
|
1894
|
-
else {
|
|
1895
|
-
let frag = this.curFrag = this.fragments[this.fragI];
|
|
1896
|
-
this.curTo = (_a = frag.tree.prop(stoppedInner)) !== null && _a !== void 0 ? _a : frag.to;
|
|
1897
|
-
this.inner = new StructureCursor(frag.tree, -frag.offset);
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
findMounts(pos, parser) {
|
|
1901
|
-
var _a;
|
|
1902
|
-
let result = [];
|
|
1903
|
-
if (this.inner) {
|
|
1904
|
-
this.inner.cursor.moveTo(pos, 1);
|
|
1905
|
-
for (let pos = this.inner.cursor.node; pos; pos = pos.parent) {
|
|
1906
|
-
let mount = (_a = pos.tree) === null || _a === void 0 ? void 0 : _a.prop(NodeProp.mounted);
|
|
1907
|
-
if (mount && mount.parser == parser) for (let i = this.fragI; i < this.fragments.length; i++) {
|
|
1908
|
-
let frag = this.fragments[i];
|
|
1909
|
-
if (frag.from >= pos.to) break;
|
|
1910
|
-
if (frag.tree == this.curFrag.tree) result.push({
|
|
1911
|
-
frag,
|
|
1912
|
-
pos: pos.from - frag.offset,
|
|
1913
|
-
mount
|
|
1914
|
-
});
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
return result;
|
|
1919
|
-
}
|
|
1920
|
-
};
|
|
1921
|
-
function punchRanges(outer, ranges) {
|
|
1922
|
-
let copy = null, current = ranges;
|
|
1923
|
-
for (let i = 1, j = 0; i < outer.length; i++) {
|
|
1924
|
-
let gapFrom = outer[i - 1].to, gapTo = outer[i].from;
|
|
1925
|
-
for (; j < current.length; j++) {
|
|
1926
|
-
let r = current[j];
|
|
1927
|
-
if (r.from >= gapTo) break;
|
|
1928
|
-
if (r.to <= gapFrom) continue;
|
|
1929
|
-
if (!copy) current = copy = ranges.slice();
|
|
1930
|
-
if (r.from < gapFrom) {
|
|
1931
|
-
copy[j] = new Range(r.from, gapFrom);
|
|
1932
|
-
if (r.to > gapTo) copy.splice(j + 1, 0, new Range(gapTo, r.to));
|
|
1933
|
-
} else if (r.to > gapTo) copy[j--] = new Range(gapTo, r.to);
|
|
1934
|
-
else copy.splice(j--, 1);
|
|
1935
|
-
}
|
|
1936
|
-
}
|
|
1937
|
-
return current;
|
|
1938
|
-
}
|
|
1939
|
-
function findCoverChanges(a, b, from, to) {
|
|
1940
|
-
let iA = 0, iB = 0, inA = false, inB = false, pos = -1e9;
|
|
1941
|
-
let result = [];
|
|
1942
|
-
for (;;) {
|
|
1943
|
-
let nextA = iA == a.length ? 1e9 : inA ? a[iA].to : a[iA].from;
|
|
1944
|
-
let nextB = iB == b.length ? 1e9 : inB ? b[iB].to : b[iB].from;
|
|
1945
|
-
if (inA != inB) {
|
|
1946
|
-
let start = Math.max(pos, from), end = Math.min(nextA, nextB, to);
|
|
1947
|
-
if (start < end) result.push(new Range(start, end));
|
|
1948
|
-
}
|
|
1949
|
-
pos = Math.min(nextA, nextB);
|
|
1950
|
-
if (pos == 1e9) break;
|
|
1951
|
-
if (nextA == pos) {
|
|
1952
|
-
if (!inA) inA = true;
|
|
1953
|
-
else {
|
|
1954
|
-
inA = false;
|
|
1955
|
-
iA++;
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
if (nextB == pos) {
|
|
1959
|
-
if (!inB) inB = true;
|
|
1960
|
-
else {
|
|
1961
|
-
inB = false;
|
|
1962
|
-
iB++;
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
}
|
|
1966
|
-
return result;
|
|
1967
|
-
}
|
|
1968
|
-
function enterFragments(mounts, ranges) {
|
|
1969
|
-
let result = [];
|
|
1970
|
-
for (let { pos, mount, frag } of mounts) {
|
|
1971
|
-
let startPos = pos + (mount.overlay ? mount.overlay[0].from : 0), endPos = startPos + mount.tree.length;
|
|
1972
|
-
let from = Math.max(frag.from, startPos), to = Math.min(frag.to, endPos);
|
|
1973
|
-
if (mount.overlay) {
|
|
1974
|
-
let changes = findCoverChanges(ranges, mount.overlay.map((r) => new Range(r.from + pos, r.to + pos)), from, to);
|
|
1975
|
-
for (let i = 0, pos = from;; i++) {
|
|
1976
|
-
let last = i == changes.length, end = last ? to : changes[i].from;
|
|
1977
|
-
if (end > pos) result.push(new TreeFragment(pos, end, mount.tree, -startPos, frag.from >= pos || frag.openStart, frag.to <= end || frag.openEnd));
|
|
1978
|
-
if (last) break;
|
|
1979
|
-
pos = changes[i].to;
|
|
1980
|
-
}
|
|
1981
|
-
} else result.push(new TreeFragment(from, to, mount.tree, -startPos, frag.from >= startPos || frag.openStart, frag.to <= endPos || frag.openEnd));
|
|
1982
|
-
}
|
|
1983
|
-
return result;
|
|
1984
|
-
}
|
|
1985
|
-
// node_modules/@lezer/highlight/dist/index.js
|
|
1986
|
-
var nextTagID = 0;
|
|
1987
|
-
/**
|
|
1988
|
-
Highlighting tags are markers that denote a highlighting category.
|
|
1989
|
-
They are [associated](#highlight.styleTags) with parts of a syntax
|
|
1990
|
-
tree by a language mode, and then mapped to an actual CSS style by
|
|
1991
|
-
a [highlighter](#highlight.Highlighter).
|
|
1992
|
-
|
|
1993
|
-
Because syntax tree node types and highlight styles have to be
|
|
1994
|
-
able to talk the same language, CodeMirror uses a mostly _closed_
|
|
1995
|
-
[vocabulary](#highlight.tags) of syntax tags (as opposed to
|
|
1996
|
-
traditional open string-based systems, which make it hard for
|
|
1997
|
-
highlighting themes to cover all the tokens produced by the
|
|
1998
|
-
various languages).
|
|
1999
|
-
|
|
2000
|
-
It _is_ possible to [define](#highlight.Tag^define) your own
|
|
2001
|
-
highlighting tags for system-internal use (where you control both
|
|
2002
|
-
the language package and the highlighter), but such tags will not
|
|
2003
|
-
be picked up by regular highlighters (though you can derive them
|
|
2004
|
-
from standard tags to allow highlighters to fall back to those).
|
|
2005
|
-
*/
|
|
2006
|
-
var Tag = class Tag {
|
|
2007
|
-
/**
|
|
2008
|
-
@internal
|
|
2009
|
-
*/
|
|
2010
|
-
constructor(name, set, base, modified) {
|
|
2011
|
-
this.name = name;
|
|
2012
|
-
this.set = set;
|
|
2013
|
-
this.base = base;
|
|
2014
|
-
this.modified = modified;
|
|
2015
|
-
/**
|
|
2016
|
-
@internal
|
|
2017
|
-
*/
|
|
2018
|
-
this.id = nextTagID++;
|
|
2019
|
-
}
|
|
2020
|
-
toString() {
|
|
2021
|
-
let { name } = this;
|
|
2022
|
-
for (let mod of this.modified) if (mod.name) name = `${mod.name}(${name})`;
|
|
2023
|
-
return name;
|
|
2024
|
-
}
|
|
2025
|
-
static define(nameOrParent, parent) {
|
|
2026
|
-
let name = typeof nameOrParent == "string" ? nameOrParent : "?";
|
|
2027
|
-
if (nameOrParent instanceof Tag) parent = nameOrParent;
|
|
2028
|
-
if (parent === null || parent === void 0 ? void 0 : parent.base) throw new Error("Can not derive from a modified tag");
|
|
2029
|
-
let tag = new Tag(name, [], null, []);
|
|
2030
|
-
tag.set.push(tag);
|
|
2031
|
-
if (parent) for (let t of parent.set) tag.set.push(t);
|
|
2032
|
-
return tag;
|
|
2033
|
-
}
|
|
2034
|
-
/**
|
|
2035
|
-
Define a tag _modifier_, which is a function that, given a tag,
|
|
2036
|
-
will return a tag that is a subtag of the original. Applying the
|
|
2037
|
-
same modifier to a twice tag will return the same value (`m1(t1)
|
|
2038
|
-
== m1(t1)`) and applying multiple modifiers will, regardless or
|
|
2039
|
-
order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
|
|
2040
|
-
|
|
2041
|
-
When multiple modifiers are applied to a given base tag, each
|
|
2042
|
-
smaller set of modifiers is registered as a parent, so that for
|
|
2043
|
-
example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
|
|
2044
|
-
`m1(m3(t1)`, and so on.
|
|
2045
|
-
*/
|
|
2046
|
-
static defineModifier(name) {
|
|
2047
|
-
let mod = new Modifier(name);
|
|
2048
|
-
return (tag) => {
|
|
2049
|
-
if (tag.modified.indexOf(mod) > -1) return tag;
|
|
2050
|
-
return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));
|
|
2051
|
-
};
|
|
2052
|
-
}
|
|
2053
|
-
};
|
|
2054
|
-
var nextModifierID = 0;
|
|
2055
|
-
var Modifier = class Modifier {
|
|
2056
|
-
constructor(name) {
|
|
2057
|
-
this.name = name;
|
|
2058
|
-
this.instances = [];
|
|
2059
|
-
this.id = nextModifierID++;
|
|
2060
|
-
}
|
|
2061
|
-
static get(base, mods) {
|
|
2062
|
-
if (!mods.length) return base;
|
|
2063
|
-
let exists = mods[0].instances.find((t) => t.base == base && sameArray(mods, t.modified));
|
|
2064
|
-
if (exists) return exists;
|
|
2065
|
-
let set = [], tag = new Tag(base.name, set, base, mods);
|
|
2066
|
-
for (let m of mods) m.instances.push(tag);
|
|
2067
|
-
let configs = powerSet(mods);
|
|
2068
|
-
for (let parent of base.set) if (!parent.modified.length) for (let config of configs) set.push(Modifier.get(parent, config));
|
|
2069
|
-
return tag;
|
|
2070
|
-
}
|
|
2071
|
-
};
|
|
2072
|
-
function sameArray(a, b) {
|
|
2073
|
-
return a.length == b.length && a.every((x, i) => x == b[i]);
|
|
2074
|
-
}
|
|
2075
|
-
function powerSet(array) {
|
|
2076
|
-
let sets = [[]];
|
|
2077
|
-
for (let i = 0; i < array.length; i++) for (let j = 0, e = sets.length; j < e; j++) sets.push(sets[j].concat(array[i]));
|
|
2078
|
-
return sets.sort((a, b) => b.length - a.length);
|
|
2079
|
-
}
|
|
2080
|
-
/**
|
|
2081
|
-
This function is used to add a set of tags to a language syntax
|
|
2082
|
-
via [`NodeSet.extend`](#common.NodeSet.extend) or
|
|
2083
|
-
[`LRParser.configure`](#lr.LRParser.configure).
|
|
2084
|
-
|
|
2085
|
-
The argument object maps node selectors to [highlighting
|
|
2086
|
-
tags](#highlight.Tag) or arrays of tags.
|
|
2087
|
-
|
|
2088
|
-
Node selectors may hold one or more (space-separated) node paths.
|
|
2089
|
-
Such a path can be a [node name](#common.NodeType.name), or
|
|
2090
|
-
multiple node names (or `*` wildcards) separated by slash
|
|
2091
|
-
characters, as in `"Block/Declaration/VariableName"`. Such a path
|
|
2092
|
-
matches the final node but only if its direct parent nodes are the
|
|
2093
|
-
other nodes mentioned. A `*` in such a path matches any parent,
|
|
2094
|
-
but only a single level—wildcards that match multiple parents
|
|
2095
|
-
aren't supported, both for efficiency reasons and because Lezer
|
|
2096
|
-
trees make it rather hard to reason about what they would match.)
|
|
2097
|
-
|
|
2098
|
-
A path can be ended with `/...` to indicate that the tag assigned
|
|
2099
|
-
to the node should also apply to all child nodes, even if they
|
|
2100
|
-
match their own style (by default, only the innermost style is
|
|
2101
|
-
used).
|
|
2102
|
-
|
|
2103
|
-
When a path ends in `!`, as in `Attribute!`, no further matching
|
|
2104
|
-
happens for the node's child nodes, and the entire node gets the
|
|
2105
|
-
given style.
|
|
2106
|
-
|
|
2107
|
-
In this notation, node names that contain `/`, `!`, `*`, or `...`
|
|
2108
|
-
must be quoted as JSON strings.
|
|
2109
|
-
|
|
2110
|
-
For example:
|
|
2111
|
-
|
|
2112
|
-
```javascript
|
|
2113
|
-
parser.configure({props: [
|
|
2114
|
-
styleTags({
|
|
2115
|
-
// Style Number and BigNumber nodes
|
|
2116
|
-
"Number BigNumber": tags.number,
|
|
2117
|
-
// Style Escape nodes whose parent is String
|
|
2118
|
-
"String/Escape": tags.escape,
|
|
2119
|
-
// Style anything inside Attributes nodes
|
|
2120
|
-
"Attributes!": tags.meta,
|
|
2121
|
-
// Add a style to all content inside Italic nodes
|
|
2122
|
-
"Italic/...": tags.emphasis,
|
|
2123
|
-
// Style InvalidString nodes as both `string` and `invalid`
|
|
2124
|
-
"InvalidString": [tags.string, tags.invalid],
|
|
2125
|
-
// Style the node named "/" as punctuation
|
|
2126
|
-
'"/"': tags.punctuation
|
|
2127
|
-
})
|
|
2128
|
-
]})
|
|
2129
|
-
```
|
|
2130
|
-
*/
|
|
2131
|
-
function styleTags(spec) {
|
|
2132
|
-
let byName = Object.create(null);
|
|
2133
|
-
for (let prop in spec) {
|
|
2134
|
-
let tags = spec[prop];
|
|
2135
|
-
if (!Array.isArray(tags)) tags = [tags];
|
|
2136
|
-
for (let part of prop.split(" ")) if (part) {
|
|
2137
|
-
let pieces = [], mode = 2, rest = part;
|
|
2138
|
-
for (let pos = 0;;) {
|
|
2139
|
-
if (rest == "..." && pos > 0 && pos + 3 == part.length) {
|
|
2140
|
-
mode = 1;
|
|
2141
|
-
break;
|
|
2142
|
-
}
|
|
2143
|
-
let m = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(rest);
|
|
2144
|
-
if (!m) throw new RangeError("Invalid path: " + part);
|
|
2145
|
-
pieces.push(m[0] == "*" ? "" : m[0][0] == "\"" ? JSON.parse(m[0]) : m[0]);
|
|
2146
|
-
pos += m[0].length;
|
|
2147
|
-
if (pos == part.length) break;
|
|
2148
|
-
let next = part[pos++];
|
|
2149
|
-
if (pos == part.length && next == "!") {
|
|
2150
|
-
mode = 0;
|
|
2151
|
-
break;
|
|
2152
|
-
}
|
|
2153
|
-
if (next != "/") throw new RangeError("Invalid path: " + part);
|
|
2154
|
-
rest = part.slice(pos);
|
|
2155
|
-
}
|
|
2156
|
-
let last = pieces.length - 1, inner = pieces[last];
|
|
2157
|
-
if (!inner) throw new RangeError("Invalid path: " + part);
|
|
2158
|
-
byName[inner] = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null).sort(byName[inner]);
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
return ruleNodeProp.add(byName);
|
|
2162
|
-
}
|
|
2163
|
-
var ruleNodeProp = new NodeProp({ combine(a, b) {
|
|
2164
|
-
let cur, root, take;
|
|
2165
|
-
while (a || b) {
|
|
2166
|
-
if (!a || b && a.depth <= b.depth) {
|
|
2167
|
-
take = b;
|
|
2168
|
-
b = b.next;
|
|
2169
|
-
} else {
|
|
2170
|
-
take = a;
|
|
2171
|
-
a = a.next;
|
|
2172
|
-
}
|
|
2173
|
-
if (cur && cur.mode == take.mode && !take.context && !cur.context) continue;
|
|
2174
|
-
let copy = new Rule(take.tags, take.mode, take.context);
|
|
2175
|
-
if (cur) cur.next = copy;
|
|
2176
|
-
else root = copy;
|
|
2177
|
-
cur = copy;
|
|
2178
|
-
}
|
|
2179
|
-
return root;
|
|
2180
|
-
} });
|
|
2181
|
-
var Rule = class {
|
|
2182
|
-
constructor(tags, mode, context, next) {
|
|
2183
|
-
this.tags = tags;
|
|
2184
|
-
this.mode = mode;
|
|
2185
|
-
this.context = context;
|
|
2186
|
-
this.next = next;
|
|
2187
|
-
}
|
|
2188
|
-
get opaque() {
|
|
2189
|
-
return this.mode == 0;
|
|
2190
|
-
}
|
|
2191
|
-
get inherit() {
|
|
2192
|
-
return this.mode == 1;
|
|
2193
|
-
}
|
|
2194
|
-
sort(other) {
|
|
2195
|
-
if (!other || other.depth < this.depth) {
|
|
2196
|
-
this.next = other;
|
|
2197
|
-
return this;
|
|
2198
|
-
}
|
|
2199
|
-
other.next = this.sort(other.next);
|
|
2200
|
-
return other;
|
|
2201
|
-
}
|
|
2202
|
-
get depth() {
|
|
2203
|
-
return this.context ? this.context.length : 0;
|
|
2204
|
-
}
|
|
2205
|
-
};
|
|
2206
|
-
Rule.empty = new Rule([], 2, null);
|
|
2207
|
-
/**
|
|
2208
|
-
Define a [highlighter](#highlight.Highlighter) from an array of
|
|
2209
|
-
tag/class pairs. Classes associated with more specific tags will
|
|
2210
|
-
take precedence.
|
|
2211
|
-
*/
|
|
2212
|
-
function tagHighlighter(tags, options) {
|
|
2213
|
-
let map = Object.create(null);
|
|
2214
|
-
for (let style of tags) if (!Array.isArray(style.tag)) map[style.tag.id] = style.class;
|
|
2215
|
-
else for (let tag of style.tag) map[tag.id] = style.class;
|
|
2216
|
-
let { scope, all = null } = options || {};
|
|
2217
|
-
return {
|
|
2218
|
-
style: (tags) => {
|
|
2219
|
-
let cls = all;
|
|
2220
|
-
for (let tag of tags) for (let sub of tag.set) {
|
|
2221
|
-
let tagClass = map[sub.id];
|
|
2222
|
-
if (tagClass) {
|
|
2223
|
-
cls = cls ? cls + " " + tagClass : tagClass;
|
|
2224
|
-
break;
|
|
2225
|
-
}
|
|
2226
|
-
}
|
|
2227
|
-
return cls;
|
|
2228
|
-
},
|
|
2229
|
-
scope
|
|
2230
|
-
};
|
|
2231
|
-
}
|
|
2232
|
-
function highlightTags(highlighters, tags) {
|
|
2233
|
-
let result = null;
|
|
2234
|
-
for (let highlighter of highlighters) {
|
|
2235
|
-
let value = highlighter.style(tags);
|
|
2236
|
-
if (value) result = result ? result + " " + value : value;
|
|
2237
|
-
}
|
|
2238
|
-
return result;
|
|
2239
|
-
}
|
|
2240
|
-
/**
|
|
2241
|
-
Highlight the given [tree](#common.Tree) with the given
|
|
2242
|
-
[highlighter](#highlight.Highlighter). Often, the higher-level
|
|
2243
|
-
[`highlightCode`](#highlight.highlightCode) function is easier to
|
|
2244
|
-
use.
|
|
2245
|
-
*/
|
|
2246
|
-
function highlightTree(tree, highlighter, putStyle, from = 0, to = tree.length) {
|
|
2247
|
-
let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);
|
|
2248
|
-
builder.highlightRange(tree.cursor(), from, to, "", builder.highlighters);
|
|
2249
|
-
builder.flush(to);
|
|
2250
|
-
}
|
|
2251
|
-
var HighlightBuilder = class {
|
|
2252
|
-
constructor(at, highlighters, span) {
|
|
2253
|
-
this.at = at;
|
|
2254
|
-
this.highlighters = highlighters;
|
|
2255
|
-
this.span = span;
|
|
2256
|
-
this.class = "";
|
|
2257
|
-
}
|
|
2258
|
-
startSpan(at, cls) {
|
|
2259
|
-
if (cls != this.class) {
|
|
2260
|
-
this.flush(at);
|
|
2261
|
-
if (at > this.at) this.at = at;
|
|
2262
|
-
this.class = cls;
|
|
2263
|
-
}
|
|
2264
|
-
}
|
|
2265
|
-
flush(to) {
|
|
2266
|
-
if (to > this.at && this.class) this.span(this.at, to, this.class);
|
|
2267
|
-
}
|
|
2268
|
-
highlightRange(cursor, from, to, inheritedClass, highlighters) {
|
|
2269
|
-
let { type, from: start, to: end } = cursor;
|
|
2270
|
-
if (start >= to || end <= from) return;
|
|
2271
|
-
if (type.isTop) highlighters = this.highlighters.filter((h) => !h.scope || h.scope(type));
|
|
2272
|
-
let cls = inheritedClass;
|
|
2273
|
-
let rule = getStyleTags(cursor) || Rule.empty;
|
|
2274
|
-
let tagCls = highlightTags(highlighters, rule.tags);
|
|
2275
|
-
if (tagCls) {
|
|
2276
|
-
if (cls) cls += " ";
|
|
2277
|
-
cls += tagCls;
|
|
2278
|
-
if (rule.mode == 1) inheritedClass += (inheritedClass ? " " : "") + tagCls;
|
|
2279
|
-
}
|
|
2280
|
-
this.startSpan(Math.max(from, start), cls);
|
|
2281
|
-
if (rule.opaque) return;
|
|
2282
|
-
let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted);
|
|
2283
|
-
if (mounted && mounted.overlay) {
|
|
2284
|
-
let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);
|
|
2285
|
-
let innerHighlighters = this.highlighters.filter((h) => !h.scope || h.scope(mounted.tree.type));
|
|
2286
|
-
let hasChild = cursor.firstChild();
|
|
2287
|
-
for (let i = 0, pos = start;; i++) {
|
|
2288
|
-
let next = i < mounted.overlay.length ? mounted.overlay[i] : null;
|
|
2289
|
-
let nextPos = next ? next.from + start : end;
|
|
2290
|
-
let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);
|
|
2291
|
-
if (rangeFrom < rangeTo && hasChild) while (cursor.from < rangeTo) {
|
|
2292
|
-
this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);
|
|
2293
|
-
this.startSpan(Math.min(rangeTo, cursor.to), cls);
|
|
2294
|
-
if (cursor.to >= nextPos || !cursor.nextSibling()) break;
|
|
2295
|
-
}
|
|
2296
|
-
if (!next || nextPos > to) break;
|
|
2297
|
-
pos = next.to + start;
|
|
2298
|
-
if (pos > from) {
|
|
2299
|
-
this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), "", innerHighlighters);
|
|
2300
|
-
this.startSpan(Math.min(to, pos), cls);
|
|
2301
|
-
}
|
|
2302
|
-
}
|
|
2303
|
-
if (hasChild) cursor.parent();
|
|
2304
|
-
} else if (cursor.firstChild()) {
|
|
2305
|
-
if (mounted) inheritedClass = "";
|
|
2306
|
-
do {
|
|
2307
|
-
if (cursor.to <= from) continue;
|
|
2308
|
-
if (cursor.from >= to) break;
|
|
2309
|
-
this.highlightRange(cursor, from, to, inheritedClass, highlighters);
|
|
2310
|
-
this.startSpan(Math.min(to, cursor.to), cls);
|
|
2311
|
-
} while (cursor.nextSibling());
|
|
2312
|
-
cursor.parent();
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
};
|
|
2316
|
-
/**
|
|
2317
|
-
Match a syntax node's [highlight rules](#highlight.styleTags). If
|
|
2318
|
-
there's a match, return its set of tags, and whether it is
|
|
2319
|
-
opaque (uses a `!`) or applies to all child nodes (`/...`).
|
|
2320
|
-
*/
|
|
2321
|
-
function getStyleTags(node) {
|
|
2322
|
-
let rule = node.type.prop(ruleNodeProp);
|
|
2323
|
-
while (rule && rule.context && !node.matchContext(rule.context)) rule = rule.next;
|
|
2324
|
-
return rule || null;
|
|
2325
|
-
}
|
|
2326
|
-
var t = Tag.define;
|
|
2327
|
-
var comment = t();
|
|
2328
|
-
var name = t();
|
|
2329
|
-
var typeName = t(name);
|
|
2330
|
-
var propertyName = t(name);
|
|
2331
|
-
var literal = t();
|
|
2332
|
-
var string = t(literal);
|
|
2333
|
-
var number = t(literal);
|
|
2334
|
-
var content = t();
|
|
2335
|
-
var heading = t(content);
|
|
2336
|
-
var keyword = t();
|
|
2337
|
-
var operator = t();
|
|
2338
|
-
var punctuation = t();
|
|
2339
|
-
var bracket = t(punctuation);
|
|
2340
|
-
var meta = t();
|
|
2341
|
-
/**
|
|
2342
|
-
The default set of highlighting [tags](#highlight.Tag).
|
|
2343
|
-
|
|
2344
|
-
This collection is heavily biased towards programming languages,
|
|
2345
|
-
and necessarily incomplete. A full ontology of syntactic
|
|
2346
|
-
constructs would fill a stack of books, and be impractical to
|
|
2347
|
-
write themes for. So try to make do with this set. If all else
|
|
2348
|
-
fails, [open an
|
|
2349
|
-
issue](https://code.haverbeke.berlin/codemirror/dev/issues) to propose a
|
|
2350
|
-
new tag, or [define](#highlight.Tag^define) a local custom tag for
|
|
2351
|
-
your use case.
|
|
2352
|
-
|
|
2353
|
-
Note that it is not obligatory to always attach the most specific
|
|
2354
|
-
tag possible to an element—if your grammar can't easily
|
|
2355
|
-
distinguish a certain type of element (such as a local variable),
|
|
2356
|
-
it is okay to style it as its more general variant (a variable).
|
|
2357
|
-
|
|
2358
|
-
For tags that extend some parent tag, the documentation links to
|
|
2359
|
-
the parent.
|
|
2360
|
-
*/
|
|
2361
|
-
var tags = {
|
|
2362
|
-
/**
|
|
2363
|
-
A comment.
|
|
2364
|
-
*/
|
|
2365
|
-
comment,
|
|
2366
|
-
/**
|
|
2367
|
-
A line [comment](#highlight.tags.comment).
|
|
2368
|
-
*/
|
|
2369
|
-
lineComment: t(comment),
|
|
2370
|
-
/**
|
|
2371
|
-
A block [comment](#highlight.tags.comment).
|
|
2372
|
-
*/
|
|
2373
|
-
blockComment: t(comment),
|
|
2374
|
-
/**
|
|
2375
|
-
A documentation [comment](#highlight.tags.comment).
|
|
2376
|
-
*/
|
|
2377
|
-
docComment: t(comment),
|
|
2378
|
-
/**
|
|
2379
|
-
Any kind of identifier.
|
|
2380
|
-
*/
|
|
2381
|
-
name,
|
|
2382
|
-
/**
|
|
2383
|
-
The [name](#highlight.tags.name) of a variable.
|
|
2384
|
-
*/
|
|
2385
|
-
variableName: t(name),
|
|
2386
|
-
/**
|
|
2387
|
-
A type [name](#highlight.tags.name).
|
|
2388
|
-
*/
|
|
2389
|
-
typeName,
|
|
2390
|
-
/**
|
|
2391
|
-
A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
|
|
2392
|
-
*/
|
|
2393
|
-
tagName: t(typeName),
|
|
2394
|
-
/**
|
|
2395
|
-
A property or field [name](#highlight.tags.name).
|
|
2396
|
-
*/
|
|
2397
|
-
propertyName,
|
|
2398
|
-
/**
|
|
2399
|
-
An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
|
|
2400
|
-
*/
|
|
2401
|
-
attributeName: t(propertyName),
|
|
2402
|
-
/**
|
|
2403
|
-
The [name](#highlight.tags.name) of a class.
|
|
2404
|
-
*/
|
|
2405
|
-
className: t(name),
|
|
2406
|
-
/**
|
|
2407
|
-
A label [name](#highlight.tags.name).
|
|
2408
|
-
*/
|
|
2409
|
-
labelName: t(name),
|
|
2410
|
-
/**
|
|
2411
|
-
A namespace [name](#highlight.tags.name).
|
|
2412
|
-
*/
|
|
2413
|
-
namespace: t(name),
|
|
2414
|
-
/**
|
|
2415
|
-
The [name](#highlight.tags.name) of a macro.
|
|
2416
|
-
*/
|
|
2417
|
-
macroName: t(name),
|
|
2418
|
-
/**
|
|
2419
|
-
A literal value.
|
|
2420
|
-
*/
|
|
2421
|
-
literal,
|
|
2422
|
-
/**
|
|
2423
|
-
A string [literal](#highlight.tags.literal).
|
|
2424
|
-
*/
|
|
2425
|
-
string,
|
|
2426
|
-
/**
|
|
2427
|
-
A documentation [string](#highlight.tags.string).
|
|
2428
|
-
*/
|
|
2429
|
-
docString: t(string),
|
|
2430
|
-
/**
|
|
2431
|
-
A character literal (subtag of [string](#highlight.tags.string)).
|
|
2432
|
-
*/
|
|
2433
|
-
character: t(string),
|
|
2434
|
-
/**
|
|
2435
|
-
An attribute value (subtag of [string](#highlight.tags.string)).
|
|
2436
|
-
*/
|
|
2437
|
-
attributeValue: t(string),
|
|
2438
|
-
/**
|
|
2439
|
-
A number [literal](#highlight.tags.literal).
|
|
2440
|
-
*/
|
|
2441
|
-
number,
|
|
2442
|
-
/**
|
|
2443
|
-
An integer [number](#highlight.tags.number) literal.
|
|
2444
|
-
*/
|
|
2445
|
-
integer: t(number),
|
|
2446
|
-
/**
|
|
2447
|
-
A floating-point [number](#highlight.tags.number) literal.
|
|
2448
|
-
*/
|
|
2449
|
-
float: t(number),
|
|
2450
|
-
/**
|
|
2451
|
-
A boolean [literal](#highlight.tags.literal).
|
|
2452
|
-
*/
|
|
2453
|
-
bool: t(literal),
|
|
2454
|
-
/**
|
|
2455
|
-
Regular expression [literal](#highlight.tags.literal).
|
|
2456
|
-
*/
|
|
2457
|
-
regexp: t(literal),
|
|
2458
|
-
/**
|
|
2459
|
-
An escape [literal](#highlight.tags.literal), for example a
|
|
2460
|
-
backslash escape in a string.
|
|
2461
|
-
*/
|
|
2462
|
-
escape: t(literal),
|
|
2463
|
-
/**
|
|
2464
|
-
A color [literal](#highlight.tags.literal).
|
|
2465
|
-
*/
|
|
2466
|
-
color: t(literal),
|
|
2467
|
-
/**
|
|
2468
|
-
A URL [literal](#highlight.tags.literal).
|
|
2469
|
-
*/
|
|
2470
|
-
url: t(literal),
|
|
2471
|
-
/**
|
|
2472
|
-
A language keyword.
|
|
2473
|
-
*/
|
|
2474
|
-
keyword,
|
|
2475
|
-
/**
|
|
2476
|
-
The [keyword](#highlight.tags.keyword) for the self or this
|
|
2477
|
-
object.
|
|
2478
|
-
*/
|
|
2479
|
-
self: t(keyword),
|
|
2480
|
-
/**
|
|
2481
|
-
The [keyword](#highlight.tags.keyword) for null.
|
|
2482
|
-
*/
|
|
2483
|
-
null: t(keyword),
|
|
2484
|
-
/**
|
|
2485
|
-
A [keyword](#highlight.tags.keyword) denoting some atomic value.
|
|
2486
|
-
*/
|
|
2487
|
-
atom: t(keyword),
|
|
2488
|
-
/**
|
|
2489
|
-
A [keyword](#highlight.tags.keyword) that represents a unit.
|
|
2490
|
-
*/
|
|
2491
|
-
unit: t(keyword),
|
|
2492
|
-
/**
|
|
2493
|
-
A modifier [keyword](#highlight.tags.keyword).
|
|
2494
|
-
*/
|
|
2495
|
-
modifier: t(keyword),
|
|
2496
|
-
/**
|
|
2497
|
-
A [keyword](#highlight.tags.keyword) that acts as an operator.
|
|
2498
|
-
*/
|
|
2499
|
-
operatorKeyword: t(keyword),
|
|
2500
|
-
/**
|
|
2501
|
-
A control-flow related [keyword](#highlight.tags.keyword).
|
|
2502
|
-
*/
|
|
2503
|
-
controlKeyword: t(keyword),
|
|
2504
|
-
/**
|
|
2505
|
-
A [keyword](#highlight.tags.keyword) that defines something.
|
|
2506
|
-
*/
|
|
2507
|
-
definitionKeyword: t(keyword),
|
|
2508
|
-
/**
|
|
2509
|
-
A [keyword](#highlight.tags.keyword) related to defining or
|
|
2510
|
-
interfacing with modules.
|
|
2511
|
-
*/
|
|
2512
|
-
moduleKeyword: t(keyword),
|
|
2513
|
-
/**
|
|
2514
|
-
An operator.
|
|
2515
|
-
*/
|
|
2516
|
-
operator,
|
|
2517
|
-
/**
|
|
2518
|
-
An [operator](#highlight.tags.operator) that dereferences something.
|
|
2519
|
-
*/
|
|
2520
|
-
derefOperator: t(operator),
|
|
2521
|
-
/**
|
|
2522
|
-
Arithmetic-related [operator](#highlight.tags.operator).
|
|
2523
|
-
*/
|
|
2524
|
-
arithmeticOperator: t(operator),
|
|
2525
|
-
/**
|
|
2526
|
-
Logical [operator](#highlight.tags.operator).
|
|
2527
|
-
*/
|
|
2528
|
-
logicOperator: t(operator),
|
|
2529
|
-
/**
|
|
2530
|
-
Bit [operator](#highlight.tags.operator).
|
|
2531
|
-
*/
|
|
2532
|
-
bitwiseOperator: t(operator),
|
|
2533
|
-
/**
|
|
2534
|
-
Comparison [operator](#highlight.tags.operator).
|
|
2535
|
-
*/
|
|
2536
|
-
compareOperator: t(operator),
|
|
2537
|
-
/**
|
|
2538
|
-
[Operator](#highlight.tags.operator) that updates its operand.
|
|
2539
|
-
*/
|
|
2540
|
-
updateOperator: t(operator),
|
|
2541
|
-
/**
|
|
2542
|
-
[Operator](#highlight.tags.operator) that defines something.
|
|
2543
|
-
*/
|
|
2544
|
-
definitionOperator: t(operator),
|
|
2545
|
-
/**
|
|
2546
|
-
Type-related [operator](#highlight.tags.operator).
|
|
2547
|
-
*/
|
|
2548
|
-
typeOperator: t(operator),
|
|
2549
|
-
/**
|
|
2550
|
-
Control-flow [operator](#highlight.tags.operator).
|
|
2551
|
-
*/
|
|
2552
|
-
controlOperator: t(operator),
|
|
2553
|
-
/**
|
|
2554
|
-
Program or markup punctuation.
|
|
2555
|
-
*/
|
|
2556
|
-
punctuation,
|
|
2557
|
-
/**
|
|
2558
|
-
[Punctuation](#highlight.tags.punctuation) that separates
|
|
2559
|
-
things.
|
|
2560
|
-
*/
|
|
2561
|
-
separator: t(punctuation),
|
|
2562
|
-
/**
|
|
2563
|
-
Bracket-style [punctuation](#highlight.tags.punctuation).
|
|
2564
|
-
*/
|
|
2565
|
-
bracket,
|
|
2566
|
-
/**
|
|
2567
|
-
Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
|
|
2568
|
-
tokens).
|
|
2569
|
-
*/
|
|
2570
|
-
angleBracket: t(bracket),
|
|
2571
|
-
/**
|
|
2572
|
-
Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
|
|
2573
|
-
tokens).
|
|
2574
|
-
*/
|
|
2575
|
-
squareBracket: t(bracket),
|
|
2576
|
-
/**
|
|
2577
|
-
Parentheses (usually `(` and `)` tokens). Subtag of
|
|
2578
|
-
[bracket](#highlight.tags.bracket).
|
|
2579
|
-
*/
|
|
2580
|
-
paren: t(bracket),
|
|
2581
|
-
/**
|
|
2582
|
-
Braces (usually `{` and `}` tokens). Subtag of
|
|
2583
|
-
[bracket](#highlight.tags.bracket).
|
|
2584
|
-
*/
|
|
2585
|
-
brace: t(bracket),
|
|
2586
|
-
/**
|
|
2587
|
-
Content, for example plain text in XML or markup documents.
|
|
2588
|
-
*/
|
|
2589
|
-
content,
|
|
2590
|
-
/**
|
|
2591
|
-
[Content](#highlight.tags.content) that represents a heading.
|
|
2592
|
-
*/
|
|
2593
|
-
heading,
|
|
2594
|
-
/**
|
|
2595
|
-
A level 1 [heading](#highlight.tags.heading).
|
|
2596
|
-
*/
|
|
2597
|
-
heading1: t(heading),
|
|
2598
|
-
/**
|
|
2599
|
-
A level 2 [heading](#highlight.tags.heading).
|
|
2600
|
-
*/
|
|
2601
|
-
heading2: t(heading),
|
|
2602
|
-
/**
|
|
2603
|
-
A level 3 [heading](#highlight.tags.heading).
|
|
2604
|
-
*/
|
|
2605
|
-
heading3: t(heading),
|
|
2606
|
-
/**
|
|
2607
|
-
A level 4 [heading](#highlight.tags.heading).
|
|
2608
|
-
*/
|
|
2609
|
-
heading4: t(heading),
|
|
2610
|
-
/**
|
|
2611
|
-
A level 5 [heading](#highlight.tags.heading).
|
|
2612
|
-
*/
|
|
2613
|
-
heading5: t(heading),
|
|
2614
|
-
/**
|
|
2615
|
-
A level 6 [heading](#highlight.tags.heading).
|
|
2616
|
-
*/
|
|
2617
|
-
heading6: t(heading),
|
|
2618
|
-
/**
|
|
2619
|
-
A prose [content](#highlight.tags.content) separator (such as a horizontal rule).
|
|
2620
|
-
*/
|
|
2621
|
-
contentSeparator: t(content),
|
|
2622
|
-
/**
|
|
2623
|
-
[Content](#highlight.tags.content) that represents a list.
|
|
2624
|
-
*/
|
|
2625
|
-
list: t(content),
|
|
2626
|
-
/**
|
|
2627
|
-
[Content](#highlight.tags.content) that represents a quote.
|
|
2628
|
-
*/
|
|
2629
|
-
quote: t(content),
|
|
2630
|
-
/**
|
|
2631
|
-
[Content](#highlight.tags.content) that is emphasized.
|
|
2632
|
-
*/
|
|
2633
|
-
emphasis: t(content),
|
|
2634
|
-
/**
|
|
2635
|
-
[Content](#highlight.tags.content) that is styled strong.
|
|
2636
|
-
*/
|
|
2637
|
-
strong: t(content),
|
|
2638
|
-
/**
|
|
2639
|
-
[Content](#highlight.tags.content) that is part of a link.
|
|
2640
|
-
*/
|
|
2641
|
-
link: t(content),
|
|
2642
|
-
/**
|
|
2643
|
-
[Content](#highlight.tags.content) that is styled as code or
|
|
2644
|
-
monospace.
|
|
2645
|
-
*/
|
|
2646
|
-
monospace: t(content),
|
|
2647
|
-
/**
|
|
2648
|
-
[Content](#highlight.tags.content) that has a strike-through
|
|
2649
|
-
style.
|
|
2650
|
-
*/
|
|
2651
|
-
strikethrough: t(content),
|
|
2652
|
-
/**
|
|
2653
|
-
Inserted text in a change-tracking format.
|
|
2654
|
-
*/
|
|
2655
|
-
inserted: t(),
|
|
2656
|
-
/**
|
|
2657
|
-
Deleted text.
|
|
2658
|
-
*/
|
|
2659
|
-
deleted: t(),
|
|
2660
|
-
/**
|
|
2661
|
-
Changed text.
|
|
2662
|
-
*/
|
|
2663
|
-
changed: t(),
|
|
2664
|
-
/**
|
|
2665
|
-
An invalid or unsyntactic element.
|
|
2666
|
-
*/
|
|
2667
|
-
invalid: t(),
|
|
2668
|
-
/**
|
|
2669
|
-
Metadata or meta-instruction.
|
|
2670
|
-
*/
|
|
2671
|
-
meta,
|
|
2672
|
-
/**
|
|
2673
|
-
[Metadata](#highlight.tags.meta) that applies to the entire
|
|
2674
|
-
document.
|
|
2675
|
-
*/
|
|
2676
|
-
documentMeta: t(meta),
|
|
2677
|
-
/**
|
|
2678
|
-
[Metadata](#highlight.tags.meta) that annotates or adds
|
|
2679
|
-
attributes to a given syntactic element.
|
|
2680
|
-
*/
|
|
2681
|
-
annotation: t(meta),
|
|
2682
|
-
/**
|
|
2683
|
-
Processing instruction or preprocessor directive. Subtag of
|
|
2684
|
-
[meta](#highlight.tags.meta).
|
|
2685
|
-
*/
|
|
2686
|
-
processingInstruction: t(meta),
|
|
2687
|
-
/**
|
|
2688
|
-
[Modifier](#highlight.Tag^defineModifier) that indicates that a
|
|
2689
|
-
given element is being defined. Expected to be used with the
|
|
2690
|
-
various [name](#highlight.tags.name) tags.
|
|
2691
|
-
*/
|
|
2692
|
-
definition: Tag.defineModifier("definition"),
|
|
2693
|
-
/**
|
|
2694
|
-
[Modifier](#highlight.Tag^defineModifier) that indicates that
|
|
2695
|
-
something is constant. Mostly expected to be used with
|
|
2696
|
-
[variable names](#highlight.tags.variableName).
|
|
2697
|
-
*/
|
|
2698
|
-
constant: Tag.defineModifier("constant"),
|
|
2699
|
-
/**
|
|
2700
|
-
[Modifier](#highlight.Tag^defineModifier) used to indicate that
|
|
2701
|
-
a [variable](#highlight.tags.variableName) or [property
|
|
2702
|
-
name](#highlight.tags.propertyName) is being called or defined
|
|
2703
|
-
as a function.
|
|
2704
|
-
*/
|
|
2705
|
-
function: Tag.defineModifier("function"),
|
|
2706
|
-
/**
|
|
2707
|
-
[Modifier](#highlight.Tag^defineModifier) that can be applied to
|
|
2708
|
-
[names](#highlight.tags.name) to indicate that they belong to
|
|
2709
|
-
the language's standard environment.
|
|
2710
|
-
*/
|
|
2711
|
-
standard: Tag.defineModifier("standard"),
|
|
2712
|
-
/**
|
|
2713
|
-
[Modifier](#highlight.Tag^defineModifier) that indicates a given
|
|
2714
|
-
[names](#highlight.tags.name) is local to some scope.
|
|
2715
|
-
*/
|
|
2716
|
-
local: Tag.defineModifier("local"),
|
|
2717
|
-
/**
|
|
2718
|
-
A generic variant [modifier](#highlight.Tag^defineModifier) that
|
|
2719
|
-
can be used to tag language-specific alternative variants of
|
|
2720
|
-
some common tag. It is recommended for themes to define special
|
|
2721
|
-
forms of at least the [string](#highlight.tags.string) and
|
|
2722
|
-
[variable name](#highlight.tags.variableName) tags, since those
|
|
2723
|
-
come up a lot.
|
|
2724
|
-
*/
|
|
2725
|
-
special: Tag.defineModifier("special")
|
|
2726
|
-
};
|
|
2727
|
-
for (let name in tags) {
|
|
2728
|
-
let val = tags[name];
|
|
2729
|
-
if (val instanceof Tag) val.name = name;
|
|
2730
|
-
}
|
|
2731
|
-
tagHighlighter([
|
|
2732
|
-
{
|
|
2733
|
-
tag: tags.link,
|
|
2734
|
-
class: "tok-link"
|
|
2735
|
-
},
|
|
2736
|
-
{
|
|
2737
|
-
tag: tags.heading,
|
|
2738
|
-
class: "tok-heading"
|
|
2739
|
-
},
|
|
2740
|
-
{
|
|
2741
|
-
tag: tags.emphasis,
|
|
2742
|
-
class: "tok-emphasis"
|
|
2743
|
-
},
|
|
2744
|
-
{
|
|
2745
|
-
tag: tags.strong,
|
|
2746
|
-
class: "tok-strong"
|
|
2747
|
-
},
|
|
2748
|
-
{
|
|
2749
|
-
tag: tags.keyword,
|
|
2750
|
-
class: "tok-keyword"
|
|
2751
|
-
},
|
|
2752
|
-
{
|
|
2753
|
-
tag: tags.atom,
|
|
2754
|
-
class: "tok-atom"
|
|
2755
|
-
},
|
|
2756
|
-
{
|
|
2757
|
-
tag: tags.bool,
|
|
2758
|
-
class: "tok-bool"
|
|
2759
|
-
},
|
|
2760
|
-
{
|
|
2761
|
-
tag: tags.url,
|
|
2762
|
-
class: "tok-url"
|
|
2763
|
-
},
|
|
2764
|
-
{
|
|
2765
|
-
tag: tags.labelName,
|
|
2766
|
-
class: "tok-labelName"
|
|
2767
|
-
},
|
|
2768
|
-
{
|
|
2769
|
-
tag: tags.inserted,
|
|
2770
|
-
class: "tok-inserted"
|
|
2771
|
-
},
|
|
2772
|
-
{
|
|
2773
|
-
tag: tags.deleted,
|
|
2774
|
-
class: "tok-deleted"
|
|
2775
|
-
},
|
|
2776
|
-
{
|
|
2777
|
-
tag: tags.literal,
|
|
2778
|
-
class: "tok-literal"
|
|
2779
|
-
},
|
|
2780
|
-
{
|
|
2781
|
-
tag: tags.string,
|
|
2782
|
-
class: "tok-string"
|
|
2783
|
-
},
|
|
2784
|
-
{
|
|
2785
|
-
tag: tags.number,
|
|
2786
|
-
class: "tok-number"
|
|
2787
|
-
},
|
|
2788
|
-
{
|
|
2789
|
-
tag: [
|
|
2790
|
-
tags.regexp,
|
|
2791
|
-
tags.escape,
|
|
2792
|
-
tags.special(tags.string)
|
|
2793
|
-
],
|
|
2794
|
-
class: "tok-string2"
|
|
2795
|
-
},
|
|
2796
|
-
{
|
|
2797
|
-
tag: tags.variableName,
|
|
2798
|
-
class: "tok-variableName"
|
|
2799
|
-
},
|
|
2800
|
-
{
|
|
2801
|
-
tag: tags.local(tags.variableName),
|
|
2802
|
-
class: "tok-variableName tok-local"
|
|
2803
|
-
},
|
|
2804
|
-
{
|
|
2805
|
-
tag: tags.definition(tags.variableName),
|
|
2806
|
-
class: "tok-variableName tok-definition"
|
|
2807
|
-
},
|
|
2808
|
-
{
|
|
2809
|
-
tag: tags.special(tags.variableName),
|
|
2810
|
-
class: "tok-variableName2"
|
|
2811
|
-
},
|
|
2812
|
-
{
|
|
2813
|
-
tag: tags.definition(tags.propertyName),
|
|
2814
|
-
class: "tok-propertyName tok-definition"
|
|
2815
|
-
},
|
|
2816
|
-
{
|
|
2817
|
-
tag: tags.typeName,
|
|
2818
|
-
class: "tok-typeName"
|
|
2819
|
-
},
|
|
2820
|
-
{
|
|
2821
|
-
tag: tags.namespace,
|
|
2822
|
-
class: "tok-namespace"
|
|
2823
|
-
},
|
|
2824
|
-
{
|
|
2825
|
-
tag: tags.className,
|
|
2826
|
-
class: "tok-className"
|
|
2827
|
-
},
|
|
2828
|
-
{
|
|
2829
|
-
tag: tags.macroName,
|
|
2830
|
-
class: "tok-macroName"
|
|
2831
|
-
},
|
|
2832
|
-
{
|
|
2833
|
-
tag: tags.propertyName,
|
|
2834
|
-
class: "tok-propertyName"
|
|
2835
|
-
},
|
|
2836
|
-
{
|
|
2837
|
-
tag: tags.operator,
|
|
2838
|
-
class: "tok-operator"
|
|
2839
|
-
},
|
|
2840
|
-
{
|
|
2841
|
-
tag: tags.comment,
|
|
2842
|
-
class: "tok-comment"
|
|
2843
|
-
},
|
|
2844
|
-
{
|
|
2845
|
-
tag: tags.meta,
|
|
2846
|
-
class: "tok-meta"
|
|
2847
|
-
},
|
|
2848
|
-
{
|
|
2849
|
-
tag: tags.invalid,
|
|
2850
|
-
class: "tok-invalid"
|
|
2851
|
-
},
|
|
2852
|
-
{
|
|
2853
|
-
tag: tags.punctuation,
|
|
2854
|
-
class: "tok-punctuation"
|
|
2855
|
-
}
|
|
2856
|
-
]);
|
|
2857
|
-
export { tags as a, NodeProp as c, NodeWeakMap as d, Parser as f, StyleModule as g, parseMixed as h, tagHighlighter as i, NodeSet as l, TreeFragment as m, highlightTree as n, DefaultBufferLength as o, Tree as p, styleTags as r, IterMode as s, Tag as t, NodeType as u };
|