@fluentui/global-context 9.0.0-beta.16 → 9.0.0-beta.18
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 +43 -1
- package/CHANGELOG.md +22 -2
- package/lib/global-context-selector.js.map +1 -1
- package/lib/global-context.js.map +1 -1
- package/lib/utils.js.map +1 -1
- package/lib-commonjs/global-context-selector.js.map +1 -1
- package/lib-commonjs/global-context.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/types.js.map +1 -1
- package/lib-commonjs/utils.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,49 @@
|
|
|
2
2
|
"name": "@fluentui/global-context",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Wed, 08 Mar 2023 17:39:19 GMT",
|
|
6
|
+
"tag": "@fluentui/global-context_v9.0.0-beta.18",
|
|
7
|
+
"version": "9.0.0-beta.18",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "beachball",
|
|
12
|
+
"package": "@fluentui/global-context",
|
|
13
|
+
"comment": "Bump @fluentui/react-context-selector to v9.1.11",
|
|
14
|
+
"commit": "e0d11faf97f6466f4cd23ed18266cf1e80094f56"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@fluentui/global-context",
|
|
19
|
+
"comment": "Bump @fluentui/react-utilities to v9.6.1",
|
|
20
|
+
"commit": "e0d11faf97f6466f4cd23ed18266cf1e80094f56"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"date": "Wed, 15 Feb 2023 11:44:52 GMT",
|
|
27
|
+
"tag": "@fluentui/global-context_v9.0.0-beta.17",
|
|
28
|
+
"version": "9.0.0-beta.17",
|
|
29
|
+
"comments": {
|
|
30
|
+
"prerelease": [
|
|
31
|
+
{
|
|
32
|
+
"author": "beachball",
|
|
33
|
+
"package": "@fluentui/global-context",
|
|
34
|
+
"comment": "Bump @fluentui/react-context-selector to v9.1.10",
|
|
35
|
+
"commit": "087d981aab96bef2e332a373069a19bc702a7ca2"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"author": "beachball",
|
|
39
|
+
"package": "@fluentui/global-context",
|
|
40
|
+
"comment": "Bump @fluentui/react-utilities to v9.6.0",
|
|
41
|
+
"commit": "087d981aab96bef2e332a373069a19bc702a7ca2"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"date": "Mon, 13 Feb 2023 23:43:14 GMT",
|
|
6
48
|
"tag": "@fluentui/global-context_v9.0.0-beta.16",
|
|
7
49
|
"version": "9.0.0-beta.16",
|
|
8
50
|
"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 Wed, 08 Mar 2023 17:39:19 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-beta.18](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.18)
|
|
8
|
+
|
|
9
|
+
Wed, 08 Mar 2023 17:39:19 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.17..@fluentui/global-context_v9.0.0-beta.18)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- Bump @fluentui/react-context-selector to v9.1.11 ([PR #27127](https://github.com/microsoft/fluentui/pull/27127) by beachball)
|
|
15
|
+
- Bump @fluentui/react-utilities to v9.6.1 ([PR #27127](https://github.com/microsoft/fluentui/pull/27127) by beachball)
|
|
16
|
+
|
|
17
|
+
## [9.0.0-beta.17](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.17)
|
|
18
|
+
|
|
19
|
+
Wed, 15 Feb 2023 11:44:52 GMT
|
|
20
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.16..@fluentui/global-context_v9.0.0-beta.17)
|
|
21
|
+
|
|
22
|
+
### Changes
|
|
23
|
+
|
|
24
|
+
- Bump @fluentui/react-context-selector to v9.1.10 ([PR #26845](https://github.com/microsoft/fluentui/pull/26845) by beachball)
|
|
25
|
+
- Bump @fluentui/react-utilities to v9.6.0 ([PR #26845](https://github.com/microsoft/fluentui/pull/26845) by beachball)
|
|
26
|
+
|
|
7
27
|
## [9.0.0-beta.16](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.16)
|
|
8
28
|
|
|
9
|
-
Mon, 13 Feb 2023 23:
|
|
29
|
+
Mon, 13 Feb 2023 23:43:14 GMT
|
|
10
30
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.15..@fluentui/global-context_v9.0.0-beta.16)
|
|
11
31
|
|
|
12
32
|
### Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["createContext","baseCreateContext","canUseDOM","getMajorVersion","isBrowser","globalObject","window","global","SYMBOL_NAMESPACE","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","_a","Symbol","keyFor","startsWith","defaultValue","name","packageName","packageVersion","for","includes"],"sources":["../src/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"],"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,CAAAC,EAAA,GAAAC,MAAM,CAACC,MAAM,CAACH,GAAG,CAAC,cAAAC,EAAA,uBAAAA,EAAA,CAAEG,UAAU,CAACZ,gBAAgB,CAAC,EAAE;MACpD;MACA,OAAOH,YAAY,CAACW,GAAG,CAAC;;EAE5B,CAAC,CAAC;;AAGJ;;;;;;;;;;;;;AAaA,OAAO,MAAMhB,aAAa,GAAGA,CAAIqB,YAAe,EAAEC,IAAY,EAAEC,WAAmB,EAAEC,cAAsB,KAAI;EAC7G;EACA,MAAMR,GAAG,GAAGE,MAAM,CAACO,GAAG,CAAC,GAAGjB,gBAAgB,GAAGe,WAAW,IAAID,IAAI,KAAKnB,eAAe,CAACqB,cAAc,CAAC,EAAE,CAAC;EAEvG;EACA;EACA,MAAMZ,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,GAAGf,iBAAiB,CAACoB,YAAY,CAAC;;EAGrD;EACA,OAAOhB,YAAY,CAACW,GAAG,CAAqB;AAC9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","canUseDOM","getMajorVersion","isBrowser","globalObject","window","global","SYMBOL_NAMESPACE","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","_a","Symbol","keyFor","startsWith","createContext","defaultValue","name","packageName","packageVersion","for","includes"],"sources":["../src/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"],"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,CAAAC,EAAA,GAAAC,MAAM,CAACC,MAAM,CAACH,GAAG,CAAC,cAAAC,EAAA,uBAAAA,EAAA,CAAEG,UAAU,CAACZ,gBAAgB,CAAC,EAAE;MACpD;MACA,OAAOH,YAAY,CAACW,GAAG,CAAC;;EAE5B,CAAC,CAAC;;AAGJ;;;;;;;;;;;;;AAaA,OAAO,MAAMK,aAAa,GAAGA,CAAIC,YAAe,EAAEC,IAAY,EAAEC,WAAmB,EAAEC,cAAsB,KAAI;EAC7G;EACA,MAAMT,GAAG,GAAGE,MAAM,CAACQ,GAAG,CAAC,GAAGlB,gBAAgB,GAAGgB,WAAW,IAAID,IAAI,KAAKpB,eAAe,CAACsB,cAAc,CAAC,EAAE,CAAC;EAEvG;EACA;EACA,MAAMb,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,gBAAGf,KAAK,CAACoB,aAAa,CAACC,YAAY,CAAC;;EAGvD;EACA,OAAOjB,YAAY,CAACW,GAAG,CAAqB;AAC9C,CAAC"}
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["getMajorVersion","version","Number","split"],"sources":["../src/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"],"mappings":"AAAA;;;;AAIA,OAAM,SAAUA,eAAeA,CAACC,OAAe;EAC7C,OAAOC,MAAM,CAACD,OAAO,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["react_context_selector_1","require","react_utilities_1","utils_1","isBrowser","canUseDOM","globalObject","window","global","exports","SYMBOL_NAMESPACE","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","_a","Symbol","keyFor","startsWith","createContext","defaultValue","name","packageName","packageVersion","for","getMajorVersion","includes"],"sources":["../src/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"],"mappings":";;;;;;AACA,MAAAA,wBAAA,gBAAAC,OAAA;AACA,MAAAC,iBAAA,gBAAAD,OAAA;AACA,MAAAE,OAAA,gBAAAF,OAAA;AAGA,MAAMG,SAAS,gBAAGF,iBAAA,CAAAG,SAAS,EAAE;AAC7B,MAAMC,YAAY,GAAiBF,SAAS,GAAGG,MAAM,GAAGC,MAAM;AAE9D;AACA;AACaC,OAAA,CAAAC,gBAAgB,GAAG,0BAA0B;AAE1D;AACA;AACA,IAAI,CAACN,SAAS,IAAIO,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;EACvD,MAAMC,aAAa,gBAAGC,MAAM,CAACC,qBAAqB,CAACV,YAAY,CAAC;EAChEQ,aAAa,CAACG,OAAO,CAACC,GAAG,IAAG;;IAC1B,IAAI,CAAAC,EAAA,GAAAC,MAAM,CAACC,MAAM,CAACH,GAAG,CAAC,cAAAC,EAAA,uBAAAA,EAAA,CAAEG,UAAU,CAACb,OAAA,CAAAC,gBAAgB,CAAC,EAAE;MACpD;MACA,OAAOJ,YAAY,CAACY,GAAG,CAAC;;EAE5B,CAAC,CAAC;;AAGJ;;;;;;;;;;;;;AAaO,MAAMK,aAAa,GAAGA,CAAIC,YAAe,EAAEC,IAAY,EAAEC,WAAmB,EAAEC,cAAsB,KAAI;EAC7G;EACA,MAAMT,GAAG,GAAGE,MAAM,CAACQ,GAAG,CAAC,GAAGnB,OAAA,CAAAC,gBAAgB,GAAGgB,WAAW,IAAID,IAAI,KAAKtB,OAAA,CAAA0B,eAAe,CAACF,cAAc,CAAC,EAAE,CAAC;EAEvG;EACA;EACA,MAAMb,aAAa,GAAGC,MAAM,CAACC,qBAAqB,CAACV,YAAY,CAAC;EAChE,IAAI,CAACQ,aAAa,CAACgB,QAAQ,CAACZ,GAAG,CAAC,EAAE;IAChC;IACA;IACAZ,YAAY,CAACY,GAAG,CAAC,GAAGlB,wBAAA,CAAAuB,aAAiB,CAACC,YAAY,CAAC;;EAGrD;EACA,OAAOlB,YAAY,CAACY,GAAG,CAAqB;AAC9C,CAAC;AAfYT,OAAA,CAAAc,aAAa,GAAAA,aAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["React","require","react_utilities_1","utils_1","isBrowser","canUseDOM","globalObject","window","global","exports","SYMBOL_NAMESPACE","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","_a","Symbol","keyFor","startsWith","createContext","defaultValue","name","packageName","packageVersion","for","getMajorVersion","includes"],"sources":["../src/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"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,iBAAA,gBAAAD,OAAA;AAEA,MAAAE,OAAA,gBAAAF,OAAA;AAEA,MAAMG,SAAS,gBAAGF,iBAAA,CAAAG,SAAS,EAAE;AAC7B,MAAMC,YAAY,GAAiBF,SAAS,GAAGG,MAAM,GAAGC,MAAM;AAE9D;AACA;AACaC,OAAA,CAAAC,gBAAgB,GAAG,iBAAiB;AAEjD;AACA;AACA,IAAI,CAACN,SAAS,IAAIO,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;EACvD,MAAMC,aAAa,gBAAGC,MAAM,CAACC,qBAAqB,CAACV,YAAY,CAAC;EAChEQ,aAAa,CAACG,OAAO,CAACC,GAAG,IAAG;;IAC1B,IAAI,CAAAC,EAAA,GAAAC,MAAM,CAACC,MAAM,CAACH,GAAG,CAAC,cAAAC,EAAA,uBAAAA,EAAA,CAAEG,UAAU,CAACb,OAAA,CAAAC,gBAAgB,CAAC,EAAE;MACpD;MACA,OAAOJ,YAAY,CAACY,GAAG,CAAC;;EAE5B,CAAC,CAAC;;AAGJ;;;;;;;;;;;;;AAaO,MAAMK,aAAa,GAAGA,CAAIC,YAAe,EAAEC,IAAY,EAAEC,WAAmB,EAAEC,cAAsB,KAAI;EAC7G;EACA,MAAMT,GAAG,GAAGE,MAAM,CAACQ,GAAG,CAAC,GAAGnB,OAAA,CAAAC,gBAAgB,GAAGgB,WAAW,IAAID,IAAI,KAAKtB,OAAA,CAAA0B,eAAe,CAACF,cAAc,CAAC,EAAE,CAAC;EAEvG;EACA;EACA,MAAMb,aAAa,GAAGC,MAAM,CAACC,qBAAqB,CAACV,YAAY,CAAC;EAChE,IAAI,CAACQ,aAAa,CAACgB,QAAQ,CAACZ,GAAG,CAAC,EAAE;IAChC;IACA;IACAZ,YAAY,CAACY,GAAG,CAAC,GAAGlB,KAAK,CAACuB,aAAa,CAACC,YAAY,CAAC;;EAGvD;EACA,OAAOlB,YAAY,CAACY,GAAG,CAAqB;AAC9C,CAAC;AAfYT,OAAA,CAAAc,aAAa,GAAAA,aAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["global_context_1","require","Object","defineProperty","exports","enumerable","get","createContext","global_context_selector_1"],"sources":["../src/packages/react-components/global-context/src/index.ts"],"sourcesContent":["export { createContext } from './global-context';\nexport { createContext as createContextSelector } from './global-context-selector';\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,gBAAAC,OAAA;AAASC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAN,gBAAA,CAAAO,aAAa;EAAA;AAAA;AACtB,IAAAC,yBAAA,gBAAAP,OAAA;AAASC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,UAAA;EAAAC,GAAA,WAAAA,CAAA;IAAA,OAAAE,yBAAA,CAAAD,aAAa;EAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":[],"sources":["../src/packages/react-components/global-context/src/types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type GlobalObject = (typeof globalThis | NodeJS.Global) & Record<symbol, React.Context<unknown>>;\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["getMajorVersion","version","Number","split","exports"],"sources":["../src/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"],"mappings":";;;;;;AAAA;;;;AAIA,SAAgBA,eAAeA,CAACC,OAAe;EAC7C,OAAOC,MAAM,CAACD,OAAO,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC;AAFAC,OAAA,CAAAJ,eAAA,GAAAA,eAAA"}
|
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.18",
|
|
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",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@fluentui/scripts-tasks": "*"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@fluentui/react-context-selector": "^9.1.
|
|
35
|
-
"@fluentui/react-utilities": "^9.
|
|
34
|
+
"@fluentui/react-context-selector": "^9.1.11",
|
|
35
|
+
"@fluentui/react-utilities": "^9.6.1",
|
|
36
36
|
"tslib": "^2.1.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|