lumiverse-spindle-types 0.5.12 → 0.5.13

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/dom.ts +34 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumiverse-spindle-types",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "types": "./src/index.ts",
5
5
  "keywords": [
6
6
  "lumiverse",
package/src/dom.ts CHANGED
@@ -11,9 +11,38 @@ export interface SpindleMessageElement {
11
11
 
12
12
  /** DOM helper API provided to frontend extension modules. */
13
13
  export interface SpindleDOMHelper {
14
- /** Inject sanitized HTML into the host document at the given target. */
14
+ /**
15
+ * Inject sanitized HTML into the host document at the given target and
16
+ * return the wrapper element containing the parsed content.
17
+ *
18
+ * **Element identity is preserved across chat-list virtualization.**
19
+ * When the injection lands inside a chat-message bubble, the host
20
+ * registers the wrapper and *moves* (not recreates) it back into place
21
+ * when the bubble next mounts. That means form-control state, event
22
+ * listeners bound to the wrapper subtree, and any refs the extension is
23
+ * holding all survive scroll-away/scroll-back cycles. Extensions can
24
+ * cache the returned Element and trust it indefinitely until they
25
+ * explicitly retire it via `uninject()` or `cleanup()`.
26
+ *
27
+ * To deliberately remove an injection, call `uninject(wrapper)` — NOT
28
+ * `wrapper.remove()`. The latter detaches the wrapper but leaves the
29
+ * registry record in place, so the host will resurrect the wrapper on
30
+ * the next bubble remount.
31
+ *
32
+ * Injections outside any chat-message bubble (sidebar, modals, toolbar)
33
+ * are unaffected by virtualization and don't go through replay — they
34
+ * stay attached wherever the extension put them.
35
+ */
15
36
  inject(target: string | Element, html: string, position?: InsertPosition): Element;
16
37
 
38
+ /**
39
+ * Retire an injection previously returned by `inject()`. Removes the
40
+ * wrapper from the DOM and drops its replay registration so the host
41
+ * won't restore it on future bubble remounts. No-op if the element
42
+ * isn't a recognised Spindle injection wrapper.
43
+ */
44
+ uninject(element: Element): void;
45
+
17
46
  /** Create a style element in the host document. Returns a removal function. */
18
47
  addStyle(css: string): () => void;
19
48
 
@@ -60,8 +89,10 @@ export interface SpindleDOMHelper {
60
89
  * Typical use: extension wants to attach content to a specific known
61
90
  * message id. If `null` comes back, the bubble isn't currently
62
91
  * mounted. Injections previously made via `dom.inject()` against a
63
- * bubble element are auto-replayed by the host when that bubble next
64
- * mounts, so extensions don't need to re-inject on scroll themselves.
92
+ * bubble element are auto-replayed by the host (with the original
93
+ * Element identity preserved see `inject()` for the full contract)
94
+ * when that bubble next mounts, so extensions don't need to re-inject
95
+ * on scroll themselves.
65
96
  */
66
97
  findMessageElement(messageId: string): Element | null;
67
98