@fluentui/global-context 9.0.0-beta.28 → 9.0.0-beta.29
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 +30 -1
- package/CHANGELOG.md +12 -2
- package/lib/global-context-selector.js +19 -24
- package/lib/global-context-selector.js.map +1 -1
- package/lib/global-context.js +19 -24
- package/lib/global-context.js.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/types.js +0 -1
- package/lib/types.js.map +1 -1
- package/lib/utils.js +2 -3
- package/lib/utils.js.map +1 -1
- package/lib-commonjs/global-context-selector.js +3 -8
- package/lib-commonjs/global-context-selector.js.map +1 -1
- package/lib-commonjs/global-context.js +3 -8
- package/lib-commonjs/global-context.js.map +1 -1
- package/lib-commonjs/index.js +0 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types.js +0 -3
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/utils.js +1 -3
- package/lib-commonjs/utils.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,36 @@
|
|
|
2
2
|
"name": "@fluentui/global-context",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Wed, 31 May 2023 06:42:51 GMT",
|
|
6
|
+
"tag": "@fluentui/global-context_v9.0.0-beta.29",
|
|
7
|
+
"version": "9.0.0-beta.29",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"author": "martinhochel@microsoft.com",
|
|
12
|
+
"package": "@fluentui/global-context",
|
|
13
|
+
"commit": "4b637ced41e430bf8d79c7fc67c103d5efdfd3a8",
|
|
14
|
+
"comment": "fix: tweak type errors exposed in ts 4.5"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"prerelease": [
|
|
18
|
+
{
|
|
19
|
+
"author": "beachball",
|
|
20
|
+
"package": "@fluentui/global-context",
|
|
21
|
+
"comment": "Bump @fluentui/react-context-selector to v9.1.22",
|
|
22
|
+
"commit": "17ca96c6b7f684f36a5c63e40e78b4986a86c713"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"author": "beachball",
|
|
26
|
+
"package": "@fluentui/global-context",
|
|
27
|
+
"comment": "Bump @fluentui/react-utilities to v9.9.2",
|
|
28
|
+
"commit": "17ca96c6b7f684f36a5c63e40e78b4986a86c713"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"date": "Thu, 25 May 2023 10:00:48 GMT",
|
|
6
35
|
"tag": "@fluentui/global-context_v9.0.0-beta.28",
|
|
7
36
|
"version": "9.0.0-beta.28",
|
|
8
37
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
# Change Log - @fluentui/global-context
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 31 May 2023 06:42:51 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-beta.29](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.29)
|
|
8
|
+
|
|
9
|
+
Wed, 31 May 2023 06:42:51 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.28..@fluentui/global-context_v9.0.0-beta.29)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- Bump @fluentui/react-context-selector to v9.1.22 ([PR #28054](https://github.com/microsoft/fluentui/pull/28054) by beachball)
|
|
15
|
+
- Bump @fluentui/react-utilities to v9.9.2 ([PR #28054](https://github.com/microsoft/fluentui/pull/28054) by beachball)
|
|
16
|
+
|
|
7
17
|
## [9.0.0-beta.28](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.28)
|
|
8
18
|
|
|
9
|
-
Thu, 25 May 2023
|
|
19
|
+
Thu, 25 May 2023 10:00:48 GMT
|
|
10
20
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.27..@fluentui/global-context_v9.0.0-beta.28)
|
|
11
21
|
|
|
12
22
|
### Changes
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { createContext as baseCreateContext } from '@fluentui/react-context-selector';
|
|
3
3
|
import { canUseDOM } from '@fluentui/react-utilities';
|
|
4
4
|
import { getMajorVersion } from './utils';
|
|
5
|
-
const isBrowser =
|
|
5
|
+
const isBrowser = canUseDOM();
|
|
6
6
|
const globalObject = isBrowser ? window : global;
|
|
7
7
|
// Identifier for the symbol, for easy idenfitifaction of symbols created by this util
|
|
8
8
|
// Useful for clearning global object during SSR reloads
|
|
@@ -10,14 +10,13 @@ export const SYMBOL_NAMESPACE = 'global-context-selector:';
|
|
|
10
10
|
// During SSR the global object persists with the server process
|
|
11
11
|
// Clean out the global object during server reload during development
|
|
12
12
|
if (!isBrowser && process.env.NODE_ENV !== 'production') {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
});
|
|
13
|
+
const globalSymbols = Object.getOwnPropertySymbols(globalObject);
|
|
14
|
+
globalSymbols.forEach((sym)=>{
|
|
15
|
+
var _Symbol_keyFor;
|
|
16
|
+
if ((_Symbol_keyFor = Symbol.keyFor(sym)) === null || _Symbol_keyFor === void 0 ? void 0 : _Symbol_keyFor.startsWith(SYMBOL_NAMESPACE)) {
|
|
17
|
+
delete globalObject[sym];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
21
20
|
}
|
|
22
21
|
/**
|
|
23
22
|
* Wrapper around @see createContext from \@fluentui/react-context-selector that implements context registration
|
|
@@ -31,19 +30,15 @@ if (!isBrowser && process.env.NODE_ENV !== 'production') {
|
|
|
31
30
|
* @param packageName - name of the npm package where the module is used
|
|
32
31
|
* @param packageVersion - version of the npm package where the module is used
|
|
33
32
|
* @returns @see React.createContext
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
globalObject[sym]
|
|
45
|
-
}
|
|
46
|
-
// @ts-expect-error - Indexing object with symbols not supported until TS 4.4
|
|
47
|
-
return globalObject[sym];
|
|
33
|
+
*/ export const createContext = (defaultValue, name, packageName, packageVersion)=>{
|
|
34
|
+
// Symbol guaranteed to be unique for the entire runtime
|
|
35
|
+
const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);
|
|
36
|
+
// Objects keyed with symbols are not visible with console.log
|
|
37
|
+
// Object symbol properties can't be iterated with `for` or `Object.keys`
|
|
38
|
+
const globalSymbols = Object.getOwnPropertySymbols(globalObject);
|
|
39
|
+
if (!globalSymbols.includes(sym)) {
|
|
40
|
+
// eslint-disable-next-line @fluentui/no-context-default-value
|
|
41
|
+
globalObject[sym] = baseCreateContext(defaultValue);
|
|
42
|
+
}
|
|
43
|
+
return globalObject[sym];
|
|
48
44
|
};
|
|
49
|
-
//# sourceMappingURL=global-context-selector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["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 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 // eslint-disable-next-line @fluentui/no-context-default-value\n globalObject[sym] = baseCreateContext<unknown>(defaultValue);\n }\n\n return globalObject[sym] as React.Context<T>;\n};\n"],"names":["React","createContext","baseCreateContext","canUseDOM","getMajorVersion","isBrowser","globalObject","window","global","SYMBOL_NAMESPACE","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","Symbol","keyFor","startsWith","defaultValue","name","packageName","packageVersion","for","includes"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,iBAAiBC,iBAAiB,QAAQ,mCAAmC;AACtF,SAASC,SAAS,QAAQ,4BAA4B;AACtD,SAASC,eAAe,QAAQ,UAAU;AAG1C,MAAMC,YAAYF;AAClB,MAAMG,eAA6BD,YAAYE,SAASC,MAAM;AAE9D,sFAAsF;AACtF,wDAAwD;AACxD,OAAO,MAAMC,mBAAmB,2BAA2B;AAE3D,gEAAgE;AAChE,sEAAsE;AACtE,IAAI,CAACJ,aAAaK,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACvD,MAAMC,gBAAgBC,OAAOC,qBAAqB,CAACT;IACnDO,cAAcG,OAAO,CAACC,CAAAA,MAAO;YACvBC;QAAJ,IAAIA,CAAAA,iBAAAA,OAAOC,MAAM,CAACF,kBAAdC,4BAAAA,KAAAA,IAAAA,eAAoBE,WAAWX,mBAAmB;YACpD,OAAOH,YAAY,CAACW,IAAI;QAC1B,CAAC;IACH;AACF,CAAC;AAED;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMhB,gBAAgB,CAAIoB,cAAiBC,MAAcC,aAAqBC,iBAA2B;IAC9G,wDAAwD;IACxD,MAAMP,MAAMC,OAAOO,GAAG,CAAC,CAAC,EAAEhB,iBAAiB,EAAEc,YAAY,CAAC,EAAED,KAAK,EAAE,EAAElB,gBAAgBoB,gBAAgB,CAAC;IAEtG,8DAA8D;IAC9D,yEAAyE;IACzE,MAAMX,gBAAgBC,OAAOC,qBAAqB,CAACT;IACnD,IAAI,CAACO,cAAca,QAAQ,CAACT,MAAM;QAChC,8DAA8D;QAC9DX,YAAY,CAACW,IAAI,GAAGf,kBAA2BmB;IACjD,CAAC;IAED,OAAOf,YAAY,CAACW,IAAI;AAC1B,EAAE"}
|
package/lib/global-context.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { canUseDOM } from '@fluentui/react-utilities';
|
|
3
3
|
import { getMajorVersion } from './utils';
|
|
4
|
-
const isBrowser =
|
|
4
|
+
const isBrowser = canUseDOM();
|
|
5
5
|
const globalObject = isBrowser ? window : global;
|
|
6
6
|
// Identifier for the symbol, for easy idenfitifaction of symbols created by this util
|
|
7
7
|
// Useful for clearning global object during SSR reloads
|
|
@@ -9,14 +9,13 @@ export const SYMBOL_NAMESPACE = 'global-context:';
|
|
|
9
9
|
// During SSR the global object persists with the server process
|
|
10
10
|
// Clean out the global object during server reload during development
|
|
11
11
|
if (!isBrowser && process.env.NODE_ENV !== 'production') {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
});
|
|
12
|
+
const globalSymbols = Object.getOwnPropertySymbols(globalObject);
|
|
13
|
+
globalSymbols.forEach((sym)=>{
|
|
14
|
+
var _Symbol_keyFor;
|
|
15
|
+
if ((_Symbol_keyFor = Symbol.keyFor(sym)) === null || _Symbol_keyFor === void 0 ? void 0 : _Symbol_keyFor.startsWith(SYMBOL_NAMESPACE)) {
|
|
16
|
+
delete globalObject[sym];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
20
19
|
}
|
|
21
20
|
/**
|
|
22
21
|
* Wrapper around @see React.createContext that implements context registration
|
|
@@ -30,19 +29,15 @@ if (!isBrowser && process.env.NODE_ENV !== 'production') {
|
|
|
30
29
|
* @param packageName - name of the npm package where the module is used
|
|
31
30
|
* @param packageVersion - version of the npm package where the module is used
|
|
32
31
|
* @returns @see React.createContext
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
globalObject[sym]
|
|
44
|
-
}
|
|
45
|
-
// @ts-expect-error - Indexing object with symbols not supported until TS 4.4
|
|
46
|
-
return globalObject[sym];
|
|
32
|
+
*/ export const createContext = (defaultValue, name, packageName, packageVersion)=>{
|
|
33
|
+
// Symbol guaranteed to be unique for the entire runtime
|
|
34
|
+
const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);
|
|
35
|
+
// Objects keyed with symbols are not visible with console.log
|
|
36
|
+
// Object symbol properties can't be iterated with `for` or `Object.keys`
|
|
37
|
+
const globalSymbols = Object.getOwnPropertySymbols(globalObject);
|
|
38
|
+
if (!globalSymbols.includes(sym)) {
|
|
39
|
+
// eslint-disable-next-line @fluentui/no-context-default-value
|
|
40
|
+
globalObject[sym] = React.createContext(defaultValue);
|
|
41
|
+
}
|
|
42
|
+
return globalObject[sym];
|
|
47
43
|
};
|
|
48
|
-
//# sourceMappingURL=global-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["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 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 // eslint-disable-next-line @fluentui/no-context-default-value\n globalObject[sym] = React.createContext<unknown>(defaultValue);\n }\n\n return globalObject[sym] as React.Context<T>;\n};\n"],"names":["React","canUseDOM","getMajorVersion","isBrowser","globalObject","window","global","SYMBOL_NAMESPACE","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","Symbol","keyFor","startsWith","createContext","defaultValue","name","packageName","packageVersion","for","includes"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,SAAS,QAAQ,4BAA4B;AAEtD,SAASC,eAAe,QAAQ,UAAU;AAE1C,MAAMC,YAAYF;AAClB,MAAMG,eAA6BD,YAAYE,SAASC,MAAM;AAE9D,sFAAsF;AACtF,wDAAwD;AACxD,OAAO,MAAMC,mBAAmB,kBAAkB;AAElD,gEAAgE;AAChE,sEAAsE;AACtE,IAAI,CAACJ,aAAaK,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACvD,MAAMC,gBAAgBC,OAAOC,qBAAqB,CAACT;IACnDO,cAAcG,OAAO,CAACC,CAAAA,MAAO;YACvBC;QAAJ,IAAIA,CAAAA,iBAAAA,OAAOC,MAAM,CAACF,kBAAdC,4BAAAA,KAAAA,IAAAA,eAAoBE,WAAWX,mBAAmB;YACpD,OAAOH,YAAY,CAACW,IAAI;QAC1B,CAAC;IACH;AACF,CAAC;AAED;;;;;;;;;;;;CAYC,GACD,OAAO,MAAMI,gBAAgB,CAAIC,cAAiBC,MAAcC,aAAqBC,iBAA2B;IAC9G,wDAAwD;IACxD,MAAMR,MAAMC,OAAOQ,GAAG,CAAC,CAAC,EAAEjB,iBAAiB,EAAEe,YAAY,CAAC,EAAED,KAAK,EAAE,EAAEnB,gBAAgBqB,gBAAgB,CAAC;IAEtG,8DAA8D;IAC9D,yEAAyE;IACzE,MAAMZ,gBAAgBC,OAAOC,qBAAqB,CAACT;IACnD,IAAI,CAACO,cAAcc,QAAQ,CAACV,MAAM;QAChC,8DAA8D;QAC9DX,YAAY,CAACW,IAAI,GAAGf,MAAMmB,aAAa,CAAUC;IACnD,CAAC;IAED,OAAOhB,YAAY,CAACW,IAAI;AAC1B,EAAE"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export { createContext } from './global-context';\nexport { createContext as createContextSelector } from './global-context-selector';\n"],"names":["createContext","createContextSelector"],"mappings":"AAAA,SAASA,aAAa,QAAQ,mBAAmB;AACjD,SAASA,iBAAiBC,qBAAqB,QAAQ,4BAA4B"}
|
package/lib/types.js
CHANGED
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type GlobalObject = typeof globalThis & Record<symbol, React.Context<unknown>>;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
package/lib/utils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param version - semver version string
|
|
3
3
|
* @returns The major version number
|
|
4
|
-
*/export function getMajorVersion(version) {
|
|
5
|
-
|
|
4
|
+
*/ export function getMajorVersion(version) {
|
|
5
|
+
return Number(version.split('.')[0]);
|
|
6
6
|
}
|
|
7
|
-
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["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"],"names":["getMajorVersion","version","Number","split"],"mappings":"AAAA;;;CAGC,GACD,OAAO,SAASA,gBAAgBC,OAAe,EAAE;IAC/C,OAAOC,OAAOD,QAAQE,KAAK,CAAC,IAAI,CAAC,EAAE;AACrC,CAAC"}
|
|
@@ -17,17 +17,16 @@ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
|
17
17
|
const _reactContextSelector = require("@fluentui/react-context-selector");
|
|
18
18
|
const _reactUtilities = require("@fluentui/react-utilities");
|
|
19
19
|
const _utils = require("./utils");
|
|
20
|
-
const isBrowser =
|
|
20
|
+
const isBrowser = (0, _reactUtilities.canUseDOM)();
|
|
21
21
|
const globalObject = isBrowser ? window : global;
|
|
22
22
|
const SYMBOL_NAMESPACE = 'global-context-selector:';
|
|
23
23
|
// During SSR the global object persists with the server process
|
|
24
24
|
// Clean out the global object during server reload during development
|
|
25
25
|
if (!isBrowser && process.env.NODE_ENV !== 'production') {
|
|
26
|
-
const globalSymbols =
|
|
26
|
+
const globalSymbols = Object.getOwnPropertySymbols(globalObject);
|
|
27
27
|
globalSymbols.forEach((sym)=>{
|
|
28
28
|
var _Symbol_keyFor;
|
|
29
29
|
if ((_Symbol_keyFor = Symbol.keyFor(sym)) === null || _Symbol_keyFor === void 0 ? void 0 : _Symbol_keyFor.startsWith(SYMBOL_NAMESPACE)) {
|
|
30
|
-
// @ts-expect-error - Indexing object with symbols not supported until TS 4.4
|
|
31
30
|
delete globalObject[sym];
|
|
32
31
|
}
|
|
33
32
|
});
|
|
@@ -39,12 +38,8 @@ const createContext = (defaultValue, name, packageName, packageVersion)=>{
|
|
|
39
38
|
// Object symbol properties can't be iterated with `for` or `Object.keys`
|
|
40
39
|
const globalSymbols = Object.getOwnPropertySymbols(globalObject);
|
|
41
40
|
if (!globalSymbols.includes(sym)) {
|
|
42
|
-
// @ts-expect-error - Indexing object with symbols not supported until TS 4.4
|
|
43
41
|
// eslint-disable-next-line @fluentui/no-context-default-value
|
|
44
42
|
globalObject[sym] = (0, _reactContextSelector.createContext)(defaultValue);
|
|
45
43
|
}
|
|
46
|
-
// @ts-expect-error - Indexing object with symbols not supported until TS 4.4
|
|
47
44
|
return globalObject[sym];
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=global-context-selector.js.map
|
|
45
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["global-context-selector.js"],"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';\nconst isBrowser = canUseDOM();\nconst globalObject = isBrowser ? window : global;\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// 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 var _Symbol_keyFor;\n if ((_Symbol_keyFor = Symbol.keyFor(sym)) === null || _Symbol_keyFor === void 0 ? void 0 : _Symbol_keyFor.startsWith(SYMBOL_NAMESPACE)) {\n delete globalObject[sym];\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 */ export const createContext = (defaultValue, name, packageName, packageVersion)=>{\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\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 // eslint-disable-next-line @fluentui/no-context-default-value\n globalObject[sym] = baseCreateContext(defaultValue);\n }\n return globalObject[sym];\n};\n"],"names":["SYMBOL_NAMESPACE","createContext","isBrowser","canUseDOM","globalObject","window","global","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","_Symbol_keyFor","Symbol","keyFor","startsWith","defaultValue","name","packageName","packageVersion","for","getMajorVersion","includes","baseCreateContext"],"mappings":";;;;;;;;;;;IAQaA,gBAAgB,MAAhBA;IAwBIC,aAAa,MAAbA;;;6DAhCM;sCAC4B;gCACzB;uBACM;AAChC,MAAMC,YAAYC,IAAAA,yBAAS;AAC3B,MAAMC,eAAeF,YAAYG,SAASC,MAAM;AAGzC,MAAMN,mBAAmB;AAChC,gEAAgE;AAChE,sEAAsE;AACtE,IAAI,CAACE,aAAaK,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACrD,MAAMC,gBAAgBC,OAAOC,qBAAqB,CAACR;IACnDM,cAAcG,OAAO,CAAC,CAACC,MAAM;QACzB,IAAIC;QACJ,IAAI,AAACA,CAAAA,iBAAiBC,OAAOC,MAAM,CAACH,IAAG,MAAO,IAAI,IAAIC,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeG,UAAU,CAAClB,iBAAiB,EAAE;YACpI,OAAOI,YAAY,CAACU,IAAI;QAC5B,CAAC;IACL;AACJ,CAAC;AAaU,MAAMb,gBAAgB,CAACkB,cAAcC,MAAMC,aAAaC,iBAAiB;IAChF,wDAAwD;IACxD,MAAMR,MAAME,OAAOO,GAAG,CAAC,CAAC,EAAEvB,iBAAiB,EAAEqB,YAAY,CAAC,EAAED,KAAK,EAAE,EAAEI,IAAAA,sBAAe,EAACF,gBAAgB,CAAC;IACtG,8DAA8D;IAC9D,yEAAyE;IACzE,MAAMZ,gBAAgBC,OAAOC,qBAAqB,CAACR;IACnD,IAAI,CAACM,cAAce,QAAQ,CAACX,MAAM;QAC9B,8DAA8D;QAC9DV,YAAY,CAACU,IAAI,GAAGY,IAAAA,mCAAiB,EAACP;IAC1C,CAAC;IACD,OAAOf,YAAY,CAACU,IAAI;AAC5B"}
|
|
@@ -16,17 +16,16 @@ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildc
|
|
|
16
16
|
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
17
17
|
const _reactUtilities = require("@fluentui/react-utilities");
|
|
18
18
|
const _utils = require("./utils");
|
|
19
|
-
const isBrowser =
|
|
19
|
+
const isBrowser = (0, _reactUtilities.canUseDOM)();
|
|
20
20
|
const globalObject = isBrowser ? window : global;
|
|
21
21
|
const SYMBOL_NAMESPACE = 'global-context:';
|
|
22
22
|
// During SSR the global object persists with the server process
|
|
23
23
|
// Clean out the global object during server reload during development
|
|
24
24
|
if (!isBrowser && process.env.NODE_ENV !== 'production') {
|
|
25
|
-
const globalSymbols =
|
|
25
|
+
const globalSymbols = Object.getOwnPropertySymbols(globalObject);
|
|
26
26
|
globalSymbols.forEach((sym)=>{
|
|
27
27
|
var _Symbol_keyFor;
|
|
28
28
|
if ((_Symbol_keyFor = Symbol.keyFor(sym)) === null || _Symbol_keyFor === void 0 ? void 0 : _Symbol_keyFor.startsWith(SYMBOL_NAMESPACE)) {
|
|
29
|
-
// @ts-expect-error - Indexing object with symbols not supported until TS 4.4
|
|
30
29
|
delete globalObject[sym];
|
|
31
30
|
}
|
|
32
31
|
});
|
|
@@ -38,12 +37,8 @@ const createContext = (defaultValue, name, packageName, packageVersion)=>{
|
|
|
38
37
|
// Object symbol properties can't be iterated with `for` or `Object.keys`
|
|
39
38
|
const globalSymbols = Object.getOwnPropertySymbols(globalObject);
|
|
40
39
|
if (!globalSymbols.includes(sym)) {
|
|
41
|
-
// @ts-expect-error - Indexing object with symbols not supported until TS 4.4
|
|
42
40
|
// eslint-disable-next-line @fluentui/no-context-default-value
|
|
43
41
|
globalObject[sym] = /*#__PURE__*/ _react.createContext(defaultValue);
|
|
44
42
|
}
|
|
45
|
-
// @ts-expect-error - Indexing object with symbols not supported until TS 4.4
|
|
46
43
|
return globalObject[sym];
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
//# sourceMappingURL=global-context.js.map
|
|
44
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["global-context.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { getMajorVersion } from './utils';\nconst isBrowser = canUseDOM();\nconst globalObject = isBrowser ? window : global;\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// 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 var _Symbol_keyFor;\n if ((_Symbol_keyFor = Symbol.keyFor(sym)) === null || _Symbol_keyFor === void 0 ? void 0 : _Symbol_keyFor.startsWith(SYMBOL_NAMESPACE)) {\n delete globalObject[sym];\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 */ export const createContext = (defaultValue, name, packageName, packageVersion)=>{\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\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 // eslint-disable-next-line @fluentui/no-context-default-value\n globalObject[sym] = React.createContext(defaultValue);\n }\n return globalObject[sym];\n};\n"],"names":["SYMBOL_NAMESPACE","createContext","isBrowser","canUseDOM","globalObject","window","global","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","_Symbol_keyFor","Symbol","keyFor","startsWith","defaultValue","name","packageName","packageVersion","for","getMajorVersion","includes","React"],"mappings":";;;;;;;;;;;IAOaA,gBAAgB,MAAhBA;IAwBIC,aAAa,MAAbA;;;6DA/BM;gCACG;uBACM;AAChC,MAAMC,YAAYC,IAAAA,yBAAS;AAC3B,MAAMC,eAAeF,YAAYG,SAASC,MAAM;AAGzC,MAAMN,mBAAmB;AAChC,gEAAgE;AAChE,sEAAsE;AACtE,IAAI,CAACE,aAAaK,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACrD,MAAMC,gBAAgBC,OAAOC,qBAAqB,CAACR;IACnDM,cAAcG,OAAO,CAAC,CAACC,MAAM;QACzB,IAAIC;QACJ,IAAI,AAACA,CAAAA,iBAAiBC,OAAOC,MAAM,CAACH,IAAG,MAAO,IAAI,IAAIC,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeG,UAAU,CAAClB,iBAAiB,EAAE;YACpI,OAAOI,YAAY,CAACU,IAAI;QAC5B,CAAC;IACL;AACJ,CAAC;AAaU,MAAMb,gBAAgB,CAACkB,cAAcC,MAAMC,aAAaC,iBAAiB;IAChF,wDAAwD;IACxD,MAAMR,MAAME,OAAOO,GAAG,CAAC,CAAC,EAAEvB,iBAAiB,EAAEqB,YAAY,CAAC,EAAED,KAAK,EAAE,EAAEI,IAAAA,sBAAe,EAACF,gBAAgB,CAAC;IACtG,8DAA8D;IAC9D,yEAAyE;IACzE,MAAMZ,gBAAgBC,OAAOC,qBAAqB,CAACR;IACnD,IAAI,CAACM,cAAce,QAAQ,CAACX,MAAM;QAC9B,8DAA8D;QAC9DV,YAAY,CAACU,IAAI,iBAAGY,OAAMzB,aAAa,CAACkB;IAC5C,CAAC;IACD,OAAOf,YAAY,CAACU,IAAI;AAC5B"}
|
package/lib-commonjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export { createContext } from './global-context';\nexport { createContext as createContextSelector } from './global-context-selector';\n"],"names":["createContext","createContextSelector"],"mappings":";;;;;;;;;;;IAASA,aAAa,MAAbA,4BAAa;IACIC,qBAAqB,MAAtCD,oCAAa;;+BADQ;uCACyB"}
|
package/lib-commonjs/types.js
CHANGED
|
@@ -4,6 +4,3 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
|
6
6
|
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
7
|
-
//# sourceMappingURL=types.js.map
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;6DAAuB"}
|
package/lib-commonjs/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["utils.js"],"sourcesContent":["/**\n * @param version - semver version string\n * @returns The major version number\n */ export function getMajorVersion(version) {\n return Number(version.split('.')[0]);\n}\n"],"names":["getMajorVersion","version","Number","split"],"mappings":"AAAA;;;CAGC;;;;+BAAmBA;;aAAAA;;AAAT,SAASA,gBAAgBC,OAAO,EAAE;IACzC,OAAOC,OAAOD,QAAQE,KAAK,CAAC,IAAI,CAAC,EAAE;AACvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/global-context",
|
|
3
|
-
"version": "9.0.0-beta.
|
|
3
|
+
"version": "9.0.0-beta.29",
|
|
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",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@fluentui/scripts-tasks": "*"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@fluentui/react-context-selector": "^9.1.
|
|
36
|
-
"@fluentui/react-utilities": "^9.9.
|
|
35
|
+
"@fluentui/react-context-selector": "^9.1.22",
|
|
36
|
+
"@fluentui/react-utilities": "^9.9.2",
|
|
37
37
|
"@swc/helpers": "^0.4.14"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|