@fluentui/global-context 9.0.0-beta.3 → 9.0.0-beta.30

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.
@@ -1,64 +1,45 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.createContext = exports.SYMBOL_NAMESPACE = void 0;
7
-
8
- const react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
9
-
10
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
-
12
- const utils_1 = /*#__PURE__*/require("./utils");
13
-
14
- const isBrowser = /*#__PURE__*/react_utilities_1.canUseDOM();
15
- const globalObject = isBrowser ? window : global; // Identifier for the symbol, for easy idenfitifaction of symbols created by this util
16
- // Useful for clearning global object during SSR reloads
17
-
18
- exports.SYMBOL_NAMESPACE = 'global-context-selector:'; // During SSR the global object persists with the server process
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ SYMBOL_NAMESPACE: ()=>SYMBOL_NAMESPACE,
13
+ createContext: ()=>createContext
14
+ });
15
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
16
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
17
+ const _reactContextSelector = require("@fluentui/react-context-selector");
18
+ const _reactUtilities = require("@fluentui/react-utilities");
19
+ const _utils = require("./utils");
20
+ const isBrowser = (0, _reactUtilities.canUseDOM)();
21
+ const globalObject = isBrowser ? window : global;
22
+ const SYMBOL_NAMESPACE = 'global-context-selector:';
23
+ // During SSR the global object persists with the server process
19
24
  // Clean out the global object during server reload during development
20
-
21
25
  if (!isBrowser && process.env.NODE_ENV !== 'production') {
22
- const globalSymbols = /*#__PURE__*/Object.getOwnPropertySymbols(globalObject);
23
- globalSymbols.forEach(sym => {
24
- var _a;
25
-
26
- if ((_a = Symbol.keyFor(sym)) === null || _a === void 0 ? void 0 : _a.startsWith(exports.SYMBOL_NAMESPACE)) {
27
- // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
28
- delete globalObject[sym];
29
- }
30
- });
26
+ const globalSymbols = Object.getOwnPropertySymbols(globalObject);
27
+ globalSymbols.forEach((sym)=>{
28
+ var _Symbol_keyFor;
29
+ if ((_Symbol_keyFor = Symbol.keyFor(sym)) === null || _Symbol_keyFor === void 0 ? void 0 : _Symbol_keyFor.startsWith(SYMBOL_NAMESPACE)) {
30
+ delete globalObject[sym];
31
+ }
32
+ });
31
33
  }
