@fluentui/global-context 9.0.0-beta.1 → 9.0.0-beta.11

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/CHANGELOG.json CHANGED
@@ -2,7 +2,307 @@
2
2
  "name": "@fluentui/global-context",
3
3
  "entries": [
4
4
  {
5
- "date": "Tue, 28 Jun 2022 15:09:20 GMT",
5
+ "date": "Wed, 04 Jan 2023 01:36:07 GMT",
6
+ "tag": "@fluentui/global-context_v9.0.0-beta.11",
7
+ "version": "9.0.0-beta.11",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "author": "martinhochel@microsoft.com",
12
+ "package": "@fluentui/global-context",
13
+ "commit": "4ec2b998b294d6d9c3196d3d82893bdd97d0c105",
14
+ "comment": "chore(scripts): move index.ts to to follow sub-folder domain packaging"
15
+ },
16
+ {
17
+ "author": "martinhochel@microsoft.com",
18
+ "package": "@fluentui/global-context",
19
+ "commit": "194b0cf0cc27c1c1233aa945f09b3ad29778d8ca",
20
+ "comment": "chore(scripts): use for @fluentui/scripts version within all package.json"
21
+ }
22
+ ],
23
+ "prerelease": [
24
+ {
25
+ "author": "beachball",
26
+ "package": "@fluentui/global-context",
27
+ "comment": "Bump @fluentui/react-context-selector to v9.1.4",
28
+ "commit": "3e322d15529451be153e97298873253e21af4082"
29
+ },
30
+ {
31
+ "author": "beachball",
32
+ "package": "@fluentui/global-context",
33
+ "comment": "Bump @fluentui/react-utilities to v9.3.1",
34
+ "commit": "3e322d15529451be153e97298873253e21af4082"
35
+ }
36
+ ]
37
+ }
38
+ },
39
+ {
40
+ "date": "Tue, 20 Dec 2022 14:59:34 GMT",
41
+ "tag": "@fluentui/global-context_v9.0.0-beta.10",
42
+ "version": "9.0.0-beta.10",
43
+ "comments": {
44
+ "prerelease": [
45
+ {
46
+ "author": "beachball",
47
+ "package": "@fluentui/global-context",
48
+ "comment": "Bump @fluentui/react-context-selector to v9.1.3",
49
+ "commit": "e7530bc179fd0e303448083c76a4af41a0e15322"
50
+ },
51
+ {
52
+ "author": "beachball",
53
+ "package": "@fluentui/global-context",
54
+ "comment": "Bump @fluentui/react-utilities to v9.3.0",
55
+ "commit": "e7530bc179fd0e303448083c76a4af41a0e15322"
56
+ }
57
+ ]
58
+ }
59
+ },
60
+ {
61
+ "date": "Thu, 17 Nov 2022 23:05:31 GMT",
62
+ "tag": "@fluentui/global-context_v9.0.0-beta.9",
63
+ "version": "9.0.0-beta.9",
64
+ "comments": {
65
+ "none": [
66
+ {
67
+ "author": "martinhochel@microsoft.com",
68
+ "package": "@fluentui/global-context",
69
+ "commit": "ea768501802d65d63ddc63fff3816fb6b5008ae4",
70
+ "comment": "chore: update package scaffold"
71
+ }
72
+ ],
73
+ "prerelease": [
74
+ {
75
+ "author": "beachball",
76
+ "package": "@fluentui/global-context",
77
+ "comment": "Bump @fluentui/react-context-selector to v9.1.2",
78
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
79
+ },
80
+ {
81
+ "author": "beachball",
82
+ "package": "@fluentui/global-context",
83
+ "comment": "Bump @fluentui/react-utilities to v9.2.2",
84
+ "commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
85
+ }
86
+ ]
87
+ }
88
+ },
89
+ {
90
+ "date": "Fri, 11 Nov 2022 14:57:50 GMT",
91
+ "tag": "@fluentui/global-context_v9.0.0-beta.8",
92
+ "version": "9.0.0-beta.8",
93
+ "comments": {
94
+ "prerelease": [
95
+ {
96
+ "author": "martinhochel@microsoft.com",
97
+ "package": "@fluentui/global-context",
98
+ "commit": "b3907043bd8d7b650c55e8e7c3119b14f2606c38",
99
+ "comment": "fix: create valid export maps"
100
+ },
101
+ {
102
+ "author": "beachball",
103
+ "package": "@fluentui/global-context",
104
+ "comment": "Bump @fluentui/react-context-selector to v9.1.1",
105
+ "commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
106
+ },
107
+ {
108
+ "author": "beachball",
109
+ "package": "@fluentui/global-context",
110
+ "comment": "Bump @fluentui/react-utilities to v9.2.1",
111
+ "commit": "b4c9a0ae8d7444bf746f1307ab01e2dc16310720"
112
+ }
113
+ ]
114
+ }
115
+ },
116
+ {
117
+ "date": "Wed, 02 Nov 2022 11:58:07 GMT",
118
+ "tag": "@fluentui/global-context_v9.0.0-beta.7",
119
+ "version": "9.0.0-beta.7",
120
+ "comments": {
121
+ "prerelease": [
122
+ {
123
+ "author": "beachball",
124
+ "package": "@fluentui/global-context",
125
+ "comment": "Bump @fluentui/react-context-selector to v9.1.0",
126
+ "commit": "393a7b169155997a97a6ce1ad36ee3eafc6f461b"
127
+ },
128
+ {
129
+ "author": "beachball",
130
+ "package": "@fluentui/global-context",
131
+ "comment": "Bump @fluentui/react-utilities to v9.2.0",
132
+ "commit": "393a7b169155997a97a6ce1ad36ee3eafc6f461b"
133
+ }
134
+ ]
135
+ }
136
+ },
137
+ {
138
+ "date": "Tue, 25 Oct 2022 00:35:27 GMT",
139
+ "tag": "@fluentui/global-context_v9.0.0-beta.6",
140
+ "version": "9.0.0-beta.6",
141
+ "comments": {
142
+ "none": [
143
+ {
144
+ "author": "miroslav.stastny@microsoft.com",
145
+ "package": "@fluentui/global-context",
146
+ "commit": "6ced976a8d0e6a0e2e207da8fe0eb810e2bd19bc",
147
+ "comment": "Update package readme"
148
+ },
149
+ {
150
+ "author": "tristan.watanabe@gmail.com",
151
+ "package": "@fluentui/global-context",
152
+ "commit": "07141711530bbdba82fd5198fe4bcef462403f40",
153
+ "comment": "chore: Migrate to new package structure."
154
+ }
155
+ ]
156
+ }
157
+ },
158
+ {
159
+ "date": "Thu, 20 Oct 2022 08:39:56 GMT",
160
+ "tag": "@fluentui/global-context_v9.0.0-beta.6",
161
+ "version": "9.0.0-beta.6",
162
+ "comments": {
163
+ "prerelease": [
164
+ {
165
+ "author": "mgodbolt@microsoft.com",
166
+ "package": "@fluentui/global-context",
167
+ "commit": "17096b3137d9d3e7c7443ddc3ce0738b2910a334",
168
+ "comment": "chore: Bump peer deps to support React 18"
169
+ },
170
+ {
171
+ "author": "beachball",
172
+ "package": "@fluentui/global-context",
173
+ "comment": "Bump @fluentui/react-context-selector to v9.0.5",
174
+ "commit": "5ea1372675d910d76cf1b9cbd74d05b7c4e8fcbc"
175
+ },
176
+ {
177
+ "author": "beachball",
178
+ "package": "@fluentui/global-context",
179
+ "comment": "Bump @fluentui/react-utilities to v9.1.2",
180
+ "commit": "5ea1372675d910d76cf1b9cbd74d05b7c4e8fcbc"
181
+ }
182
+ ]
183
+ }
184
+ },
185
+ {
186
+ "date": "Thu, 13 Oct 2022 11:03:06 GMT",
187
+ "tag": "@fluentui/global-context_v9.0.0-beta.5",
188
+ "version": "9.0.0-beta.5",
189
+ "comments": {
190
+ "prerelease": [
191
+ {
192
+ "author": "beachball",
193
+ "package": "@fluentui/global-context",
194
+ "comment": "Bump @fluentui/react-context-selector to v9.0.4",
195
+ "commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
196
+ },
197
+ {
198
+ "author": "beachball",
199
+ "package": "@fluentui/global-context",
200
+ "comment": "Bump @fluentui/react-utilities to v9.1.1",
201
+ "commit": "cd05c21e62ff37812d614330eb70f97fd978c97a"
202
+ }
203
+ ]
204
+ }
205
+ },
206
+ {
207
+ "date": "Thu, 15 Sep 2022 09:49:44 GMT",
208
+ "tag": "@fluentui/global-context_v9.0.0-beta.4",
209
+ "version": "9.0.0-beta.4",
210
+ "comments": {
211
+ "none": [
212
+ {
213
+ "author": "martinhochel@microsoft.com",
214
+ "package": "@fluentui/global-context",
215
+ "commit": "e6cf183695d6d67a24e038c49a876224e5ed35e5",
216
+ "comment": "chore: update package scaffold"
217
+ },
218
+ {
219
+ "author": "martinhochel@microsoft.com",
220
+ "package": "@fluentui/global-context",
221
+ "commit": "ba9444d594f3a960cc590eae5237c08bf7c5a07f",
222
+ "comment": "chore: consume cypress.config from it's package boundary"
223
+ }
224
+ ],
225
+ "prerelease": [
226
+ {
227
+ "author": "beachball",
228
+ "package": "@fluentui/global-context",
229
+ "comment": "Bump @fluentui/react-context-selector to v9.0.3",
230
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
231
+ },
232
+ {
233
+ "author": "beachball",
234
+ "package": "@fluentui/global-context",
235
+ "comment": "Bump @fluentui/react-utilities to v9.1.0",
236
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
237
+ }
238
+ ]
239
+ }
240
+ },
241
+ {
242
+ "date": "Wed, 03 Aug 2022 16:03:35 GMT",
243
+ "tag": "@fluentui/global-context_v9.0.0-beta.3",
244
+ "version": "9.0.0-beta.3",
245
+ "comments": {
246
+ "none": [
247
+ {
248
+ "author": "bernardo.sunderhus@gmail.com",
249
+ "package": "@fluentui/global-context",
250
+ "commit": "d966ea3d9169f2e8d69f0d2a4daf86fe4ca328d6",
251
+ "comment": "disables eslint rule @fluentui/no-context-default-value for local component context"
252
+ }
253
+ ]
254
+ }
255
+ },
256
+ {
257
+ "date": "Thu, 14 Jul 2022 21:21:07 GMT",
258
+ "tag": "@fluentui/global-context_v9.0.0-beta.3",
259
+ "version": "9.0.0-beta.3",
260
+ "comments": {
261
+ "prerelease": [
262
+ {
263
+ "author": "Humberto.Morimoto@microsoft.com",
264
+ "package": "@fluentui/global-context",
265
+ "commit": "802bc4e3730a88b0fc61b5bf42ef7fc6b6543fe2",
266
+ "comment": "fix: Fixing bad version bump of @fluentui/react-utilities."
267
+ },
268
+ {
269
+ "author": "beachball",
270
+ "package": "@fluentui/global-context",
271
+ "comment": "Bump @fluentui/react-context-selector to v9.0.2",
272
+ "commit": "79b513146194367544160f364b0a7dd749ed93e4"
273
+ },
274
+ {
275
+ "author": "beachball",
276
+ "package": "@fluentui/global-context",
277
+ "comment": "Bump @fluentui/react-utilities to v9.0.2",
278
+ "commit": "79b513146194367544160f364b0a7dd749ed93e4"
279
+ }
280
+ ]
281
+ }
282
+ },
283
+ {
284
+ "date": "Thu, 14 Jul 2022 17:06:26 GMT",
285
+ "tag": "@fluentui/global-context_v9.0.0-beta.2",
286
+ "version": "9.0.0-beta.2",
287
+ "comments": {
288
+ "prerelease": [
289
+ {
290
+ "author": "beachball",
291
+ "package": "@fluentui/global-context",
292
+ "comment": "Bump @fluentui/react-context-selector to v9.0.1",
293
+ "commit": "35237381e941c8935b1892c9217096cea3e5601f"
294
+ },
295
+ {
296
+ "author": "beachball",
297
+ "package": "@fluentui/global-context",
298
+ "comment": "Bump @fluentui/react-utilities to v9.0.1-0",
299
+ "commit": "35237381e941c8935b1892c9217096cea3e5601f"
300
+ }
301
+ ]
302
+ }
303
+ },
304
+ {
305
+ "date": "Tue, 28 Jun 2022 15:14:09 GMT",
6
306
  "tag": "@fluentui/global-context_v9.0.0-beta.1",
7
307
  "version": "9.0.0-beta.1",
8
308
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,115 @@
1
1
  # Change Log - @fluentui/global-context
2
2
 
3
- This log was last generated on Tue, 28 Jun 2022 15:09:20 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 04 Jan 2023 01:36:07 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.0-beta.11](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.11)
8
+
9
+ Wed, 04 Jan 2023 01:36:07 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.10..@fluentui/global-context_v9.0.0-beta.11)
11
+
12
+ ### Changes
13
+
14
+ - Bump @fluentui/react-context-selector to v9.1.4 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
15
+ - Bump @fluentui/react-utilities to v9.3.1 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
16
+
17
+ ## [9.0.0-beta.10](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.10)
18
+
19
+ Tue, 20 Dec 2022 14:59:34 GMT
20
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.9..@fluentui/global-context_v9.0.0-beta.10)
21
+
22
+ ### Changes
23
+
24
+ - Bump @fluentui/react-context-selector to v9.1.3 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
25
+ - Bump @fluentui/react-utilities to v9.3.0 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
26
+
27
+ ## [9.0.0-beta.9](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.9)
28
+
29
+ Thu, 17 Nov 2022 23:05:31 GMT
30
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.8..@fluentui/global-context_v9.0.0-beta.9)
31
+
32
+ ### Changes
33
+
34
+ - Bump @fluentui/react-context-selector to v9.1.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
35
+ - Bump @fluentui/react-utilities to v9.2.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
36
+
37
+ ## [9.0.0-beta.8](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.8)
38
+
39
+ Fri, 11 Nov 2022 14:57:50 GMT
40
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.7..@fluentui/global-context_v9.0.0-beta.8)
41
+
42
+ ### Changes
43
+
44
+ - fix: create valid export maps ([PR #25558](https://github.com/microsoft/fluentui/pull/25558) by martinhochel@microsoft.com)
45
+ - Bump @fluentui/react-context-selector to v9.1.1 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
46
+ - Bump @fluentui/react-utilities to v9.2.1 ([PR #25615](https://github.com/microsoft/fluentui/pull/25615) by beachball)
47
+
48
+ ## [9.0.0-beta.7](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.7)
49
+
50
+ Wed, 02 Nov 2022 11:58:07 GMT
51
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.6..@fluentui/global-context_v9.0.0-beta.7)
52
+
53
+ ### Changes
54
+
55
+ - Bump @fluentui/react-context-selector to v9.1.0 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
56
+ - Bump @fluentui/react-utilities to v9.2.0 ([PR #25456](https://github.com/microsoft/fluentui/pull/25456) by beachball)
57
+
58
+ ## [9.0.0-beta.6](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.6)
59
+
60
+ Thu, 20 Oct 2022 08:39:56 GMT
61
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.5..@fluentui/global-context_v9.0.0-beta.6)
62
+
63
+ ### Changes
64
+
65
+ - chore: Bump peer deps to support React 18 ([PR #24972](https://github.com/microsoft/fluentui/pull/24972) by mgodbolt@microsoft.com)
66
+ - Bump @fluentui/react-context-selector to v9.0.5 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
67
+ - Bump @fluentui/react-utilities to v9.1.2 ([PR #25265](https://github.com/microsoft/fluentui/pull/25265) by beachball)
68
+
69
+ ## [9.0.0-beta.5](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.5)
70
+
71
+ Thu, 13 Oct 2022 11:03:06 GMT
72
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.4..@fluentui/global-context_v9.0.0-beta.5)
73
+
74
+ ### Changes
75
+
76
+ - Bump @fluentui/react-context-selector to v9.0.4 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
77
+ - Bump @fluentui/react-utilities to v9.1.1 ([PR #25181](https://github.com/microsoft/fluentui/pull/25181) by beachball)
78
+
79
+ ## [9.0.0-beta.4](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.4)
80
+
81
+ Thu, 15 Sep 2022 09:49:44 GMT
82
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.3..@fluentui/global-context_v9.0.0-beta.4)
83
+
84
+ ### Changes
85
+
86
+ - Bump @fluentui/react-context-selector to v9.0.3 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
87
+ - Bump @fluentui/react-utilities to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
88
+
89
+ ## [9.0.0-beta.3](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.3)
90
+
91
+ Thu, 14 Jul 2022 21:21:07 GMT
92
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.2..@fluentui/global-context_v9.0.0-beta.3)
93
+
94
+ ### Changes
95
+
96
+ - fix: Fixing bad version bump of @fluentui/react-utilities. ([PR #23920](https://github.com/microsoft/fluentui/pull/23920) by Humberto.Morimoto@microsoft.com)
97
+ - Bump @fluentui/react-context-selector to v9.0.2 ([PR #23918](https://github.com/microsoft/fluentui/pull/23918) by beachball)
98
+ - Bump @fluentui/react-utilities to v9.0.2 ([PR #23918](https://github.com/microsoft/fluentui/pull/23918) by beachball)
99
+
100
+ ## [9.0.0-beta.2](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.2)
101
+
102
+ Thu, 14 Jul 2022 17:06:26 GMT
103
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.1..@fluentui/global-context_v9.0.0-beta.2)
104
+
105
+ ### Changes
106
+
107
+ - Bump @fluentui/react-context-selector to v9.0.1 ([PR #23897](https://github.com/microsoft/fluentui/pull/23897) by beachball)
108
+ - Bump @fluentui/react-utilities to v9.0.1-0 ([PR #23897](https://github.com/microsoft/fluentui/pull/23897) by beachball)
109
+
7
110
  ## [9.0.0-beta.1](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.1)
8
111
 
9
- Tue, 28 Jun 2022 15:09:20 GMT
112
+ Tue, 28 Jun 2022 15:14:09 GMT
10
113
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-alpha.0..@fluentui/global-context_v9.0.0-beta.1)
11
114
 
12
115
  ### Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @fluentui/global-context
2
2
 
3
- **Global Context for [Fluent UI React](https://developer.microsoft.com/en-us/fluentui)**
3
+ **Global Context for [Fluent UI React](https://react.fluentui.dev)**
4
4
 
5
5
  This package contains a shim for `React.createContext` API that will register the context object to the global
6
6
  scope (`window` for browsers, `global` for nodejs). This means that contexts will be real singletons.
@@ -2,17 +2,16 @@ import { createContext as baseCreateContext } from '@fluentui/react-context-sele
2
2
  import { canUseDOM } from '@fluentui/react-utilities';
3
3
  import { getMajorVersion } from './utils';
4
4
  const isBrowser = /*#__PURE__*/canUseDOM();
5
- const globalObject = isBrowser ? window : global; // Identifier for the symbol, for easy idenfitifaction of symbols created by this util
5
+ const globalObject = isBrowser ? window : global;
6
+ // Identifier for the symbol, for easy idenfitifaction of symbols created by this util
6
7
  // Useful for clearning global object during SSR reloads
7
-
8
- export const SYMBOL_NAMESPACE = 'global-context-selector:'; // During SSR the global object persists with the server process
8
+ export const SYMBOL_NAMESPACE = 'global-context-selector:';
9
+ // During SSR the global object persists with the server process
9
10
  // Clean out the global object during server reload during development
10
-
11
11
  if (!isBrowser && process.env.NODE_ENV !== 'production') {
12
12
  const globalSymbols = /*#__PURE__*/Object.getOwnPropertySymbols(globalObject);
13
13
  globalSymbols.forEach(sym => {
14
14
  var _a;
15
-
16
15
  if ((_a = Symbol.keyFor(sym)) === null || _a === void 0 ? void 0 : _a.startsWith(SYMBOL_NAMESPACE)) {
17
16
  // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
18
17
  delete globalObject[sym];
@@ -32,21 +31,18 @@ if (!isBrowser && process.env.NODE_ENV !== 'production') {
32
31
  * @param packageVersion - version of the npm package where the module is used
33
32
  * @returns @see React.createContext
34
33
  */
35
-
36
-
37
34
  export const createContext = (defaultValue, name, packageName, packageVersion) => {
38
35
  // Symbol guaranteed to be unique for the entire runtime
39
- const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`); // Objects keyed with symbols are not visible with console.log
36
+ const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);
37
+ // Objects keyed with symbols are not visible with console.log
40
38
  // Object symbol properties can't be iterated with `for` or `Object.keys`
41
-
42
39
  const globalSymbols = Object.getOwnPropertySymbols(globalObject);
43
-
44
40
  if (!globalSymbols.includes(sym)) {
45
41
  // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
42
+ // eslint-disable-next-line @fluentui/no-context-default-value
46
43
  globalObject[sym] = baseCreateContext(defaultValue);
47
- } // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
48
-
49
-
44
+ }
45
+ // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
50
46
  return globalObject[sym];
51
47
  };
52
48
  //# sourceMappingURL=global-context-selector.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["global-context-selector.ts"],"names":[],"mappings":"AACA,SAAS,aAAa,IAAI,iBAA1B,QAAmD,kCAAnD;AACA,SAAS,SAAT,QAA0B,2BAA1B;AACA,SAAS,eAAT,QAAgC,SAAhC;AAGA,MAAM,SAAS,gBAAG,SAAS,EAA3B;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACA,OAAO,MAAM,gBAAgB,GAAG,0BAAzB,C,CAEP;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACH,OAAO,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,eAAe,CAAC,cAAD,CAAgB,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA,YAAY,CAAC,GAAD,CAAZ,GAAoB,iBAAiB,CAAC,YAAD,CAArC;EACD,CAV4G,CAY7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAdM","sourcesContent":["import * as React from 'react';\nimport { createContext as baseCreateContext } from '@fluentui/react-context-selector';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { getMajorVersion } from './utils';\nimport { GlobalObject } from './types';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context-selector:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see createContext from \\@fluentui/react-context-selector that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n globalObject[sym] = baseCreateContext(defaultValue);\n }\n\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n return globalObject[sym] as React.Context<T>;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"AACA,SAASA,aAAa,IAAIC,iBAAiB,QAAQ,kCAAkC;AACrF,SAASC,SAAS,QAAQ,2BAA2B;AACrD,SAASC,eAAe,QAAQ,SAAS;AAGzC,MAAMC,SAAS,gBAAGF,SAAS,EAAE;AAC7B,MAAMG,YAAY,GAAiBD,SAAS,GAAGE,MAAM,GAAGC,MAAM;AAE9D;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,0BAA0B;AAE1D;AACA;AACA,IAAI,CAACJ,SAAS,IAAIK,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;EACvD,MAAMC,aAAa,gBAAGC,MAAM,CAACC,qBAAqB,CAACT,YAAY,CAAC;EAChEO,aAAa,CAACG,OAAO,CAACC,GAAG,IAAG;;IAC1B,IAAI,YAAM,CAACC,MAAM,CAACD,GAAG,CAAC,0CAAEE,UAAU,CAACV,gBAAgB,CAAC,EAAE;MACpD;MACA,OAAOH,YAAY,CAACW,GAAG,CAAC;;EAE5B,CAAC,CAAC;;AAGJ;;;;;;;;;;;;;AAaA,OAAO,MAAMhB,aAAa,GAAG,CAAImB,YAAe,EAAEC,IAAY,EAAEC,WAAmB,EAAEC,cAAsB,KAAI;EAC7G;EACA,MAAMN,GAAG,GAAGO,MAAM,CAACC,GAAG,CAAC,GAAGhB,gBAAgB,GAAGa,WAAW,IAAID,IAAI,KAAKjB,eAAe,CAACmB,cAAc,CAAC,EAAE,CAAC;EAEvG;EACA;EACA,MAAMV,aAAa,GAAGC,MAAM,CAACC,qBAAqB,CAACT,YAAY,CAAC;EAChE,IAAI,CAACO,aAAa,CAACa,QAAQ,CAACT,GAAG,CAAC,EAAE;IAChC;IACA;IACAX,YAAY,CAACW,GAAG,CAAC,GAAGf,iBAAiB,CAACkB,YAAY,CAAC;;EAGrD;EACA,OAAOd,YAAY,CAACW,GAAG,CAAqB;AAC9C,CAAC","names":["createContext","baseCreateContext","canUseDOM","getMajorVersion","isBrowser","globalObject","window","global","SYMBOL_NAMESPACE","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","keyFor","startsWith","defaultValue","name","packageName","packageVersion","Symbol","for","includes"],"sourceRoot":"../src/","sources":["packages/react-components/global-context/src/global-context-selector.ts"],"sourcesContent":["import * as React from 'react';\nimport { createContext as baseCreateContext } from '@fluentui/react-context-selector';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { getMajorVersion } from './utils';\nimport { GlobalObject } from './types';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context-selector:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see createContext from \\@fluentui/react-context-selector that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n // eslint-disable-next-line @fluentui/no-context-default-value\n globalObject[sym] = baseCreateContext(defaultValue);\n }\n\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n return globalObject[sym] as React.Context<T>;\n};\n"]}
@@ -2,17 +2,16 @@ import * as React from 'react';
2
2
  import { canUseDOM } from '@fluentui/react-utilities';
3
3
  import { getMajorVersion } from './utils';
4
4
  const isBrowser = /*#__PURE__*/canUseDOM();
5
- const globalObject = isBrowser ? window : global; // Identifier for the symbol, for easy idenfitifaction of symbols created by this util
5
+ const globalObject = isBrowser ? window : global;
6
+ // Identifier for the symbol, for easy idenfitifaction of symbols created by this util
6
7
  // Useful for clearning global object during SSR reloads
7
-
8
- export const SYMBOL_NAMESPACE = 'global-context:'; // During SSR the global object persists with the server process
8
+ export const SYMBOL_NAMESPACE = 'global-context:';
9
+ // During SSR the global object persists with the server process
9
10
  // Clean out the global object during server reload during development
10
-
11
11
  if (!isBrowser && process.env.NODE_ENV !== 'production') {
12
12
  const globalSymbols = /*#__PURE__*/Object.getOwnPropertySymbols(globalObject);
13
13
  globalSymbols.forEach(sym => {
14
14
  var _a;
15
-
16
15
  if ((_a = Symbol.keyFor(sym)) === null || _a === void 0 ? void 0 : _a.startsWith(SYMBOL_NAMESPACE)) {
17
16
  // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
18
17
  delete globalObject[sym];
@@ -32,21 +31,18 @@ if (!isBrowser && process.env.NODE_ENV !== 'production') {
32
31
  * @param packageVersion - version of the npm package where the module is used
33
32
  * @returns @see React.createContext
34
33
  */
35
-
36
-
37
34
  export const createContext = (defaultValue, name, packageName, packageVersion) => {
38
35
  // Symbol guaranteed to be unique for the entire runtime
39
- const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`); // Objects keyed with symbols are not visible with console.log
36
+ const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);
37
+ // Objects keyed with symbols are not visible with console.log
40
38
  // Object symbol properties can't be iterated with `for` or `Object.keys`
41
-
42
39
  const globalSymbols = Object.getOwnPropertySymbols(globalObject);
43
-
44
40
  if (!globalSymbols.includes(sym)) {
45
41
  // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
42
+ // eslint-disable-next-line @fluentui/no-context-default-value
46
43
  globalObject[sym] = /*#__PURE__*/React.createContext(defaultValue);
47
- } // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
48
-
49
-
44
+ }
45
+ // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
50
46
  return globalObject[sym];
51
47
  };
52
48
  //# sourceMappingURL=global-context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["global-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,SAAT,QAA0B,2BAA1B;AAEA,SAAS,eAAT,QAAgC,SAAhC;AAEA,MAAM,SAAS,gBAAG,SAAS,EAA3B;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACA,OAAO,MAAM,gBAAgB,GAAG,iBAAzB,C,CAEP;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACH,OAAO,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,eAAe,CAAC,cAAD,CAAgB,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA,YAAY,CAAC,GAAD,CAAZ,gBAAoB,KAAK,CAAC,aAAN,CAAoB,YAApB,CAApB;EACD,CAV4G,CAY7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAdM","sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { GlobalObject } from './types';\nimport { getMajorVersion } from './utils';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see React.createContext that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n globalObject[sym] = React.createContext(defaultValue);\n }\n\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n return globalObject[sym] as React.Context<T>;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,SAAS,QAAQ,2BAA2B;AAErD,SAASC,eAAe,QAAQ,SAAS;AAEzC,MAAMC,SAAS,gBAAGF,SAAS,EAAE;AAC7B,MAAMG,YAAY,GAAiBD,SAAS,GAAGE,MAAM,GAAGC,MAAM;AAE9D;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,iBAAiB;AAEjD;AACA;AACA,IAAI,CAACJ,SAAS,IAAIK,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;EACvD,MAAMC,aAAa,gBAAGC,MAAM,CAACC,qBAAqB,CAACT,YAAY,CAAC;EAChEO,aAAa,CAACG,OAAO,CAACC,GAAG,IAAG;;IAC1B,IAAI,YAAM,CAACC,MAAM,CAACD,GAAG,CAAC,0CAAEE,UAAU,CAACV,gBAAgB,CAAC,EAAE;MACpD;MACA,OAAOH,YAAY,CAACW,GAAG,CAAC;;EAE5B,CAAC,CAAC;;AAGJ;;;;;;;;;;;;;AAaA,OAAO,MAAMG,aAAa,GAAG,CAAIC,YAAe,EAAEC,IAAY,EAAEC,WAAmB,EAAEC,cAAsB,KAAI;EAC7G;EACA,MAAMP,GAAG,GAAGQ,MAAM,CAACC,GAAG,CAAC,GAAGjB,gBAAgB,GAAGc,WAAW,IAAID,IAAI,KAAKlB,eAAe,CAACoB,cAAc,CAAC,EAAE,CAAC;EAEvG;EACA;EACA,MAAMX,aAAa,GAAGC,MAAM,CAACC,qBAAqB,CAACT,YAAY,CAAC;EAChE,IAAI,CAACO,aAAa,CAACc,QAAQ,CAACV,GAAG,CAAC,EAAE;IAChC;IACA;IACAX,YAAY,CAACW,GAAG,CAAC,gBAAGf,KAAK,CAACkB,aAAa,CAACC,YAAY,CAAC;;EAGvD;EACA,OAAOf,YAAY,CAACW,GAAG,CAAqB;AAC9C,CAAC","names":["React","canUseDOM","getMajorVersion","isBrowser","globalObject","window","global","SYMBOL_NAMESPACE","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","keyFor","startsWith","createContext","defaultValue","name","packageName","packageVersion","Symbol","for","includes"],"sourceRoot":"../src/","sources":["packages/react-components/global-context/src/global-context.ts"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { GlobalObject } from './types';\nimport { getMajorVersion } from './utils';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see React.createContext that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n // eslint-disable-next-line @fluentui/no-context-default-value\n globalObject[sym] = React.createContext(defaultValue);\n }\n\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n return globalObject[sym] as React.Context<T>;\n};\n"]}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["export { createContext } from './global-context';\nexport { createContext as createContextSelector } from './global-context-selector';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/global-context/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["export { createContext } from './global-context';\nexport { createContext as createContextSelector } from './global-context-selector';\n"]}
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"../src/","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\nexport type GlobalObject = (typeof globalThis | NodeJS.Global) & Record<symbol, React.Context<unknown>>;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"../src/","sources":["packages/react-components/global-context/src/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\nexport type GlobalObject = (typeof globalThis | NodeJS.Global) & Record<symbol, React.Context<unknown>>;\n"]}
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["utils.ts"],"names":[],"mappings":"AAAA;;;AAGG;AACH,OAAM,SAAU,eAAV,CAA0B,OAA1B,EAAyC;EAC7C,OAAO,MAAM,CAAC,OAAO,CAAC,KAAR,CAAc,GAAd,EAAmB,CAAnB,CAAD,CAAb;AACD","sourcesContent":["/**\n * @param version - semver version string\n * @returns The major version number\n */\nexport function getMajorVersion(version: string) {\n return Number(version.split('.')[0]);\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"AAAA;;;;AAIA,OAAM,SAAUA,eAAe,CAACC,OAAe;EAC7C,OAAOC,MAAM,CAACD,OAAO,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC","names":["getMajorVersion","version","Number","split"],"sourceRoot":"../src/","sources":["packages/react-components/global-context/src/utils.ts"],"sourcesContent":["/**\n * @param version - semver version string\n * @returns The major version number\n */\nexport function getMajorVersion(version: string) {\n return Number(version.split('.')[0]);\n}\n"]}
@@ -4,25 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createContext = exports.SYMBOL_NAMESPACE = void 0;
7
-
8
7
  const react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
9
-
10
8
  const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
-
12
9
  const utils_1 = /*#__PURE__*/require("./utils");
13
-
14
10
  const isBrowser = /*#__PURE__*/react_utilities_1.canUseDOM();
15
- const globalObject = isBrowser ? window : global; // Identifier for the symbol, for easy idenfitifaction of symbols created by this util
11
+ const globalObject = isBrowser ? window : global;
12
+ // Identifier for the symbol, for easy idenfitifaction of symbols created by this util
16
13
  // Useful for clearning global object during SSR reloads
17
-
18
- exports.SYMBOL_NAMESPACE = 'global-context-selector:'; // During SSR the global object persists with the server process
14
+ exports.SYMBOL_NAMESPACE = 'global-context-selector:';
15
+ // During SSR the global object persists with the server process
19
16
  // Clean out the global object during server reload during development
20
-
21
17
  if (!isBrowser && process.env.NODE_ENV !== 'production') {
22
18
  const globalSymbols = /*#__PURE__*/Object.getOwnPropertySymbols(globalObject);
23
19
  globalSymbols.forEach(sym => {
24
20
  var _a;
25
-
26
21
  if ((_a = Symbol.keyFor(sym)) === null || _a === void 0 ? void 0 : _a.startsWith(exports.SYMBOL_NAMESPACE)) {
27
22
  // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
28
23
  delete globalObject[sym];
@@ -42,23 +37,19 @@ if (!isBrowser && process.env.NODE_ENV !== 'production') {
42
37
  * @param packageVersion - version of the npm package where the module is used
43
38
  * @returns @see React.createContext
44
39
  */
45
-
46
-
47
40
  const createContext = (defaultValue, name, packageName, packageVersion) => {
48
41
  // Symbol guaranteed to be unique for the entire runtime
49
- const sym = Symbol.for(`${exports.SYMBOL_NAMESPACE}${packageName}/${name}/@${utils_1.getMajorVersion(packageVersion)}`); // Objects keyed with symbols are not visible with console.log
42
+ const sym = Symbol.for(`${exports.SYMBOL_NAMESPACE}${packageName}/${name}/@${utils_1.getMajorVersion(packageVersion)}`);
43
+ // Objects keyed with symbols are not visible with console.log
50
44
  // Object symbol properties can't be iterated with `for` or `Object.keys`
51
-
52
45
  const globalSymbols = Object.getOwnPropertySymbols(globalObject);
53
-
54
46
  if (!globalSymbols.includes(sym)) {
55
47
  // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
48
+ // eslint-disable-next-line @fluentui/no-context-default-value
56
49
  globalObject[sym] = react_context_selector_1.createContext(defaultValue);
57
- } // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
58
-
59
-
50
+ }
51
+ // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
60
52
  return globalObject[sym];
61
53
  };
62
-
63
54
  exports.createContext = createContext;
64
55
  //# sourceMappingURL=global-context-selector.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["global-context-selector.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AAGA,MAAM,SAAS,gBAAG,iBAAA,CAAA,SAAA,EAAlB;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACa,OAAA,CAAA,gBAAA,GAAmB,0BAAnB,C,CAEb;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,OAAA,CAAA,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACI,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,OAAA,CAAA,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,OAAA,CAAA,eAAA,CAAgB,cAAhB,CAA+B,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA,YAAY,CAAC,GAAD,CAAZ,GAAoB,wBAAA,CAAA,aAAA,CAAkB,YAAlB,CAApB;EACD,CAV4G,CAY7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAdM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourcesContent":["import * as React from 'react';\nimport { createContext as baseCreateContext } from '@fluentui/react-context-selector';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { getMajorVersion } from './utils';\nimport { GlobalObject } from './types';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context-selector:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see createContext from \\@fluentui/react-context-selector that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n globalObject[sym] = baseCreateContext(defaultValue);\n }\n\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n return globalObject[sym] as React.Context<T>;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AACA;AACA;AACA;AAGA,MAAMA,SAAS,gBAAGC,2BAAS,EAAE;AAC7B,MAAMC,YAAY,GAAiBF,SAAS,GAAGG,MAAM,GAAGC,MAAM;AAE9D;AACA;AACaC,wBAAgB,GAAG,0BAA0B;AAE1D;AACA;AACA,IAAI,CAACL,SAAS,IAAIM,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;EACvD,MAAMC,aAAa,gBAAGC,MAAM,CAACC,qBAAqB,CAACT,YAAY,CAAC;EAChEO,aAAa,CAACG,OAAO,CAACC,GAAG,IAAG;;IAC1B,IAAI,YAAM,CAACC,MAAM,CAACD,GAAG,CAAC,0CAAEE,UAAU,CAACV,wBAAgB,CAAC,EAAE;MACpD;MACA,OAAOH,YAAY,CAACW,GAAG,CAAC;;EAE5B,CAAC,CAAC;;AAGJ;;;;;;;;;;;;;AAaO,MAAMG,aAAa,GAAG,CAAIC,YAAe,EAAEC,IAAY,EAAEC,WAAmB,EAAEC,cAAsB,KAAI;EAC7G;EACA,MAAMP,GAAG,GAAGQ,MAAM,CAACC,GAAG,CAAC,GAAGjB,wBAAgB,GAAGc,WAAW,IAAID,IAAI,KAAKK,uBAAe,CAACH,cAAc,CAAC,EAAE,CAAC;EAEvG;EACA;EACA,MAAMX,aAAa,GAAGC,MAAM,CAACC,qBAAqB,CAACT,YAAY,CAAC;EAChE,IAAI,CAACO,aAAa,CAACe,QAAQ,CAACX,GAAG,CAAC,EAAE;IAChC;IACA;IACAX,YAAY,CAACW,GAAG,CAAC,GAAGY,sCAAiB,CAACR,YAAY,CAAC;;EAGrD;EACA,OAAOf,YAAY,CAACW,GAAG,CAAqB;AAC9C,CAAC;AAfYR,qBAAa","names":["isBrowser","react_utilities_1","globalObject","window","global","exports","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","keyFor","startsWith","createContext","defaultValue","name","packageName","packageVersion","Symbol","for","utils_1","includes","react_context_selector_1"],"sourceRoot":"../src/","sources":["packages/react-components/global-context/src/global-context-selector.ts"],"sourcesContent":["import * as React from 'react';\nimport { createContext as baseCreateContext } from '@fluentui/react-context-selector';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { getMajorVersion } from './utils';\nimport { GlobalObject } from './types';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context-selector:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see createContext from \\@fluentui/react-context-selector that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n // eslint-disable-next-line @fluentui/no-context-default-value\n globalObject[sym] = baseCreateContext(defaultValue);\n }\n\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n return globalObject[sym] as React.Context<T>;\n};\n"]}
@@ -4,25 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createContext = exports.SYMBOL_NAMESPACE = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
-
12
9
  const utils_1 = /*#__PURE__*/require("./utils");
13
-
14
10
  const isBrowser = /*#__PURE__*/react_utilities_1.canUseDOM();
15
- const globalObject = isBrowser ? window : global; // Identifier for the symbol, for easy idenfitifaction of symbols created by this util
11
+ const globalObject = isBrowser ? window : global;
12
+ // Identifier for the symbol, for easy idenfitifaction of symbols created by this util
16
13
  // Useful for clearning global object during SSR reloads
17
-
18
- exports.SYMBOL_NAMESPACE = 'global-context:'; // During SSR the global object persists with the server process
14
+ exports.SYMBOL_NAMESPACE = 'global-context:';
15
+ // During SSR the global object persists with the server process
19
16
  // Clean out the global object during server reload during development
20
-
21
17
  if (!isBrowser && process.env.NODE_ENV !== 'production') {
22
18
  const globalSymbols = /*#__PURE__*/Object.getOwnPropertySymbols(globalObject);
23
19
  globalSymbols.forEach(sym => {
24
20
  var _a;
25
-
26
21
  if ((_a = Symbol.keyFor(sym)) === null || _a === void 0 ? void 0 : _a.startsWith(exports.SYMBOL_NAMESPACE)) {
27
22
  // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
28
23
  delete globalObject[sym];
@@ -42,23 +37,19 @@ if (!isBrowser && process.env.NODE_ENV !== 'production') {
42
37
  * @param packageVersion - version of the npm package where the module is used
43
38
  * @returns @see React.createContext
44
39
  */
45
-
46
-
47
40
  const createContext = (defaultValue, name, packageName, packageVersion) => {
48
41
  // Symbol guaranteed to be unique for the entire runtime
49
- const sym = Symbol.for(`${exports.SYMBOL_NAMESPACE}${packageName}/${name}/@${utils_1.getMajorVersion(packageVersion)}`); // Objects keyed with symbols are not visible with console.log
42
+ const sym = Symbol.for(`${exports.SYMBOL_NAMESPACE}${packageName}/${name}/@${utils_1.getMajorVersion(packageVersion)}`);
43
+ // Objects keyed with symbols are not visible with console.log
50
44
  // Object symbol properties can't be iterated with `for` or `Object.keys`
51
-
52
45
  const globalSymbols = Object.getOwnPropertySymbols(globalObject);
53
-
54
46
  if (!globalSymbols.includes(sym)) {
55
47
  // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
48
+ // eslint-disable-next-line @fluentui/no-context-default-value
56
49
  globalObject[sym] = React.createContext(defaultValue);
57
- } // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
58
-
59
-
50
+ }
51
+ // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
60
52
  return globalObject[sym];
61
53
  };
62
-
63
54
  exports.createContext = createContext;
64
55
  //# sourceMappingURL=global-context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["global-context.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAEA,MAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AAEA,MAAM,SAAS,gBAAG,iBAAA,CAAA,SAAA,EAAlB;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACa,OAAA,CAAA,gBAAA,GAAmB,iBAAnB,C,CAEb;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,OAAA,CAAA,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACI,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,OAAA,CAAA,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,OAAA,CAAA,eAAA,CAAgB,cAAhB,CAA+B,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA,YAAY,CAAC,GAAD,CAAZ,GAAoB,KAAK,CAAC,aAAN,CAAoB,YAApB,CAApB;EACD,CAV4G,CAY7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAdM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { GlobalObject } from './types';\nimport { getMajorVersion } from './utils';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see React.createContext that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n globalObject[sym] = React.createContext(defaultValue);\n }\n\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n return globalObject[sym] as React.Context<T>;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AAEA;AAEA,MAAMA,SAAS,gBAAGC,2BAAS,EAAE;AAC7B,MAAMC,YAAY,GAAiBF,SAAS,GAAGG,MAAM,GAAGC,MAAM;AAE9D;AACA;AACaC,wBAAgB,GAAG,iBAAiB;AAEjD;AACA;AACA,IAAI,CAACL,SAAS,IAAIM,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;EACvD,MAAMC,aAAa,gBAAGC,MAAM,CAACC,qBAAqB,CAACT,YAAY,CAAC;EAChEO,aAAa,CAACG,OAAO,CAACC,GAAG,IAAG;;IAC1B,IAAI,YAAM,CAACC,MAAM,CAACD,GAAG,CAAC,0CAAEE,UAAU,CAACV,wBAAgB,CAAC,EAAE;MACpD;MACA,OAAOH,YAAY,CAACW,GAAG,CAAC;;EAE5B,CAAC,CAAC;;AAGJ;;;;;;;;;;;;;AAaO,MAAMG,aAAa,GAAG,CAAIC,YAAe,EAAEC,IAAY,EAAEC,WAAmB,EAAEC,cAAsB,KAAI;EAC7G;EACA,MAAMP,GAAG,GAAGQ,MAAM,CAACC,GAAG,CAAC,GAAGjB,wBAAgB,GAAGc,WAAW,IAAID,IAAI,KAAKK,uBAAe,CAACH,cAAc,CAAC,EAAE,CAAC;EAEvG;EACA;EACA,MAAMX,aAAa,GAAGC,MAAM,CAACC,qBAAqB,CAACT,YAAY,CAAC;EAChE,IAAI,CAACO,aAAa,CAACe,QAAQ,CAACX,GAAG,CAAC,EAAE;IAChC;IACA;IACAX,YAAY,CAACW,GAAG,CAAC,GAAGY,KAAK,CAACT,aAAa,CAACC,YAAY,CAAC;;EAGvD;EACA,OAAOf,YAAY,CAACW,GAAG,CAAqB;AAC9C,CAAC;AAfYR,qBAAa","names":["isBrowser","react_utilities_1","globalObject","window","global","exports","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","keyFor","startsWith","createContext","defaultValue","name","packageName","packageVersion","Symbol","for","utils_1","includes","React"],"sourceRoot":"../src/","sources":["packages/react-components/global-context/src/global-context.ts"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { GlobalObject } from './types';\nimport { getMajorVersion } from './utils';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see React.createContext that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n // eslint-disable-next-line @fluentui/no-context-default-value\n globalObject[sym] = React.createContext(defaultValue);\n }\n\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n return globalObject[sym] as React.Context<T>;\n};\n"]}
@@ -4,18 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createContextSelector = exports.createContext = void 0;
7
-
8
7
  var global_context_1 = /*#__PURE__*/require("./global-context");
9
-
10
8
  Object.defineProperty(exports, "createContext", {
11
9
  enumerable: true,
12
10
  get: function () {
13
11
  return global_context_1.createContext;
14
12
  }
15
13
  });
16
-
17
14
  var global_context_selector_1 = /*#__PURE__*/require("./global-context-selector");
18
-
19
15
  Object.defineProperty(exports, "createContextSelector", {
20
16
  enumerable: true,
21
17
  get: function () {
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,gBAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,eAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,gBAAA,CAAA,aAAA;EAAa;AAAb,CAAA;;AACT,IAAA,yBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,uBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,yBAAA,CAAA,aAAA;EAAa;AAAb,CAAA","sourcesContent":["export { createContext } from './global-context';\nexport { createContext as createContextSelector } from './global-context-selector';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AAASA;EAAAC;EAAAC;IAAA,qCAAa;EAAA;AAAA;AACtB;AAASF;EAAAC;EAAAC;IAAA,8CAAa;EAAA;AAAA","names":["Object","enumerable","get"],"sourceRoot":"../src/","sources":["packages/react-components/global-context/src/index.ts"],"sourcesContent":["export { createContext } from './global-context';\nexport { createContext as createContextSelector } from './global-context-selector';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
@@ -8,10 +8,8 @@ exports.getMajorVersion = void 0;
8
8
  * @param version - semver version string
9
9
  * @returns The major version number
10
10
  */
11
-
12
11
  function getMajorVersion(version) {
13
12
  return Number(version.split('.')[0]);
14
13
  }
15
-
16
14
  exports.getMajorVersion = getMajorVersion;
17
15
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["utils.ts"],"names":[],"mappings":";;;;;;AAAA;;;AAGG;;AACH,SAAgB,eAAhB,CAAgC,OAAhC,EAA+C;EAC7C,OAAO,MAAM,CAAC,OAAO,CAAC,KAAR,CAAc,GAAd,EAAmB,CAAnB,CAAD,CAAb;AACD;;AAFD,OAAA,CAAA,eAAA,GAAA,eAAA","sourcesContent":["/**\n * @param version - semver version string\n * @returns The major version number\n */\nexport function getMajorVersion(version: string) {\n return Number(version.split('.')[0]);\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;;;;AAIA,SAAgBA,eAAe,CAACC,OAAe;EAC7C,OAAOC,MAAM,CAACD,OAAO,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC;AAFAC","names":["getMajorVersion","version","Number","split","exports"],"sourceRoot":"../src/","sources":["packages/react-components/global-context/src/utils.ts"],"sourcesContent":["/**\n * @param version - semver version string\n * @returns The major version number\n */\nexport function getMajorVersion(version: string) {\n return Number(version.split('.')[0]);\n}\n"]}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@fluentui/global-context",
3
- "version": "9.0.0-beta.1",
3
+ "version": "9.0.0-beta.11",
4
4
  "description": "Extension of React createContext to be a true singleton on the global scope",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
7
- "typings": "dist/index.d.ts",
7
+ "typings": "./dist/index.d.ts",
8
8
  "sideEffects": false,
9
9
  "repository": {
10
10
  "type": "git",
@@ -16,31 +16,28 @@
16
16
  "bundle-size": "bundle-size measure",
17
17
  "clean": "just-scripts clean",
18
18
  "code-style": "just-scripts code-style",
19
- "e2e": "yarn cypress run --component",
20
- "e2e:local": "yarn cypress open --component",
19
+ "e2e": "cypress run --component",
20
+ "e2e:local": "cypress open --component",
21
21
  "just": "just-scripts",
22
22
  "lint": "just-scripts lint",
23
- "start": "yarn storybook",
24
23
  "test": "jest --passWithNoTests",
25
- "docs": "api-extractor run --config=config/api-extractor.local.json --local",
26
- "build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/types/packages/react-components/global-context/src && yarn docs",
27
- "storybook": "node ../../../scripts/storybook/runner",
28
- "type-check": "tsc -b tsconfig.json"
24
+ "type-check": "tsc -b tsconfig.json",
25
+ "generate-api": "tsc -p ./tsconfig.lib.json --emitDeclarationOnly && just-scripts api-extractor"
29
26
  },
30
27
  "devDependencies": {
31
28
  "@fluentui/eslint-plugin": "*",
32
- "@fluentui/scripts": "^1.0.0"
29
+ "@fluentui/scripts": "*"
33
30
  },
34
31
  "dependencies": {
35
- "@fluentui/react-context-selector": "^9.0.0",
36
- "@fluentui/react-utilities": "^9.0.0",
32
+ "@fluentui/react-context-selector": "^9.1.4",
33
+ "@fluentui/react-utilities": "^9.3.1",
37
34
  "tslib": "^2.1.0"
38
35
  },
39
36
  "peerDependencies": {
40
- "@types/react": ">=16.8.0 <18.0.0",
41
- "@types/react-dom": ">=16.8.0 <18.0.0",
42
- "react": ">=16.8.0 <18.0.0",
43
- "react-dom": ">=16.8.0 <18.0.0",
37
+ "@types/react": ">=16.8.0 <19.0.0",
38
+ "@types/react-dom": ">=16.8.0 <19.0.0",
39
+ "react": ">=16.8.0 <19.0.0",
40
+ "react-dom": ">=16.8.0 <19.0.0",
44
41
  "scheduler": "^0.19.0 || ^0.20.0"
45
42
  },
46
43
  "beachball": {
@@ -49,5 +46,13 @@
49
46
  "minor",
50
47
  "patch"
51
48
  ]
49
+ },
50
+ "exports": {
51
+ ".": {
52
+ "types": "./dist/index.d.ts",
53
+ "import": "./lib/index.js",
54
+ "require": "./lib-commonjs/index.js"
55
+ },
56
+ "./package.json": "./package.json"
52
57
  }
53
58
  }
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.18.1"
9
- }
10
- ]
11
- }