snice 7.1.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. package/README.md +5 -0
  2. package/adapters/react/SniceProvider.js +1 -1
  3. package/adapters/react/SniceRouter.js +1 -1
  4. package/adapters/react/matchRoute.js +1 -1
  5. package/adapters/react/useRequestHandler.js +1 -1
  6. package/dist/cdn/accordion/snice-accordion.js +1 -1
  7. package/dist/cdn/action-bar/snice-action-bar.js +1 -1
  8. package/dist/cdn/activity-feed/snice-activity-feed.js +1 -1
  9. package/dist/cdn/alert/snice-alert.js +1 -1
  10. package/dist/cdn/app-tiles/snice-app-tiles.js +1 -1
  11. package/dist/cdn/approval-flow/snice-approval-flow.js +1 -1
  12. package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
  13. package/dist/cdn/availability/snice-availability.js +1 -1
  14. package/dist/cdn/avatar/snice-avatar.js +1 -1
  15. package/dist/cdn/avatar-group/snice-avatar-group.js +1 -1
  16. package/dist/cdn/badge/snice-badge.js +1 -1
  17. package/dist/cdn/banner/snice-banner.js +1 -1
  18. package/dist/cdn/binpack/snice-binpack.js +1 -1
  19. package/dist/cdn/book/snice-book.js +1 -1
  20. package/dist/cdn/booking/snice-booking.js +1 -1
  21. package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +1 -1
  22. package/dist/cdn/button/snice-button.js +1 -1
  23. package/dist/cdn/calendar/snice-calendar.js +1 -1
  24. package/dist/cdn/camera/snice-camera.js +1 -1
  25. package/dist/cdn/camera-annotate/snice-camera-annotate.js +1 -1
  26. package/dist/cdn/candlestick/snice-candlestick.js +1 -1
  27. package/dist/cdn/card/snice-card.js +1 -1
  28. package/dist/cdn/carousel/snice-carousel.js +1 -1
  29. package/dist/cdn/cart/snice-cart.js +1 -1
  30. package/dist/cdn/chart/snice-chart.js +1 -1
  31. package/dist/cdn/chat/snice-chat.js +1 -1
  32. package/dist/cdn/checkbox/snice-checkbox.js +1 -1
  33. package/dist/cdn/chip/snice-chip.js +1 -1
  34. package/dist/cdn/code-block/snice-code-block.js +1 -1
  35. package/dist/cdn/color-display/snice-color-display.js +1 -1
  36. package/dist/cdn/color-picker/snice-color-picker.js +1 -1
  37. package/dist/cdn/command-palette/snice-command-palette.js +1 -1
  38. package/dist/cdn/comments/snice-comments.js +1 -1
  39. package/dist/cdn/countdown/snice-countdown.js +1 -1
  40. package/dist/cdn/cropper/snice-cropper.js +1 -1
  41. package/dist/cdn/data-card/snice-data-card.js +1 -1
  42. package/dist/cdn/date-picker/snice-date-picker.js +1 -1
  43. package/dist/cdn/date-range-picker/snice-date-range-picker.js +1 -1
  44. package/dist/cdn/date-time-picker/snice-date-time-picker.js +1 -1
  45. package/dist/cdn/diff/snice-diff.js +1 -1
  46. package/dist/cdn/divider/snice-divider.js +1 -1
  47. package/dist/cdn/doc/snice-doc.js +1 -1
  48. package/dist/cdn/draw/snice-draw.js +1 -1
  49. package/dist/cdn/drawer/snice-drawer.js +1 -1
  50. package/dist/cdn/empty-state/snice-empty-state.js +1 -1
  51. package/dist/cdn/estimate/snice-estimate.js +1 -1
  52. package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
  53. package/dist/cdn/file-upload/snice-file-upload.js +1 -1
  54. package/dist/cdn/flip-card/snice-flip-card.js +1 -1
  55. package/dist/cdn/flow/snice-flow.js +1 -1
  56. package/dist/cdn/form-layout/snice-form-layout.js +1 -1
  57. package/dist/cdn/funnel/snice-funnel.js +1 -1
  58. package/dist/cdn/gantt/snice-gantt.js +1 -1
  59. package/dist/cdn/gauge/snice-gauge.js +1 -1
  60. package/dist/cdn/grid/snice-grid.js +1 -1
  61. package/dist/cdn/heatmap/snice-heatmap.js +1 -1
  62. package/dist/cdn/image/snice-image.js +1 -1
  63. package/dist/cdn/input/snice-input.js +1 -1
  64. package/dist/cdn/invoice/snice-invoice.js +1 -1
  65. package/dist/cdn/kanban/snice-kanban.js +1 -1
  66. package/dist/cdn/key-value/snice-key-value.js +1 -1
  67. package/dist/cdn/kpi/snice-kpi.js +1 -1
  68. package/dist/cdn/layout/snice-layout.js +1 -1
  69. package/dist/cdn/leaderboard/snice-leaderboard.js +1 -1
  70. package/dist/cdn/link/snice-link.js +1 -1
  71. package/dist/cdn/link-preview/snice-link-preview.js +1 -1
  72. package/dist/cdn/list/snice-list.js +1 -1
  73. package/dist/cdn/location/snice-location.js +1 -1
  74. package/dist/cdn/login/snice-login.js +1 -1
  75. package/dist/cdn/map/snice-map.js +1 -1
  76. package/dist/cdn/markdown/snice-markdown.js +1 -1
  77. package/dist/cdn/masonry/snice-masonry.js +1 -1
  78. package/dist/cdn/menu/snice-menu.js +1 -1
  79. package/dist/cdn/message-strip/snice-message-strip.js +1 -1
  80. package/dist/cdn/modal/snice-modal.js +1 -1
  81. package/dist/cdn/music-player/snice-music-player.js +1 -1
  82. package/dist/cdn/nav/snice-nav.js +1 -1
  83. package/dist/cdn/network-graph/snice-network-graph.js +1 -1
  84. package/dist/cdn/notification-center/snice-notification-center.js +1 -1
  85. package/dist/cdn/order-tracker/snice-order-tracker.js +1 -1
  86. package/dist/cdn/org-chart/snice-org-chart.js +1 -1
  87. package/dist/cdn/pagination/snice-pagination.js +1 -1
  88. package/dist/cdn/paint/snice-paint.js +1 -1
  89. package/dist/cdn/pdf-viewer/snice-pdf-viewer.js +1 -1
  90. package/dist/cdn/permission-matrix/snice-permission-matrix.js +1 -1
  91. package/dist/cdn/podcast-player/snice-podcast-player.js +1 -1
  92. package/dist/cdn/popover/snice-popover.js +1 -1
  93. package/dist/cdn/pricing-table/snice-pricing-table.js +1 -1
  94. package/dist/cdn/product-card/snice-product-card.js +1 -1
  95. package/dist/cdn/progress/snice-progress.js +1 -1
  96. package/dist/cdn/progress-ring/snice-progress-ring.js +1 -1
  97. package/dist/cdn/qr-code/snice-qr-code.js +1 -1
  98. package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
  99. package/dist/cdn/radio/snice-radio.js +1 -1
  100. package/dist/cdn/range-slider/snice-range-slider.js +1 -1
  101. package/dist/cdn/rating/snice-rating.js +1 -1
  102. package/dist/cdn/receipt/snice-receipt.js +1 -1
  103. package/dist/cdn/recipe/snice-recipe.js +1 -1
  104. package/dist/cdn/runtime/README.md +2 -2
  105. package/dist/cdn/runtime/snice-runtime.esm.js +114 -15
  106. package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
  107. package/dist/cdn/runtime/snice-runtime.esm.min.js +1 -1
  108. package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
  109. package/dist/cdn/runtime/snice-runtime.js +114 -15
  110. package/dist/cdn/runtime/snice-runtime.js.map +1 -1
  111. package/dist/cdn/runtime/snice-runtime.min.js +1 -1
  112. package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
  113. package/dist/cdn/sankey/snice-sankey.js +1 -1
  114. package/dist/cdn/segmented-control/snice-segmented-control.js +1 -1
  115. package/dist/cdn/select/snice-select.js +1 -1
  116. package/dist/cdn/skeleton/snice-skeleton.js +1 -1
  117. package/dist/cdn/slider/snice-slider.js +1 -1
  118. package/dist/cdn/sortable/snice-sortable.js +1 -1
  119. package/dist/cdn/sparkline/snice-sparkline.js +1 -1
  120. package/dist/cdn/spinner/snice-spinner.js +1 -1
  121. package/dist/cdn/split-button/snice-split-button.js +1 -1
  122. package/dist/cdn/split-pane/snice-split-pane.js +1 -1
  123. package/dist/cdn/spotlight/snice-spotlight.js +1 -1
  124. package/dist/cdn/stat-group/snice-stat-group.js +1 -1
  125. package/dist/cdn/step-input/snice-step-input.js +1 -1
  126. package/dist/cdn/stepper/snice-stepper.js +1 -1
  127. package/dist/cdn/switch/snice-switch.js +1 -1
  128. package/dist/cdn/table/snice-table.esm.js +1 -1
  129. package/dist/cdn/table/snice-table.js +1 -1
  130. package/dist/cdn/tabs/snice-tabs.js +1 -1
  131. package/dist/cdn/tag/snice-tag.js +1 -1
  132. package/dist/cdn/tag-input/snice-tag-input.js +1 -1
  133. package/dist/cdn/terminal/snice-terminal.js +1 -1
  134. package/dist/cdn/testimonial/snice-testimonial.js +1 -1
  135. package/dist/cdn/textarea/snice-textarea.js +1 -1
  136. package/dist/cdn/time-picker/snice-time-picker.js +1 -1
  137. package/dist/cdn/time-range-picker/snice-time-range-picker.js +1 -1
  138. package/dist/cdn/timeline/snice-timeline.js +1 -1
  139. package/dist/cdn/timer/snice-timer.js +1 -1
  140. package/dist/cdn/toast/snice-toast.js +1 -1
  141. package/dist/cdn/tooltip/snice-tooltip.js +1 -1
  142. package/dist/cdn/tree/snice-tree.js +1 -1
  143. package/dist/cdn/treemap/snice-treemap.js +1 -1
  144. package/dist/cdn/user-card/snice-user-card.js +1 -1
  145. package/dist/cdn/video-player/snice-video-player.js +1 -1
  146. package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +1 -1
  147. package/dist/cdn/waterfall/snice-waterfall.js +1 -1
  148. package/dist/cdn/weather/snice-weather.js +1 -1
  149. package/dist/cdn/work-order/snice-work-order.js +1 -1
  150. package/dist/controller.d.ts +5 -0
  151. package/dist/index.cjs +111 -12
  152. package/dist/index.cjs.map +1 -1
  153. package/dist/index.esm.js +111 -12
  154. package/dist/index.esm.js.map +1 -1
  155. package/dist/index.iife.js +111 -12
  156. package/dist/index.iife.js.map +1 -1
  157. package/dist/parts.d.ts +2 -2
  158. package/dist/react/SniceProvider.js +1 -1
  159. package/dist/react/SniceRouter.js +1 -1
  160. package/dist/react/index.js +1 -1
  161. package/dist/react/matchRoute.js +1 -1
  162. package/dist/react/useRequestHandler.js +1 -1
  163. package/dist/symbols.cjs +9 -1
  164. package/dist/symbols.cjs.map +1 -1
  165. package/dist/symbols.d.ts +2 -0
  166. package/dist/symbols.esm.js +8 -2
  167. package/dist/symbols.esm.js.map +1 -1
  168. package/dist/transitions.cjs +1 -1
  169. package/dist/transitions.esm.js +1 -1
  170. package/docs/ai/architecture.md +1 -1
  171. package/docs/ai/bindings.md +1 -1
  172. package/docs/ai/controllers.md +1 -1
  173. package/docs/ai/decorators.md +1 -1
  174. package/docs/ai/patterns.md +4 -3
  175. package/docs/bindings.md +1 -1
  176. package/docs/controllers.md +8 -2
  177. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * snice v7.0.3
