snice 5.0.0 → 5.1.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/adapters/react/SniceProvider.js +1 -1
- package/adapters/react/SniceRouter.js +1 -1
- package/adapters/react/matchRoute.js +1 -1
- package/adapters/react/useRequestHandler.js +1 -1
- package/bin/templates/default/package.json +1 -1
- package/bin/templates/react/package.json +1 -1
- package/dist/cdn/accordion/snice-accordion.js +1 -1
- package/dist/cdn/accordion/snice-accordion.min.js +1 -1
- package/dist/cdn/action-bar/snice-action-bar.js +1 -1
- package/dist/cdn/action-bar/snice-action-bar.min.js +1 -1
- package/dist/cdn/activity-feed/snice-activity-feed.js +1 -1
- package/dist/cdn/activity-feed/snice-activity-feed.min.js +1 -1
- package/dist/cdn/alert/snice-alert.js +1 -1
- package/dist/cdn/alert/snice-alert.min.js +1 -1
- package/dist/cdn/app-tiles/snice-app-tiles.js +1 -1
- package/dist/cdn/app-tiles/snice-app-tiles.min.js +1 -1
- package/dist/cdn/approval-flow/snice-approval-flow.js +1 -1
- package/dist/cdn/approval-flow/snice-approval-flow.min.js +1 -1
- package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
- package/dist/cdn/audio-recorder/snice-audio-recorder.min.js +1 -1
- package/dist/cdn/availability/snice-availability.js +1 -1
- package/dist/cdn/availability/snice-availability.min.js +1 -1
- package/dist/cdn/avatar/snice-avatar.js +1 -1
- package/dist/cdn/avatar/snice-avatar.min.js +1 -1
- package/dist/cdn/avatar-group/snice-avatar-group.js +1 -1
- package/dist/cdn/avatar-group/snice-avatar-group.min.js +1 -1
- package/dist/cdn/badge/snice-badge.js +1 -1
- package/dist/cdn/badge/snice-badge.min.js +1 -1
- package/dist/cdn/banner/snice-banner.js +1 -1
- package/dist/cdn/banner/snice-banner.min.js +1 -1
- package/dist/cdn/binpack/snice-binpack.js +1 -1
- package/dist/cdn/binpack/snice-binpack.min.js +1 -1
- package/dist/cdn/book/snice-book.js +1 -1
- package/dist/cdn/book/snice-book.min.js +1 -1
- package/dist/cdn/booking/snice-booking.js +1 -1
- package/dist/cdn/booking/snice-booking.min.js +1 -1
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +1 -1
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.min.js +1 -1
- package/dist/cdn/button/snice-button.js +1 -1
- package/dist/cdn/button/snice-button.min.js +1 -1
- package/dist/cdn/calendar/snice-calendar.js +1 -1
- package/dist/cdn/calendar/snice-calendar.min.js +1 -1
- package/dist/cdn/camera/snice-camera.js +1 -1
- package/dist/cdn/camera/snice-camera.min.js +1 -1
- package/dist/cdn/camera-annotate/snice-camera-annotate.js +1 -1
- package/dist/cdn/camera-annotate/snice-camera-annotate.min.js +1 -1
- package/dist/cdn/candlestick/snice-candlestick.js +1 -1
- package/dist/cdn/candlestick/snice-candlestick.min.js +1 -1
- package/dist/cdn/card/snice-card.js +1 -1
- package/dist/cdn/card/snice-card.min.js +1 -1
- package/dist/cdn/carousel/snice-carousel.js +1 -1
- package/dist/cdn/carousel/snice-carousel.min.js +1 -1
- package/dist/cdn/cart/snice-cart.js +1 -1
- package/dist/cdn/cart/snice-cart.min.js +1 -1
- package/dist/cdn/chart/snice-chart.js +1 -1
- package/dist/cdn/chart/snice-chart.min.js +1 -1
- package/dist/cdn/chat/snice-chat.js +1 -1
- package/dist/cdn/chat/snice-chat.min.js +1 -1
- package/dist/cdn/checkbox/snice-checkbox.js +1 -1
- package/dist/cdn/checkbox/snice-checkbox.min.js +1 -1
- package/dist/cdn/chip/snice-chip.js +1 -1
- package/dist/cdn/chip/snice-chip.min.js +1 -1
- package/dist/cdn/code-block/snice-code-block.js +1 -1
- package/dist/cdn/code-block/snice-code-block.min.js +1 -1
- package/dist/cdn/color-display/snice-color-display.js +1 -1
- package/dist/cdn/color-display/snice-color-display.min.js +1 -1
- package/dist/cdn/color-picker/snice-color-picker.js +1 -1
- package/dist/cdn/color-picker/snice-color-picker.min.js +1 -1
- package/dist/cdn/command-palette/snice-command-palette.js +1 -1
- package/dist/cdn/command-palette/snice-command-palette.min.js +1 -1
- package/dist/cdn/comments/snice-comments.js +1 -1
- package/dist/cdn/comments/snice-comments.min.js +1 -1
- package/dist/cdn/countdown/snice-countdown.js +1 -1
- package/dist/cdn/countdown/snice-countdown.min.js +1 -1
- package/dist/cdn/cropper/snice-cropper.js +1 -1
- package/dist/cdn/cropper/snice-cropper.min.js +1 -1
- package/dist/cdn/data-card/snice-data-card.js +1 -1
- package/dist/cdn/data-card/snice-data-card.min.js +1 -1
- package/dist/cdn/date-picker/snice-date-picker.js +1 -1
- package/dist/cdn/date-picker/snice-date-picker.min.js +1 -1
- package/dist/cdn/date-range-picker/snice-date-range-picker.js +1 -1
- package/dist/cdn/date-range-picker/snice-date-range-picker.min.js +1 -1
- package/dist/cdn/date-time-picker/snice-date-time-picker.js +1 -1
- package/dist/cdn/date-time-picker/snice-date-time-picker.min.js +1 -1
- package/dist/cdn/diff/snice-diff.js +1 -1
- package/dist/cdn/diff/snice-diff.min.js +1 -1
- package/dist/cdn/divider/snice-divider.js +1 -1
- package/dist/cdn/divider/snice-divider.min.js +1 -1
- package/dist/cdn/doc/snice-doc.js +1 -1
- package/dist/cdn/doc/snice-doc.min.js +1 -1
- package/dist/cdn/draw/snice-draw.js +1 -1
- package/dist/cdn/draw/snice-draw.min.js +1 -1
- package/dist/cdn/drawer/snice-drawer.js +1 -1
- package/dist/cdn/drawer/snice-drawer.min.js +1 -1
- package/dist/cdn/empty-state/snice-empty-state.js +1 -1
- package/dist/cdn/empty-state/snice-empty-state.min.js +1 -1
- package/dist/cdn/estimate/snice-estimate.js +1 -1
- package/dist/cdn/estimate/snice-estimate.min.js +1 -1
- package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
- package/dist/cdn/file-gallery/snice-file-gallery.min.js +1 -1
- package/dist/cdn/file-upload/snice-file-upload.js +1 -1
- package/dist/cdn/file-upload/snice-file-upload.min.js +1 -1
- package/dist/cdn/flip-card/snice-flip-card.js +1 -1
- package/dist/cdn/flip-card/snice-flip-card.min.js +1 -1
- package/dist/cdn/flow/snice-flow.js +1 -1
- package/dist/cdn/flow/snice-flow.min.js +1 -1
- package/dist/cdn/form-layout/snice-form-layout.js +1 -1
- package/dist/cdn/form-layout/snice-form-layout.min.js +1 -1
- package/dist/cdn/funnel/snice-funnel.js +1 -1
- package/dist/cdn/funnel/snice-funnel.min.js +1 -1
- package/dist/cdn/gantt/snice-gantt.js +1 -1
- package/dist/cdn/gantt/snice-gantt.min.js +1 -1
- package/dist/cdn/gauge/snice-gauge.js +1 -1
- package/dist/cdn/gauge/snice-gauge.min.js +1 -1
- package/dist/cdn/grid/snice-grid.js +1 -1
- package/dist/cdn/grid/snice-grid.min.js +1 -1
- package/dist/cdn/heatmap/snice-heatmap.js +1 -1
- package/dist/cdn/heatmap/snice-heatmap.min.js +1 -1
- package/dist/cdn/image/snice-image.js +1 -1
- package/dist/cdn/image/snice-image.min.js +1 -1
- package/dist/cdn/input/snice-input.js +1 -1
- package/dist/cdn/input/snice-input.min.js +1 -1
- package/dist/cdn/invoice/snice-invoice.js +1 -1
- package/dist/cdn/invoice/snice-invoice.min.js +1 -1
- package/dist/cdn/kanban/snice-kanban.js +1 -1
- package/dist/cdn/kanban/snice-kanban.min.js +1 -1
- package/dist/cdn/key-value/snice-key-value.js +1 -1
- package/dist/cdn/key-value/snice-key-value.min.js +1 -1
- package/dist/cdn/kpi/snice-kpi.js +1 -1
- package/dist/cdn/kpi/snice-kpi.min.js +1 -1
- package/dist/cdn/layout/snice-layout.js +1 -1
- package/dist/cdn/layout/snice-layout.min.js +1 -1
- package/dist/cdn/leaderboard/snice-leaderboard.js +1 -1
- package/dist/cdn/leaderboard/snice-leaderboard.min.js +1 -1
- package/dist/cdn/link/snice-link.js +1 -1
- package/dist/cdn/link/snice-link.min.js +1 -1
- package/dist/cdn/link-preview/snice-link-preview.js +1 -1
- package/dist/cdn/link-preview/snice-link-preview.min.js +1 -1
- package/dist/cdn/list/snice-list.js +1 -1
- package/dist/cdn/list/snice-list.min.js +1 -1
- package/dist/cdn/location/snice-location.js +1 -1
- package/dist/cdn/location/snice-location.min.js +1 -1
- package/dist/cdn/login/snice-login.js +1 -1
- package/dist/cdn/login/snice-login.min.js +1 -1
- package/dist/cdn/map/snice-map.js +1 -1
- package/dist/cdn/map/snice-map.min.js +1 -1
- package/dist/cdn/markdown/snice-markdown.js +1 -1
- package/dist/cdn/markdown/snice-markdown.min.js +1 -1
- package/dist/cdn/masonry/snice-masonry.js +1 -1
- package/dist/cdn/masonry/snice-masonry.min.js +1 -1
- package/dist/cdn/menu/snice-menu.js +1 -1
- package/dist/cdn/menu/snice-menu.min.js +1 -1
- package/dist/cdn/message-strip/snice-message-strip.js +1 -1
- package/dist/cdn/message-strip/snice-message-strip.min.js +1 -1
- package/dist/cdn/metric-table/snice-metric-table.js +1 -1
- package/dist/cdn/metric-table/snice-metric-table.min.js +1 -1
- package/dist/cdn/modal/snice-modal.js +1 -1
- package/dist/cdn/modal/snice-modal.min.js +1 -1
- package/dist/cdn/music-player/snice-music-player.js +1 -1
- package/dist/cdn/music-player/snice-music-player.min.js +1 -1
- package/dist/cdn/nav/snice-nav.js +1 -1
- package/dist/cdn/nav/snice-nav.min.js +1 -1
- package/dist/cdn/network-graph/snice-network-graph.js +1 -1
- package/dist/cdn/network-graph/snice-network-graph.min.js +1 -1
- package/dist/cdn/notification-center/snice-notification-center.js +1 -1
- package/dist/cdn/notification-center/snice-notification-center.min.js +1 -1
- package/dist/cdn/order-tracker/snice-order-tracker.js +1 -1
- package/dist/cdn/order-tracker/snice-order-tracker.min.js +1 -1
- package/dist/cdn/org-chart/snice-org-chart.js +1 -1
- package/dist/cdn/org-chart/snice-org-chart.min.js +1 -1
- package/dist/cdn/pagination/snice-pagination.js +1 -1
- package/dist/cdn/pagination/snice-pagination.min.js +1 -1
- package/dist/cdn/paint/snice-paint.js +1 -1
- package/dist/cdn/paint/snice-paint.min.js +1 -1
- package/dist/cdn/pdf-viewer/snice-pdf-viewer.js +1 -1
- package/dist/cdn/pdf-viewer/snice-pdf-viewer.min.js +1 -1
- package/dist/cdn/permission-matrix/snice-permission-matrix.js +1 -1
- package/dist/cdn/permission-matrix/snice-permission-matrix.min.js +1 -1
- package/dist/cdn/podcast-player/snice-podcast-player.js +1 -1
- package/dist/cdn/podcast-player/snice-podcast-player.min.js +1 -1
- package/dist/cdn/popover/snice-popover.js +1 -1
- package/dist/cdn/popover/snice-popover.min.js +1 -1
- package/dist/cdn/pricing-table/snice-pricing-table.js +1 -1
- package/dist/cdn/pricing-table/snice-pricing-table.min.js +1 -1
- package/dist/cdn/product-card/snice-product-card.js +1 -1
- package/dist/cdn/product-card/snice-product-card.min.js +1 -1
- package/dist/cdn/progress/snice-progress.js +1 -1
- package/dist/cdn/progress/snice-progress.min.js +1 -1
- package/dist/cdn/progress-ring/snice-progress-ring.js +1 -1
- package/dist/cdn/progress-ring/snice-progress-ring.min.js +1 -1
- package/dist/cdn/qr-code/snice-qr-code.js +1 -1
- package/dist/cdn/qr-code/snice-qr-code.min.js +1 -1
- package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
- package/dist/cdn/qr-reader/snice-qr-reader.min.js +1 -1
- package/dist/cdn/radio/snice-radio.js +1 -1
- package/dist/cdn/radio/snice-radio.min.js +1 -1
- package/dist/cdn/range-slider/snice-range-slider.js +1 -1
- package/dist/cdn/range-slider/snice-range-slider.min.js +1 -1
- package/dist/cdn/rating/snice-rating.js +1 -1
- package/dist/cdn/rating/snice-rating.min.js +1 -1
- package/dist/cdn/receipt/snice-receipt.js +1 -1
- package/dist/cdn/receipt/snice-receipt.min.js +1 -1
- package/dist/cdn/recipe/snice-recipe.js +1 -1
- package/dist/cdn/recipe/snice-recipe.min.js +1 -1
- package/dist/cdn/runtime/README.md +2 -2
- package/dist/cdn/runtime/snice-runtime.esm.js +104 -44
- package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.min.js +8 -8
- package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.js +104 -44
- package/dist/cdn/runtime/snice-runtime.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.min.js +8 -8
- package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
- package/dist/cdn/sankey/snice-sankey.js +1 -1
- package/dist/cdn/sankey/snice-sankey.min.js +1 -1
- package/dist/cdn/segmented-control/snice-segmented-control.js +1 -1
- package/dist/cdn/segmented-control/snice-segmented-control.min.js +1 -1
- package/dist/cdn/select/snice-select.js +1 -1
- package/dist/cdn/select/snice-select.min.js +1 -1
- package/dist/cdn/skeleton/snice-skeleton.js +1 -1
- package/dist/cdn/skeleton/snice-skeleton.min.js +1 -1
- package/dist/cdn/slider/snice-slider.js +1 -1
- package/dist/cdn/slider/snice-slider.min.js +1 -1
- package/dist/cdn/sortable/snice-sortable.js +1 -1
- package/dist/cdn/sortable/snice-sortable.min.js +1 -1
- package/dist/cdn/sparkline/snice-sparkline.js +1 -1
- package/dist/cdn/sparkline/snice-sparkline.min.js +1 -1
- package/dist/cdn/spinner/snice-spinner.js +1 -1
- package/dist/cdn/spinner/snice-spinner.min.js +1 -1
- package/dist/cdn/split-button/snice-split-button.js +1 -1
- package/dist/cdn/split-button/snice-split-button.min.js +1 -1
- package/dist/cdn/split-pane/snice-split-pane.js +1 -1
- package/dist/cdn/split-pane/snice-split-pane.min.js +1 -1
- package/dist/cdn/spotlight/snice-spotlight.js +1 -1
- package/dist/cdn/spotlight/snice-spotlight.min.js +1 -1
- package/dist/cdn/stat-group/snice-stat-group.js +1 -1
- package/dist/cdn/stat-group/snice-stat-group.min.js +1 -1
- package/dist/cdn/step-input/snice-step-input.js +1 -1
- package/dist/cdn/step-input/snice-step-input.min.js +1 -1
- package/dist/cdn/stepper/snice-stepper.js +1 -1
- package/dist/cdn/stepper/snice-stepper.min.js +1 -1
- package/dist/cdn/switch/snice-switch.js +1 -1
- package/dist/cdn/switch/snice-switch.min.js +1 -1
- package/dist/cdn/table/snice-table.js +1 -1
- package/dist/cdn/table/snice-table.min.js +1 -1
- package/dist/cdn/tabs/snice-tabs.js +1 -1
- package/dist/cdn/tabs/snice-tabs.min.js +1 -1
- package/dist/cdn/tag/snice-tag.js +1 -1
- package/dist/cdn/tag/snice-tag.min.js +1 -1
- package/dist/cdn/tag-input/snice-tag-input.js +1 -1
- package/dist/cdn/tag-input/snice-tag-input.min.js +1 -1
- package/dist/cdn/terminal/snice-terminal.js +1 -1
- package/dist/cdn/terminal/snice-terminal.min.js +1 -1
- package/dist/cdn/testimonial/snice-testimonial.js +1 -1
- package/dist/cdn/testimonial/snice-testimonial.min.js +1 -1
- package/dist/cdn/textarea/snice-textarea.js +1 -1
- package/dist/cdn/textarea/snice-textarea.min.js +1 -1
- package/dist/cdn/time-picker/snice-time-picker.js +1 -1
- package/dist/cdn/time-picker/snice-time-picker.min.js +1 -1
- package/dist/cdn/time-range-picker/snice-time-range-picker.js +1 -1
- package/dist/cdn/time-range-picker/snice-time-range-picker.min.js +1 -1
- package/dist/cdn/timeline/snice-timeline.js +1 -1
- package/dist/cdn/timeline/snice-timeline.min.js +1 -1
- package/dist/cdn/timer/snice-timer.js +1 -1
- package/dist/cdn/timer/snice-timer.min.js +1 -1
- package/dist/cdn/toast/snice-toast.js +1 -1
- package/dist/cdn/toast/snice-toast.min.js +1 -1
- package/dist/cdn/tooltip/snice-tooltip.js +1 -1
- package/dist/cdn/tooltip/snice-tooltip.min.js +1 -1
- package/dist/cdn/tree/snice-tree.js +1 -1
- package/dist/cdn/tree/snice-tree.min.js +1 -1
- package/dist/cdn/treemap/snice-treemap.js +1 -1
- package/dist/cdn/treemap/snice-treemap.min.js +1 -1
- package/dist/cdn/user-card/snice-user-card.js +1 -1
- package/dist/cdn/user-card/snice-user-card.min.js +1 -1
- package/dist/cdn/video-player/snice-video-player.js +1 -1
- package/dist/cdn/video-player/snice-video-player.min.js +1 -1
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +1 -1
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.min.js +1 -1
- package/dist/cdn/waterfall/snice-waterfall.js +1 -1
- package/dist/cdn/waterfall/snice-waterfall.min.js +1 -1
- package/dist/cdn/weather/snice-weather.js +1 -1
- package/dist/cdn/weather/snice-weather.min.js +1 -1
- package/dist/cdn/work-order/snice-work-order.js +1 -1
- package/dist/cdn/work-order/snice-work-order.min.js +1 -1
- package/dist/context.d.ts +17 -7
- package/dist/index.cjs +101 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +101 -41
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +101 -41
- package/dist/index.iife.js.map +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 +3 -1
- package/dist/symbols.cjs.map +1 -1
- package/dist/symbols.d.ts +1 -0
- package/dist/symbols.esm.js +3 -2
- package/dist/symbols.esm.js.map +1 -1
- package/dist/transitions.cjs +1 -1
- package/dist/transitions.esm.js +1 -1
- package/docs/ai/api.md +11 -5
- package/docs/ai/architecture.md +3 -5
- package/docs/ai/decorators.md +6 -1
- package/docs/ai/patterns.md +7 -13
- package/docs/elements.md +28 -21
- package/docs/routing.md +19 -10
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -15,23 +15,33 @@ export interface ContextOptions {
|
|
|
15
15
|
/**
|
|
16
16
|
* @context decorator for receiving router context updates
|
|
17
17
|
*
|
|
18
|
+
* Works on both methods and fields:
|
|
19
|
+
*
|
|
20
|
+
* - **Method form**: the method is invoked with the current Context on every
|
|
21
|
+
* update (and once at register time so the first render sees the context).
|
|
22
|
+
* - **Field form**: the field is overwritten with the current Context on
|
|
23
|
+
* every update (and once at register time). Pair with `@property` if you
|
|
24
|
+
* want assignment to also schedule a re-render.
|
|
25
|
+
*
|
|
18
26
|
* @example
|
|
19
27
|
* ```typescript
|
|
20
28
|
* @element('my-layout')
|
|
21
29
|
* class MyLayout extends HTMLElement {
|
|
22
|
-
*
|
|
30
|
+
* // Method form
|
|
31
|
+
* @context()
|
|
23
32
|
* handleContext(ctx: Context) {
|
|
24
|
-
* this.renderNav(ctx.placards, ctx.
|
|
33
|
+
* this.renderNav(ctx.navigation.placards, ctx.navigation.route);
|
|
25
34
|
* }
|
|
26
35
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
36
|
+
* // Field form — the field is populated before first render
|
|
37
|
+
* @context() ctx!: Context;
|
|
38
|
+
*
|
|
39
|
+
* // Field + @property — assignment also triggers re-render
|
|
40
|
+
* @property({ attribute: false }) @context() reactiveCtx!: Context;
|
|
31
41
|
* }
|
|
32
42
|
* ```
|
|
33
43
|
*/
|
|
34
|
-
export declare function context(options?: ContextOptions): (
|
|
44
|
+
export declare function context(options?: ContextOptions): (value: any, decoratorContext: ClassMethodDecoratorContext | ClassFieldDecoratorContext) => any;
|
|
35
45
|
/**
|
|
36
46
|
* Setup context handler for an element instance
|
|
37
47
|
* Called automatically during element connection
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* snice
|
|
2
|
+
* snice v5.0.0
|
|
3
3
|
* A decorator-driven web component library with differential rendering, routing, controllers, and 130+ ready-made UI components. Use as much or as little as you want. Zero dependencies, works anywhere.
|
|
4
4
|
* (c) 2024
|
|
5
5
|
* Released under the MIT License.
|
|
@@ -91,6 +91,7 @@ const CONTEXT_NOTIFY_ELEMENT = getSymbol('context-notify-element');
|
|
|
91
91
|
const CONTEXT_TIMER = getSymbol('context-timer');
|
|
92
92
|
const CONTEXT_CALLED = getSymbol('context-called');
|
|
93
93
|
const CONTEXT_UPDATE = getSymbol('context-update');
|
|
94
|
+
const WRAPPED_CONTEXT_HANDLERS = getSymbol('wrapped-context-handlers');
|
|
94
95
|
// Registration de-dup sets on the constructor — replace previous `__*Methods`
|
|
95
96
|
// expando strings that violated the no-double-underscore rule.
|
|
96
97
|
const CONTEXT_METHODS = getSymbol('context-methods');
|
|
@@ -266,13 +267,17 @@ class Context {
|
|
|
266
267
|
const names = elementsMap.get(element);
|
|
267
268
|
if (!names)
|
|
268
269
|
continue;
|
|
269
|
-
|
|
270
|
-
|
|
270
|
+
const wrapped = element[WRAPPED_CONTEXT_HANDLERS];
|
|
271
|
+
if (!wrapped)
|
|
272
|
+
continue;
|
|
273
|
+
for (const handlerName of names) {
|
|
274
|
+
const fn = wrapped.get(handlerName);
|
|
275
|
+
if (typeof fn === 'function') {
|
|
271
276
|
try {
|
|
272
|
-
|
|
277
|
+
fn(this);
|
|
273
278
|
}
|
|
274
279
|
catch (error) {
|
|
275
|
-
console.error(`Error calling @context
|
|
280
|
+
console.error(`Error calling @context handler ${handlerName}:`, error);
|
|
276
281
|
}
|
|
277
282
|
}
|
|
278
283
|
}
|
|
@@ -287,10 +292,13 @@ class Context {
|
|
|
287
292
|
const names = this[REGISTERED_ELEMENTS].get(element);
|
|
288
293
|
if (!names)
|
|
289
294
|
return;
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
295
|
+
const wrapped = element[WRAPPED_CONTEXT_HANDLERS];
|
|
296
|
+
if (!wrapped)
|
|
297
|
+
return;
|
|
298
|
+
for (const handlerName of names) {
|
|
299
|
+
const fn = wrapped.get(handlerName);
|
|
300
|
+
if (typeof fn === 'function')
|
|
301
|
+
fn(this);
|
|
294
302
|
}
|
|
295
303
|
}
|
|
296
304
|
}
|
|
@@ -2959,46 +2967,78 @@ const CONTEXT_HANDLERS = getSymbol('context-handlers');
|
|
|
2959
2967
|
/**
|
|
2960
2968
|
* @context decorator for receiving router context updates
|
|
2961
2969
|
*
|
|
2970
|
+
* Works on both methods and fields:
|
|
2971
|
+
*
|
|
2972
|
+
* - **Method form**: the method is invoked with the current Context on every
|
|
2973
|
+
* update (and once at register time so the first render sees the context).
|
|
2974
|
+
* - **Field form**: the field is overwritten with the current Context on
|
|
2975
|
+
* every update (and once at register time). Pair with `@property` if you
|
|
2976
|
+
* want assignment to also schedule a re-render.
|
|
2977
|
+
*
|
|
2962
2978
|
* @example
|
|
2963
2979
|
* ```typescript
|
|
2964
2980
|
* @element('my-layout')
|
|
2965
2981
|
* class MyLayout extends HTMLElement {
|
|
2966
|
-
*
|
|
2982
|
+
* // Method form
|
|
2983
|
+
* @context()
|
|
2967
2984
|
* handleContext(ctx: Context) {
|
|
2968
|
-
* this.renderNav(ctx.placards, ctx.
|
|
2985
|
+
* this.renderNav(ctx.navigation.placards, ctx.navigation.route);
|
|
2969
2986
|
* }
|
|
2970
2987
|
*
|
|
2971
|
-
*
|
|
2972
|
-
*
|
|
2973
|
-
*
|
|
2974
|
-
*
|
|
2988
|
+
* // Field form — the field is populated before first render
|
|
2989
|
+
* @context() ctx!: Context;
|
|
2990
|
+
*
|
|
2991
|
+
* // Field + @property — assignment also triggers re-render
|
|
2992
|
+
* @property({ attribute: false }) @context() reactiveCtx!: Context;
|
|
2975
2993
|
* }
|
|
2976
2994
|
* ```
|
|
2977
2995
|
*/
|
|
2978
2996
|
function context$1(options = {}) {
|
|
2979
|
-
return function (
|
|
2980
|
-
const
|
|
2981
|
-
|
|
2997
|
+
return function (value, decoratorContext) {
|
|
2998
|
+
const name = decoratorContext.name;
|
|
2999
|
+
const kind = decoratorContext.kind;
|
|
3000
|
+
const registerHandler = function () {
|
|
2982
3001
|
const constructor = this.constructor;
|
|
2983
|
-
//
|
|
2984
|
-
// the prototype chain.
|
|
3002
|
+
// De-dupe: methods identify by reference, fields identify by name.
|
|
2985
3003
|
if (!Object.prototype.hasOwnProperty.call(constructor, CONTEXT_METHODS)) {
|
|
2986
3004
|
constructor[CONTEXT_METHODS] = new Set();
|
|
2987
3005
|
}
|
|
2988
|
-
|
|
3006
|
+
const dedupeKey = kind === 'method' ? value : `field:${name}`;
|
|
3007
|
+
if (constructor[CONTEXT_METHODS].has(dedupeKey))
|
|
2989
3008
|
return;
|
|
2990
|
-
constructor[CONTEXT_METHODS].add(
|
|
3009
|
+
constructor[CONTEXT_METHODS].add(dedupeKey);
|
|
2991
3010
|
if (!Object.prototype.hasOwnProperty.call(constructor, CONTEXT_HANDLERS)) {
|
|
2992
3011
|
const inherited = constructor[CONTEXT_HANDLERS];
|
|
2993
3012
|
constructor[CONTEXT_HANDLERS] = inherited ? [...inherited] : [];
|
|
2994
3013
|
}
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3014
|
+
if (kind === 'method') {
|
|
3015
|
+
constructor[CONTEXT_HANDLERS].push({
|
|
3016
|
+
kind: 'method',
|
|
3017
|
+
methodName: name,
|
|
3018
|
+
method: value,
|
|
3019
|
+
options,
|
|
3020
|
+
});
|
|
3021
|
+
}
|
|
3022
|
+
else if (kind === 'field' || kind === 'accessor') {
|
|
3023
|
+
constructor[CONTEXT_HANDLERS].push({
|
|
3024
|
+
kind: 'field',
|
|
3025
|
+
fieldName: name,
|
|
3026
|
+
options,
|
|
3027
|
+
});
|
|
3028
|
+
}
|
|
3029
|
+
};
|
|
3030
|
+
if (kind === 'method') {
|
|
3031
|
+
decoratorContext.addInitializer(registerHandler);
|
|
3032
|
+
return value;
|
|
3033
|
+
}
|
|
3034
|
+
// Field decorators: do registration via the init function (fires per
|
|
3035
|
+
// instance during construction, with `this` bound). Returning the init
|
|
3036
|
+
// function is the canonical Stage 3 way for field decorators —
|
|
3037
|
+
// `addInitializer` for fields can be late or unreliable across runtimes.
|
|
3038
|
+
return function (initialValue) {
|
|
3039
|
+
registerHandler.call(this);
|
|
3040
|
+
return initialValue;
|
|
3041
|
+
};
|
|
3002
3042
|
};
|
|
3003
3043
|
}
|
|
3004
3044
|
/**
|
|
@@ -3017,18 +3057,30 @@ function setupContextHandler(element) {
|
|
|
3017
3057
|
}
|
|
3018
3058
|
// Store the Context instance for cleanup
|
|
3019
3059
|
element[NAVIGATION_CONTEXT_INSTANCE] = ctx;
|
|
3060
|
+
// Per-element Map of handler-name → wrapped function. Symbol-keyed so it
|
|
3061
|
+
// doesn't pollute the element's public surface.
|
|
3062
|
+
let wrapped = element[WRAPPED_CONTEXT_HANDLERS];
|
|
3063
|
+
if (!wrapped) {
|
|
3064
|
+
wrapped = new Map();
|
|
3065
|
+
element[WRAPPED_CONTEXT_HANDLERS] = wrapped;
|
|
3066
|
+
}
|
|
3020
3067
|
// Register each handler with the Context
|
|
3021
3068
|
for (const handler of handlers) {
|
|
3022
|
-
const {
|
|
3023
|
-
const
|
|
3069
|
+
const { kind, options } = handler;
|
|
3070
|
+
const handlerName = kind === 'field' ? handler.fieldName : handler.methodName;
|
|
3024
3071
|
// Create wrapped method with timing controls
|
|
3025
|
-
|
|
3072
|
+
const wrappedFn = function (context) {
|
|
3026
3073
|
// Skip if already called once
|
|
3027
3074
|
if (options.once && element[CONTEXT_CALLED]) {
|
|
3028
3075
|
return;
|
|
3029
3076
|
}
|
|
3030
3077
|
const callMethod = () => {
|
|
3031
|
-
|
|
3078
|
+
if (kind === 'field') {
|
|
3079
|
+
element[handler.fieldName] = context;
|
|
3080
|
+
}
|
|
3081
|
+
else {
|
|
3082
|
+
handler.method.call(element, context);
|
|
3083
|
+
}
|
|
3032
3084
|
// Handle once option
|
|
3033
3085
|
if (options.once) {
|
|
3034
3086
|
element[CONTEXT_CALLED] = true;
|
|
@@ -3043,7 +3095,7 @@ function setupContextHandler(element) {
|
|
|
3043
3095
|
// element overwriting each other's state.
|
|
3044
3096
|
const timerSlot = element[CONTEXT_TIMER] ||
|
|
3045
3097
|
(element[CONTEXT_TIMER] = {});
|
|
3046
|
-
const timerKey =
|
|
3098
|
+
const timerKey = handlerName;
|
|
3047
3099
|
if (options.debounce) {
|
|
3048
3100
|
clearTimeout(timerSlot[timerKey]?.timeout);
|
|
3049
3101
|
timerSlot[timerKey] = {
|
|
@@ -3062,9 +3114,20 @@ function setupContextHandler(element) {
|
|
|
3062
3114
|
}
|
|
3063
3115
|
callMethod();
|
|
3064
3116
|
};
|
|
3065
|
-
|
|
3117
|
+
wrapped.set(handlerName, wrappedFn);
|
|
3118
|
+
// Register with the Context using the handler name (lookup goes through
|
|
3119
|
+
// the WRAPPED_CONTEXT_HANDLERS Map on the element).
|
|
3066
3120
|
if (typeof ctx[CONTEXT_REGISTER] === 'function') {
|
|
3067
|
-
ctx[CONTEXT_REGISTER](element,
|
|
3121
|
+
ctx[CONTEXT_REGISTER](element, handlerName);
|
|
3122
|
+
}
|
|
3123
|
+
// Synchronously emit current context to the just-registered handler so
|
|
3124
|
+
// field/method values are populated BEFORE the first render microtask
|
|
3125
|
+
// flushes — eliminates the cold-render flicker where ctx is undefined.
|
|
3126
|
+
try {
|
|
3127
|
+
wrappedFn(ctx);
|
|
3128
|
+
}
|
|
3129
|
+
catch (error) {
|
|
3130
|
+
console.error(`Error invoking @context handler at registration:`, error);
|
|
3068
3131
|
}
|
|
3069
3132
|
}
|
|
3070
3133
|
}
|
|
@@ -3086,11 +3149,8 @@ function cleanupContextHandler(element) {
|
|
|
3086
3149
|
}
|
|
3087
3150
|
delete element[CONTEXT_TIMER];
|
|
3088
3151
|
}
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
const wrappedMethodName = `__wrapped_${handler.methodName}`;
|
|
3092
|
-
delete element[wrappedMethodName];
|
|
3093
|
-
}
|
|
3152
|
+
// Drop the per-element wrapped-handlers Map.
|
|
3153
|
+
delete element[WRAPPED_CONTEXT_HANDLERS];
|
|
3094
3154
|
// Unregister from Context if available
|
|
3095
3155
|
const ctx = element[NAVIGATION_CONTEXT_INSTANCE];
|
|
3096
3156
|
if (ctx && typeof ctx[CONTEXT_UNREGISTER] === 'function') {
|