@fluentui/global-context 9.0.0-beta.8 → 9.0.0-beta.9
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.map +1 -1
- package/lib/global-context.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/types.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/utils.js.map +1 -1
- package/package.json +5 -6
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,36 @@
|
|
|
2
2
|
"name": "@fluentui/global-context",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Thu, 17 Nov 2022 23:02:29 GMT",
|
|
6
|
+
"tag": "@fluentui/global-context_v9.0.0-beta.9",
|
|
7
|
+
"version": "9.0.0-beta.9",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"author": "martinhochel@microsoft.com",
|
|
12
|
+
"package": "@fluentui/global-context",
|
|
13
|
+
"commit": "ea768501802d65d63ddc63fff3816fb6b5008ae4",
|
|
14
|
+
"comment": "chore: update package scaffold"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"prerelease": [
|
|
18
|
+
{
|
|
19
|
+
"author": "beachball",
|
|
20
|
+
"package": "@fluentui/global-context",
|
|
21
|
+
"comment": "Bump @fluentui/react-context-selector to v9.1.2",
|
|
22
|
+
"commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"author": "beachball",
|
|
26
|
+
"package": "@fluentui/global-context",
|
|
27
|
+
"comment": "Bump @fluentui/react-utilities to v9.2.2",
|
|
28
|
+
"commit": "94e156be5d3b5790d82dccf08c32672733fb9335"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"date": "Fri, 11 Nov 2022 14:57:50 GMT",
|
|
6
35
|
"tag": "@fluentui/global-context_v9.0.0-beta.8",
|
|
7
36
|
"version": "9.0.0-beta.8",
|
|
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 Thu, 17 Nov 2022 23:02:29 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-beta.9](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.9)
|
|
8
|
+
|
|
9
|
+
Thu, 17 Nov 2022 23:02:29 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.8..@fluentui/global-context_v9.0.0-beta.9)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- Bump @fluentui/react-context-selector to v9.1.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
|
|
15
|
+
- Bump @fluentui/react-utilities to v9.2.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
|
|
16
|
+
|
|
7
17
|
## [9.0.0-beta.8](https://github.com/microsoft/fluentui/tree/@fluentui/global-context_v9.0.0-beta.8)
|
|
8
18
|
|
|
9
|
-
Fri, 11 Nov 2022 14:
|
|
19
|
+
Fri, 11 Nov 2022 14:57:50 GMT
|
|
10
20
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/global-context_v9.0.0-beta.7..@fluentui/global-context_v9.0.0-beta.8)
|
|
11
21
|
|
|
12
22
|
### Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["global-context-selector.ts"],"names":[],"mappings":"AACA,SAAS,aAAa,IAAI,iBAA1B,QAAmD,kCAAnD;AACA,SAAS,SAAT,QAA0B,2BAA1B;AACA,SAAS,eAAT,QAAgC,SAAhC;AAGA,MAAM,SAAS,gBAAG,SAAS,EAA3B;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACA,OAAO,MAAM,gBAAgB,GAAG,0BAAzB,C,CAEP;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACH,OAAO,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,eAAe,CAAC,cAAD,CAAgB,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA;IACA,YAAY,CAAC,GAAD,CAAZ,GAAoB,iBAAiB,CAAC,YAAD,CAArC;EACD,CAX4G,CAa7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAfM","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"],"sourceRoot":"../src/"}
|
|
1
|
+
{"version":3,"sources":["packages/react-components/global-context/src/global-context-selector.ts"],"names":[],"mappings":"AACA,SAAS,aAAa,IAAI,iBAA1B,QAAmD,kCAAnD;AACA,SAAS,SAAT,QAA0B,2BAA1B;AACA,SAAS,eAAT,QAAgC,SAAhC;AAGA,MAAM,SAAS,gBAAG,SAAS,EAA3B;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACA,OAAO,MAAM,gBAAgB,GAAG,0BAAzB,C,CAEP;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACH,OAAO,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,eAAe,CAAC,cAAD,CAAgB,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA;IACA,YAAY,CAAC,GAAD,CAAZ,GAAoB,iBAAiB,CAAC,YAAD,CAArC;EACD,CAX4G,CAa7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAfM","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"],"sourceRoot":"../src/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["global-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,SAAT,QAA0B,2BAA1B;AAEA,SAAS,eAAT,QAAgC,SAAhC;AAEA,MAAM,SAAS,gBAAG,SAAS,EAA3B;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACA,OAAO,MAAM,gBAAgB,GAAG,iBAAzB,C,CAEP;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACH,OAAO,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,eAAe,CAAC,cAAD,CAAgB,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA;IACA,YAAY,CAAC,GAAD,CAAZ,gBAAoB,KAAK,CAAC,aAAN,CAAoB,YAApB,CAApB;EACD,CAX4G,CAa7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAfM","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"],"sourceRoot":"../src/"}
|
|
1
|
+
{"version":3,"sources":["packages/react-components/global-context/src/global-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,SAAT,QAA0B,2BAA1B;AAEA,SAAS,eAAT,QAAgC,SAAhC;AAEA,MAAM,SAAS,gBAAG,SAAS,EAA3B;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACA,OAAO,MAAM,gBAAgB,GAAG,iBAAzB,C,CAEP;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACH,OAAO,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,eAAe,CAAC,cAAD,CAAgB,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA;IACA,YAAY,CAAC,GAAD,CAAZ,gBAAoB,KAAK,CAAC,aAAN,CAAoB,YAApB,CAApB;EACD,CAX4G,CAa7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAfM","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"],"sourceRoot":"../src/"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["export { createContext } from './global-context';\nexport { createContext as createContextSelector } from './global-context-selector';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/global-context/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["export { createContext } from './global-context';\nexport { createContext as createContextSelector } from './global-context-selector';\n"]}
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"../src/","sources":["types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\nexport type GlobalObject = (typeof globalThis | NodeJS.Global) & Record<symbol, React.Context<unknown>>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../src/","sources":["packages/react-components/global-context/src/types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\n\nexport type GlobalObject = (typeof globalThis | NodeJS.Global) & Record<symbol, React.Context<unknown>>;\n"]}
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utils.ts"],"names":[],"mappings":"AAAA;;;AAGG;AACH,OAAM,SAAU,eAAV,CAA0B,OAA1B,EAAyC;EAC7C,OAAO,MAAM,CAAC,OAAO,CAAC,KAAR,CAAc,GAAd,EAAmB,CAAnB,CAAD,CAAb;AACD","sourcesContent":["/**\n * @param version - semver version string\n * @returns The major version number\n */\nexport function getMajorVersion(version: string) {\n return Number(version.split('.')[0]);\n}\n"],"sourceRoot":"../src/"}
|
|
1
|
+
{"version":3,"sources":["packages/react-components/global-context/src/utils.ts"],"names":[],"mappings":"AAAA;;;AAGG;AACH,OAAM,SAAU,eAAV,CAA0B,OAA1B,EAAyC;EAC7C,OAAO,MAAM,CAAC,OAAO,CAAC,KAAR,CAAc,GAAd,EAAmB,CAAnB,CAAD,CAAb;AACD","sourcesContent":["/**\n * @param version - semver version string\n * @returns The major version number\n */\nexport function getMajorVersion(version: string) {\n return Number(version.split('.')[0]);\n}\n"],"sourceRoot":"../src/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["global-context-selector.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AAGA,MAAM,SAAS,gBAAG,iBAAA,CAAA,SAAA,EAAlB;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACa,OAAA,CAAA,gBAAA,GAAmB,0BAAnB,C,CAEb;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,OAAA,CAAA,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACI,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,OAAA,CAAA,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,OAAA,CAAA,eAAA,CAAgB,cAAhB,CAA+B,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA;IACA,YAAY,CAAC,GAAD,CAAZ,GAAoB,wBAAA,CAAA,aAAA,CAAkB,YAAlB,CAApB;EACD,CAX4G,CAa7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAfM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourcesContent":["import * as React from 'react';\nimport { createContext as baseCreateContext } from '@fluentui/react-context-selector';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { getMajorVersion } from './utils';\nimport { GlobalObject } from './types';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context-selector:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see createContext from \\@fluentui/react-context-selector that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n // 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"],"sourceRoot":"../src/"}
|
|
1
|
+
{"version":3,"sources":["packages/react-components/global-context/src/global-context-selector.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AAGA,MAAM,SAAS,gBAAG,iBAAA,CAAA,SAAA,EAAlB;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACa,OAAA,CAAA,gBAAA,GAAmB,0BAAnB,C,CAEb;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,OAAA,CAAA,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACI,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,OAAA,CAAA,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,OAAA,CAAA,eAAA,CAAgB,cAAhB,CAA+B,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA;IACA,YAAY,CAAC,GAAD,CAAZ,GAAoB,wBAAA,CAAA,aAAA,CAAkB,YAAlB,CAApB;EACD,CAX4G,CAa7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAfM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourcesContent":["import * as React from 'react';\nimport { createContext as baseCreateContext } from '@fluentui/react-context-selector';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { getMajorVersion } from './utils';\nimport { GlobalObject } from './types';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context-selector:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see createContext from \\@fluentui/react-context-selector that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n // 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"],"sourceRoot":"../src/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["global-context.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAEA,MAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AAEA,MAAM,SAAS,gBAAG,iBAAA,CAAA,SAAA,EAAlB;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACa,OAAA,CAAA,gBAAA,GAAmB,iBAAnB,C,CAEb;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,OAAA,CAAA,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACI,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,OAAA,CAAA,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,OAAA,CAAA,eAAA,CAAgB,cAAhB,CAA+B,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA;IACA,YAAY,CAAC,GAAD,CAAZ,GAAoB,KAAK,CAAC,aAAN,CAAoB,YAApB,CAApB;EACD,CAX4G,CAa7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAfM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { GlobalObject } from './types';\nimport { getMajorVersion } from './utils';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see React.createContext that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n // 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"],"sourceRoot":"../src/"}
|
|
1
|
+
{"version":3,"sources":["packages/react-components/global-context/src/global-context.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAEA,MAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AAEA,MAAM,SAAS,gBAAG,iBAAA,CAAA,SAAA,EAAlB;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACa,OAAA,CAAA,gBAAA,GAAmB,iBAAnB,C,CAEb;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,OAAA,CAAA,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACI,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,OAAA,CAAA,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,OAAA,CAAA,eAAA,CAAgB,cAAhB,CAA+B,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA;IACA,YAAY,CAAC,GAAD,CAAZ,GAAoB,KAAK,CAAC,aAAN,CAAoB,YAApB,CAApB;EACD,CAX4G,CAa7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAfM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { GlobalObject } from './types';\nimport { getMajorVersion } from './utils';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see React.createContext that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n // 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"],"sourceRoot":"../src/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,gBAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,eAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,gBAAA,CAAA,aAAA;EAAa;AAAb,CAAA;;AACT,IAAA,yBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,uBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,yBAAA,CAAA,aAAA;EAAa;AAAb,CAAA","sourcesContent":["export { createContext } from './global-context';\nexport { createContext as createContextSelector } from './global-context-selector';\n"],"sourceRoot":"../src/"}
|
|
1
|
+
{"version":3,"sources":["packages/react-components/global-context/src/index.ts"],"names":[],"mappings":";;;;;;;AAAA,IAAA,gBAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,eAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,gBAAA,CAAA,aAAA;EAAa;AAAb,CAAA;;AACT,IAAA,yBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAAS,MAAA,CAAA,cAAA,CAAA,OAAA,EAAA,uBAAA,EAAA;EAAA,UAAA,EAAA,IAAA;EAAA,GAAA,EAAA,YAAA;IAAA,OAAA,yBAAA,CAAA,aAAA;EAAa;AAAb,CAAA","sourcesContent":["export { createContext } from './global-context';\nexport { createContext as createContextSelector } from './global-context-selector';\n"],"sourceRoot":"../src/"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utils.ts"],"names":[],"mappings":";;;;;;AAAA;;;AAGG;;AACH,SAAgB,eAAhB,CAAgC,OAAhC,EAA+C;EAC7C,OAAO,MAAM,CAAC,OAAO,CAAC,KAAR,CAAc,GAAd,EAAmB,CAAnB,CAAD,CAAb;AACD;;AAFD,OAAA,CAAA,eAAA,GAAA,eAAA","sourcesContent":["/**\n * @param version - semver version string\n * @returns The major version number\n */\nexport function getMajorVersion(version: string) {\n return Number(version.split('.')[0]);\n}\n"],"sourceRoot":"../src/"}
|
|
1
|
+
{"version":3,"sources":["packages/react-components/global-context/src/utils.ts"],"names":[],"mappings":";;;;;;AAAA;;;AAGG;;AACH,SAAgB,eAAhB,CAAgC,OAAhC,EAA+C;EAC7C,OAAO,MAAM,CAAC,OAAO,CAAC,KAAR,CAAc,GAAd,EAAmB,CAAnB,CAAD,CAAb;AACD;;AAFD,OAAA,CAAA,eAAA,GAAA,eAAA","sourcesContent":["/**\n * @param version - semver version string\n * @returns The major version number\n */\nexport function getMajorVersion(version: string) {\n return Number(version.split('.')[0]);\n}\n"],"sourceRoot":"../src/"}
|
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.9",
|
|
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",
|
|
@@ -21,17 +21,16 @@
|
|
|
21
21
|
"just": "just-scripts",
|
|
22
22
|
"lint": "just-scripts lint",
|
|
23
23
|
"test": "jest --passWithNoTests",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"type-check": "tsc -b tsconfig.json"
|
|
24
|
+
"type-check": "tsc -b tsconfig.json",
|
|
25
|
+
"generate-api": "tsc -p ./tsconfig.lib.json --emitDeclarationOnly && just-scripts api-extractor"
|
|
27
26
|
},
|
|
28
27
|
"devDependencies": {
|
|
29
28
|
"@fluentui/eslint-plugin": "*",
|
|
30
29
|
"@fluentui/scripts": "^1.0.0"
|
|
31
30
|
},
|
|
32
31
|
"dependencies": {
|
|
33
|
-
"@fluentui/react-context-selector": "^9.1.
|
|
34
|
-
"@fluentui/react-utilities": "^9.2.
|
|
32
|
+
"@fluentui/react-context-selector": "^9.1.2",
|
|
33
|
+
"@fluentui/react-utilities": "^9.2.2",
|
|
35
34
|
"tslib": "^2.1.0"
|
|
36
35
|
},
|
|
37
36
|
"peerDependencies": {
|