32
- /**
33
- * Wrapper around @see createContext from \@fluentui/react-context-selector that implements context registration
34
- * in the globalThis object to avoid duplicate contexts. Contexts are keyed with
35
- * a unique sybmol for the package name, version and name of the context.
36
- *
37
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}
38
- *
39
- * @param defaultValue - @see React.createContext
40
- * @param name - name of the context
41
- * @param packageName - name of the npm package where the module is used
42
- * @param packageVersion - version of the npm package where the module is used
43
- * @returns @see React.createContext
44
- */
45
-
46
-
47
- const createContext = (defaultValue, name, packageName, packageVersion) => {
48
- // Symbol guaranteed to be unique for the entire runtime
49
- const sym = Symbol.for(`${exports.SYMBOL_NAMESPACE}${packageName}/${name}/@${utils_1.getMajorVersion(packageVersion)}`); // Objects keyed with symbols are not visible with console.log
50
- // Object symbol properties can't be iterated with `for` or `Object.keys`
51
-
52
- const globalSymbols = Object.getOwnPropertySymbols(globalObject);
53
-
54
- if (!globalSymbols.includes(sym)) {
55
- // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
56
- globalObject[sym] = react_context_selector_1.createContext(defaultValue);
57
- } // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
58
-
59
-
60
- return globalObject[sym];
34
+ const createContext = (defaultValue, name, packageName, packageVersion)=>{
35
+ // Symbol guaranteed to be unique for the entire runtime
36
+ const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${(0, _utils.getMajorVersion)(packageVersion)}`);
37
+ // Objects keyed with symbols are not visible with console.log
38
+ // Object symbol properties can't be iterated with `for` or `Object.keys`
39
+ const globalSymbols = Object.getOwnPropertySymbols(globalObject);
40
+ if (!globalSymbols.includes(sym)) {
41
+ // eslint-disable-next-line @fluentui/no-context-default-value
42
+ globalObject[sym] = (0, _reactContextSelector.createContext)(defaultValue);
43
+ }
44
+ return globalObject[sym];
61
45
  };
62
-
63
- exports.createContext = createContext;
64
- //# sourceMappingURL=global-context-selector.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["global-context-selector.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AAGA,MAAM,SAAS,gBAAG,iBAAA,CAAA,SAAA,EAAlB;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACa,OAAA,CAAA,gBAAA,GAAmB,0BAAnB,C,CAEb;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,OAAA,CAAA,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACI,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,OAAA,CAAA,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,OAAA,CAAA,eAAA,CAAgB,cAAhB,CAA+B,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA,YAAY,CAAC,GAAD,CAAZ,GAAoB,wBAAA,CAAA,aAAA,CAAkB,YAAlB,CAApB;EACD,CAV4G,CAY7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAdM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourcesContent":["import * as React from 'react';\nimport { createContext as baseCreateContext } from '@fluentui/react-context-selector';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { getMajorVersion } from './utils';\nimport { GlobalObject } from './types';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context-selector:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see createContext from \\@fluentui/react-context-selector that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n globalObject[sym] = baseCreateContext(defaultValue);\n }\n\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n return globalObject[sym] as React.Context<T>;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["global-context-selector.js"],"sourcesContent":["import * as React from 'react';\nimport { createContext as baseCreateContext } from '@fluentui/react-context-selector';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { getMajorVersion } from './utils';\nconst isBrowser = canUseDOM();\nconst globalObject = isBrowser ? window : global;\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context-selector:';\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach((sym)=>{\n var _Symbol_keyFor;\n if ((_Symbol_keyFor = Symbol.keyFor(sym)) === null || _Symbol_keyFor === void 0 ? void 0 : _Symbol_keyFor.startsWith(SYMBOL_NAMESPACE)) {\n delete globalObject[sym];\n }\n });\n}\n/**\n * Wrapper around @see createContext from \\@fluentui/react-context-selector that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */ export const createContext = (defaultValue, name, packageName, packageVersion)=>{\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // eslint-disable-next-line @fluentui/no-context-default-value\n globalObject[sym] = baseCreateContext(defaultValue);\n }\n return globalObject[sym];\n};\n"],"names":["SYMBOL_NAMESPACE","createContext","isBrowser","canUseDOM","globalObject","window","global","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","_Symbol_keyFor","Symbol","keyFor","startsWith","defaultValue","name","packageName","packageVersion","for","getMajorVersion","includes","baseCreateContext"],"mappings":";;;;;;;;;;;IAQaA,gBAAgB,MAAhBA;IAwBIC,aAAa,MAAbA;;;6DAhCM;sCAC4B;gCACzB;uBACM;AAChC,MAAMC,YAAYC,IAAAA,yBAAS;AAC3B,MAAMC,eAAeF,YAAYG,SAASC,MAAM;AAGzC,MAAMN,mBAAmB;AAChC,gEAAgE;AAChE,sEAAsE;AACtE,IAAI,CAACE,aAAaK,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACrD,MAAMC,gBAAgBC,OAAOC,qBAAqB,CAACR;IACnDM,cAAcG,OAAO,CAAC,CAACC,MAAM;QACzB,IAAIC;QACJ,IAAI,AAACA,CAAAA,iBAAiBC,OAAOC,MAAM,CAACH,IAAG,MAAO,IAAI,IAAIC,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeG,UAAU,CAAClB,iBAAiB,EAAE;YACpI,OAAOI,YAAY,CAACU,IAAI;QAC5B,CAAC;IACL;AACJ,CAAC;AAaU,MAAMb,gBAAgB,CAACkB,cAAcC,MAAMC,aAAaC,iBAAiB;IAChF,wDAAwD;IACxD,MAAMR,MAAME,OAAOO,GAAG,CAAC,CAAC,EAAEvB,iBAAiB,EAAEqB,YAAY,CAAC,EAAED,KAAK,EAAE,EAAEI,IAAAA,sBAAe,EAACF,gBAAgB,CAAC;IACtG,8DAA8D;IAC9D,yEAAyE;IACzE,MAAMZ,gBAAgBC,OAAOC,qBAAqB,CAACR;IACnD,IAAI,CAACM,cAAce,QAAQ,CAACX,MAAM;QAC9B,8DAA8D;QAC9DV,YAAY,CAACU,IAAI,GAAGY,IAAAA,mCAAiB,EAACP;IAC1C,CAAC;IACD,OAAOf,YAAY,CAACU,IAAI;AAC5B"}
@@ -1,64 +1,44 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.createContext = exports.SYMBOL_NAMESPACE = void 0;
7
-
8
- const React = /*#__PURE__*/require("react");
9
-
10
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
11
-
12
- const utils_1 = /*#__PURE__*/require("./utils");
13
-
14
- const isBrowser = /*#__PURE__*/react_utilities_1.canUseDOM();
15
- const globalObject = isBrowser ? window : global; // Identifier for the symbol, for easy idenfitifaction of symbols created by this util
16
- // Useful for clearning global object during SSR reloads
17
-
18
- exports.SYMBOL_NAMESPACE = 'global-context:'; // During SSR the global object persists with the server process
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ SYMBOL_NAMESPACE: ()=>SYMBOL_NAMESPACE,
13
+ createContext: ()=>createContext
14
+ });
15
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
16
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
17
+ const _reactUtilities = require("@fluentui/react-utilities");
18
+ const _utils = require("./utils");
19
+ const isBrowser = (0, _reactUtilities.canUseDOM)();
20
+ const globalObject = isBrowser ? window : global;
21
+ const SYMBOL_NAMESPACE = 'global-context:';
22
+ // During SSR the global object persists with the server process
19
23
  // Clean out the global object during server reload during development
20
-
21
24
  if (!isBrowser && process.env.NODE_ENV !== 'production') {
22
- const globalSymbols = /*#__PURE__*/Object.getOwnPropertySymbols(globalObject);
23
- globalSymbols.forEach(sym => {
24
- var _a;
25
-
26
- if ((_a = Symbol.keyFor(sym)) === null || _a === void 0 ? void 0 : _a.startsWith(exports.SYMBOL_NAMESPACE)) {
27
- // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
28
- delete globalObject[sym];
29
- }
30
- });
25
+ const globalSymbols = Object.getOwnPropertySymbols(globalObject);
26
+ globalSymbols.forEach((sym)=>{
27
+ var _Symbol_keyFor;
28
+ if ((_Symbol_keyFor = Symbol.keyFor(sym)) === null || _Symbol_keyFor === void 0 ? void 0 : _Symbol_keyFor.startsWith(SYMBOL_NAMESPACE)) {
29
+ delete globalObject[sym];
30
+ }
31
+ });
31
32
  }
32
- /**
33
- * Wrapper around @see React.createContext that implements context registration
34
- * in the globalThis object to avoid duplicate contexts. Contexts are keyed with
35
- * a unique sybmol for the package name, version and name of the context.
36
- *
37
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}
38
- *
39
- * @param defaultValue - @see React.createContext
40
- * @param name - name of the context
41
- * @param packageName - name of the npm package where the module is used
42
- * @param packageVersion - version of the npm package where the module is used
43
- * @returns @see React.createContext
44
- */
45
-
46
-
47
- const createContext = (defaultValue, name, packageName, packageVersion) => {
48
- // Symbol guaranteed to be unique for the entire runtime
49
- const sym = Symbol.for(`${exports.SYMBOL_NAMESPACE}${packageName}/${name}/@${utils_1.getMajorVersion(packageVersion)}`); // Objects keyed with symbols are not visible with console.log
50
- // Object symbol properties can't be iterated with `for` or `Object.keys`
51
-
52
- const globalSymbols = Object.getOwnPropertySymbols(globalObject);
53
-
54
- if (!globalSymbols.includes(sym)) {
55
- // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
56
- globalObject[sym] = React.createContext(defaultValue);
57
- } // @ts-expect-error - Indexing object with symbols not supported until TS 4.4
58
-
59
-
60
- return globalObject[sym];
33
+ const createContext = (defaultValue, name, packageName, packageVersion)=>{
34
+ // Symbol guaranteed to be unique for the entire runtime
35
+ const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${(0, _utils.getMajorVersion)(packageVersion)}`);
36
+ // Objects keyed with symbols are not visible with console.log
37
+ // Object symbol properties can't be iterated with `for` or `Object.keys`
38
+ const globalSymbols = Object.getOwnPropertySymbols(globalObject);
39
+ if (!globalSymbols.includes(sym)) {
40
+ // eslint-disable-next-line @fluentui/no-context-default-value
41
+ globalObject[sym] = /*#__PURE__*/ _react.createContext(defaultValue);
42
+ }
43
+ return globalObject[sym];
61
44
  };