2
+ * snice v7.1.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.
@@ -63,9 +63,15 @@ var Snice = (function (exports) {
63
63
  const CONTROLLER_ID = getSymbol('controller-id');
64
64
  const CONTROLLER_OPERATIONS = getSymbol('controller-operations');
65
65
  const NATIVE_CONTROLLER = getSymbol('native-controller');
66
+ // Decorator name stored on the class so direct class bindings can expose the
67
+ // same useful DOM label without resolving the controller through the registry.
68
+ const CONTROLLER_REGISTRY_NAME = getSymbol('controller-registry-name');
66
69
  // Set while a controller CLASS (not a registry name) is attached — the
67
70
  // attribute/MutationObserver channel must not attach over or detach it.
68
71
  const DIRECT_CONTROLLER = getSymbol('direct-controller');
72
+ // Guards framework-authored diagnostic controller attribute writes from the
73
+ // synchronous custom-element attributeChangedCallback path.
74
+ const CONTROLLER_ATTRIBUTE_SYNC = getSymbol('controller-attribute-sync');
69
75
  // A controller class bound by a template before the custom element was
70
76
  // defined/upgraded. Picked up by connectedCallback on first initialization.
71
77
  const PENDING_CONTROLLER_BINDING = getSymbol('pending-controller-binding');
@@ -2123,6 +2129,12 @@ var Snice = (function (exports) {
2123
2129
  registry.set(name, constructor);
2124
2130
  // Mark as controller class for channel decorator detection
2125
2131
  constructor.prototype[IS_CONTROLLER_CLASS] = true;
2132
+ // Preserve the registry name on the class. Direct class attachments still
2133
+ // skip registry lookup; this is only their inspectable DOM label.
2134
+ Object.defineProperty(constructor, CONTROLLER_REGISTRY_NAME, {
2135
+ value: name,
2136
+ configurable: true
2137
+ });
2126
2138
  const pending = snice.pendingControllerAttachments.get(name);
2127
2139
  if (pending) {
2128
2140
  snice.pendingControllerAttachments.delete(name);
@@ -2194,6 +2206,52 @@ var Snice = (function (exports) {
2194
2206
  ? controller
2195
2207
  : (controller?.name || '(anonymous controller class)');
2196
2208
  }
2209
+ /** Registry/decorator name used for a direct class attachment's DOM marker. */
2210
+ function directControllerAttributeName(controllerClass) {
2211
+ const registeredName = Object.prototype.hasOwnProperty.call(controllerClass, CONTROLLER_REGISTRY_NAME)
2212
+ ? controllerClass[CONTROLLER_REGISTRY_NAME]
2213
+ : undefined;
2214
+ return typeof registeredName === 'string'
2215
+ ? registeredName
2216
+ : controllerLabel(controllerClass);
2217
+ }
2218
+ /**
2219
+ * Write the inspectable controller marker without feeding it back into the
2220
+ * custom-element attribute channel. Native MutationObservers are asynchronous
2221
+ * and are excluded independently by DIRECT_CONTROLLER.
2222
+ */
2223
+ function writeControllerAttribute(element, value) {
2224
+ if (value === null) {
2225
+ if (!element.hasAttribute('controller'))
2226
+ return;
2227
+ }
2228
+ else if (element.getAttribute('controller') === value) {
2229
+ return;
2230
+ }
2231
+ element[CONTROLLER_ATTRIBUTE_SYNC] = true;
2232
+ try {
2233
+ if (value === null)
2234
+ element.removeAttribute('controller');
2235
+ else
2236
+ element.setAttribute('controller', value);
2237
+ }
2238
+ finally {
2239
+ delete element[CONTROLLER_ATTRIBUTE_SYNC];
2240
+ }
2241
+ }
2242
+ /**
2243
+ * Restore the diagnostic attribute for an attached class controller. Returns
2244
+ * true when the direct class channel owns the element.
2245
+ */
2246
+ function restoreDirectControllerAttribute(element) {
2247
+ if (!element[DIRECT_CONTROLLER])
2248
+ return false;
2249
+ const source = element[CONTROLLER_NAME_KEY];
2250
+ if (typeof source !== 'function')
2251
+ return false;
2252
+ writeControllerAttribute(element, directControllerAttributeName(source));
2253
+ return true;
2254
+ }
2197
2255
  /**
2198
2256
  * Attaches a controller to an element
2199
2257
  * @param element The element to attach the controller to
@@ -2223,11 +2281,26 @@ var Snice = (function (exports) {
2223
2281
  }
2224
2282
  if (existingSource === controller && existingController) {
2225
2283
  // Already attached and controller exists (name or class reference match)
2284
+ if (typeof controller !== 'string') {
2285
+ restoreDirectControllerAttribute(element);
2286
+ }
2226
2287
  return;
2227
2288
  }
2228
2289
  // If there's an existing controller, detach it first
2229
2290
  if (existingController) {
2230
2291
  await detachController(element);
2292
+ // Light-DOM reconciliation can issue commit() and reconnected() requests
2293
+ // for the same class while the previous controller is still detaching.
2294
+ // If the other request already installed that exact source, this request
2295
+ // is redundant. Different sources retain the established rapid-switch
2296
+ // behavior and continue through the normal replacement path.
2297
+ const replacement = element[CONTROLLER_KEY];
2298
+ const replacementSource = element[CONTROLLER_NAME_KEY];
2299
+ if (replacement && replacementSource === controller) {
2300
+ if (typeof controller !== 'string')
2301
+ restoreDirectControllerAttribute(element);
2302
+ return;
2303
+ }
2231
2304
  }
2232
2305
  let ControllerClass;
2233
2306
  if (typeof controller === 'string') {
@@ -2243,13 +2316,16 @@ var Snice = (function (exports) {
2243
2316
  }
2244
2317
  else {
2245
2318
  ControllerClass = controller;
2246
- // The class channel owns the element from here on: the attribute /
2247
- // MutationObserver channel goes inert and its bookkeeping is dropped.
2248
- element[DIRECT_CONTROLLER] = true;
2249
- delete element[NATIVE_CONTROLLER];
2250
2319
  }
2251
2320
  // Create controller instance with unique ID and scope
2252
2321
  const controllerInstance = new ControllerClass();
2322
+ if (typeof controller !== 'string') {
2323
+ // Construction succeeded, so the class channel can safely take ownership.
2324
+ // Setting this before construction would leave a stale observer guard when
2325
+ // a controller constructor throws.
2326
+ element[DIRECT_CONTROLLER] = true;
2327
+ delete element[NATIVE_CONTROLLER];
2328
+ }
2253
2329
  snice.controllerIdCounter += 1;
2254
2330
  const controllerId = snice.controllerIdCounter;
2255
2331
  const scope = new ControllerScope();
@@ -2268,6 +2344,12 @@ var Snice = (function (exports) {
2268
2344
  element[CONTROLLER_KEY] = controllerInstance;
2269
2345
  element[CONTROLLER_NAME_KEY] = controller;
2270
2346
  element[CONTROLLER_OPERATIONS] = scope;
2347
+ if (typeof controller !== 'string') {
2348
+ // The class reference remains the sole attachment authority. This
2349
+ // attribute is diagnostic only; custom-element callbacks and native
2350
+ // MutationObservers are guarded from treating it as a string attachment.
2351
+ restoreDirectControllerAttribute(element);
2352
+ }
2271
2353
  // Wait for element to be ready. Race against abort (detachController) and
2272
2354
  // a 30s deadline so a caller that forgets to append the element gets a
2273
2355
  // clear error instead of an unresolvable promise.
@@ -2299,6 +2381,9 @@ var Snice = (function (exports) {
2299
2381
  // attached — otherwise a later attach short-circuits as "already attached"
2300
2382
  // and a detach would run detach() on it.
2301
2383
  if (element[CONTROLLER_KEY] === controllerInstance) {
2384
+ if (typeof controller !== 'string') {
2385
+ writeControllerAttribute(element, null);
2386
+ }
2302
2387
  delete element[CONTROLLER_KEY];
2303
2388
  delete element[CONTROLLER_NAME_KEY];
2304
2389
  delete element[CONTROLLER_OPERATIONS];
@@ -2350,6 +2435,12 @@ var Snice = (function (exports) {
2350
2435
  // controller reassignment) finds no instance and returns, instead of running
2351
2436
  // detach() a second time on the same controller. The rest of this function
2352
2437
  // works off the locals captured above.
2438
+ if (typeof controllerSource === 'function') {
2439
+ // Remove the class channel's diagnostic marker while its guards are still
2440
+ // active. A queued native MutationObserver therefore sees no attribute and
2441
+ // cannot resurrect a registry attachment after detach.
2442
+ writeControllerAttribute(element, null);
2443
+ }
2353
2444
  delete element[CONTROLLER_KEY];
2354
2445
  delete element[CONTROLLER_NAME_KEY];
2355
2446
  delete element[CONTROLLER_OPERATIONS];
@@ -2424,8 +2515,12 @@ var Snice = (function (exports) {
2424
2515
  // attachController(el, Class)). The class channel owns the element:
2425
2516
  // attribute writes must not attach over it, and insertion sweeps must
2426
2517
  // not detach it.
2427
- if (element[DIRECT_CONTROLLER])
2518
+ if (element[DIRECT_CONTROLLER]) {
2519
+ // External writes cannot replace a class binding. Keep the DOM marker
2520
+ // honest about the class that is actually attached.
2521
+ restoreDirectControllerAttribute(element);
2428
2522
  return;
2523
+ }
2429
2524
  const controllerName = element.getAttribute('controller');
2430
2525
  const currentControllerName = element[NATIVE_CONTROLLER];
2431
2526
  // No change
@@ -4663,8 +4758,8 @@ var Snice = (function (exports) {
4663
4758
  * Accepts a controller class decorated with @controller (attached directly,
4664
4759
  * no registry lookup) or a registry name string (delegated to the attribute
4665
4760
  * channel with the exact semantics of a static controller="name"). While a
4666
- * class is bound it owns the element: the attribute/MutationObserver channel
4667
- * is inert until the class is unbound.
4761
+ * class is bound it owns the element: the decorator name is reflected for
4762
+ * inspection, while the attribute/MutationObserver attach channel stays inert.
4668
4763
  *
4669
4764
  * Renders commit while the tree is detached and connect afterwards, so
4670
4765
  * attachment happens on reconnected()/connected commits; every hook is
@@ -4703,10 +4798,6 @@ var Snice = (function (exports) {
4703
4798
  }
4704
4799
  }
4705
4800
  if (typeof next === 'function') {
4706
- // Class binding takes over — drop any attribute so the string channel
4707
- // cannot fight it.
4708
- if (this.element.hasAttribute('controller'))
4709
- this.element.removeAttribute('controller');
4710
4801
  if (this.isConnected) {
4711
4802
  this._apply(next);
4712
4803
  }
@@ -6778,6 +6869,14 @@ var Snice = (function (exports) {
6778
6869
  constructor.prototype.attributeChangedCallback = function (name, oldValue, newValue) {
6779
6870
  originalAttributeChangedCallback?.call(this, name, oldValue, newValue);
6780
6871
  if (name === 'controller') {
6872
+ // A class attachment reflects its decorator name for DOM diagnostics,
6873
+ // but the class reference remains the only attachment authority.
6874
+ if (this[CONTROLLER_ATTRIBUTE_SYNC])
6875
+ return;
6876
+ if (this[DIRECT_CONTROLLER]) {
6877
+ restoreDirectControllerAttribute(this);
6878
+ return;
6879
+ }
6781
6880
  this.controller = newValue;
6782
6881
  return;
6783
6882
  }