@atlaskit/react-ufo 3.13.11 → 3.13.12

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.
@@ -0,0 +1,20 @@
1
+ ---
2
+ description:
3
+ globs:
4
+ alwaysApply: true
5
+ ---
6
+ ## Code Comments Rule
7
+
8
+ When adding comments to code, ensure comments explain the code's purpose and behavior within the context of the codebase, not the context of the current change request or prompt. Comments should be written as if they were part of the original codebase and should be suitable for committing directly without any reference to the specific modification being made.
9
+
10
+ **Good examples:**
11
+ - "Ensures a single instance exists across the entire application"
12
+ - "Returns existing instance if already initialized"
13
+ - "Handles edge case where network request fails"
14
+ **Avoid:**
15
+ - "I will change this to use globalThis"
16
+ - "Moving this from local variable to global"
17
+ - "As requested, updating the implementation"
18
+ - References to "this change" or "this modification"
19
+
20
+ Comments should focus on explaining WHY the code exists and WHAT it does, not HOW it came to be implemented during the current session.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 3.13.12
4
+
5
+ ### Patch Changes
6
+
7
+ - [#161803](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/161803)
8
+ [`71ce852a73a06`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/71ce852a73a06) -
9
+ AFO-3919 make DefaultInteractionID global singleton
10
+
3
11
  ## 3.13.11
4
12
 
5
13
  ### Patch Changes
@@ -42,10 +42,24 @@ var ObservableInteractionID = /*#__PURE__*/function () {
42
42
  }
43
43
  }
44
44
  }]);
45
- }(); // The default InteractionID object is a global singleton
46
- // It's the one that holds the root value used in routing,
47
- // and is overwritten when we have new interactions start.
48
- var DefaultInteractionID = exports.DefaultInteractionID = new ObservableInteractionID();
45
+ }(); // Type declaration for globalThis extension
46
+ // Ensures a single DefaultInteractionID instance exists across the entire application,
47
+ // even when the module is loaded multiple times in different contexts
48
+ var initializeGlobalDefaultInteractionID = function initializeGlobalDefaultInteractionID() {
49
+ // Return existing instance if already initialized
50
+ if (globalThis.__UFO_DEFAULT_INTERACTION_ID__) {
51
+ return globalThis.__UFO_DEFAULT_INTERACTION_ID__;
52
+ }
53
+
54
+ // Create and store new instance globally
55
+ var instance = new ObservableInteractionID();
56
+ globalThis.__UFO_DEFAULT_INTERACTION_ID__ = instance;
57
+ return instance;
58
+ };
59
+
60
+ // The default InteractionID object is a global singleton stored in globalThis.
61
+ // It holds the root value used in routing and is updated when new interactions start.
62
+ var DefaultInteractionID = exports.DefaultInteractionID = initializeGlobalDefaultInteractionID();
49
63
 
50
64
  // Subscription functions
51
65
  var subscribeToInteractionIdChanges = exports.subscribeToInteractionIdChanges = function subscribeToInteractionIdChanges(listener) {
@@ -30,10 +30,25 @@ class ObservableInteractionID {
30
30
  }
31
31
  }
32
32
 
33
- // The default InteractionID object is a global singleton
34
- // It's the one that holds the root value used in routing,
35
- // and is overwritten when we have new interactions start.
36
- export const DefaultInteractionID = new ObservableInteractionID();
33
+ // Type declaration for globalThis extension
34
+
35
+ // Ensures a single DefaultInteractionID instance exists across the entire application,
36
+ // even when the module is loaded multiple times in different contexts
37
+ const initializeGlobalDefaultInteractionID = () => {
38
+ // Return existing instance if already initialized
39
+ if (globalThis.__UFO_DEFAULT_INTERACTION_ID__) {
40
+ return globalThis.__UFO_DEFAULT_INTERACTION_ID__;
41
+ }
42
+
43
+ // Create and store new instance globally
44
+ const instance = new ObservableInteractionID();
45
+ globalThis.__UFO_DEFAULT_INTERACTION_ID__ = instance;
46
+ return instance;
47
+ };
48
+
49
+ // The default InteractionID object is a global singleton stored in globalThis.
50
+ // It holds the root value used in routing and is updated when new interactions start.
51
+ export const DefaultInteractionID = initializeGlobalDefaultInteractionID();
37
52
 
38
53
  // Subscription functions
39
54
  export const subscribeToInteractionIdChanges = listener => {
@@ -36,10 +36,24 @@ var ObservableInteractionID = /*#__PURE__*/function () {
36
36
  }
37
37
  }
38
38
  }]);
39
- }(); // The default InteractionID object is a global singleton
40
- // It's the one that holds the root value used in routing,
41
- // and is overwritten when we have new interactions start.
42
- export var DefaultInteractionID = new ObservableInteractionID();
39
+ }(); // Type declaration for globalThis extension
40
+ // Ensures a single DefaultInteractionID instance exists across the entire application,
41
+ // even when the module is loaded multiple times in different contexts
42
+ var initializeGlobalDefaultInteractionID = function initializeGlobalDefaultInteractionID() {
43
+ // Return existing instance if already initialized
44
+ if (globalThis.__UFO_DEFAULT_INTERACTION_ID__) {
45
+ return globalThis.__UFO_DEFAULT_INTERACTION_ID__;
46
+ }
47
+
48
+ // Create and store new instance globally
49
+ var instance = new ObservableInteractionID();
50
+ globalThis.__UFO_DEFAULT_INTERACTION_ID__ = instance;
51
+ return instance;
52
+ };
53
+
54
+ // The default InteractionID object is a global singleton stored in globalThis.
55
+ // It holds the root value used in routing and is updated when new interactions start.
56
+ export var DefaultInteractionID = initializeGlobalDefaultInteractionID();
43
57
 
44
58
  // Subscription functions
45
59
  export var subscribeToInteractionIdChanges = function subscribeToInteractionIdChanges(listener) {
@@ -3,6 +3,9 @@ export type InteractionIDContextType = {
3
3
  current: string | null;
4
4
  };
5
5
  type InteractionIDListener = (newId: string | null) => void;
6
+ declare global {
7
+ var __UFO_DEFAULT_INTERACTION_ID__: InteractionIDContextType | undefined;
8
+ }
6
9
  export declare const DefaultInteractionID: InteractionIDContextType;
7
10
  export declare const subscribeToInteractionIdChanges: (listener: InteractionIDListener) => (() => void);
8
11
  declare const _default: import("react").Context<InteractionIDContextType>;
@@ -3,6 +3,9 @@ export type InteractionIDContextType = {
3
3
  current: string | null;
4
4
  };
5
5
  type InteractionIDListener = (newId: string | null) => void;
6
+ declare global {
7
+ var __UFO_DEFAULT_INTERACTION_ID__: InteractionIDContextType | undefined;
8
+ }
6
9
  export declare const DefaultInteractionID: InteractionIDContextType;
7
10
  export declare const subscribeToInteractionIdChanges: (listener: InteractionIDListener) => (() => void);
8
11
  declare const _default: import("react").Context<InteractionIDContextType>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "3.13.11",
3
+ "version": "3.13.12",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",