62
-
63
- exports.createContext = createContext;
64
- //# sourceMappingURL=global-context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["global-context.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAEA,MAAA,OAAA,gBAAA,OAAA,CAAA,SAAA,CAAA;;AAEA,MAAM,SAAS,gBAAG,iBAAA,CAAA,SAAA,EAAlB;AACA,MAAM,YAAY,GAAiB,SAAS,GAAG,MAAH,GAAY,MAAxD,C,CAEA;AACA;;AACa,OAAA,CAAA,gBAAA,GAAmB,iBAAnB,C,CAEb;AACA;;AACA,IAAI,CAAC,SAAD,IAAc,OAAO,CAAC,GAAR,CAAY,QAAZ,KAAyB,YAA3C,EAAyD;EACvD,MAAM,aAAa,gBAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;EACA,aAAa,CAAC,OAAd,CAAsB,GAAG,IAAG;;;IAC1B,IAAI,CAAA,EAAA,GAAA,MAAM,CAAC,MAAP,CAAc,GAAd,CAAA,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,UAAF,CAAa,OAAA,CAAA,gBAAb,CAAtB,EAAsD;MACpD;MACA,OAAO,YAAY,CAAC,GAAD,CAAnB;IACD;EACF,CALD;AAMD;AAED;;;;;;;;;;;;AAYG;;;AACI,MAAM,aAAa,GAAG,CAAI,YAAJ,EAAqB,IAArB,EAAmC,WAAnC,EAAwD,cAAxD,KAAkF;EAC7G;EACA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAP,CAAW,GAAG,OAAA,CAAA,gBAAgB,GAAG,WAAW,IAAI,IAAI,KAAK,OAAA,CAAA,eAAA,CAAgB,cAAhB,CAA+B,EAAxF,CAAZ,CAF6G,CAI7G;EACA;;EACA,MAAM,aAAa,GAAG,MAAM,CAAC,qBAAP,CAA6B,YAA7B,CAAtB;;EACA,IAAI,CAAC,aAAa,CAAC,QAAd,CAAuB,GAAvB,CAAL,EAAkC;IAChC;IACA,YAAY,CAAC,GAAD,CAAZ,GAAoB,KAAK,CAAC,aAAN,CAAoB,YAApB,CAApB;EACD,CAV4G,CAY7G;;;EACA,OAAO,YAAY,CAAC,GAAD,CAAnB;AACD,CAdM;;AAAM,OAAA,CAAA,aAAA,GAAa,aAAb","sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { GlobalObject } from './types';\nimport { getMajorVersion } from './utils';\n\nconst isBrowser = canUseDOM();\nconst globalObject: GlobalObject = isBrowser ? window : global;\n\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context:';\n\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach(sym => {\n if (Symbol.keyFor(sym)?.startsWith(SYMBOL_NAMESPACE)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n delete globalObject[sym];\n }\n });\n}\n\n/**\n * Wrapper around @see React.createContext that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */\nexport const createContext = <T>(defaultValue: T, name: string, packageName: string, packageVersion: string) => {\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n globalObject[sym] = React.createContext(defaultValue);\n }\n\n // @ts-expect-error - Indexing object with symbols not supported until TS 4.4\n return globalObject[sym] as React.Context<T>;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["global-context.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '@fluentui/react-utilities';\nimport { getMajorVersion } from './utils';\nconst isBrowser = canUseDOM();\nconst globalObject = isBrowser ? window : global;\n// Identifier for the symbol, for easy idenfitifaction of symbols created by this util\n// Useful for clearning global object during SSR reloads\nexport const SYMBOL_NAMESPACE = 'global-context:';\n// During SSR the global object persists with the server process\n// Clean out the global object during server reload during development\nif (!isBrowser && process.env.NODE_ENV !== 'production') {\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n globalSymbols.forEach((sym)=>{\n var _Symbol_keyFor;\n if ((_Symbol_keyFor = Symbol.keyFor(sym)) === null || _Symbol_keyFor === void 0 ? void 0 : _Symbol_keyFor.startsWith(SYMBOL_NAMESPACE)) {\n delete globalObject[sym];\n }\n });\n}\n/**\n * Wrapper around @see React.createContext that implements context registration\n * in the globalThis object to avoid duplicate contexts. Contexts are keyed with\n * a unique sybmol for the package name, version and name of the context.\n *\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol}\n *\n * @param defaultValue - @see React.createContext\n * @param name - name of the context\n * @param packageName - name of the npm package where the module is used\n * @param packageVersion - version of the npm package where the module is used\n * @returns @see React.createContext\n */ export const createContext = (defaultValue, name, packageName, packageVersion)=>{\n // Symbol guaranteed to be unique for the entire runtime\n const sym = Symbol.for(`${SYMBOL_NAMESPACE}${packageName}/${name}/@${getMajorVersion(packageVersion)}`);\n // Objects keyed with symbols are not visible with console.log\n // Object symbol properties can't be iterated with `for` or `Object.keys`\n const globalSymbols = Object.getOwnPropertySymbols(globalObject);\n if (!globalSymbols.includes(sym)) {\n // eslint-disable-next-line @fluentui/no-context-default-value\n globalObject[sym] = React.createContext(defaultValue);\n }\n return globalObject[sym];\n};\n"],"names":["SYMBOL_NAMESPACE","createContext","isBrowser","canUseDOM","globalObject","window","global","process","env","NODE_ENV","globalSymbols","Object","getOwnPropertySymbols","forEach","sym","_Symbol_keyFor","Symbol","keyFor","startsWith","defaultValue","name","packageName","packageVersion","for","getMajorVersion","includes","React"],"mappings":";;;;;;;;;;;IAOaA,gBAAgB,MAAhBA;IAwBIC,aAAa,MAAbA;;;6DA/BM;gCACG;uBACM;AAChC,MAAMC,YAAYC,IAAAA,yBAAS;AAC3B,MAAMC,eAAeF,YAAYG,SAASC,MAAM;AAGzC,MAAMN,mBAAmB;AAChC,gEAAgE;AAChE,sEAAsE;AACtE,IAAI,CAACE,aAAaK,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACrD,MAAMC,gBAAgBC,OAAOC,qBAAqB,CAACR;IACnDM,cAAcG,OAAO,CAAC,CAACC,MAAM;QACzB,IAAIC;QACJ,IAAI,AAACA,CAAAA,iBAAiBC,OAAOC,MAAM,CAACH,IAAG,MAAO,IAAI,IAAIC,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeG,UAAU,CAAClB,iBAAiB,EAAE;YACpI,OAAOI,YAAY,CAACU,IAAI;QAC5B,CAAC;IACL;AACJ,CAAC;AAaU,MAAMb,gBAAgB,CAACkB,cAAcC,MAAMC,aAAaC,iBAAiB;IAChF,wDAAwD;IACxD,MAAMR,MAAME,OAAOO,GAAG,CAAC,CAAC,EAAEvB,iBAAiB,EAAEqB,YAAY,CAAC,EAAED,KAAK,EAAE,EAAEI,IAAAA,sBAAe,EAACF,gBAAgB,CAAC;IACtG,8DAA8D;IAC9D,yEAAyE;IACzE,MAAMZ,gBAAgBC,OAAOC,qBAAqB,CAACR;IACnD,IAAI,CAACM,cAAce,QAAQ,CAACX,MAAM;QAC9B,8DAA8D;QAC9DV,YAAY,CAACU,IAAI,iBAAGY,OAAMzB,aAAa,CAACkB;IAC5C,CAAC;IACD,OAAOf,YAAY,CAACU,IAAI;AAC5B"}
@@ -1,25 +1,16 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- exports.createContextSelector = exports.createContext = void 0;
7
-
8
- var global_context_1 = /*#__PURE__*/require("./global-context");
9
-
10
- Object.defineProperty(exports, "createContext", {
11
- enumerable: true,
12
- get: function () {
13
- return global_context_1.createContext;
14
- }
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ createContext: ()=>_globalContext.createContext,
13
+ createContextSelector: ()=>_globalContextSelector.createContext
15
14
  });
