snice 7.8.0 → 7.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/adapters/react/SniceProvider.js +1 -1
- package/adapters/react/SniceRouter.js +1 -1
- package/adapters/react/matchRoute.js +1 -1
- package/adapters/react/table.d.ts +1 -0
- package/adapters/react/table.d.ts.map +1 -1
- package/adapters/react/table.js +1 -1
- package/adapters/react/table.js.map +1 -1
- package/adapters/react/table.tsx +2 -1
- package/adapters/react/useRequestHandler.js +1 -1
- package/bin/analyzer-contracts.js +17 -1
- package/custom-elements.json +57 -3
- package/dist/cdn/accordion/snice-accordion.js +1 -1
- package/dist/cdn/action-bar/snice-action-bar.js +1 -1
- package/dist/cdn/activity-feed/snice-activity-feed.js +1 -1
- package/dist/cdn/alert/snice-alert.js +1 -1
- package/dist/cdn/app-tiles/snice-app-tiles.js +1 -1
- package/dist/cdn/approval-flow/snice-approval-flow.js +1 -1
- package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
- package/dist/cdn/availability/snice-availability.js +1 -1
- package/dist/cdn/avatar/snice-avatar.js +1 -1
- package/dist/cdn/avatar-group/snice-avatar-group.js +1 -1
- package/dist/cdn/badge/snice-badge.js +1 -1
- package/dist/cdn/banner/snice-banner.js +1 -1
- package/dist/cdn/binpack/snice-binpack.js +1 -1
- package/dist/cdn/book/snice-book.js +1 -1
- package/dist/cdn/booking/snice-booking.js +1 -1
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +1 -1
- package/dist/cdn/button/snice-button.js +1 -1
- package/dist/cdn/calendar/README.md +2 -2
- package/dist/cdn/calendar/snice-calendar.js +537 -44
- package/dist/cdn/calendar/snice-calendar.js.map +1 -1
- package/dist/cdn/calendar/snice-calendar.min.js +2 -2
- package/dist/cdn/calendar/snice-calendar.min.js.map +1 -1
- package/dist/cdn/camera/snice-camera.js +1 -1
- package/dist/cdn/camera-annotate/snice-camera-annotate.js +1 -1
- package/dist/cdn/candlestick/snice-candlestick.js +1 -1
- package/dist/cdn/card/snice-card.js +1 -1
- package/dist/cdn/carousel/snice-carousel.js +1 -1
- package/dist/cdn/cart/snice-cart.js +1 -1
- package/dist/cdn/chart/snice-chart.js +1 -1
- package/dist/cdn/chat/snice-chat.js +1 -1
- package/dist/cdn/checkbox/snice-checkbox.js +1 -1
- package/dist/cdn/chip/snice-chip.js +1 -1
- package/dist/cdn/code-block/README.md +2 -2
- package/dist/cdn/code-block/snice-code-block.js +177 -167
- package/dist/cdn/code-block/snice-code-block.js.map +1 -1
- package/dist/cdn/code-block/snice-code-block.min.js +2 -2
- package/dist/cdn/code-block/snice-code-block.min.js.map +1 -1
- package/dist/cdn/color-display/snice-color-display.js +1 -1
- package/dist/cdn/color-picker/snice-color-picker.js +1 -1
- package/dist/cdn/command-palette/README.md +1 -1
- package/dist/cdn/command-palette/snice-command-palette.js +2 -2
- package/dist/cdn/command-palette/snice-command-palette.js.map +1 -1
- package/dist/cdn/command-palette/snice-command-palette.min.js +1 -1
- package/dist/cdn/command-palette/snice-command-palette.min.js.map +1 -1
- package/dist/cdn/comments/snice-comments.js +1 -1
- package/dist/cdn/countdown/snice-countdown.js +1 -1
- package/dist/cdn/cropper/snice-cropper.js +1 -1
- package/dist/cdn/data-card/snice-data-card.js +1 -1
- package/dist/cdn/date-picker/snice-date-picker.js +1 -1
- package/dist/cdn/date-range-picker/snice-date-range-picker.js +1 -1
- package/dist/cdn/date-time-picker/snice-date-time-picker.js +1 -1
- package/dist/cdn/diff/snice-diff.js +1 -1
- package/dist/cdn/divider/snice-divider.js +1 -1
- package/dist/cdn/doc/snice-doc.js +1 -1
- package/dist/cdn/draw/snice-draw.js +1 -1
- package/dist/cdn/drawer/snice-drawer.js +1 -1
- package/dist/cdn/empty-state/snice-empty-state.js +1 -1
- package/dist/cdn/estimate/snice-estimate.js +1 -1
- package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
- package/dist/cdn/file-upload/snice-file-upload.js +1 -1
- package/dist/cdn/flip-card/snice-flip-card.js +1 -1
- package/dist/cdn/flow/snice-flow.js +1 -1
- package/dist/cdn/form-layout/snice-form-layout.js +1 -1
- package/dist/cdn/funnel/snice-funnel.js +1 -1
- package/dist/cdn/gantt/snice-gantt.js +1 -1
- package/dist/cdn/gauge/snice-gauge.js +1 -1
- package/dist/cdn/grid/snice-grid.js +1 -1
- package/dist/cdn/heatmap/snice-heatmap.js +1 -1
- package/dist/cdn/image/snice-image.js +1 -1
- package/dist/cdn/input/snice-input.js +1 -1
- package/dist/cdn/invoice/snice-invoice.js +1 -1
- package/dist/cdn/kanban/snice-kanban.js +1 -1
- package/dist/cdn/key-value/snice-key-value.js +1 -1
- package/dist/cdn/kpi/snice-kpi.js +1 -1
- package/dist/cdn/layout/snice-layout.js +1 -1
- package/dist/cdn/leaderboard/snice-leaderboard.js +1 -1
- package/dist/cdn/link/snice-link.js +1 -1
- package/dist/cdn/link-preview/snice-link-preview.js +1 -1
- package/dist/cdn/list/snice-list.js +1 -1
- package/dist/cdn/location/snice-location.js +1 -1
- package/dist/cdn/login/snice-login.js +1 -1
- package/dist/cdn/map/snice-map.js +1 -1
- package/dist/cdn/markdown/snice-markdown.js +1 -1
- package/dist/cdn/masonry/snice-masonry.js +1 -1
- package/dist/cdn/menu/snice-menu.js +1 -1
- package/dist/cdn/message-strip/snice-message-strip.js +1 -1
- package/dist/cdn/modal/snice-modal.js +1 -1
- package/dist/cdn/music-player/snice-music-player.js +1 -1
- package/dist/cdn/nav/snice-nav.js +1 -1
- package/dist/cdn/network-graph/snice-network-graph.js +1 -1
- package/dist/cdn/notification-center/snice-notification-center.js +1 -1
- package/dist/cdn/order-tracker/snice-order-tracker.js +1 -1
- package/dist/cdn/org-chart/snice-org-chart.js +1 -1
- package/dist/cdn/pagination/snice-pagination.js +1 -1
- package/dist/cdn/paint/snice-paint.js +1 -1
- package/dist/cdn/pdf-viewer/snice-pdf-viewer.js +1 -1
- package/dist/cdn/permission-matrix/snice-permission-matrix.js +1 -1
- package/dist/cdn/podcast-player/snice-podcast-player.js +1 -1
- package/dist/cdn/popover/snice-popover.js +1 -1
- package/dist/cdn/pricing-table/snice-pricing-table.js +1 -1
- package/dist/cdn/product-card/snice-product-card.js +1 -1
- package/dist/cdn/progress/snice-progress.js +2 -2
- package/dist/cdn/progress/snice-progress.js.map +1 -1
- package/dist/cdn/progress/snice-progress.min.js +1 -1
- package/dist/cdn/progress/snice-progress.min.js.map +1 -1
- package/dist/cdn/progress-ring/snice-progress-ring.js +1 -1
- package/dist/cdn/qr-code/README.md +2 -2
- package/dist/cdn/qr-code/snice-qr-code.js +19 -3
- package/dist/cdn/qr-code/snice-qr-code.js.map +1 -1
- package/dist/cdn/qr-code/snice-qr-code.min.js +2 -2
- package/dist/cdn/qr-code/snice-qr-code.min.js.map +1 -1
- package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
- package/dist/cdn/radio/snice-radio.js +1 -1
- package/dist/cdn/range-slider/snice-range-slider.js +1 -1
- package/dist/cdn/rating/snice-rating.js +1 -1
- package/dist/cdn/receipt/snice-receipt.js +5 -2
- package/dist/cdn/receipt/snice-receipt.js.map +1 -1
- package/dist/cdn/receipt/snice-receipt.min.js +1 -1
- package/dist/cdn/receipt/snice-receipt.min.js.map +1 -1
- package/dist/cdn/recipe/snice-recipe.js +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.js +4 -4
- package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.js +4 -4
- package/dist/cdn/runtime/snice-runtime.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
- package/dist/cdn/sankey/snice-sankey.js +1 -1
- package/dist/cdn/segmented-control/snice-segmented-control.js +1 -1
- package/dist/cdn/select/README.md +2 -2
- package/dist/cdn/select/snice-select.js +6 -9
- package/dist/cdn/select/snice-select.js.map +1 -1
- package/dist/cdn/select/snice-select.min.js +2 -2
- package/dist/cdn/select/snice-select.min.js.map +1 -1
- package/dist/cdn/skeleton/snice-skeleton.js +1 -1
- package/dist/cdn/slider/snice-slider.js +1 -1
- package/dist/cdn/sortable/snice-sortable.js +1 -1
- package/dist/cdn/sparkline/snice-sparkline.js +1 -1
- package/dist/cdn/spinner/snice-spinner.js +1 -1
- package/dist/cdn/split-button/snice-split-button.js +1 -1
- package/dist/cdn/split-pane/snice-split-pane.js +1 -1
- package/dist/cdn/spotlight/snice-spotlight.js +1 -1
- package/dist/cdn/stat-group/snice-stat-group.js +1 -1
- package/dist/cdn/step-input/snice-step-input.js +1 -1
- package/dist/cdn/stepper/snice-stepper.js +1 -1
- package/dist/cdn/switch/snice-switch.js +1 -1
- package/dist/cdn/table/README.md +2 -2
- package/dist/cdn/table/snice-table.esm.js +1940 -407
- package/dist/cdn/table/snice-table.esm.js.map +1 -1
- package/dist/cdn/table/snice-table.esm.min.js +242 -53
- package/dist/cdn/table/snice-table.esm.min.js.map +1 -1
- package/dist/cdn/table/snice-table.js +1940 -407
- package/dist/cdn/table/snice-table.js.map +1 -1
- package/dist/cdn/table/snice-table.min.js +234 -45
- package/dist/cdn/table/snice-table.min.js.map +1 -1
- package/dist/cdn/tabs/snice-tabs.js +1 -1
- package/dist/cdn/tag/snice-tag.js +1 -1
- package/dist/cdn/tag-input/snice-tag-input.js +1 -1
- package/dist/cdn/terminal/snice-terminal.js +1 -1
- package/dist/cdn/testimonial/snice-testimonial.js +1 -1
- package/dist/cdn/textarea/snice-textarea.js +1 -1
- package/dist/cdn/time-picker/snice-time-picker.js +1 -1
- package/dist/cdn/time-range-picker/snice-time-range-picker.js +1 -1
- package/dist/cdn/timeline/snice-timeline.js +1 -1
- package/dist/cdn/timer/snice-timer.js +1 -1
- package/dist/cdn/toast/snice-toast.js +1 -1
- package/dist/cdn/tooltip/snice-tooltip.js +1 -1
- package/dist/cdn/tree/snice-tree.js +1 -1
- package/dist/cdn/treemap/snice-treemap.js +1 -1
- package/dist/cdn/user-card/snice-user-card.js +1 -1
- package/dist/cdn/video-player/snice-video-player.js +1 -1
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +1 -1
- package/dist/cdn/waterfall/snice-waterfall.js +1 -1
- package/dist/cdn/weather/snice-weather.js +1 -1
- package/dist/cdn/work-order/snice-work-order.js +1 -1
- package/dist/components/calendar/snice-calendar.d.ts +187 -5
- package/dist/components/calendar/snice-calendar.js +537 -44
- package/dist/components/calendar/snice-calendar.js.map +1 -1
- package/dist/components/calendar/snice-calendar.types.d.ts +2 -1
- package/dist/components/code-block/formatter.d.ts +6 -0
- package/dist/components/code-block/formatter.js +174 -164
- package/dist/components/code-block/formatter.js.map +1 -1
- package/dist/components/code-block/grammars/snice.json +1 -1
- package/dist/components/code-block/grammars/typescript.json +1 -1
- package/dist/components/command-palette/snice-command-palette.js +1 -1
- package/dist/components/command-palette/snice-command-palette.js.map +1 -1
- package/dist/components/progress/snice-progress.js +1 -1
- package/dist/components/progress/snice-progress.js.map +1 -1
- package/dist/components/qr-code/qrcode.d.ts +1 -1
- package/dist/components/qr-code/qrcode.js +18 -2
- package/dist/components/qr-code/qrcode.js.map +1 -1
- package/dist/components/receipt/snice-receipt.js +4 -1
- package/dist/components/receipt/snice-receipt.js.map +1 -1
- package/dist/components/select/snice-select.d.ts +1 -1
- package/dist/components/select/snice-select.js +5 -8
- package/dist/components/select/snice-select.js.map +1 -1
- package/dist/components/table/snice-cell-actions.js +1 -1
- package/dist/components/table/snice-cell-actions.js.map +1 -1
- package/dist/components/table/snice-cell-color.js +1 -1
- package/dist/components/table/snice-cell-color.js.map +1 -1
- package/dist/components/table/snice-cell-date.js +20 -8
- package/dist/components/table/snice-cell-date.js.map +1 -1
- package/dist/components/table/snice-cell-email.js +1 -1
- package/dist/components/table/snice-cell-email.js.map +1 -1
- package/dist/components/table/snice-cell-image.js +1 -1
- package/dist/components/table/snice-cell-image.js.map +1 -1
- package/dist/components/table/snice-cell-json.js +1 -1
- package/dist/components/table/snice-cell-json.js.map +1 -1
- package/dist/components/table/snice-cell-link.js +1 -1
- package/dist/components/table/snice-cell-link.js.map +1 -1
- package/dist/components/table/snice-cell-location.js +1 -1
- package/dist/components/table/snice-cell-location.js.map +1 -1
- package/dist/components/table/snice-cell-phone.js +1 -1
- package/dist/components/table/snice-cell-phone.js.map +1 -1
- package/dist/components/table/snice-cell-status.js +1 -1
- package/dist/components/table/snice-cell-status.js.map +1 -1
- package/dist/components/table/snice-cell.d.ts +10 -0
- package/dist/components/table/snice-cell.js +59 -13
- package/dist/components/table/snice-cell.js.map +1 -1
- package/dist/components/table/snice-row.d.ts +0 -1
- package/dist/components/table/snice-row.js +4 -10
- package/dist/components/table/snice-row.js.map +1 -1
- package/dist/components/table/snice-table.d.ts +170 -2
- package/dist/components/table/snice-table.js +868 -189
- package/dist/components/table/snice-table.js.map +1 -1
- package/dist/components/table/snice-table.types.d.ts +17 -0
- package/dist/components/table/table-cell-presentation.d.ts +17 -4
- package/dist/components/table/table-cell-presentation.js +37 -11
- package/dist/components/table/table-cell-presentation.js.map +1 -1
- package/dist/components/table/table-column-manager.d.ts +153 -2
- package/dist/components/table/table-column-manager.js +364 -43
- package/dist/components/table/table-column-manager.js.map +1 -1
- package/dist/components/table/table-date.d.ts +29 -0
- package/dist/components/table/table-date.js +78 -0
- package/dist/components/table/table-date.js.map +1 -0
- package/dist/components/table/table-export.js +6 -2
- package/dist/components/table/table-export.js.map +1 -1
- package/dist/components/table/table-filter-engine.d.ts +9 -0
- package/dist/components/table/table-filter-engine.js +58 -14
- package/dist/components/table/table-filter-engine.js.map +1 -1
- package/dist/components/table/table-keyboard.d.ts +8 -0
- package/dist/components/table/table-keyboard.js +14 -3
- package/dist/components/table/table-keyboard.js.map +1 -1
- package/dist/components/table/table-toolbar.js +1 -0
- package/dist/components/table/table-toolbar.js.map +1 -1
- package/dist/components/table/table-tree-data.d.ts +2 -0
- package/dist/components/table/table-tree-data.js +35 -9
- package/dist/components/table/table-tree-data.js.map +1 -1
- package/dist/components/table/table-virtualizer.d.ts +44 -7
- package/dist/components/table/table-virtualizer.js +101 -54
- package/dist/components/table/table-virtualizer.js.map +1 -1
- package/dist/components/theme/theme.css +9 -0
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/react/SniceProvider.js +1 -1
- package/dist/react/SniceRouter.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/matchRoute.js +1 -1
- package/dist/react/useRequestHandler.js +1 -1
- package/dist/symbols.cjs +1 -1
- package/dist/symbols.esm.js +1 -1
- package/dist/testing-dom.cjs +1 -1
- package/dist/testing-dom.esm.js +1 -1
- package/dist/transitions.cjs +1 -1
- package/dist/transitions.esm.js +1 -1
- package/docs/ai/DEVELOPMENT.md +93 -2
- package/docs/ai/components/calendar.md +113 -10
- package/docs/ai/components/code-block.md +4 -0
- package/docs/ai/components/doc.md +1 -1
- package/docs/ai/components/progress.md +1 -0
- package/docs/ai/components/receipt.md +1 -1
- package/docs/ai/components/table.md +29 -30
- package/docs/ai/components/theme.md +1 -0
- package/docs/ai/events.md +30 -0
- package/docs/ai/theme.md +1 -0
- package/docs/components/calendar.md +171 -11
- package/docs/components/code-block.md +2 -0
- package/docs/components/doc.md +1 -1
- package/docs/components/progress.md +13 -0
- package/docs/components/receipt.md +1 -0
- package/docs/components/table.md +274 -15
- package/docs/components/theme.md +5 -0
- package/docs/events.md +49 -0
- package/docs/plans/2026-03-06-date-range-picker-plan.md +4 -4
- package/docs/plans/2026-03-07-table-mui-parity-design.md +1 -1
- package/docs/plans/2026-03-09-action-bar-plan.md +11 -11
- package/docs/superpowers/specs/2026-07-09-table-incredible-design.md +1 -1
- package/docs/superpowers/specs/2026-07-09-table-phase0-implementation.md +2 -2
- package/package.json +3 -1
- package/vscode.html-custom-data.json +13 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
void 0===globalThis.Snice&&console.warn("[snice] snice-runtime.min.js must be loaded before snice-code-block.min.js");var SniceCodeBlock=function(e,t){"use strict";function a(e,t,a,r,n,o){function c(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var i,s=r.kind,l="getter"===s?"get":"setter"===s?"set":"value",h=!t&&e?r.static?e:e.prototype:null,d=t||(h?Object.getOwnPropertyDescriptor(h,r.name):{}),b=!1,
|
|
1
|
+
void 0===globalThis.Snice&&console.warn("[snice] snice-runtime.min.js must be loaded before snice-code-block.min.js");var SniceCodeBlock=function(e,t){"use strict";function a(e,t,a,r,n,o){function c(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var i,s=r.kind,l="getter"===s?"get":"setter"===s?"set":"value",h=!t&&e?r.static?e:e.prototype:null,d=t||(h?Object.getOwnPropertyDescriptor(h,r.name):{}),b=!1,m=a.length-1;m>=0;m--){var g={};for(var u in r)g[u]="access"===u?{}:r[u];for(var u in r.access)g.access[u]=r.access[u];g.addInitializer=function(e){if(b)throw new TypeError("Cannot add initializers after decoration has completed");o.push(c(e||null))};var p=(0,a[m])("accessor"===s?{get:d.get,set:d.set}:d[l],g);if("accessor"===s){if(void 0===p)continue;if(null===p||"object"!=typeof p)throw new TypeError("Object expected");(i=c(p.get))&&(d.get=i),(i=c(p.set))&&(d.set=i),(i=c(p.init))&&n.unshift(i)}else(i=c(p))&&("field"===s?n.unshift(i):d[l]=i)}h&&Object.defineProperty(h,r.name,d),b=!0}function r(e,t,a){for(var r=arguments.length>2,n=0;n<t.length;n++)a=r?t[n].call(e,a):t[n].call(e);return r?a:void 0}"function"==typeof SuppressedError&&SuppressedError;const n=new WeakMap;function o(e,t,a){const r=[];for(const n of t)if("include"in n){const t=n.include.replace(/^@/,"");if(a.has(t))continue;a.add(t);const c=e.tokenizer[t];c&&r.push(...o(e,c,a))}else r.push(n);return r}function c(e,t,a){if("string"==typeof t)return t;for(const[r,n]of Object.entries(t.cases))if("@default"!==r)if(r.startsWith("@")){const t=e[r.slice(1)];if(Array.isArray(t)&&t.includes(a))return n}else if(r===a)return n;return void 0!==t.cases["@default"]?t.cases["@default"]:""}function i(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const s=new Map,l=new Map;let h=(()=>{let e,h,d,b,m,g,u,p,f,v,_,y,k,x,E,w,C,B,G,L,S,H,M,F,A,j,R,q,$,T,z,N,O,U=[t.element("snice-code-block")],V=[],I=HTMLElement,P=[],D=[],W=[],J=[],K=[],Q=[],X=[],Y=[],Z=[],ee=[],te=[],ae=[],re=[],ne=[],oe=[],ce=[],ie=[],se=[],le=[],he=[],de=[],be=[],me=[],ge=[],ue=[],pe=[],fe=[],ve=[],_e=[];return class extends I{static{h=this}static{const n="function"==typeof Symbol&&Symbol.metadata?Object.create(I[Symbol.metadata]??null):void 0;d=[t.property({})],b=[t.property({type:Boolean,attribute:"show-line-numbers"})],m=[t.property({type:Number,attribute:"start-line"})],g=[t.property({type:Array,attribute:!1})],u=[t.property({type:Boolean})],p=[t.property({})],f=[t.property({})],v=[t.property({attribute:"fetch-mode"})],_=[t.property({})],y=[t.property({})],k=[t.query(".code-block__code")],x=[t.query(".code-block__header")],E=[t.query(".code-block__filename")],w=[t.query(".code-block__copy")],C=[t.dispatch("code-copy",{bubbles:!0,composed:!0})],B=[t.dispatch("code-before-highlight",{bubbles:!0,composed:!0})],G=[t.dispatch("code-after-highlight",{bubbles:!0,composed:!0})],L=[t.dispatch("code-before-format",{bubbles:!0,composed:!0})],S=[t.dispatch("code-after-format",{bubbles:!0,composed:!0})],H=[t.dispatch("grammar-request",{bubbles:!0,composed:!0})],M=[t.dispatch("grammar-loaded",{bubbles:!0,composed:!0})],F=[t.request("snice/code-block/load-grammar")],A=[t.render({once:!0})],j=[t.styles()],R=[t.ready()],q=[t.on("slotchange",{target:"slot"})],$=[t.watch("grammar")],T=[t.watch("fetchMode")],z=[t.watch("format")],N=[t.watch("filename","copyable")],O=[t.watch("language")],a(this,null,C,{kind:"method",name:"dispatchCopyEvent",static:!1,private:!1,access:{has:e=>"dispatchCopyEvent"in e,get:e=>e.dispatchCopyEvent},metadata:n},null,P),a(this,null,B,{kind:"method",name:"dispatchBeforeHighlightEvent",static:!1,private:!1,access:{has:e=>"dispatchBeforeHighlightEvent"in e,get:e=>e.dispatchBeforeHighlightEvent},metadata:n},null,P),a(this,null,G,{kind:"method",name:"dispatchAfterHighlightEvent",static:!1,private:!1,access:{has:e=>"dispatchAfterHighlightEvent"in e,get:e=>e.dispatchAfterHighlightEvent},metadata:n},null,P),a(this,null,L,{kind:"method",name:"dispatchBeforeFormatEvent",static:!1,private:!1,access:{has:e=>"dispatchBeforeFormatEvent"in e,get:e=>e.dispatchBeforeFormatEvent},metadata:n},null,P),a(this,null,S,{kind:"method",name:"dispatchAfterFormatEvent",static:!1,private:!1,access:{has:e=>"dispatchAfterFormatEvent"in e,get:e=>e.dispatchAfterFormatEvent},metadata:n},null,P),a(this,null,H,{kind:"method",name:"dispatchGrammarRequestEvent",static:!1,private:!1,access:{has:e=>"dispatchGrammarRequestEvent"in e,get:e=>e.dispatchGrammarRequestEvent},metadata:n},null,P),a(this,null,M,{kind:"method",name:"dispatchGrammarLoadedEvent",static:!1,private:!1,access:{has:e=>"dispatchGrammarLoadedEvent"in e,get:e=>e.dispatchGrammarLoadedEvent},metadata:n},null,P),a(this,null,F,{kind:"method",name:"requestGrammar",static:!1,private:!1,access:{has:e=>"requestGrammar"in e,get:e=>e.requestGrammar},metadata:n},null,P),a(this,null,A,{kind:"method",name:"template",static:!1,private:!1,access:{has:e=>"template"in e,get:e=>e.template},metadata:n},null,P),a(this,null,j,{kind:"method",name:"styles",static:!1,private:!1,access:{has:e=>"styles"in e,get:e=>e.styles},metadata:n},null,P),a(this,null,R,{kind:"method",name:"onReady",static:!1,private:!1,access:{has:e=>"onReady"in e,get:e=>e.onReady},metadata:n},null,P),a(this,null,q,{kind:"method",name:"handleSlotChange",static:!1,private:!1,access:{has:e=>"handleSlotChange"in e,get:e=>e.handleSlotChange},metadata:n},null,P),a(this,null,$,{kind:"method",name:"onGrammarChange",static:!1,private:!1,access:{has:e=>"onGrammarChange"in e,get:e=>e.onGrammarChange},metadata:n},null,P),a(this,null,T,{kind:"method",name:"onFetchModeChange",static:!1,private:!1,access:{has:e=>"onFetchModeChange"in e,get:e=>e.onFetchModeChange},metadata:n},null,P),a(this,null,z,{kind:"method",name:"onFormatChange",static:!1,private:!1,access:{has:e=>"onFormatChange"in e,get:e=>e.onFormatChange},metadata:n},null,P),a(this,null,N,{kind:"method",name:"updateHeader",static:!1,private:!1,access:{has:e=>"updateHeader"in e,get:e=>e.updateHeader},metadata:n},null,P),a(this,null,O,{kind:"method",name:"onLanguageChange",static:!1,private:!1,access:{has:e=>"onLanguageChange"in e,get:e=>e.onLanguageChange},metadata:n},null,P),a(null,null,d,{kind:"field",name:"language",static:!1,private:!1,access:{has:e=>"language"in e,get:e=>e.language,set:(e,t)=>{e.language=t}},metadata:n},D,W),a(null,null,b,{kind:"field",name:"showLineNumbers",static:!1,private:!1,access:{has:e=>"showLineNumbers"in e,get:e=>e.showLineNumbers,set:(e,t)=>{e.showLineNumbers=t}},metadata:n},J,K),a(null,null,m,{kind:"field",name:"startLine",static:!1,private:!1,access:{has:e=>"startLine"in e,get:e=>e.startLine,set:(e,t)=>{e.startLine=t}},metadata:n},Q,X),a(null,null,g,{kind:"field",name:"highlightLines",static:!1,private:!1,access:{has:e=>"highlightLines"in e,get:e=>e.highlightLines,set:(e,t)=>{e.highlightLines=t}},metadata:n},Y,Z),a(null,null,u,{kind:"field",name:"copyable",static:!1,private:!1,access:{has:e=>"copyable"in e,get:e=>e.copyable,set:(e,t)=>{e.copyable=t}},metadata:n},ee,te),a(null,null,p,{kind:"field",name:"filename",static:!1,private:!1,access:{has:e=>"filename"in e,get:e=>e.filename,set:(e,t)=>{e.filename=t}},metadata:n},ae,re),a(null,null,f,{kind:"field",name:"grammar",static:!1,private:!1,access:{has:e=>"grammar"in e,get:e=>e.grammar,set:(e,t)=>{e.grammar=t}},metadata:n},ne,oe),a(null,null,v,{kind:"field",name:"fetchMode",static:!1,private:!1,access:{has:e=>"fetchMode"in e,get:e=>e.fetchMode,set:(e,t)=>{e.fetchMode=t}},metadata:n},ce,ie),a(null,null,_,{kind:"field",name:"format",static:!1,private:!1,access:{has:e=>"format"in e,get:e=>e.format,set:(e,t)=>{e.format=t}},metadata:n},se,le),a(null,null,y,{kind:"field",name:"theme",static:!1,private:!1,access:{has:e=>"theme"in e,get:e=>e.theme,set:(e,t)=>{e.theme=t}},metadata:n},he,de),a(null,null,k,{kind:"field",name:"codeEl",static:!1,private:!1,access:{has:e=>"codeEl"in e,get:e=>e.codeEl,set:(e,t)=>{e.codeEl=t}},metadata:n},be,me),a(null,null,x,{kind:"field",name:"headerEl",static:!1,private:!1,access:{has:e=>"headerEl"in e,get:e=>e.headerEl,set:(e,t)=>{e.headerEl=t}},metadata:n},ge,ue),a(null,null,E,{kind:"field",name:"filenameEl",static:!1,private:!1,access:{has:e=>"filenameEl"in e,get:e=>e.filenameEl,set:(e,t)=>{e.filenameEl=t}},metadata:n},pe,fe),a(null,null,w,{kind:"field",name:"copyBtn",static:!1,private:!1,access:{has:e=>"copyBtn"in e,get:e=>e.copyBtn,set:(e,t)=>{e.copyBtn=t}},metadata:n},ve,_e),a(null,e={value:h},U,{kind:"class",name:h.name,metadata:n},null,V),h=e.value,n&&Object.defineProperty(h,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:n}),r(h,V)}dispatchCopyEvent(){return{code:this.code,codeBlock:this}}dispatchBeforeHighlightEvent(){return{code:this.code,language:this.language,codeBlock:this}}dispatchAfterHighlightEvent(){return{code:this.code,language:this.language,codeBlock:this}}dispatchBeforeFormatEvent(){return{code:this.code,language:this.language,codeBlock:this}}dispatchAfterFormatEvent(){return{code:this.code,language:this.language,codeBlock:this}}dispatchGrammarRequestEvent(){return{url:this.grammar,language:this.language,codeBlock:this}}dispatchGrammarLoadedEvent(e,t){return{grammar:e,url:t,language:this.language,codeBlock:this}}async*requestGrammar(e){return await(yield{url:e})}template(){return t.html`
|
|
2
2
|
<slot style="display:none"></slot>
|
|
3
3
|
<div class="code-block" part="container">
|
|
4
4
|
<div class="code-block__header" part="header">
|
|
@@ -15,5 +15,5 @@ void 0===globalThis.Snice&&console.warn("[snice] snice-runtime.min.js must be lo
|
|
|
15
15
|
<pre class="code-block__pre" part="pre"><code class="code-block__code language-${this.language}" part="code" data-language="${this.language}"></code></pre>
|
|
16
16
|
</div>
|
|
17
17
|
</div>
|
|
18
|
-
`}styles(){return t.css`${":host([hidden]){display:none}:host{display:block;--_cb-bg:var(--snice-color-surface-container, #282c34);--_cb-text:var(--snice-color-text-secondary, #abb2bf);--_cb-header-bg:var(--snice-color-surface-container-low, #21252b);--_cb-header-border:var(--snice-color-border, rgb(51 56 66));--_cb-header-text:var(--snice-color-text-tertiary, #9da5b4);--_cb-btn-border:var(--snice-color-border, rgb(75 82 99));--_cb-btn-hover-bg:var(--snice-color-surface-hover, rgb(51 56 66));--_cb-btn-hover-border:var(--snice-color-border-hover, rgb(92 99 112));--_cb-line-number:var(--snice-color-text-tertiary, #636d83);--_cb-highlight-bg:rgb(255 255 255 / 0.07);--_cb-keyword:#c678dd;--_cb-function:#61afef;--_cb-string:#98c379;--_cb-number:#d19a66;--_cb-comment:#6a9955;--_cb-operator:#56b6c2;--_cb-punctuation:#abb2bf;--_cb-tag:#e06c75;--_cb-attr-name:#d19a66;--_cb-attr-value:#98c379;--_cb-constant:#d19a66;--_cb-class:#e5c07b;--_cb-builtin:#e06c75;--_cb-regex:#98c379}@media (prefers-color-scheme:light){:host(:not([theme])){--_cb-bg:var(--snice-color-surface-container, #fafafa);--_cb-text:var(--snice-color-text, #383a42);--_cb-header-bg:var(--snice-color-surface-container-low, #eaeaeb);--_cb-header-border:var(--snice-color-border, rgb(208 208 208));--_cb-header-text:var(--snice-color-text-tertiary, #696c77);--_cb-btn-border:var(--snice-color-border, rgb(192 192 192));--_cb-btn-hover-bg:var(--snice-color-surface-hover, rgb(216 216 217));--_cb-btn-hover-border:var(--snice-color-border-hover, rgb(160 160 160));--_cb-line-number:var(--snice-color-text-tertiary, #9d9d9f);--_cb-highlight-bg:rgb(0 0 0 / 0.05);--_cb-keyword:#a626a4;--_cb-function:#4078f2;--_cb-string:#50a14f;--_cb-number:#986801;--_cb-comment:#a0a1a7;--_cb-operator:#0184bc;--_cb-punctuation:#383a42;--_cb-tag:#e45649;--_cb-attr-name:#986801;--_cb-attr-value:#50a14f;--_cb-constant:#986801;--_cb-class:#c18401;--_cb-builtin:#e45649;--_cb-regex:#50a14f}}:host-context([data-theme=dark]){--_cb-bg:var(--snice-color-surface-container, #282c34);--_cb-text:var(--snice-color-text-secondary, #abb2bf);--_cb-header-bg:var(--snice-color-surface-container-low, #21252b);--_cb-header-border:var(--snice-color-border, rgb(51 56 66));--_cb-header-text:var(--snice-color-text-tertiary, #9da5b4);--_cb-btn-border:var(--snice-color-border, rgb(75 82 99));--_cb-btn-hover-bg:var(--snice-color-surface-hover, rgb(51 56 66));--_cb-btn-hover-border:var(--snice-color-border-hover, rgb(92 99 112));--_cb-line-number:var(--snice-color-text-tertiary, #636d83);--_cb-highlight-bg:rgb(255 255 255 / 0.07);--_cb-keyword:#c678dd;--_cb-function:#61afef;--_cb-string:#98c379;--_cb-number:#d19a66;--_cb-comment:#6a9955;--_cb-operator:#56b6c2;--_cb-punctuation:#abb2bf;--_cb-tag:#e06c75;--_cb-attr-name:#d19a66;--_cb-attr-value:#98c379;--_cb-constant:#d19a66;--_cb-class:#e5c07b;--_cb-builtin:#e06c75;--_cb-regex:#98c379}:host-context([data-theme=light]){--_cb-bg:var(--snice-color-surface-container, #fafafa);--_cb-text:var(--snice-color-text, #383a42);--_cb-header-bg:var(--snice-color-surface-container-low, #eaeaeb);--_cb-header-border:var(--snice-color-border, rgb(208 208 208));--_cb-header-text:var(--snice-color-text-tertiary, #696c77);--_cb-btn-border:var(--snice-color-border, rgb(192 192 192));--_cb-btn-hover-bg:var(--snice-color-surface-hover, rgb(216 216 217));--_cb-btn-hover-border:var(--snice-color-border-hover, rgb(160 160 160));--_cb-line-number:var(--snice-color-text-tertiary, #9d9d9f);--_cb-highlight-bg:rgb(0 0 0 / 0.05);--_cb-keyword:#a626a4;--_cb-function:#4078f2;--_cb-string:#50a14f;--_cb-number:#986801;--_cb-comment:#a0a1a7;--_cb-operator:#0184bc;--_cb-punctuation:#383a42;--_cb-tag:#e45649;--_cb-attr-name:#986801;--_cb-attr-value:#50a14f;--_cb-constant:#986801;--_cb-class:#c18401;--_cb-builtin:#e45649;--_cb-regex:#50a14f}:host([theme=dark]){--_cb-bg:var(--snice-color-surface-container, #282c34);--_cb-text:var(--snice-color-text-secondary, #abb2bf);--_cb-header-bg:var(--snice-color-surface-container-low, #21252b);--_cb-header-border:var(--snice-color-border, rgb(51 56 66));--_cb-header-text:var(--snice-color-text-tertiary, #9da5b4);--_cb-btn-border:var(--snice-color-border, rgb(75 82 99));--_cb-btn-hover-bg:var(--snice-color-surface-hover, rgb(51 56 66));--_cb-btn-hover-border:var(--snice-color-border-hover, rgb(92 99 112));--_cb-line-number:var(--snice-color-text-tertiary, #636d83);--_cb-highlight-bg:rgb(255 255 255 / 0.07);--_cb-keyword:#c678dd;--_cb-function:#61afef;--_cb-string:#98c379;--_cb-number:#d19a66;--_cb-comment:#6a9955;--_cb-operator:#56b6c2;--_cb-punctuation:#abb2bf;--_cb-tag:#e06c75;--_cb-attr-name:#d19a66;--_cb-attr-value:#98c379;--_cb-constant:#d19a66;--_cb-class:#e5c07b;--_cb-builtin:#e06c75;--_cb-regex:#98c379}:host([theme=light]){--_cb-bg:var(--snice-color-surface-container, #fafafa);--_cb-text:var(--snice-color-text, #383a42);--_cb-header-bg:var(--snice-color-surface-container-low, #eaeaeb);--_cb-header-border:var(--snice-color-border, rgb(208 208 208));--_cb-header-text:var(--snice-color-text-tertiary, #696c77);--_cb-btn-border:var(--snice-color-border, rgb(192 192 192));--_cb-btn-hover-bg:var(--snice-color-surface-hover, rgb(216 216 217));--_cb-btn-hover-border:var(--snice-color-border-hover, rgb(160 160 160));--_cb-line-number:var(--snice-color-text-tertiary, #9d9d9f);--_cb-highlight-bg:rgb(0 0 0 / 0.05);--_cb-keyword:#a626a4;--_cb-function:#4078f2;--_cb-string:#50a14f;--_cb-number:#986801;--_cb-comment:#a0a1a7;--_cb-operator:#0184bc;--_cb-punctuation:#383a42;--_cb-tag:#e45649;--_cb-attr-name:#986801;--_cb-attr-value:#50a14f;--_cb-constant:#986801;--_cb-class:#c18401;--_cb-builtin:#e45649;--_cb-regex:#50a14f}.code-block{position:relative;background:var(--code-block-bg,var(--_cb-bg));border-radius:var(--snice-border-radius-md,.375rem);overflow:hidden}.code-block__header{font-family:var(--snice-font-family-display, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);display:flex;justify-content:space-between;align-items:center;padding:var(--snice-spacing-sm,.75rem) var(--snice-spacing-md,1rem);background:var(--code-block-header-bg,var(--_cb-header-bg));border-bottom:1px solid var(--_cb-header-border)}.code-block__filename{font-size:var(--snice-font-size-sm, .875rem);color:var(--_cb-header-text);font-family:var(--snice-font-family-mono, monospace)}.code-block__copy{background:0 0;border:1px solid var(--_cb-btn-border);color:var(--_cb-header-text);padding:.25rem .5rem;border-radius:var(--snice-border-radius-sm,.25rem);cursor:pointer;font-size:var(--snice-font-size-xs, .75rem);transition:all var(--snice-transition-fast, 150ms)}.code-block__copy:hover{background:var(--_cb-btn-hover-bg);border-color:var(--_cb-btn-hover-border)}.code-block__copy--copied{background:var(--snice-color-success,rgb(22 163 74));border-color:var(--snice-color-success,rgb(22 163 74));color:var(--snice-color-text-inverse,rgb(250 250 250))}.code-block__content{overflow-x:auto}.code-block__pre{margin:0;padding:var(--snice-spacing-md,1rem);background:0 0;overflow-x:auto}.code-block__code{font-family:var(--snice-font-family-mono, 'Courier New', monospace);font-size:var(--snice-font-size-sm, .875rem);line-height:1.5;color:var(--code-block-text,var(--_cb-text));display:block}.code-block__line{display:block}.code-block__line--highlight{background:var(--_cb-highlight-bg);border-left:3px solid var(--snice-color-primary,rgb(37 99 235));padding-left:calc(var(--snice-spacing-sm,.75rem) - 3px);margin-left:calc(-1 * var(--snice-spacing-md,1rem));padding-right:var(--snice-spacing-md,1rem)}.code-block__line-number{display:inline-block;width:3rem;text-align:right;margin-right:var(--snice-spacing-md,1rem);color:var(--_cb-line-number);user-select:none}.token.keyword{color:var(--code-keyword-color,var(--_cb-keyword))}.token.function{color:var(--code-function-color,var(--_cb-function))}.token.string{color:var(--code-string-color,var(--_cb-string))}.token.number{color:var(--code-number-color,var(--_cb-number))}.token.comment{color:var(--code-comment-color,var(--_cb-comment));font-style:italic}.token.operator{color:var(--code-operator-color,var(--_cb-operator))}.token.punctuation{color:var(--code-punctuation-color,var(--_cb-punctuation))}.token.tag{color:var(--code-tag-color,var(--_cb-tag))}.token.attr-name,.token.property{color:var(--code-attr-name-color,var(--_cb-attr-name))}.token.attr-value{color:var(--code-attr-value-color,var(--_cb-attr-value))}.token.boolean,.token.constant{color:var(--code-constant-color,var(--_cb-constant))}.token.class-name{color:var(--code-class-color,var(--_cb-class))}.token.builtin{color:var(--code-builtin-color,var(--_cb-builtin))}.token.regex{color:var(--code-regex-color,var(--_cb-regex))}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}@media (prefers-reduced-motion:reduce){*{transition-duration:0s!important;animation-duration:0s!important}}"}`}async onReady(){this.updateHeader(),this.code||this.readSlottedContent(),this.code&&await this.highlight()}handleSlotChange(){this.readSlottedContent()}readSlottedContent(){const e=this.textContent;if(!e)return;const t=function(e){const t=e.replace(/^\n+/,"").replace(/\n\s*$/,"").split("\n");if(0===t.length)return"";const a=t.filter(e=>e.trim()).map(e=>e.match(/^(\s*)/)?.[1].length??0);if(0===a.length)return t.join("\n");const r=Math.min(...a);return 0===r?t.join("\n"):t.map(e=>e.slice(r)).join("\n")}(e);t&&(this.code=t,this.highlight())}onGrammarChange(){this.loadedGrammar=null,this.loadedGrammarUrl=null,this.code&&this.highlight()}onFetchModeChange(){this.loadedGrammar=null,this.loadedGrammarUrl=null,this.code&&this.highlight()}onFormatChange(){this.code&&this.highlight()}updateHeader(){this.headerEl&&(this.headerEl.style.display=this.filename||this.copyable?"":"none",this.filenameEl&&(this.filenameEl.textContent=this.filename),this.copyBtn&&(this.copyBtn.style.display=this.copyable?"":"none"))}onLanguageChange(){this.codeEl&&(this.codeEl.className=`code-block__code language-${this.language}`,this.codeEl.setAttribute("data-language",this.language))}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}updateCodeDisplay(){if(!this.codeEl)return;const e=this.highlightedCode||this.escapeHtml(this.code);if(this.showLineNumbers||this.highlightLines.length>0){const t=e.split("\n").map((e,t)=>{const a=this.startLine+t;return`<span class="${["code-block__line",this.highlightLines.includes(a)?"code-block__line--highlight":""].filter(Boolean).join(" ")}">${this.showLineNumbers?`<span class="code-block__line-number">${a}</span>`:""}${e}\n</span>`}).join("");this.codeEl.innerHTML=t}else this.codeEl.innerHTML=e}async copy(){try{await navigator.clipboard.writeText(this.code),this.copied=!0,this.dispatchCopyEvent(),this.copyBtn&&(this.copyBtn.textContent="Copied!"),setTimeout(()=>{this.copied=!1,this.copyBtn&&(this.copyBtn.textContent="Copy")},2e3)}catch(e){console.error("Failed to copy code:",e)}}setHighlighter(e){this.highlighter=e}setFormatter(e){this.formatter=e}setGrammar(e){this.loadedGrammar=e,this.loadedGrammarUrl=null,this.dispatchGrammarLoadedEvent(e,""),this.code&&this.highlight()}async resolveGrammar(){if(this.loadedGrammar)return this.loadedGrammar;if(!this.grammar)return null;try{switch(this.fetchMode){case"native":{const e=await function(e){let t=h.get(e);return t||(t=fetch(e).then(e=>e.json()).catch(t=>{throw h.delete(e),t}),h.set(e,t)),t}(this.grammar);return e&&(this.loadedGrammar=e,this.loadedGrammarUrl=this.grammar,this.dispatchGrammarLoadedEvent(e,this.grammar)),e}case"virtual":{const e=await this.requestGrammar(this.grammar);return e&&(this.loadedGrammar=e,this.loadedGrammarUrl=this.grammar,this.dispatchGrammarLoadedEvent(e,this.grammar)),e}case"event":return this.dispatchGrammarRequestEvent(),null;default:return null}}catch(e){return console.error(`Failed to load grammar from ${this.grammar}:`,e),null}}async highlight(){if(!this.code)return;const e=++this.highlightVersion;let t=this.formatter;if(!t&&this.format){const a=await this.resolveGrammar();if(e!==this.highlightVersion)return;if(a?.formatters?.[this.format]){const e=a.formatters[this.format];t=t=>function(e,t){const a=t.useTabs?"\t":" ".repeat(t.tabSize??2),r=t.trimTrailing??!0,n=t.skipStrings??!0,o=t.skipComments??!0,c=t.newlineAfter?new RegExp(t.newlineAfter):null,i=t.newlineBefore?new RegExp(t.newlineBefore):null,s=t.spaceAfter?new RegExp(t.spaceAfter):null,h=t.spaceBefore?new RegExp(t.spaceBefore):null,d=t.spaceAround?new RegExp(t.spaceAround):null,b=t.indent?new RegExp(t.indent):null,g=t.dedent?new RegExp(t.dedent):null,m=function(e,t,a){let r="",n=null,o=!1,c=!1;for(let i=0;i<e.length;i++){const s=e[i],l=i>0?e[i-1]:"",h=i+1<e.length?e[i+1]:"";if(!o&&!c&&t){if(n){r+=s,s===n&&"\\"!==l&&(n=null);continue}if('"'===s||"'"===s||"`"===s){n=s,r+=s;continue}}if(a){if(c){"\n"===s?(c=!1,r+=s):r+=s;continue}if(o){r+=s,"/"===s&&"*"===l&&(o=!1);continue}if("/"===s&&"/"===h){c=!0,r+=s;continue}if("/"===s&&"*"===h){o=!0,r+=s;continue}}/\s/.test(s)?r.length>0&&!/\s/.test(r[r.length-1])&&(r+=" "):r+=s}return r}(e,n,o);let u="",p=0,f=!0,v=null,_=!1,y=!1;for(let e=0;e<m.length;e++){const t=m[e],r=e>0?m[e-1]:"",k=e+1<m.length?m[e+1]:"";if(!_&&!y&&n){if(v){u+=t,t===v&&"\\"!==r&&(v=null);continue}if('"'===t||"'"===t||"`"===t){v=t,f&&(u+=a.repeat(p),f=!1),u+=t;continue}}if(o){if(y){u+=t,"\n"===t&&(y=!1,f=!0);continue}if(_){u+=t,"/"===t&&"*"===r&&(_=!1);continue}if("/"===t&&"/"===k){f&&(u+=a.repeat(p),f=!1),y=!0,u+=t;continue}if("/"===t&&"*"===k){f&&(u+=a.repeat(p),f=!1),_=!0,u+=t;continue}}g&&g.test(t)&&(p=Math.max(0,p-1)),i&&i.test(t)&&(f||(u=l(u),u+="\n",f=!0)),(h&&h.test(t)||d&&d.test(t))&&!f&&u.length>0&&" "!==u[u.length-1]&&"\n"!==u[u.length-1]&&(u+=" "),f&&"\n"!==t&&(u+=a.repeat(p),f=!1),u+=t,b&&b.test(t)&&p++,(s&&s.test(t)||d&&d.test(t))&&k&&"\n"!==k&&" "!==k&&(u+=" "),c&&c.test(t)&&(u=l(u),u+="\n",f=!0)}let k=u.split("\n");for(r&&(k=k.map(e=>e.replace(/\s+$/,""))),void 0!==t.collapseBlankLines&&(k=function(e,t){const a=[];let r=0;for(const n of e)""===n.trim()?(r++,r<=t&&a.push(n)):(r=0,a.push(n));return a}(k,t.collapseBlankLines));k.length>0&&""===k[0].trim();)k.shift();for(;k.length>0&&""===k[k.length-1].trim();)k.pop();return k.join("\n")}(t,e)}}if(t&&this.format){this.dispatchBeforeFormatEvent();try{const a=await t(this.code,this.language);if(e!==this.highlightVersion)return;this.code=a,this.dispatchAfterFormatEvent()}catch(e){console.error("Code formatting failed:",e)}}this.dispatchBeforeHighlightEvent();try{if(this.highlighter){const t=this.escapeHtml(this.code).split("\n"),a=await Promise.all(t.map(e=>this.highlighter(e,this.language)));if(e!==this.highlightVersion)return;this.highlightedCode=a.join("\n")}else{const t=await this.resolveGrammar();if(e!==this.highlightVersion)return;this.highlightedCode=function(e,t){const a="string"==typeof t?function(e){return s.get(e.toLowerCase())}(t):t;if(!a)return i(e);const r=function(e){const t=n.get(e);if(t)return t;const a=new Map,r=e.ignoreCase?"yi":"y";for(const[t,n]of Object.entries(e.tokenizer)){const c=o(e,n,new Set).map(e=>({regex:new RegExp(e[0],r),token:e[1],nextState:e[2]}));a.set(t,c)}const c={grammar:e,states:a};return n.set(e,c),c}(a);return l=function(e,t){const{grammar:a,states:r}=t,n=[],o=["root"];let i=0;const s=a.defaultToken||"",l=10*e.length;let h=0;for(;i<e.length&&h<l;){h++;const t=r.get(o[o.length-1]);if(!t){n.push({text:e[i],type:s||null}),i++;continue}let d=!1;for(const r of t){r.regex.lastIndex=i;const t=r.regex.exec(e);if(t&&t.index===i&&t[0].length>0){const e=c(a,r.token,t[0]);if(n.push({text:t[0],type:e||null}),i+=t[0].length,r.nextState)if("@pop"===r.nextState)o.length>1&&o.pop();else{const e=r.nextState.replace(/^@/,"");o.push(e)}d=!0;break}}if(!d){let a=i+1;for(;a<e.length;){let r=!1;for(const n of t){n.regex.lastIndex=a;const t=n.regex.exec(e);if(t&&t.index===a&&t[0].length>0){r=!0;break}}if(r)break;if(a++,h++,h>=l)break}n.push({text:e.slice(i,a),type:s||null}),i=a}}return n}(e,r),l.map(e=>{const t=i(e.text);return e.type?`<span class="token ${e.type}">${t}</span>`:t}).join("");var l}(this.code,t||this.language)}this.updateCodeDisplay(),this.dispatchAfterHighlightEvent()}catch(e){console.error("Syntax highlighting failed:",e)}}constructor(){super(...arguments),this.code=(r(this,D),""),this.language=r(this,W,"plaintext"),this.showLineNumbers=(r(this,J),r(this,K,!1)),this.startLine=(r(this,Q),r(this,X,1)),this.highlightLines=(r(this,Y),r(this,Z,[])),this.copyable=(r(this,ee),r(this,te,!0)),this.filename=(r(this,ae),r(this,re,"")),this.grammar=(r(this,ne),r(this,oe,"")),this.fetchMode=(r(this,ce),r(this,ie,"native")),this.format=(r(this,se),r(this,le,"")),this.theme=(r(this,he),r(this,de,"")),this.highlighter=r(this,be),this.copied=!1,this.highlightedCode="",this.loadedGrammar=null,this.loadedGrammarUrl=null,this.highlightVersion=0,this.codeEl=r(this,ge,void 0),this.headerEl=(r(this,me),r(this,ue,void 0)),this.filenameEl=(r(this,pe),r(this,fe,void 0)),this.copyBtn=(r(this,ve),r(this,_e,void 0)),r(this,ye)}},d})();return e.SniceCodeBlock=d,e}({},Snice);
|
|
18
|
+
`}styles(){return t.css`${":host([hidden]){display:none}:host{display:block;--_cb-bg:var(--snice-color-surface-container, #282c34);--_cb-text:var(--snice-color-text-secondary, #abb2bf);--_cb-header-bg:var(--snice-color-surface-container-low, #21252b);--_cb-header-border:var(--snice-color-border, rgb(51 56 66));--_cb-header-text:var(--snice-color-text-tertiary, #9da5b4);--_cb-btn-border:var(--snice-color-border, rgb(75 82 99));--_cb-btn-hover-bg:var(--snice-color-surface-hover, rgb(51 56 66));--_cb-btn-hover-border:var(--snice-color-border-hover, rgb(92 99 112));--_cb-line-number:var(--snice-color-text-tertiary, #636d83);--_cb-highlight-bg:rgb(255 255 255 / 0.07);--_cb-keyword:#c678dd;--_cb-function:#61afef;--_cb-string:#98c379;--_cb-number:#d19a66;--_cb-comment:#6a9955;--_cb-operator:#56b6c2;--_cb-punctuation:#abb2bf;--_cb-tag:#e06c75;--_cb-attr-name:#d19a66;--_cb-attr-value:#98c379;--_cb-constant:#d19a66;--_cb-class:#e5c07b;--_cb-builtin:#e06c75;--_cb-regex:#98c379}@media (prefers-color-scheme:light){:host(:not([theme])){--_cb-bg:var(--snice-color-surface-container, #fafafa);--_cb-text:var(--snice-color-text, #383a42);--_cb-header-bg:var(--snice-color-surface-container-low, #eaeaeb);--_cb-header-border:var(--snice-color-border, rgb(208 208 208));--_cb-header-text:var(--snice-color-text-tertiary, #696c77);--_cb-btn-border:var(--snice-color-border, rgb(192 192 192));--_cb-btn-hover-bg:var(--snice-color-surface-hover, rgb(216 216 217));--_cb-btn-hover-border:var(--snice-color-border-hover, rgb(160 160 160));--_cb-line-number:var(--snice-color-text-tertiary, #9d9d9f);--_cb-highlight-bg:rgb(0 0 0 / 0.05);--_cb-keyword:#a626a4;--_cb-function:#4078f2;--_cb-string:#50a14f;--_cb-number:#986801;--_cb-comment:#a0a1a7;--_cb-operator:#0184bc;--_cb-punctuation:#383a42;--_cb-tag:#e45649;--_cb-attr-name:#986801;--_cb-attr-value:#50a14f;--_cb-constant:#986801;--_cb-class:#c18401;--_cb-builtin:#e45649;--_cb-regex:#50a14f}}:host-context([data-theme=dark]){--_cb-bg:var(--snice-color-surface-container, #282c34);--_cb-text:var(--snice-color-text-secondary, #abb2bf);--_cb-header-bg:var(--snice-color-surface-container-low, #21252b);--_cb-header-border:var(--snice-color-border, rgb(51 56 66));--_cb-header-text:var(--snice-color-text-tertiary, #9da5b4);--_cb-btn-border:var(--snice-color-border, rgb(75 82 99));--_cb-btn-hover-bg:var(--snice-color-surface-hover, rgb(51 56 66));--_cb-btn-hover-border:var(--snice-color-border-hover, rgb(92 99 112));--_cb-line-number:var(--snice-color-text-tertiary, #636d83);--_cb-highlight-bg:rgb(255 255 255 / 0.07);--_cb-keyword:#c678dd;--_cb-function:#61afef;--_cb-string:#98c379;--_cb-number:#d19a66;--_cb-comment:#6a9955;--_cb-operator:#56b6c2;--_cb-punctuation:#abb2bf;--_cb-tag:#e06c75;--_cb-attr-name:#d19a66;--_cb-attr-value:#98c379;--_cb-constant:#d19a66;--_cb-class:#e5c07b;--_cb-builtin:#e06c75;--_cb-regex:#98c379}:host-context([data-theme=light]){--_cb-bg:var(--snice-color-surface-container, #fafafa);--_cb-text:var(--snice-color-text, #383a42);--_cb-header-bg:var(--snice-color-surface-container-low, #eaeaeb);--_cb-header-border:var(--snice-color-border, rgb(208 208 208));--_cb-header-text:var(--snice-color-text-tertiary, #696c77);--_cb-btn-border:var(--snice-color-border, rgb(192 192 192));--_cb-btn-hover-bg:var(--snice-color-surface-hover, rgb(216 216 217));--_cb-btn-hover-border:var(--snice-color-border-hover, rgb(160 160 160));--_cb-line-number:var(--snice-color-text-tertiary, #9d9d9f);--_cb-highlight-bg:rgb(0 0 0 / 0.05);--_cb-keyword:#a626a4;--_cb-function:#4078f2;--_cb-string:#50a14f;--_cb-number:#986801;--_cb-comment:#a0a1a7;--_cb-operator:#0184bc;--_cb-punctuation:#383a42;--_cb-tag:#e45649;--_cb-attr-name:#986801;--_cb-attr-value:#50a14f;--_cb-constant:#986801;--_cb-class:#c18401;--_cb-builtin:#e45649;--_cb-regex:#50a14f}:host([theme=dark]){--_cb-bg:var(--snice-color-surface-container, #282c34);--_cb-text:var(--snice-color-text-secondary, #abb2bf);--_cb-header-bg:var(--snice-color-surface-container-low, #21252b);--_cb-header-border:var(--snice-color-border, rgb(51 56 66));--_cb-header-text:var(--snice-color-text-tertiary, #9da5b4);--_cb-btn-border:var(--snice-color-border, rgb(75 82 99));--_cb-btn-hover-bg:var(--snice-color-surface-hover, rgb(51 56 66));--_cb-btn-hover-border:var(--snice-color-border-hover, rgb(92 99 112));--_cb-line-number:var(--snice-color-text-tertiary, #636d83);--_cb-highlight-bg:rgb(255 255 255 / 0.07);--_cb-keyword:#c678dd;--_cb-function:#61afef;--_cb-string:#98c379;--_cb-number:#d19a66;--_cb-comment:#6a9955;--_cb-operator:#56b6c2;--_cb-punctuation:#abb2bf;--_cb-tag:#e06c75;--_cb-attr-name:#d19a66;--_cb-attr-value:#98c379;--_cb-constant:#d19a66;--_cb-class:#e5c07b;--_cb-builtin:#e06c75;--_cb-regex:#98c379}:host([theme=light]){--_cb-bg:var(--snice-color-surface-container, #fafafa);--_cb-text:var(--snice-color-text, #383a42);--_cb-header-bg:var(--snice-color-surface-container-low, #eaeaeb);--_cb-header-border:var(--snice-color-border, rgb(208 208 208));--_cb-header-text:var(--snice-color-text-tertiary, #696c77);--_cb-btn-border:var(--snice-color-border, rgb(192 192 192));--_cb-btn-hover-bg:var(--snice-color-surface-hover, rgb(216 216 217));--_cb-btn-hover-border:var(--snice-color-border-hover, rgb(160 160 160));--_cb-line-number:var(--snice-color-text-tertiary, #9d9d9f);--_cb-highlight-bg:rgb(0 0 0 / 0.05);--_cb-keyword:#a626a4;--_cb-function:#4078f2;--_cb-string:#50a14f;--_cb-number:#986801;--_cb-comment:#a0a1a7;--_cb-operator:#0184bc;--_cb-punctuation:#383a42;--_cb-tag:#e45649;--_cb-attr-name:#986801;--_cb-attr-value:#50a14f;--_cb-constant:#986801;--_cb-class:#c18401;--_cb-builtin:#e45649;--_cb-regex:#50a14f}.code-block{position:relative;background:var(--code-block-bg,var(--_cb-bg));border-radius:var(--snice-border-radius-md,.375rem);overflow:hidden}.code-block__header{font-family:var(--snice-font-family-display, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif);display:flex;justify-content:space-between;align-items:center;padding:var(--snice-spacing-sm,.75rem) var(--snice-spacing-md,1rem);background:var(--code-block-header-bg,var(--_cb-header-bg));border-bottom:1px solid var(--_cb-header-border)}.code-block__filename{font-size:var(--snice-font-size-sm, .875rem);color:var(--_cb-header-text);font-family:var(--snice-font-family-mono, monospace)}.code-block__copy{background:0 0;border:1px solid var(--_cb-btn-border);color:var(--_cb-header-text);padding:.25rem .5rem;border-radius:var(--snice-border-radius-sm,.25rem);cursor:pointer;font-size:var(--snice-font-size-xs, .75rem);transition:all var(--snice-transition-fast, 150ms)}.code-block__copy:hover{background:var(--_cb-btn-hover-bg);border-color:var(--_cb-btn-hover-border)}.code-block__copy--copied{background:var(--snice-color-success,rgb(22 163 74));border-color:var(--snice-color-success,rgb(22 163 74));color:var(--snice-color-text-inverse,rgb(250 250 250))}.code-block__content{overflow-x:auto}.code-block__pre{margin:0;padding:var(--snice-spacing-md,1rem);background:0 0;overflow-x:auto}.code-block__code{font-family:var(--snice-font-family-mono, 'Courier New', monospace);font-size:var(--snice-font-size-sm, .875rem);line-height:1.5;color:var(--code-block-text,var(--_cb-text));display:block}.code-block__line{display:block}.code-block__line--highlight{background:var(--_cb-highlight-bg);border-left:3px solid var(--snice-color-primary,rgb(37 99 235));padding-left:calc(var(--snice-spacing-sm,.75rem) - 3px);margin-left:calc(-1 * var(--snice-spacing-md,1rem));padding-right:var(--snice-spacing-md,1rem)}.code-block__line-number{display:inline-block;width:3rem;text-align:right;margin-right:var(--snice-spacing-md,1rem);color:var(--_cb-line-number);user-select:none}.token.keyword{color:var(--code-keyword-color,var(--_cb-keyword))}.token.function{color:var(--code-function-color,var(--_cb-function))}.token.string{color:var(--code-string-color,var(--_cb-string))}.token.number{color:var(--code-number-color,var(--_cb-number))}.token.comment{color:var(--code-comment-color,var(--_cb-comment));font-style:italic}.token.operator{color:var(--code-operator-color,var(--_cb-operator))}.token.punctuation{color:var(--code-punctuation-color,var(--_cb-punctuation))}.token.tag{color:var(--code-tag-color,var(--_cb-tag))}.token.attr-name,.token.property{color:var(--code-attr-name-color,var(--_cb-attr-name))}.token.attr-value{color:var(--code-attr-value-color,var(--_cb-attr-value))}.token.boolean,.token.constant{color:var(--code-constant-color,var(--_cb-constant))}.token.class-name{color:var(--code-class-color,var(--_cb-class))}.token.builtin{color:var(--code-builtin-color,var(--_cb-builtin))}.token.regex{color:var(--code-regex-color,var(--_cb-regex))}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}@media (prefers-reduced-motion:reduce){*{transition-duration:0s!important;animation-duration:0s!important}}"}`}async onReady(){this.updateHeader(),this.code||this.readSlottedContent(),this.code&&await this.highlight()}handleSlotChange(){this.readSlottedContent()}readSlottedContent(){const e=this.textContent;if(!e)return;const t=function(e){const t=e.replace(/^\n+/,"").replace(/\n\s*$/,"").split("\n");if(0===t.length)return"";const a=t.filter(e=>e.trim()).map(e=>e.match(/^(\s*)/)?.[1].length??0);if(0===a.length)return t.join("\n");const r=Math.min(...a);return 0===r?t.join("\n"):t.map(e=>e.slice(r)).join("\n")}(e);t&&(this.code=t,this.highlight())}onGrammarChange(){this.loadedGrammar=null,this.loadedGrammarUrl=null,this.code&&this.highlight()}onFetchModeChange(){this.loadedGrammar=null,this.loadedGrammarUrl=null,this.code&&this.highlight()}onFormatChange(){this.code&&this.highlight()}updateHeader(){this.headerEl&&(this.headerEl.style.display=this.filename||this.copyable?"":"none",this.filenameEl&&(this.filenameEl.textContent=this.filename),this.copyBtn&&(this.copyBtn.style.display=this.copyable?"":"none"))}onLanguageChange(){this.codeEl&&(this.codeEl.className=`code-block__code language-${this.language}`,this.codeEl.setAttribute("data-language",this.language))}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}updateCodeDisplay(){if(!this.codeEl)return;const e=this.highlightedCode||this.escapeHtml(this.code);if(this.showLineNumbers||this.highlightLines.length>0){const t=e.split("\n").map((e,t)=>{const a=this.startLine+t;return`<span class="${["code-block__line",this.highlightLines.includes(a)?"code-block__line--highlight":""].filter(Boolean).join(" ")}">${this.showLineNumbers?`<span class="code-block__line-number">${a}</span>`:""}${e}\n</span>`}).join("");this.codeEl.innerHTML=t}else this.codeEl.innerHTML=e}async copy(){try{await navigator.clipboard.writeText(this.code),this.copied=!0,this.dispatchCopyEvent(),this.copyBtn&&(this.copyBtn.textContent="Copied!"),setTimeout(()=>{this.copied=!1,this.copyBtn&&(this.copyBtn.textContent="Copy")},2e3)}catch(e){console.error("Failed to copy code:",e)}}setHighlighter(e){this.highlighter=e}setFormatter(e){this.formatter=e}setGrammar(e){this.loadedGrammar=e,this.loadedGrammarUrl=null,this.dispatchGrammarLoadedEvent(e,""),this.code&&this.highlight()}async resolveGrammar(){if(this.loadedGrammar)return this.loadedGrammar;if(!this.grammar)return null;try{switch(this.fetchMode){case"native":{const e=await function(e){let t=l.get(e);return t||(t=fetch(e).then(e=>e.json()).catch(t=>{throw l.delete(e),t}),l.set(e,t)),t}(this.grammar);return e&&(this.loadedGrammar=e,this.loadedGrammarUrl=this.grammar,this.dispatchGrammarLoadedEvent(e,this.grammar)),e}case"virtual":{const e=await this.requestGrammar(this.grammar);return e&&(this.loadedGrammar=e,this.loadedGrammarUrl=this.grammar,this.dispatchGrammarLoadedEvent(e,this.grammar)),e}case"event":return this.dispatchGrammarRequestEvent(),null;default:return null}}catch(e){return console.error(`Failed to load grammar from ${this.grammar}:`,e),null}}async highlight(){if(!this.code)return;const e=++this.highlightVersion;let t=this.formatter;if(!t&&this.format){const a=await this.resolveGrammar();if(e!==this.highlightVersion)return;if(a?.formatters?.[this.format]){const e=a.formatters[this.format];t=t=>function(e,t){const a=t.useTabs?"\t":" ".repeat(t.tabSize??2),r=t.skipStrings??!0,n=t.skipComments??!0,o=t.newlineAfter?new RegExp(t.newlineAfter):null,c=t.newlineBefore?new RegExp(t.newlineBefore):null,i=t.spaceAfter?new RegExp(t.spaceAfter):null,s=t.spaceBefore?new RegExp(t.spaceBefore):null,l=t.spaceAround?new RegExp(t.spaceAround):null,h=t.indent?new RegExp(t.indent):null,d=t.dedent?new RegExp(t.dedent):null,b=/[[\],]/,m=[];let g="",u=!1,p=!1,f=!1,v=!1,_=0,y=0,k=0;const x=[];let E=null,w=!1,C=!1;const B=e=>y>0||k>0&&!b.test(e),G=()=>{g="",u=!1,p=!0,v=!1,f=null!==E||w,x.length>0&&(x[x.length-1]=!0)},L=()=>{m.push(g.replace(/[ \t]+$/,"")),G()},S=e=>{p&&(p=!1,f||(g+=a.repeat(_))),v&&(g+=" ",v=!1),g+=e,u=!0};G();for(let t=0;t<e.length;t++){const a=e[t],b=t+1<e.length?e[t+1]:"";if(C){"\n"===a?(C=!1,L()):S(a);continue}if(w){if("\n"===a){L();continue}S(a),"/"===a&&"*"===e[t-1]&&(w=!1);continue}if(E){if("\n"===a){L();continue}S(a),a===E&&"\\"!==e[t-1]&&(E=null);continue}if(r&&('"'===a||"'"===a||"`"===a)){E=a,S(a);continue}if(n){if("/"===a&&"/"===b){C=!0,S(a);continue}if("/"===a&&"*"===b){w=!0,S(a);continue}}if("\n"===a){L();continue}if("\r"===a){"\n"!==b&&L();continue}if(" "===a||"\t"===a){u&&(v=!0);continue}"("===a?y++:")"===a?y=Math.max(0,y-1):"["===a?k++:"]"===a&&(k=Math.max(0,k-1));let m=!1;d&&d.test(a)&&(_=Math.max(0,_-1),m=x.pop()??!1),!(c&&c.test(a)&&u)||B(a)||d&&d.test(a)&&!m||L();const g=t>0?e[t-1]:"",p=""!==g&&!/[ \t\n\r]/.test(g)&&/[+\-*/%=<>!&|^~?:]/.test(g);if((s&&s.test(a)||l&&l.test(a))&&u&&!p&&(v=!0),S(a),h&&h.test(a)&&(_++,x.push(!1)),(i&&i.test(a)||l&&l.test(a))&&b&&" "!==b&&"\t"!==b&&"\n"!==b&&"\r"!==b&&("="!==a||"="!==b&&">"!==b)&&(v=!0),o&&o.test(a)&&!B(a)){let a=t+1;for(;a<e.length&&(" "===e[a]||"\t"===e[a]);)a++;const r=a<e.length?e[a]:"";""===r||"\n"===r||"\r"===r||"/"===r&&("/"===e[a+1]||"*"===e[a+1])||L()}}m.push(g.replace(/[ \t]+$/,""));let H=m;for((t.trimTrailing??1)&&(H=H.map(e=>e.replace(/[ \t]+$/,""))),void 0!==t.collapseBlankLines&&(H=function(e,t){const a=[];let r=0;for(const n of e)""===n.trim()?(r++,r<=t&&a.push(n)):(r=0,a.push(n));return a}(H,t.collapseBlankLines));H.length>0&&""===H[0].trim();)H.shift();for(;H.length>0&&""===H[H.length-1].trim();)H.pop();return H.join("\n")}(t,e)}}if(t&&this.format){this.dispatchBeforeFormatEvent();try{const a=await t(this.code,this.language);if(e!==this.highlightVersion)return;this.code=a,this.dispatchAfterFormatEvent()}catch(e){console.error("Code formatting failed:",e)}}this.dispatchBeforeHighlightEvent();try{if(this.highlighter){const t=this.escapeHtml(this.code).split("\n"),a=await Promise.all(t.map(e=>this.highlighter(e,this.language)));if(e!==this.highlightVersion)return;this.highlightedCode=a.join("\n")}else{const t=await this.resolveGrammar();if(e!==this.highlightVersion)return;this.highlightedCode=function(e,t){const a="string"==typeof t?function(e){return s.get(e.toLowerCase())}(t):t;if(!a)return i(e);const r=function(e){const t=n.get(e);if(t)return t;const a=new Map,r=e.ignoreCase?"yi":"y";for(const[t,n]of Object.entries(e.tokenizer)){const c=o(e,n,new Set).map(e=>({regex:new RegExp(e[0],r),token:e[1],nextState:e[2]}));a.set(t,c)}const c={grammar:e,states:a};return n.set(e,c),c}(a);return l=function(e,t){const{grammar:a,states:r}=t,n=[],o=["root"];let i=0;const s=a.defaultToken||"",l=10*e.length;let h=0;for(;i<e.length&&h<l;){h++;const t=r.get(o[o.length-1]);if(!t){n.push({text:e[i],type:s||null}),i++;continue}let d=!1;for(const r of t){r.regex.lastIndex=i;const t=r.regex.exec(e);if(t&&t.index===i&&t[0].length>0){const e=c(a,r.token,t[0]);if(n.push({text:t[0],type:e||null}),i+=t[0].length,r.nextState)if("@pop"===r.nextState)o.length>1&&o.pop();else{const e=r.nextState.replace(/^@/,"");o.push(e)}d=!0;break}}if(!d){let a=i+1;for(;a<e.length;){let r=!1;for(const n of t){n.regex.lastIndex=a;const t=n.regex.exec(e);if(t&&t.index===a&&t[0].length>0){r=!0;break}}if(r)break;if(a++,h++,h>=l)break}n.push({text:e.slice(i,a),type:s||null}),i=a}}return n}(e,r),l.map(e=>{const t=i(e.text);return e.type?`<span class="token ${e.type}">${t}</span>`:t}).join("");var l}(this.code,t||this.language)}this.updateCodeDisplay(),this.dispatchAfterHighlightEvent()}catch(e){console.error("Syntax highlighting failed:",e)}}constructor(){super(...arguments),this.code=(r(this,P),""),this.language=r(this,D,"plaintext"),this.showLineNumbers=(r(this,W),r(this,J,!1)),this.startLine=(r(this,K),r(this,Q,1)),this.highlightLines=(r(this,X),r(this,Y,[])),this.copyable=(r(this,Z),r(this,ee,!0)),this.filename=(r(this,te),r(this,ae,"")),this.grammar=(r(this,re),r(this,ne,"")),this.fetchMode=(r(this,oe),r(this,ce,"native")),this.format=(r(this,ie),r(this,se,"")),this.theme=(r(this,le),r(this,he,"")),this.highlighter=r(this,de),this.copied=!1,this.highlightedCode="",this.loadedGrammar=null,this.loadedGrammarUrl=null,this.highlightVersion=0,this.codeEl=r(this,be,void 0),this.headerEl=(r(this,me),r(this,ge,void 0)),this.filenameEl=(r(this,ue),r(this,pe,void 0)),this.copyBtn=(r(this,fe),r(this,ve,void 0)),r(this,_e)}},h})();return e.SniceCodeBlock=h,e}({},Snice);
|
|
19
19
|
//# sourceMappingURL=snice-code-block.min.js.map
|