@fluentui/global-context 9.0.0-beta.10 → 9.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +65 -1
- package/CHANGELOG.md +22 -2
- package/lib/global-context-selector.js +8 -13
- package/lib/global-context-selector.js.map +1 -1
- package/lib/global-context.js +8 -13
- package/lib/global-context.js.map +1 -1
- package/lib/utils.js.map +1 -1
- package/lib-commonjs/global-context-selector.js +8 -18
- package/lib-commonjs/global-context-selector.js.map +1 -1
- package/lib-commonjs/global-context.js +8 -18
- package/lib-commonjs/global-context.js.map +1 -1
- package/lib-commonjs/index.js +0 -4
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/utils.js +0 -2
- package/lib-commonjs/utils.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,71 @@
|
|
|
2
2
|
"name": "@fluentui/global-context",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Mon, 09 Jan 2023 14:31:41 GMT",
|
|
6
|
+
"tag": "@fluentui/global-context_v9.0.0-beta.12",
|
|
7
|
+
"version": "9.0.0-beta.12",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"author": "martinhochel@microsoft.com",
|
|
12
|
+
"package": "@fluentui/global-context",
|
|
13
|
+
"commit": "abae9f7a10d544d8d6b530b974fff235cfd2f956",
|
|
14
|
+
"comment": "chore: introduce more barrel file api within /scripts"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"prerelease": [
|
|
18
|
+
{
|
|
19
|
+
"author": "beachball",
|
|
20
|
+
"package": "@fluentui/global-context",
|
|
21
|
+
"comment": "Bump @fluentui/react-context-selector to v9.1.5",
|
|
22
|
+
"commit": "26f0364b3837056ee8e0df42a7932c298c68290e"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"author": "beachball",
|
|
26
|
+
"package": "@fluentui/global-context",
|
|
27
|
+
"comment": "Bump @fluentui/react-utilities to v9.4.0",
|
|
28
|
+
"commit": "26f0364b3837056ee8e0df42a7932c298c68290e"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"date": "Wed, 04 Jan 2023 01:40:46 GMT",
|
|
35
|
+
"tag": "@fluentui/global-context_v9.0.0-beta.11",
|
|
36
|
+
"version": "9.0.0-beta.11",
|
|
37
|
+
"comments": {
|
|
38
|
+
"none": [
|
|
39
|
+
{
|
|
40
|
+
"author": "martinhochel@microsoft.com",
|
|
41
|
+
"package": "@fluentui/global-context",
|
|
42
|
+
"commit": "4ec2b998b294d6d9c3196d3d82893bdd97d0c105",
|
|
43
|
+
"comment": "chore(scripts): move index.ts to to follow sub-folder domain packaging"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"author": "martinhochel@microsoft.com",
|
|
47
|
+
"package": "@fluentui/global-context",
|
|
48
|
+
"commit": "194b0cf0cc27c1c1233aa945f09b3ad29778d8ca",
|
|
49
|
+
"comment": "chore(scripts): use for @fluentui/scripts version within all package.json"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"prerelease": [
|
|
53
|
+
{
|
|
54
|
+
"author": "beachball",
|
|
55
|
+
"package": "@fluentui/global-context",
|
|
56
|
+
"comment": "Bump @fluentui/react-context-selector to v9.1.4",
|
|
57
|
+
"commit": "3e322d15529451be153e97298873253e21af4082"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"author": "beachball",
|
|
61
|
+
"package": "@fluentui/global-context",
|
|
62
|
+
"comment": "Bump @fluentui/react-utilities to v9.3.1",
|
|
63
|
+
"commit": "3e322d15529451be153e97298873253e21af4082"
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"date": "Tue, 20 Dec 2022 14:59:34 GMT",
|
|
6
70
|
"tag": "@fluentui/global-context_v9.0.0-beta.10",
|
|
7
71
|
"version": "9.0.0-beta.10",
|
|
8
72
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
# Change Log - @fluentui/global-context
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 09 Jan 2023 14:31:41 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-beta.12](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.12)
|
|
8
|
+
|
|
9
|
+
Mon, 09 Jan 2023 14:31:41 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.11..@fluentui/global-context_v9.0.0-beta.12)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- Bump @fluentui/react-context-selector to v9.1.5 ([PR #26257](https://github.com/microsoft/fluentui/pull/26257) by beachball)
|
|
15
|
+
- Bump @fluentui/react-utilities to v9.4.0 ([PR #26257](https://github.com/microsoft/fluentui/pull/26257) by beachball)
|
|
16
|
+
|
|
17
|
+
## [9.0.0-beta.11](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.11)
|
|
18
|
+
|
|
19
|
+
Wed, 04 Jan 2023 01:40:46 GMT
|
|
20
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.10..@fluentui/global-context_v9.0.0-beta.11)
|
|
21
|
+
|
|
22
|
+
### Changes
|
|
23
|
+
|
|
24
|
+
- Bump @fluentui/react-context-selector to v9.1.4 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
|
|
25
|
+
- Bump @fluentui/react-utilities to v9.3.1 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
|
|
26
|
+
|
|
7
27
|
## [9.0.0-beta.10](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.10)
|
|
8
28
|
|
|
9
|
-
Tue, 20 Dec 2022 14:
|
|
29
|
+
Tue, 20 Dec 2022 14:59:34 GMT
|
|
10
30
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.9..@fluentui/global-context_v9.0.0-beta.10)
|
|
11
31
|
|
|
12
32
|
### Changes
|
|
@@ -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;
|
|
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
|
-
|
|
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,22 +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)}`);
|
|
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
|
|
46
42
|
// eslint-disable-next-line @fluentui/no-context-default-value
|
|
47
43
|
globalObject[sym] = baseCreateContext(defaultValue);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
}
|
|
45
|
+
// @ts-expect-error - Indexing object with symbols not supported until TS 4.4
|
|
51
46
|
return globalObject[sym];
|
|
52
47
|
};
|
|
53
48
|
//# sourceMappingURL=global-context-selector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"]}
|
package/lib/global-context.js
CHANGED
|
@@ -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;
|
|
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
|
-
|
|
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,22 +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)}`);
|
|
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
|
|
46
42
|
// eslint-disable-next-line @fluentui/no-context-default-value
|
|
47
43
|
globalObject[sym] = /*#__PURE__*/React.createContext(defaultValue);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
}
|
|
45
|
+
// @ts-expect-error - Indexing object with symbols not supported until TS 4.4
|
|
51
46
|
return globalObject[sym];
|
|
52
47
|
};
|
|
53
48
|
//# sourceMappingURL=global-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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;
|
|
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
|
-
|
|
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,24 +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)}`);
|
|
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
|
|
56
48
|
// eslint-disable-next-line @fluentui/no-context-default-value
|
|
57
49
|
globalObject[sym] = react_context_selector_1.createContext(defaultValue);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
}
|
|
51
|
+
// @ts-expect-error - Indexing object with symbols not supported until TS 4.4
|
|
61
52
|
return globalObject[sym];
|
|
62
53
|
};
|
|
63
|
-
|
|
64
54
|
exports.createContext = createContext;
|
|
65
55
|
//# sourceMappingURL=global-context-selector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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;
|
|
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
|
-
|
|
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,24 +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)}`);
|
|
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
|
|
56
48
|
// eslint-disable-next-line @fluentui/no-context-default-value
|
|
57
49
|
globalObject[sym] = React.createContext(defaultValue);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
}
|
|
51
|
+
// @ts-expect-error - Indexing object with symbols not supported until TS 4.4
|
|
61
52
|
return globalObject[sym];
|
|
62
53
|
};
|
|
63
|
-
|
|
64
54
|
exports.createContext = createContext;
|
|
65
55
|
//# sourceMappingURL=global-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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"]}
|
package/lib-commonjs/index.js
CHANGED
|
@@ -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,"
|
|
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,"
|
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
|
package/lib-commonjs/utils.js
CHANGED
|
@@ -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,"
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/global-context",
|
|
3
|
-
"version": "9.0.0-beta.
|
|
3
|
+
"version": "9.0.0-beta.12",
|
|
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",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@fluentui/eslint-plugin": "*",
|
|
29
|
-
"@fluentui/scripts": "
|
|
29
|
+
"@fluentui/scripts": "*"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@fluentui/react-context-selector": "^9.1.
|
|
33
|
-
"@fluentui/react-utilities": "^9.
|
|
32
|
+
"@fluentui/react-context-selector": "^9.1.5",
|
|
33
|
+
"@fluentui/react-utilities": "^9.4.0",
|
|
34
34
|
"tslib": "^2.1.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|