cometchat-visual-builder-no-code 1.0.20-authtest52 → 1.0.20-authtest53

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.
@@ -1,27 +1,64 @@
1
1
  /**
2
- * Monkeypatch document.createElement to auto-stamp all <style> elements
3
- * created after the CometChat bundle loads with a `data-cometchat-sdk` attribute.
2
+ * Marks every <style> element created/inserted after the CometChat bundle loads
3
+ * with a `data-cometchat-sdk` attribute.
4
4
  *
5
5
  * This MUST be imported as the very first import in the bundle entry point (index.tsx).
6
6
  *
7
- * How it works:
8
- * - Before the bundle loads, the host page may have already created <style> elements.
9
- * Those won't have the marker.
10
- * - After this script runs, every new <style> element created via document.createElement
11
- * will automatically get `data-cometchat-sdk="true"`.
12
- * - This covers: webpack style-loader injections, MUI/JSS runtime styles, CometChat Calls
13
- * SDK styles (goober, .ccccn, .awssld), and any other SDK-created styles.
14
- * - Host page styles added dynamically AFTER the bundle loads will also get the marker,
15
- * but that's acceptable because host pages rarely create <style> elements after load.
16
- * The key insight: host styles that exist BEFORE the bundle loads are the ones that
17
- * cause CSS conflicts, and those won't have the marker.
18
- *
19
- * The IframePortal then uses this marker to decide what to copy into the iframe:
20
- * - Has `data-cometchat-sdk` or `data-cometchat` copy (SDK/widget style)
21
- * - Doesn't have either block (host page style)
7
+ * Why the marker exists:
8
+ * - Before the bundle loads, the host page may already have <style> elements.
9
+ * Those must NOT be marked — they are host styles and cause CSS conflicts.
10
+ * - Everything marked after that point is treated as ours: webpack style-loader
11
+ * injections, MUI/JSS runtime styles, CometChat Calls SDK styles (goober, .ccccn,
12
+ * .awssld), and any other runtime styles.
13
+ *
14
+ * IframePortal uses this marker to decide what to copy into the iframe:
15
+ * - Has `data-cometchat-sdk` or `data-cometchat` -> copy (SDK/widget style)
16
+ * - Has neither -> block (host page style)
17
+ *
18
+ * Two strategies, in order of preference:
19
+ *
20
+ * 1. Monkeypatch `document.createElement`, marking at creation time. This is the
21
+ * primary path and leaves behaviour byte-identical on hosts that permit it.
22
+ *
23
+ * 2. MutationObserver fallback, marking at insertion time. Required because some
24
+ * hosts harden the document and make `createElement` non-writable and
25
+ * non-configurable:
26
+ *
27
+ * Object.getOwnPropertyDescriptor(document, "createElement")
28
+ * -> { writable: false, configurable: false }
29
+ *
30
+ * The assignment then throws in strict mode and, before this fallback existed,
31
+ * took the whole bundle down with it, so the widget never initialised at all.
32
+ *
33
+ * KNOWN TRADE-OFF (fallback path only)
34
+ * The fallback is NOT equivalent to the monkeypatch — it is strictly more
35
+ * permissive. The patch only observed `document.createElement`, whereas the
36
+ * observer also catches innerHTML/insertAdjacentHTML, cloned and adopted nodes,
37
+ * and <style> nested inside inserted subtrees. Host styles injected at runtime
38
+ * therefore get marked and copied into the iframe, weakening the isolation
39
+ * guarantee in `design.md` Property 3 / Req 1.4 on these hosts.
40
+ *
41
+ * This is an accepted trade-off, not an oversight: the marking is purely
42
+ * time-based, so there is no reliable way to tell a host's runtime <style> from
43
+ * ours. The original monkeypatch already had a narrower version of this hole
44
+ * (host styles created via createElement after load were marked too — see the
45
+ * note in the original implementation). Losing isolation on some runtime styles
46
+ * is preferable to the widget not rendering at all.
47
+ *
48
+ * KNOWN GAP: the strategy is chosen once, at module evaluation. A host that
49
+ * hardens or re-wraps `createElement` afterwards silently disables marking with
50
+ * no fallback armed.
51
+ */
52
+ /**
53
+ * Synchronously apply any marks the observer has queued but not yet delivered.
54
+ *
55
+ * MutationObserver callbacks are microtasks, so a <style> inserted earlier in
56
+ * the same task is still unmarked when a synchronous reader looks at the DOM.
57
+ * IframePortal does exactly that: it sweeps `document.querySelectorAll("style")`
58
+ * once, synchronously, and registers its own observer only afterwards — so a
59
+ * style missed by that sweep is blocked permanently, because nothing re-reads it.
60
+ *
61
+ * Callers that synchronously read style marks must call this first. It is a
62
+ * no-op on the monkeypatch path, where marking already happened at creation.
22
63
  */
23
- declare const _origCreateElement: {
24
- <K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementCreationOptions | undefined): HTMLElementTagNameMap[K];
25
- <K_1 extends keyof HTMLElementDeprecatedTagNameMap>(tagName: K_1, options?: ElementCreationOptions | undefined): HTMLElementDeprecatedTagNameMap[K_1];
26
- (tagName: string, options?: ElementCreationOptions | undefined): HTMLElement;
27
- };
64
+ export declare function flushStyleMarks(): void;
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "cometchat-visual-builder-no-code",
3
- "version": "1.0.20-authtest52",
3
+ "version": "1.0.20-authtest53",
4
4
  "description": "CometChat Widget Builder No-Code Integration",
5
5
  "cometChatCustomConfig": {
6
- "prodVersion": "1.0.34",
7
- "devStagingVersion": "1.0.20-authtest51",
6
+ "prodVersion": "1.0.36",
7
+ "devStagingVersion": "1.0.20-authtest49",
8
8
  "prodName": "@cometchat/chat-embed",
9
9
  "devName": "cometchat-visual-builder-no-code",
10
10
  "name": "cometchat-visual-builder-react-no-code",
11
- "version": "1.0.34",
11
+ "version": "1.0.36",
12
12
  "production": true
13
13
  },
14
14
  "author": "CometChat",