snice 7.7.0 → 7.8.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/calendar.d.ts +1 -0
- package/adapters/react/calendar.d.ts.map +1 -1
- package/adapters/react/calendar.js +1 -1
- package/adapters/react/calendar.js.map +1 -1
- package/adapters/react/calendar.tsx +2 -1
- package/adapters/react/matchRoute.js +1 -1
- package/adapters/react/useRequestHandler.js +1 -1
- package/bin/analyzer-contracts.js +8 -2
- package/custom-elements.json +5 -1
- 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 +26 -2
- 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/snice-code-block.js +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/snice-command-palette.js +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 +1 -1
- package/dist/cdn/progress-ring/snice-progress-ring.js +1 -1
- package/dist/cdn/qr-code/snice-qr-code.js +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 +1 -1
- package/dist/cdn/recipe/snice-recipe.js +1 -1
- package/dist/cdn/runtime/README.md +2 -2
- package/dist/cdn/runtime/snice-runtime.esm.js +130 -31
- package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.min.js +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.js +130 -31
- package/dist/cdn/runtime/snice-runtime.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.min.js +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/snice-select.js +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 +157 -33
- package/dist/cdn/table/snice-table.esm.js.map +1 -1
- package/dist/cdn/table/snice-table.esm.min.js +4 -4
- package/dist/cdn/table/snice-table.esm.min.js.map +1 -1
- package/dist/cdn/table/snice-table.js +157 -33
- package/dist/cdn/table/snice-table.js.map +1 -1
- package/dist/cdn/table/snice-table.min.js +33 -33
- 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/README.md +2 -2
- package/dist/cdn/tag-input/snice-tag-input.js +10 -16
- package/dist/cdn/tag-input/snice-tag-input.js.map +1 -1
- package/dist/cdn/tag-input/snice-tag-input.min.js +2 -2
- package/dist/cdn/tag-input/snice-tag-input.min.js.map +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 +2 -0
- package/dist/components/calendar/snice-calendar.js +25 -1
- package/dist/components/calendar/snice-calendar.js.map +1 -1
- package/dist/components/table/snice-row.d.ts +6 -0
- package/dist/components/table/snice-row.js +11 -3
- package/dist/components/table/snice-row.js.map +1 -1
- package/dist/components/table/snice-table.d.ts +31 -3
- package/dist/components/table/snice-table.js +89 -16
- package/dist/components/table/snice-table.js.map +1 -1
- package/dist/components/table/table-cell-presentation.d.ts +11 -0
- package/dist/components/table/table-cell-presentation.js +25 -8
- package/dist/components/table/table-cell-presentation.js.map +1 -1
- package/dist/components/table/table-export.d.ts +6 -0
- package/dist/components/table/table-export.js +11 -2
- package/dist/components/table/table-export.js.map +1 -1
- package/dist/components/table/table-master-detail.d.ts +11 -2
- package/dist/components/table/table-master-detail.js +20 -3
- package/dist/components/table/table-master-detail.js.map +1 -1
- package/dist/components/tag-input/snice-tag-input.d.ts +2 -2
- package/dist/components/tag-input/snice-tag-input.js +9 -15
- package/dist/components/tag-input/snice-tag-input.js.map +1 -1
- package/dist/index.cjs +127 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +127 -28
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +127 -28
- 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/request-response.d.ts +24 -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/components/calendar.md +8 -0
- package/docs/ai/components/tag-input.md +4 -0
- package/docs/ai/controllers.md +22 -6
- package/docs/components/calendar.md +24 -0
- package/docs/components/tag-input.md +6 -1
- package/docs/controllers.md +57 -6
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* snice v7.
|
|
2
|
+
* snice v7.7.0
|
|
3
3
|
* A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
|
|
4
4
|
* (c) 2024
|
|
5
5
|
* Released under the MIT License.
|
|
6
6
|
*/
|
|
7
7
|
/*!
|
|
8
|
-
* snice v7.
|
|
8
|
+
* snice v7.7.0
|
|
9
9
|
* A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
|
|
10
10
|
* (c) 2024
|
|
11
11
|
* Released under the MIT License.
|
|
@@ -1563,17 +1563,33 @@ function respond(requestName, options) {
|
|
|
1563
1563
|
});
|
|
1564
1564
|
};
|
|
1565
1565
|
}
|
|
1566
|
-
//
|
|
1567
|
-
|
|
1566
|
+
// Which handler descriptors an instance has already registered, so a second
|
|
1567
|
+
// setup pass only picks up what the first one deferred.
|
|
1568
|
+
const registeredHandlers = new WeakMap();
|
|
1569
|
+
/**
|
|
1570
|
+
* Helper to setup response handlers for elements and controllers.
|
|
1571
|
+
*
|
|
1572
|
+
* Safe to call more than once for the same instance: a handler already
|
|
1573
|
+
* registered is skipped rather than double-bound.
|
|
1574
|
+
*/
|
|
1575
|
+
function setupResponseHandlers(instance, element, options) {
|
|
1568
1576
|
const handlers = instance.constructor[CHANNEL_HANDLERS];
|
|
1569
1577
|
if (!handlers)
|
|
1570
1578
|
return;
|
|
1579
|
+
const claim = options?.claim;
|
|
1580
|
+
let registered = registeredHandlers.get(instance);
|
|
1581
|
+
if (!registered) {
|
|
1582
|
+
registered = new Set();
|
|
1583
|
+
registeredHandlers.set(instance, registered);
|
|
1584
|
+
}
|
|
1571
1585
|
// Store cleanup functions
|
|
1572
1586
|
// Initialize cleanup object if needed
|
|
1573
1587
|
if (!instance[CLEANUP]) {
|
|
1574
1588
|
instance[CLEANUP] = { events: [], channels: [] };
|
|
1575
1589
|
}
|
|
1576
1590
|
for (const handler of handlers) {
|
|
1591
|
+
if (registered.has(handler))
|
|
1592
|
+
continue;
|
|
1577
1593
|
const boundMethod = handler.method.bind(instance);
|
|
1578
1594
|
const eventName = `@request/${handler.channelName}`;
|
|
1579
1595
|
// Create timing variables for debounce/throttle per handler
|
|
@@ -1657,7 +1673,10 @@ function setupResponseHandlers(instance, element) {
|
|
|
1657
1673
|
// Clear the discovery timeout immediately - we found a handler
|
|
1658
1674
|
discovery.resolve();
|
|
1659
1675
|
// Call the timed responder method and handle the result
|
|
1660
|
-
|
|
1676
|
+
const answer = claim
|
|
1677
|
+
? Promise.resolve(claim()).then(() => timedMethod(payload))
|
|
1678
|
+
: Promise.resolve(timedMethod(payload));
|
|
1679
|
+
answer
|
|
1661
1680
|
.then(result => {
|
|
1662
1681
|
data.resolve(result);
|
|
1663
1682
|
})
|
|
@@ -1672,10 +1691,17 @@ function setupResponseHandlers(instance, element) {
|
|
|
1672
1691
|
responseTarget = requireDaemonTarget(instance, handler.options.daemon);
|
|
1673
1692
|
}
|
|
1674
1693
|
catch (error) {
|
|
1694
|
+
// The app context reaches a controller through its host element, so it
|
|
1695
|
+
// can be unreachable while the host is still disconnected. Leave the
|
|
1696
|
+
// handler for the later pass instead of dropping it permanently.
|
|
1697
|
+
if (options?.deferUnresolvableDaemons)
|
|
1698
|
+
continue;
|
|
1675
1699
|
console.warn(`[snice/@respond] ${error.message} Responder "${handler.channelName}" skipped.`);
|
|
1700
|
+
registered.add(handler);
|
|
1676
1701
|
continue;
|
|
1677
1702
|
}
|
|
1678
1703
|
}
|
|
1704
|
+
registered.add(handler);
|
|
1679
1705
|
responseTarget.addEventListener(eventName, responseHandler);
|
|
1680
1706
|
instance[CLEANUP].channels.push(() => {
|
|
1681
1707
|
responseTarget.removeEventListener(eventName, responseHandler);
|
|
@@ -1684,6 +1710,7 @@ function setupResponseHandlers(instance, element) {
|
|
|
1684
1710
|
}
|
|
1685
1711
|
// Helper to cleanup response handlers
|
|
1686
1712
|
function cleanupResponseHandlers(instance) {
|
|
1713
|
+
registeredHandlers.delete(instance);
|
|
1687
1714
|
if (instance[CLEANUP]?.channels) {
|
|
1688
1715
|
for (const cleanup of instance[CLEANUP].channels) {
|
|
1689
1716
|
cleanup();
|
|
@@ -1809,6 +1836,8 @@ function matchesKeyboardFilter(event, filter) {
|
|
|
1809
1836
|
* Use in elements or controllers to listen to DOM events or custom events
|
|
1810
1837
|
*/
|
|
1811
1838
|
const ON_HANDLERS = getSymbol('on-handlers');
|
|
1839
|
+
// Per-decoration-site counter — see the registration identity note in `on()`.
|
|
1840
|
+
let registrationCount = 0;
|
|
1812
1841
|
/**
|
|
1813
1842
|
* @on decorator for listening to events
|
|
1814
1843
|
*
|
|
@@ -1870,18 +1899,42 @@ function on(eventName, selectorOrOptions, options) {
|
|
|
1870
1899
|
if (!selector && opts.target) {
|
|
1871
1900
|
selector = opts.target;
|
|
1872
1901
|
}
|
|
1902
|
+
const eventNames = Array.isArray(eventName) ? eventName : [eventName];
|
|
1903
|
+
// Registration identity — derived from EVERY decorator argument, so no
|
|
1904
|
+
// option can be forgotten here and silently collapse two distinct stacked
|
|
1905
|
+
// @on decorators into one (that is how { debounce: 300 } stacked on a plain
|
|
1906
|
+
// @on for the same event used to lose one of its two registrations).
|
|
1907
|
+
// Options are serialized generically (sorted, so literal key order doesn't
|
|
1908
|
+
// matter); values that can't be compared by value — an EventTarget or a
|
|
1909
|
+
// resolver function passed as `scope` — fall back to this decoration site's
|
|
1910
|
+
// own id, which is stable across instances but unique per @on application.
|
|
1911
|
+
const siteId = `site:${++registrationCount}`;
|
|
1912
|
+
let optionSignature = '';
|
|
1913
|
+
let hasOpaqueOption = false;
|
|
1914
|
+
for (const key of Object.keys(opts).sort()) {
|
|
1915
|
+
const value = opts[key];
|
|
1916
|
+
if (value === undefined)
|
|
1917
|
+
continue;
|
|
1918
|
+
if (value !== null && (typeof value === 'object' || typeof value === 'function')) {
|
|
1919
|
+
hasOpaqueOption = true;
|
|
1920
|
+
continue;
|
|
1921
|
+
}
|
|
1922
|
+
optionSignature += `${key}=${String(value)};`;
|
|
1923
|
+
}
|
|
1924
|
+
const argumentKey = `${eventNames.join(',')}::${selector ?? ''}::${optionSignature}${hasOpaqueOption ? `::${siteId}` : ''}`;
|
|
1873
1925
|
return function (originalMethod, context) {
|
|
1874
1926
|
const methodName = context.name;
|
|
1927
|
+
// Same decoration, same method name → same registration. A subclass that
|
|
1928
|
+
// re-declares an identically decorated method must NOT add a second
|
|
1929
|
+
// listener on top of the one its parent's initializer already registered.
|
|
1930
|
+
const registrationKey = `${methodName}::${argumentKey}`;
|
|
1875
1931
|
context.addInitializer(function () {
|
|
1876
1932
|
const constructor = this.constructor;
|
|
1877
|
-
// Dedup by registration identity
|
|
1878
|
-
//
|
|
1879
|
-
//
|
|
1880
|
-
//
|
|
1881
|
-
//
|
|
1882
|
-
// prototype chain.
|
|
1883
|
-
const eventNames = Array.isArray(eventName) ? eventName : [eventName];
|
|
1884
|
-
const registrationKey = `${methodName}::${eventNames.join(',')}::${selector ?? ''}::daemon:${opts.daemon ?? ''}::light:${opts.light ?? ''}::shadow:${opts.shadow ?? ''}`;
|
|
1933
|
+
// Dedup by registration identity, NOT by method reference — stacked @on
|
|
1934
|
+
// decorators share one method and must each register. Use hasOwnProperty
|
|
1935
|
+
// so subclasses get their OWN Set instead of inheriting — otherwise
|
|
1936
|
+
// parent and child share state and child registrations pollute parent
|
|
1937
|
+
// (and vice versa) via the prototype chain.
|
|
1885
1938
|
if (!Object.prototype.hasOwnProperty.call(constructor, ON_METHODS)) {
|
|
1886
1939
|
constructor[ON_METHODS] = new Set();
|
|
1887
1940
|
}
|
|
@@ -2896,6 +2949,35 @@ async function attachController(element, controller) {
|
|
|
2896
2949
|
// MutationObservers are guarded from treating it as a string attachment.
|
|
2897
2950
|
restoreDirectControllerAttribute(element);
|
|
2898
2951
|
}
|
|
2952
|
+
// @respond handlers are installed before the readiness gate below, exactly
|
|
2953
|
+
// as elements install theirs in connectedCallback. A child's mount-time
|
|
2954
|
+
// @request can be the very thing keeping the host from becoming ready, so
|
|
2955
|
+
// the responder has to be reachable while `ready` is still pending. Such a
|
|
2956
|
+
// request also releases the gate — it proves the host subtree is live and
|
|
2957
|
+
// that something is blocked on this attachment — and is answered once
|
|
2958
|
+
// attach() and the remaining setup have run.
|
|
2959
|
+
//
|
|
2960
|
+
// A `@respond({ daemon })` handler resolves its target through the host's app
|
|
2961
|
+
// context, which is unreachable while the host is still disconnected (attach
|
|
2962
|
+
// before appendChild). Those are deferred here and registered by the second
|
|
2963
|
+
// pass past the gate, where they behaved correctly before this ordering.
|
|
2964
|
+
let requestClaimed = false;
|
|
2965
|
+
let releaseReadyGate;
|
|
2966
|
+
let completeAttach;
|
|
2967
|
+
let failAttach;
|
|
2968
|
+
const attached = new Promise((resolve, reject) => {
|
|
2969
|
+
completeAttach = resolve;
|
|
2970
|
+
failAttach = reject;
|
|
2971
|
+
});
|
|
2972
|
+
attached.catch(() => { }); // No requester when nothing was claimed
|
|
2973
|
+
setupResponseHandlers(controllerInstance, element, {
|
|
2974
|
+
deferUnresolvableDaemons: true,
|
|
2975
|
+
claim: () => {
|
|
2976
|
+
requestClaimed = true;
|
|
2977
|
+
releaseReadyGate?.();
|
|
2978
|
+
return attached;
|
|
2979
|
+
},
|
|
2980
|
+
});
|
|
2899
2981
|
// Normally a controller waits for its host's full initialization. The sole
|
|
2900
2982
|
// exception is attachController(host, ...) from that host's own @ready
|
|
2901
2983
|
// handler: awaiting ready there would wait on the current handler itself.
|
|
@@ -2908,6 +2990,11 @@ async function attachController(element, controller) {
|
|
|
2908
2990
|
try {
|
|
2909
2991
|
await Promise.race([
|
|
2910
2992
|
element.ready,
|
|
2993
|
+
new Promise(resolve => {
|
|
2994
|
+
if (requestClaimed)
|
|
2995
|
+
return resolve();
|
|
2996
|
+
releaseReadyGate = resolve;
|
|
2997
|
+
}),
|
|
2911
2998
|
new Promise((_, reject) => {
|
|
2912
2999
|
const onAbort = () => {
|
|
2913
3000
|
// Tagged so fire-and-forget call sites can tell this designed
|
|
@@ -2926,8 +3013,10 @@ async function attachController(element, controller) {
|
|
|
2926
3013
|
}
|
|
2927
3014
|
catch (error) {
|
|
2928
3015
|
// Attach never got past `ready` (aborted or deadline). Roll back the
|
|
2929
|
-
// stored references so a later attach does not
|
|
2930
|
-
// instance whose attach() never ran.
|
|
3016
|
+
// stored references and the early responders so a later attach does not
|
|
3017
|
+
// short-circuit against an instance whose attach() never ran.
|
|
3018
|
+
cleanupResponseHandlers(controllerInstance);
|
|
3019
|
+
failAttach(error);
|
|
2931
3020
|
if (element[CONTROLLER_KEY] === controllerInstance) {
|
|
2932
3021
|
if (typeof controller !== 'string') {
|
|
2933
3022
|
writeControllerAttribute(element, null);
|
|
@@ -2949,20 +3038,30 @@ async function attachController(element, controller) {
|
|
|
2949
3038
|
}
|
|
2950
3039
|
// Past `ready` — mark the controller so detach knows attach was actually run.
|
|
2951
3040
|
controllerInstance[CONTROLLER_ATTACHED] = true;
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
await
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
3041
|
+
try {
|
|
3042
|
+
// Run attach in the controller's scope
|
|
3043
|
+
await scope.runOperation(async () => {
|
|
3044
|
+
await controllerInstance.attach(element);
|
|
3045
|
+
});
|
|
3046
|
+
// @context has the same managed lifecycle on controllers as @on,
|
|
3047
|
+
// @observe and @respond. Catch up controllers whose async attach completed
|
|
3048
|
+
// after the Router announced the current navigation.
|
|
3049
|
+
await setupContextHandler(controllerInstance, 'microtask');
|
|
3050
|
+
// Setup @observe observers for controller
|
|
3051
|
+
setupObservers(controllerInstance, element);
|
|
3052
|
+
// Second @respond pass: registers only what the pre-gate pass deferred —
|
|
3053
|
+
// daemon-scoped responders whose app context was not resolvable yet.
|
|
3054
|
+
setupResponseHandlers(controllerInstance, element);
|
|
3055
|
+
// Setup @on event handlers for controller
|
|
3056
|
+
setupEventHandlers(controllerInstance, element);
|
|
3057
|
+
}
|
|
3058
|
+
catch (error) {
|
|
3059
|
+
// A claimed request must not wait on an attachment that never completed.
|
|
3060
|
+
failAttach(error);
|
|
3061
|
+
throw error;
|
|
3062
|
+
}
|
|
3063
|
+
// Answer whatever was claimed while the host was still becoming ready.
|
|
3064
|
+
completeAttach();
|
|
2966
3065
|
element.dispatchEvent(new CustomEvent('controller-attached', {
|
|
2967
3066
|
detail: { name: controllerName, controller: controllerInstance }
|
|
2968
3067
|
}));
|
|
@@ -10167,7 +10266,7 @@ if (typeof document !== 'undefined') {
|
|
|
10167
10266
|
}
|
|
10168
10267
|
|
|
10169
10268
|
/*!
|
|
10170
|
-
* snice v7.
|
|
10269
|
+
* snice v7.7.0
|
|
10171
10270
|
* A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
|
|
10172
10271
|
* (c) 2024
|
|
10173
10272
|
* Released under the MIT License.
|
|
@@ -10189,7 +10288,7 @@ if (!globalThis.snice) {
|
|
|
10189
10288
|
globalThis.snice.pendingControllerAttachments ??= new Map();
|
|
10190
10289
|
|
|
10191
10290
|
/*!
|
|
10192
|
-
* snice v7.
|
|
10291
|
+
* snice v7.7.0
|
|
10193
10292
|
* A decorator-driven web component library with routing, controllers, daemons, and 130+ UI components. For better coding-agent results, run npx snice init-ai.
|
|
10194
10293
|
* (c) 2024
|
|
10195
10294
|
* Released under the MIT License.
|