16
-
17
- var global_context_selector_1 = /*#__PURE__*/require("./global-context-selector");
18
-
19
- Object.defineProperty(exports, "createContextSelector", {
20
- enumerable: true,
21
- get: function () {
22
- return global_context_selector_1.createContext;
23
- }
24
- });
25
- //# sourceMappingURL=index.js.map
15
+ const _globalContext = require("./global-context");
16
+ const _globalContextSelector = require("./global-context-selector");
@@ -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":["index.js"],"sourcesContent":["export { createContext } from './global-context';\nexport { createContext as createContextSelector } from './global-context-selector';\n"],"names":["createContext","createContextSelector"],"mappings":";;;;;;;;;;;IAASA,aAAa,MAAbA,4BAAa;IACIC,qBAAqB,MAAtCD,oCAAa;;+BADQ;uCACyB"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
5
4
  });
6
- //# sourceMappingURL=types.js.map
5
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
6
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
1
+ {"version":3,"sources":["types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;6DAAuB"}
@@ -1,17 +1,14 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getMajorVersion = void 0;
7
1
  /**
8
2
  * @param version - semver version string
9
3
  * @returns The major version number
10
- */
11
-
4
+ */ "use strict";
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ Object.defineProperty(exports, "getMajorVersion", {
9
+ enumerable: true,
10
+ get: ()=>getMajorVersion
11
+ });
12
12
  function getMajorVersion(version) {
13
- return Number(version.split('.')[0]);
13
+ return Number(version.split('.')[0]);
14
14
  }
15
-
16
- exports.getMajorVersion = getMajorVersion;
17
- //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["utils.ts"],"names":[],"mappings":";;;;;;AAAA;;;AAGG;;AACH,SAAgB,eAAhB,CAAgC,OAAhC,EAA+C;EAC7C,OAAO,MAAM,CAAC,OAAO,CAAC,KAAR,CAAc,GAAd,EAAmB,CAAnB,CAAD,CAAb;AACD;;AAFD,OAAA,CAAA,eAAA,GAAA,eAAA","sourcesContent":["/**\n * @param version - semver version string\n * @returns The major version number\n */\nexport function getMajorVersion(version: string) {\n return Number(version.split('.')[0]);\n}\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["utils.js"],"sourcesContent":["/**\n * @param version - semver version string\n * @returns The major version number\n */ export function getMajorVersion(version) {\n return Number(version.split('.')[0]);\n}\n"],"names":["getMajorVersion","version","Number","split"],"mappings":"AAAA;;;CAGC;;;;+BAAmBA;;aAAAA;;AAAT,SAASA,gBAAgBC,OAAO,EAAE;IACzC,OAAOC,OAAOD,QAAQE,KAAK,CAAC,IAAI,CAAC,EAAE;AACvC"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@fluentui/global-context",
3
- "version": "9.0.0-beta.3",
3
+ "version": "9.0.0-beta.30",
4
4
  "description": "Extension of React createContext to be a true singleton on the global scope",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
7
- "typings": "dist/index.d.ts",
7
+ "typings": "./dist/index.d.ts",
8
8
  "sideEffects": false,
9
9
  "repository": {
10
10
  "type": "git",
@@ -16,31 +16,31 @@
16
16
  "bundle-size": "bundle-size measure",
17
17
  "clean": "just-scripts clean",
18
18
  "code-style": "just-scripts code-style",
19
- "e2e": "yarn cypress run --component",
20
- "e2e:local": "yarn cypress open --component",
19
+ "e2e": "cypress run --component",
20
+ "e2e:local": "cypress open --component",
21
21
  "just": "just-scripts",
22
22
  "lint": "just-scripts lint",
23
- "start": "yarn storybook",
24
23
  "test": "jest --passWithNoTests",
25
- "docs": "api-extractor run --config=config/api-extractor.local.json --local",
26
- "build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../../scripts/typescript/normalize-import --output ./dist/types/packages/react-components/global-context/src && yarn docs",
27
- "storybook": "node ../../../scripts/storybook/runner",
28
- "type-check": "tsc -b tsconfig.json"
24
+ "type-check": "tsc -b tsconfig.json",
25
+ "generate-api": "just-scripts generate-api",
26
+ "test-ssr": "test-ssr \"./stories/**/*.stories.tsx\""
29
27
  },
30
28
  "devDependencies": {
31
29
  "@fluentui/eslint-plugin": "*",
32
- "@fluentui/scripts": "^1.0.0"
30
+ "@fluentui/scripts-api-extractor": "*",
31
+ "@fluentui/scripts-cypress": "*",
32
+ "@fluentui/scripts-tasks": "*"
33
33
  },
34
34
  "dependencies": {
35
- "@fluentui/react-context-selector": "^9.0.2",
36
- "@fluentui/react-utilities": "^9.0.2",
37
- "tslib": "^2.1.0"
35
+ "@fluentui/react-context-selector": "^9.1.23",
36
+ "@fluentui/react-utilities": "^9.9.3",
37
+ "@swc/helpers": "^0.4.14"
38
38
  },
39
39
  "peerDependencies": {
40
- "@types/react": ">=16.8.0 <18.0.0",
41
- "@types/react-dom": ">=16.8.0 <18.0.0",
42
- "react": ">=16.8.0 <18.0.0",
43
- "react-dom": ">=16.8.0 <18.0.0",
40
+ "@types/react": ">=16.8.0 <19.0.0",
41
+ "@types/react-dom": ">=16.8.0 <19.0.0",
42
+ "react": ">=16.8.0 <19.0.0",
43
+ "react-dom": ">=16.8.0 <19.0.0",
44
44
  "scheduler": "^0.19.0 || ^0.20.0"
45
45
  },
46
46
  "beachball": {
@@ -49,5 +49,14 @@
49
49
  "minor",
50
50
  "patch"
51
51
  ]
52
+ },
53
+ "exports": {
54
+ ".": {
55
+ "types": "./dist/index.d.ts",
56
+ "node": "./lib-commonjs/index.js",
57
+ "import": "./lib/index.js",
58
+ "require": "./lib-commonjs/index.js"
59
+ },
60
+ "./package.json": "./package.json"
52
61
  }
53
62
  }
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.18.1"
9
- }
10
- ]
11
- }