@tamagui/create-context 2.0.0-rc.4 → 2.0.0-rc.40

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.
@@ -2,49 +2,51 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
32
34
  var create_context_exports = {};
33
35
  __export(create_context_exports, {
34
36
  createContext: () => createContext,
35
37
  createContextScope: () => createContextScope
36
38
  });
37
39
  module.exports = __toCommonJS(create_context_exports);
38
- var React = __toESM(require("react"), 1),
39
- import_jsx_runtime = require("react/jsx-runtime");
40
+ var React = __toESM(require("react"), 1);
41
+ var import_jsx_runtime = require("react/jsx-runtime");
40
42
  function createContext(rootComponentName, defaultContext) {
41
43
  const Context = React.createContext(defaultContext);
42
44
  function Provider(props) {
43
45
  const {
44
- children,
45
- ...context
46
- } = props,
47
- value = React.useMemo(() => context, Object.values(context));
46
+ children,
47
+ ...context
48
+ } = props;
49
+ const value = React.useMemo(() => context, Object.values(context));
48
50
  return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Context.Provider, {
49
51
  value,
50
52
  children
@@ -61,36 +63,43 @@ function createContext(rootComponentName, defaultContext) {
61
63
  function createContextScope(scopeName, createContextScopeDeps = []) {
62
64
  let defaultContexts = [];
63
65
  function createContext2(rootComponentName, defaultContext) {
64
- const BaseContext = React.createContext(defaultContext),
65
- index = defaultContexts.length;
66
+ const BaseContext = React.createContext(defaultContext);
67
+ const index = defaultContexts.length;
66
68
  defaultContexts = [...defaultContexts, defaultContext];
67
69
  function Provider(props) {
68
70
  const {
69
- scope,
70
- children,
71
- ...context
72
- } = props,
73
- Context = scope?.[scopeName]?.[index] || BaseContext,
74
- value = React.useMemo(() => context, Object.values(context));
71
+ scope,
72
+ children,
73
+ ...context
74
+ } = props;
75
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
76
+ const value = React.useMemo(() => context, Object.values(context));
75
77
  return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Context.Provider, {
76
78
  value,
77
79
  children
78
80
  });
79
81
  }
80
82
  function useContext(consumerName, scope, options) {
81
- const Context = scope?.[scopeName]?.[index] || BaseContext,
82
- context = React.useContext(Context);
83
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
84
+ const context = React.useContext(Context);
83
85
  if (context) return context;
84
86
  if (defaultContext !== void 0) return defaultContext;
85
87
  const missingContextMessage = `\`${consumerName}\` must be used within \`${rootComponentName}\``;
86
- if (options?.fallback) return options?.warn !== !1 && console.warn(missingContextMessage), options.fallback;
88
+ if (options?.fallback) {
89
+ if (options?.warn !== false) {
90
+ console.warn(missingContextMessage);
91
+ }
92
+ return options.fallback;
93
+ }
87
94
  throw new Error(missingContextMessage);
88
95
  }
89
96
  return [Provider, useContext];
90
97
  }
91
98
  const createScope = () => {
92
- const scopeContexts = defaultContexts.map(defaultContext => React.createContext(defaultContext));
93
- return function (scope) {
99
+ const scopeContexts = defaultContexts.map(defaultContext => {
100
+ return React.createContext(defaultContext);
101
+ });
102
+ return function useScope(scope) {
94
103
  const contexts = scope?.[scopeName] || scopeContexts;
95
104
  return React.useMemo(() => ({
96
105
  [`__scope${scopeName}`]: {
@@ -100,7 +109,8 @@ function createContextScope(scopeName, createContextScopeDeps = []) {
100
109
  }), [scope, contexts]);
101
110
  };
102
111
  };
103
- return createScope.scopeName = scopeName, [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
112
+ createScope.scopeName = scopeName;
113
+ return [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
104
114
  }
105
115
  function composeContextScopes(...scopes) {
106
116
  const baseScope = scopes[0];
@@ -110,12 +120,13 @@ function composeContextScopes(...scopes) {
110
120
  useScope: createScope2(),
111
121
  scopeName: createScope2.scopeName
112
122
  }));
113
- return function (overrideScopes) {
123
+ return function useComposedScopes(overrideScopes) {
114
124
  const nextScopes = scopeHooks.reduce((nextScopes2, {
115
125
  useScope,
116
126
  scopeName
117
127
  }) => {
118
- const currentScope = useScope(overrideScopes)[`__scope${scopeName}`];
128
+ const scopeProps = useScope(overrideScopes);
129
+ const currentScope = scopeProps[`__scope${scopeName}`];
119
130
  return {
120
131
  ...nextScopes2,
121
132
  ...currentScope
@@ -126,5 +137,6 @@ function composeContextScopes(...scopes) {
126
137
  }), [nextScopes]);
127
138
  };
128
139
  };
129
- return createScope.scopeName = baseScope.scopeName, createScope;
140
+ createScope.scopeName = baseScope.scopeName;
141
+ return createScope;
130
142
  }
@@ -4,51 +4,53 @@ var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf,
8
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: !0
13
- });
14
- },
15
- __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
18
  get: () => from[key],
18
19
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
20
  });
20
- return to;
21
- };
21
+ }
22
+ return to;
23
+ };
22
24
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: !0
30
- }) : target, mod)),
31
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: !0
33
- }), mod);
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
30
+ value: mod,
31
+ enumerable: true
32
+ }) : target, mod));
33
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
34
+ value: true
35
+ }), mod);
34
36
  var create_context_exports = {};
35
37
  __export(create_context_exports, {
36
38
  createContext: () => createContext,
37
39
  createContextScope: () => createContextScope
38
40
  });
39
41
  module.exports = __toCommonJS(create_context_exports);
40
- var import_jsx_runtime = require("react/jsx-runtime"),
41
- React = __toESM(require("react"), 1);
42
+ var import_jsx_runtime = require("react/jsx-runtime");
43
+ var React = __toESM(require("react"), 1);
42
44
  function createContext(rootComponentName, defaultContext) {
43
45
  var Context = /* @__PURE__ */React.createContext(defaultContext);
44
46
  function Provider(props) {
45
47
  var {
46
- children,
47
- ...context
48
- } = props,
49
- value = React.useMemo(function () {
50
- return context;
51
- }, Object.values(context));
48
+ children,
49
+ ...context
50
+ } = props;
51
+ var value = React.useMemo(function () {
52
+ return context;
53
+ }, Object.values(context));
52
54
  return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Context.Provider, {
53
55
  value,
54
56
  children
@@ -63,36 +65,41 @@ function createContext(rootComponentName, defaultContext) {
63
65
  return [Provider, useContext];
64
66
  }
65
67
  function createContextScope(scopeName) {
66
- var createContextScopeDeps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [],
67
- defaultContexts = [];
68
+ var createContextScopeDeps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
69
+ var defaultContexts = [];
68
70
  function createContext2(rootComponentName, defaultContext) {
69
- var BaseContext = /* @__PURE__ */React.createContext(defaultContext),
70
- index = defaultContexts.length;
71
+ var BaseContext = /* @__PURE__ */React.createContext(defaultContext);
72
+ var index = defaultContexts.length;
71
73
  defaultContexts = [...defaultContexts, defaultContext];
72
74
  function Provider(props) {
73
- var _scope_scopeName,
74
- {
75
- scope,
76
- children,
77
- ...context
78
- } = props,
79
- Context = (scope == null || (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext,
80
- value = React.useMemo(function () {
81
- return context;
82
- }, Object.values(context));
75
+ var _scope_scopeName;
76
+ var {
77
+ scope,
78
+ children,
79
+ ...context
80
+ } = props;
81
+ var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;
82
+ var value = React.useMemo(function () {
83
+ return context;
84
+ }, Object.values(context));
83
85
  return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Context.Provider, {
84
86
  value,
85
87
  children
86
88
  });
87
89
  }
88
90
  function useContext(consumerName, scope, options) {
89
- var _scope_scopeName,
90
- Context = (scope == null || (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext,
91
- context = React.useContext(Context);
91
+ var _scope_scopeName;
92
+ var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;
93
+ var context = React.useContext(Context);
92
94
  if (context) return context;
93
95
  if (defaultContext !== void 0) return defaultContext;
94
96
  var missingContextMessage = `\`${consumerName}\` must be used within \`${rootComponentName}\``;
95
- if (options?.fallback) return options?.warn !== !1 && console.warn(missingContextMessage), options.fallback;
97
+ if (options === null || options === void 0 ? void 0 : options.fallback) {
98
+ if ((options === null || options === void 0 ? void 0 : options.warn) !== false) {
99
+ console.warn(missingContextMessage);
100
+ }
101
+ return options.fallback;
102
+ }
96
103
  throw new Error(missingContextMessage);
97
104
  }
98
105
  return [Provider, useContext];
@@ -101,8 +108,8 @@ function createContextScope(scopeName) {
101
108
  var scopeContexts = defaultContexts.map(function (defaultContext) {
102
109
  return /* @__PURE__ */React.createContext(defaultContext);
103
110
  });
104
- return function (scope) {
105
- var contexts = scope?.[scopeName] || scopeContexts;
111
+ return function useScope(scope) {
112
+ var contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
106
113
  return React.useMemo(function () {
107
114
  return {
108
115
  [`__scope${scopeName}`]: {
@@ -113,10 +120,13 @@ function createContextScope(scopeName) {
113
120
  }, [scope, contexts]);
114
121
  };
115
122
  };
116
- return createScope.scopeName = scopeName, [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
123
+ createScope.scopeName = scopeName;
124
+ return [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
117
125
  }
118
126
  function composeContextScopes() {
119
- for (var _len = arguments.length, scopes = new Array(_len), _key = 0; _key < _len; _key++) scopes[_key] = arguments[_key];
127
+ for (var _len = arguments.length, scopes = new Array(_len), _key = 0; _key < _len; _key++) {
128
+ scopes[_key] = arguments[_key];
129
+ }
120
130
  var baseScope = scopes[0];
121
131
  if (scopes.length === 1) return baseScope;
122
132
  var createScope = function () {
@@ -126,14 +136,14 @@ function composeContextScopes() {
126
136
  scopeName: createScope2.scopeName
127
137
  };
128
138
  });
129
- return function (overrideScopes) {
139
+ return function useComposedScopes(overrideScopes) {
130
140
  var nextScopes = scopeHooks.reduce(function (nextScopes2, param) {
131
141
  var {
132
- useScope,
133
- scopeName
134
- } = param,
135
- scopeProps = useScope(overrideScopes),
136
- currentScope = scopeProps[`__scope${scopeName}`];
142
+ useScope,
143
+ scopeName
144
+ } = param;
145
+ var scopeProps = useScope(overrideScopes);
146
+ var currentScope = scopeProps[`__scope${scopeName}`];
137
147
  return {
138
148
  ...nextScopes2,
139
149
  ...currentScope
@@ -146,6 +156,7 @@ function composeContextScopes() {
146
156
  }, [nextScopes]);
147
157
  };
148
158
  };
149
- return createScope.scopeName = baseScope.scopeName, createScope;
159
+ createScope.scopeName = baseScope.scopeName;
160
+ return createScope;
150
161
  }
151
162
  //# sourceMappingURL=create-context.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","create_context_exports","__export","createContext","createContextScope","module","exports","import_jsx_runtime","require","React","__toESM","rootComponentName","defaultContext","Context","Provider","props","children","context","useMemo","Object","values","jsx","useContext","consumerName","Error","scopeName","createContextScopeDeps","arguments","length","defaultContexts","createContext2","BaseContext","index","_scope_scopeName","scope","options","missingContextMessage","fallback","warn","console","createScope","scopeContexts","map","contexts"],"sources":["../../src/create-context.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,sBAAA;AAAAC,QAAA,CAAAD,sBAAA;EAAAE,aAAA,EAAAA,CAAA,KAAAA,aAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAGAC,MAAA,CAAAC,OAAuB,GAAAV,YAAA,CAAAK,sBAkBZ;AAdJ,IAAAM,kBAAS,GACdC,OAAA,oBACA;EAAAC,KAIA,GAAAC,OAAA,CAAAF,OAAA;AACA,SAAML,aAAUA,CAAAQ,iBAAkD,EAAAC,cAAc;EAEhF,IAAAC,OAAS,kBAAkEJ,KAAA,CAAAN,aAAA,CAAAS,cAAA;EACzE,SAAME,QAAEA,CAAAC,KAAa;IAIrB;QAAAC,QAAO;QAAA,GAAAC;MAAA,IAAAF,KAAA;MAAAf,KA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C,QAAA;QAC9Bd,KAAA;QAMMgB;MACJ;IAGA;IACE,SAAMM,UAAWA,CAAAC,YAAQ,EAAAW,KAAS,EAAKC,OAAA;MACvC,IAAAF,gBAAa;QAAApB,OAAA,IAAAqB,KAAA,aAAAD,gBAAA,GAAAC,KAAA,CAAAT,SAAA,eAAAQ,gBAAA,uBAAAA,gBAAA,CAAAD,KAAA,MAAAD,WAAA;QAAAd,OAAA,GAAAR,KAAA,CAAAa,UAAA,CAAAT,OAAA;MAAA,IACXI,OAAS,EAAC,OAAAA,OAAU;MAAkD,IACrEL,cAAe,oBAAAA,cAAA;MAClB,IAAAwB,qBAAA,QAAAb,YAAA,4BAAAZ,iBAAA;MACF,IAAAwB,OAAA,EAAAE,QAAA,EACF,OAAAF,OAAA,EAAAG,IAAA,WAAAC,OAAA,CAAAD,IAAA,CAAAF,qBAAA,GAAAD,OAAA,CAAAE,QAAA;MAEA,UAAAb,KAAY,CAAAY,qBAAY,CAEjB;IACL;IACA,QACFtB,QAAA,EACFQ,UAAA,CAMA;EACE;EACA,IAAIkB,WAAO,YAAAA,CAAA,EAAc;IAEzB,IAAMC,aAAA,GAA2BZ,eAAM,CAAAa,GAAA,WAAA9B,cAAA;MACrC,OAAM,eAAaH,KAAW,CAACN,aAAA,CAAAS,cAAiB;IAAA,EAC9C;IAAsB,OACtB,UAAWsB,KAAA;MACX,IAAAS,QAAA,GAAAT,KAAA,GAAAT,SAAA,KAAAgB,aAAA;MAEF,OAAOhC,KAAA,CAAAS,OAA2B,aAAgB;QAChD,OAAM;UAKJ,WAAMO,SADa;YAEnB,GAAOS,KAAK;YACT,CAAAT,SAAA,GAAAkB;UAEL;QACE;MAAuD,GACtD,CACHT,KAAA,EACFS,QAAA,CACF;IAEA;EAEF","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","create_context_exports","__export","createContext","createContextScope","module","exports","import_jsx_runtime","require","React","__toESM","rootComponentName","defaultContext","Context","Provider","props","children","context","useMemo","Object","values","jsx","useContext","consumerName","Error","scopeName","createContextScopeDeps","arguments","length","defaultContexts","createContext2","BaseContext","index","_scope_scopeName","scope","options","missingContextMessage","fallback","warn","console","createScope","scopeContexts","map","useScope","contexts"],"sources":["../../src/create-context.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,sBAAA;AAAAC,QAAA,CAAAD,sBAAA;EAAAE,aAAA,EAAAA,CAAA,KAAAA,aAAA;EAAAC,kBAAA,EAAAA,CAAA,KAAAA;AAAA;AAGAC,MAAA,CAAAC,OAAuB,GAAAV,YAAA,CAAAK,sBAAA;AAkBZ,IAAAM,kBAAA,GAAAC,OAAA;AAdJ,IAAAC,KAAS,GAAAC,OAAA,CAAAF,OACd;AAMA,SAAML,aAAUA,CAAAQ,iBAAkD,EAAAC,cAAc;EAEhF,IAAAC,OAAS,kBAAkEJ,KAAA,CAAAN,aAAA,CAAAS,cAAA;EACzE,SAAME,QAAEA,CAAAC,KAAa;IAGrB;MAAMC,QAAQ;MAAA,GAAAC;IAAM,CAAQ,GAAAF,KAAM;IAClC,IAAAf,KAAO,GAAAS,KAAA,CAAAS,OAAA;MACT,OAAAD,OAAA;IAEA,GAAAE,MAAS,CAAAC,MAAA,CAAAH,OAAW;IAClB,OAAM,eAAgB,IAAAV,kBAAkB,CAAAc,GAAA,EAAAR,OAAA,CAAAC,QAAA;MACxCd,KAAI;MACJgB;IAEA;EACF;EAEA,SAAQM,UAAUA,CAAAC,YAAU;IAC9B,IAAAN,OAAA,GAAAR,KAAA,CAAAa,UAAA,CAAAT,OAAA;IAeO,IAAAI,OAAS,SAAAA,OACd;IAwBA,IAAIL,cAAA,KAA0B,eAAAA,cAAA;IAM9B,UAASY,KAAA,MAAAD,YACP,4BAEAZ,iBAAA;EACA;EACA,QACAG,QA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C,IAAAwB,qBAAa,QAAAb,YAAA,4BAAAZ,iBAAA;MAAA,IACXwB,OAAS,KAAC,QAAUA,OAAS,KAAK,KAAK,SAAQ,IAAAA,OAAY,CAAAE,QAAS,EAAE;QACtE,IAAC,CAAAF,OAAO,KAAQ,QAAAA,OAAA,uBAAAA,OAAA,CAAAG,IAAA;UAClBC,OAAA,CAAAD,IAAA,CAAAF,qBAAA;QACF;QACF,OAAAD,OAAA,CAAAE,QAAA;MAEA;MAEA,MAAO,IAAAb,KAAA,CAAAY,qBAAA;IACL;IACA,QACFtB,QAAA,EACFQ,UAAA,CAMA;EACE;EACA,IAAIkB,WAAO,YAAAA,CAAA,EAAc;IAEzB,IAAMC,aAAA,GAA2BZ,eAAM,CAAAa,GAAA,WAAA9B,cAAA;MACrC,OAAM,eAAaH,KAAW,CAACN,aAAA,CAAAS,cAAiB;IAAA,EAC9C;IAAsB,OACtB,SAAW+B,SAAAT,KAAY;MACvB,IAAAU,QAAA,IAAAV,KAAA,aAAAA,KAAA,uBAAAA,KAAA,CAAAT,SAAA,MAAAgB,aAAA;MAEF,OAAOhC,KAAA,CAAAS,OAAS,aAAkB;QAChC,OAAM;UAIJ,WAAMO,SAAa;YACnB,GAAMS,KAAA;YACN,CAAAT,SAAY,GAAAmB;UACV;QAEJ;MAAa,GACX,CACAV,KAAC,EACHU,QAAA,CACF;IACF;EAEA;EACAJ,WAAO,CAAAf,SAAA,GAAAA,SAAA;EACT,Q","ignoreList":[]}
@@ -3,15 +3,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
5
  var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
7
8
  get: () => from[key],
8
9
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
10
  });
10
- return to;
11
- },
12
- __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
15
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
- value: !0
16
+ value: true
15
17
  }), mod);
16
18
  var index_exports = {};
17
19
  module.exports = __toCommonJS(index_exports);
@@ -5,15 +5,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
9
10
  get: () => from[key],
10
11
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
11
12
  });
12
- return to;
13
- },
14
- __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ }
14
+ return to;
15
+ };
16
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
17
  var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
16
- value: !0
18
+ value: true
17
19
  }), mod);
18
20
  var index_exports = {};
19
21
  module.exports = __toCommonJS(index_exports);
@@ -1 +1 @@
1
- {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA","ignoreList":[]}
@@ -4,10 +4,10 @@ function createContext(rootComponentName, defaultContext) {
4
4
  const Context = React.createContext(defaultContext);
5
5
  function Provider(props) {
6
6
  const {
7
- children,
8
- ...context
9
- } = props,
10
- value = React.useMemo(() => context, Object.values(context));
7
+ children,
8
+ ...context
9
+ } = props;
10
+ const value = React.useMemo(() => context, Object.values(context));
11
11
  return /* @__PURE__ */jsx(Context.Provider, {
12
12
  value,
13
13
  children
@@ -24,36 +24,43 @@ function createContext(rootComponentName, defaultContext) {
24
24
  function createContextScope(scopeName, createContextScopeDeps = []) {
25
25
  let defaultContexts = [];
26
26
  function createContext2(rootComponentName, defaultContext) {
27
- const BaseContext = React.createContext(defaultContext),
28
- index = defaultContexts.length;
27
+ const BaseContext = React.createContext(defaultContext);
28
+ const index = defaultContexts.length;
29
29
  defaultContexts = [...defaultContexts, defaultContext];
30
30
  function Provider(props) {
31
31
  const {
32
- scope,
33
- children,
34
- ...context
35
- } = props,
36
- Context = scope?.[scopeName]?.[index] || BaseContext,
37
- value = React.useMemo(() => context, Object.values(context));
32
+ scope,
33
+ children,
34
+ ...context
35
+ } = props;
36
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
37
+ const value = React.useMemo(() => context, Object.values(context));
38
38
  return /* @__PURE__ */jsx(Context.Provider, {
39
39
  value,
40
40
  children
41
41
  });
42
42
  }
43
43
  function useContext(consumerName, scope, options) {
44
- const Context = scope?.[scopeName]?.[index] || BaseContext,
45
- context = React.useContext(Context);
44
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
45
+ const context = React.useContext(Context);
46
46
  if (context) return context;
47
47
  if (defaultContext !== void 0) return defaultContext;
48
48
  const missingContextMessage = `\`${consumerName}\` must be used within \`${rootComponentName}\``;
49
- if (options?.fallback) return options?.warn !== !1 && console.warn(missingContextMessage), options.fallback;
49
+ if (options?.fallback) {
50
+ if (options?.warn !== false) {
51
+ console.warn(missingContextMessage);
52
+ }
53
+ return options.fallback;
54
+ }
50
55
  throw new Error(missingContextMessage);
51
56
  }
52
57
  return [Provider, useContext];
53
58
  }
54
59
  const createScope = () => {
55
- const scopeContexts = defaultContexts.map(defaultContext => React.createContext(defaultContext));
56
- return function (scope) {
60
+ const scopeContexts = defaultContexts.map(defaultContext => {
61
+ return React.createContext(defaultContext);
62
+ });
63
+ return function useScope(scope) {
57
64
  const contexts = scope?.[scopeName] || scopeContexts;
58
65
  return React.useMemo(() => ({
59
66
  [`__scope${scopeName}`]: {
@@ -63,7 +70,8 @@ function createContextScope(scopeName, createContextScopeDeps = []) {
63
70
  }), [scope, contexts]);
64
71
  };
65
72
  };
66
- return createScope.scopeName = scopeName, [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
73
+ createScope.scopeName = scopeName;
74
+ return [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
67
75
  }
68
76
  function composeContextScopes(...scopes) {
69
77
  const baseScope = scopes[0];
@@ -73,12 +81,13 @@ function composeContextScopes(...scopes) {
73
81
  useScope: createScope2(),
74
82
  scopeName: createScope2.scopeName
75
83
  }));
76
- return function (overrideScopes) {
84
+ return function useComposedScopes(overrideScopes) {
77
85
  const nextScopes = scopeHooks.reduce((nextScopes2, {
78
86
  useScope,
79
87
  scopeName
80
88
  }) => {
81
- const currentScope = useScope(overrideScopes)[`__scope${scopeName}`];
89
+ const scopeProps = useScope(overrideScopes);
90
+ const currentScope = scopeProps[`__scope${scopeName}`];
82
91
  return {
83
92
  ...nextScopes2,
84
93
  ...currentScope
@@ -89,7 +98,8 @@ function composeContextScopes(...scopes) {
89
98
  }), [nextScopes]);
90
99
  };
91
100
  };
92
- return createScope.scopeName = baseScope.scopeName, createScope;
101
+ createScope.scopeName = baseScope.scopeName;
102
+ return createScope;
93
103
  }
94
104
  export { createContext, createContextScope };
95
105
  //# sourceMappingURL=create-context.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","jsx","createContext","rootComponentName","defaultContext","Context","Provider","props","children","context","value","useMemo","Object","values","useContext","consumerName","Error","createContextScope","scopeName","createContextScopeDeps","defaultContexts","createContext2","BaseContext","index","length","scope","options","missingContextMessage","fallback","warn","console","createScope","scopeContexts","map","contexts","composeContextScopes","scopes","baseScope","scopeHooks","createScope2","useScope","overrideScopes","nextScopes","reduce","nextScopes2","currentScope"],"sources":["../../src/create-context.tsx"],"sourcesContent":[null],"mappings":"AAGA,YAAYA,KAAA,MAAW;AAkBZ,SAAAC,GAAA;AAdJ,SAASC,cACdC,iBAAA,EACAC,cAAA,EAIA;EACA,MAAMC,OAAA,GAAUL,KAAA,CAAME,aAAA,CAA4CE,cAAc;EAEhF,SAASE,SAASC,KAAA,EAAyD;IACzE,MAAM;QAAEC,QAAA;QAAU,GAAGC;MAAQ,IAAIF,KAAA;MAG3BG,KAAA,GAAQV,KAAA,CAAMW,OAAA,CAAQ,MAAMF,OAAA,EAASG,MAAA,CAAOC,MAAA,CAAOJ,OAAO,CAAC;IACjE,OAAO,eAAAR,GAAA,CAACI,OAAA,CAAQC,QAAA,EAAR;MAAiBI,KAAA;MAAeF;IAAA,CAAS;EACnD;EAEA,SAASM,WAAWC,YAAA,EAA0D;IAC5E,MAAMN,OAAA,GAAUT,KAA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AY;QAAEJ,QAAA;QAAUtB;MAAU,MAAM;QAK5E,MAAM2B,YAAA,GADaL,QAAA,CAASC,cAAc,EACV,UAAUvB,SAAS,EAAE;QACrD,OAAO;UAAE,GAAG0B,WAAA;UAAY,GAAGC;QAAa;MAC1C,GAAG,CAAC,CAAC;MAEL,OAAO7C,KAAA,CAAMW,OAAA,CACX,OAAO;QAAE,CAAC,UAAU0B,SAAA,CAAUnB,SAAS,EAAE,GAAGwB;MAAW,IACvD,CAACA,UAAU,CACb;IACF;EACF;EAEA,OAAAX,WAAA,CAAYb,SAAA,GAAYmB,SAAA,CAAUnB,SAAA,EAC3Ba,WAAA;AACT","ignoreList":[]}
1
+ {"version":3,"names":["React","jsx","createContext","rootComponentName","defaultContext","Context","Provider","props","children","context","value","useMemo","Object","values","useContext","consumerName","Error","createContextScope","scopeName","createContextScopeDeps","defaultContexts","createContext2","BaseContext","index","length","scope","options","missingContextMessage","fallback","warn","console","createScope","scopeContexts","map","useScope","contexts","composeContextScopes","scopes","baseScope","scopeHooks","createScope2","useComposedScopes","overrideScopes","nextScopes","reduce","nextScopes2","scopeProps","currentScope"],"sources":["../../src/create-context.tsx"],"sourcesContent":[null],"mappings":"AAGA,YAAYA,KAAA,MAAW;AAkBZ,SAAAC,GAAA;AAdJ,SAASC,cACdC,iBAAA,EACAC,cAAA,EAIA;EACA,MAAMC,OAAA,GAAUL,KAAA,CAAME,aAAA,CAA4CE,cAAc;EAEhF,SAASE,SAASC,KAAA,EAAyD;IACzE,MAAM;MAAEC,QAAA;MAAU,GAAGC;IAAQ,IAAIF,KAAA;IAGjC,MAAMG,KAAA,GAAQV,KAAA,CAAMW,OAAA,CAAQ,MAAMF,OAAA,EAASG,MAAA,CAAOC,MAAA,CAAOJ,OAAO,CAAC;IACjE,OAAO,eAAAR,GAAA,CAACI,OAAA,CAAQC,QAAA,EAAR;MAAiBI,KAAA;MAAeF;IAAA,CAAS;EACnD;EAEA,SAASM,WAAWC,YAAA,EAA0D;IAC5E,M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EF,OAAO,SAASuB,kBAAkBC,cAAA,EAAgB;MAChD,MAAMC,UAAA,GAAaJ,UAAA,CAAWK,MAAA,CAAO,CAACC,WAAA,EAAY;QAAEX,QAAA;QAAUhB;MAAU,MAAM;QAI5E,MAAM4B,UAAA,GAAaZ,QAAA,CAASQ,cAAc;QAC1C,MAAMK,YAAA,GAAeD,UAAA,CAAW,UAAU5B,SAAS,EAAE;QACrD,OAAO;UAAE,GAAG2B,WAAA;UAAY,GAAGE;QAAa;MAC1C,GAAG,CAAC,CAAC;MAEL,OAAO/C,KAAA,CAAMW,OAAA,CACX,OAAO;QAAE,CAAC,UAAU2B,SAAA,CAAUpB,SAAS,EAAE,GAAGyB;MAAW,IACvD,CAACA,UAAU,CACb;IACF;EACF;EAEAZ,WAAA,CAAYb,SAAA,GAAYoB,SAAA,CAAUpB,SAAA;EAClC,OAAOa,WAAA;AACT","ignoreList":[]}
@@ -4,12 +4,12 @@ function createContext(rootComponentName, defaultContext) {
4
4
  var Context = /* @__PURE__ */React.createContext(defaultContext);
5
5
  function Provider(props) {
6
6
  var {
7
- children,
8
- ...context
9
- } = props,
10
- value = React.useMemo(function () {
11
- return context;
12
- }, Object.values(context));
7
+ children,
8
+ ...context
9
+ } = props;
10
+ var value = React.useMemo(function () {
11
+ return context;
12
+ }, Object.values(context));
13
13
  return /* @__PURE__ */_jsx(Context.Provider, {
14
14
  value,
15
15
  children
@@ -24,36 +24,41 @@ function createContext(rootComponentName, defaultContext) {
24
24
  return [Provider, useContext];
25
25
  }
26
26
  function createContextScope(scopeName) {
27
- var createContextScopeDeps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [],
28
- defaultContexts = [];
27
+ var createContextScopeDeps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
28
+ var defaultContexts = [];
29
29
  function createContext2(rootComponentName, defaultContext) {
30
- var BaseContext = /* @__PURE__ */React.createContext(defaultContext),
31
- index = defaultContexts.length;
30
+ var BaseContext = /* @__PURE__ */React.createContext(defaultContext);
31
+ var index = defaultContexts.length;
32
32
  defaultContexts = [...defaultContexts, defaultContext];
33
33
  function Provider(props) {
34
- var _scope_scopeName,
35
- {
36
- scope,
37
- children,
38
- ...context
39
- } = props,
40
- Context = (scope == null || (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext,
41
- value = React.useMemo(function () {
42
- return context;
43
- }, Object.values(context));
34
+ var _scope_scopeName;
35
+ var {
36
+ scope,
37
+ children,
38
+ ...context
39
+ } = props;
40
+ var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;
41
+ var value = React.useMemo(function () {
42
+ return context;
43
+ }, Object.values(context));
44
44
  return /* @__PURE__ */_jsx(Context.Provider, {
45
45
  value,
46
46
  children
47
47
  });
48
48
  }
49
49
  function useContext(consumerName, scope, options) {
50
- var _scope_scopeName,
51
- Context = (scope == null || (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext,
52
- context = React.useContext(Context);
50
+ var _scope_scopeName;
51
+ var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;
52
+ var context = React.useContext(Context);
53
53
  if (context) return context;
54
54
  if (defaultContext !== void 0) return defaultContext;
55
55
  var missingContextMessage = `\`${consumerName}\` must be used within \`${rootComponentName}\``;
56
- if (options?.fallback) return options?.warn !== !1 && console.warn(missingContextMessage), options.fallback;
56
+ if (options === null || options === void 0 ? void 0 : options.fallback) {
57
+ if ((options === null || options === void 0 ? void 0 : options.warn) !== false) {
58
+ console.warn(missingContextMessage);
59
+ }
60
+ return options.fallback;
61
+ }
57
62
  throw new Error(missingContextMessage);
58
63
  }
59
64
  return [Provider, useContext];
@@ -62,8 +67,8 @@ function createContextScope(scopeName) {
62
67
  var scopeContexts = defaultContexts.map(function (defaultContext) {
63
68
  return /* @__PURE__ */React.createContext(defaultContext);
64
69
  });
65
- return function (scope) {
66
- var contexts = scope?.[scopeName] || scopeContexts;
70
+ return function useScope(scope) {
71
+ var contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
67
72
  return React.useMemo(function () {
68
73
  return {
69
74
  [`__scope${scopeName}`]: {
@@ -74,10 +79,13 @@ function createContextScope(scopeName) {
74
79
  }, [scope, contexts]);
75
80
  };
76
81
  };
77
- return createScope.scopeName = scopeName, [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
82
+ createScope.scopeName = scopeName;
83
+ return [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
78
84
  }
79
85
  function composeContextScopes() {
80
- for (var _len = arguments.length, scopes = new Array(_len), _key = 0; _key < _len; _key++) scopes[_key] = arguments[_key];
86
+ for (var _len = arguments.length, scopes = new Array(_len), _key = 0; _key < _len; _key++) {
87
+ scopes[_key] = arguments[_key];
88
+ }
81
89
  var baseScope = scopes[0];
82
90
  if (scopes.length === 1) return baseScope;
83
91
  var createScope = function () {
@@ -87,14 +95,14 @@ function composeContextScopes() {
87
95
  scopeName: createScope2.scopeName
88
96
  };
89
97
  });
90
- return function (overrideScopes) {
98
+ return function useComposedScopes(overrideScopes) {
91
99
  var nextScopes = scopeHooks.reduce(function (nextScopes2, param) {
92
100
  var {
93
- useScope,
94
- scopeName
95
- } = param,
96
- scopeProps = useScope(overrideScopes),
97
- currentScope = scopeProps[`__scope${scopeName}`];
101
+ useScope,
102
+ scopeName
103
+ } = param;
104
+ var scopeProps = useScope(overrideScopes);
105
+ var currentScope = scopeProps[`__scope${scopeName}`];
98
106
  return {
99
107
  ...nextScopes2,
100
108
  ...currentScope
@@ -107,7 +115,8 @@ function composeContextScopes() {
107
115
  }, [nextScopes]);
108
116
  };
109
117
  };
110
- return createScope.scopeName = baseScope.scopeName, createScope;
118
+ createScope.scopeName = baseScope.scopeName;
119
+ return createScope;
111
120
  }
112
121
  export { createContext, createContextScope };
113
122
  //# sourceMappingURL=create-context.native.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["jsx","_jsx","React","createContext","rootComponentName","defaultContext","Context","Provider","props","children","context","value","useMemo","Object","values","useContext","consumerName","Error","createContextScope","scopeName","createContextScopeDeps","arguments","length","defaultContexts","createContext2","BaseContext","index","_scope_scopeName","scope","options","missingContextMessage","fallback","warn","console","createScope","scopeContexts","map","contexts"],"sources":["../../src/create-context.tsx"],"sourcesContent":[null],"mappings":"AAGA,SAAAA,GAAY,IAAAC,IAAA,QAAW;AAkBZ,YAAAC,KAAA;AAdJ,SAASC,cACdC,iBAAA,EACAC,cAAA,EAIA;EACA,IAAAC,OAAM,kBAAgBJ,KAAA,CAA4CC,aAAA,CAAcE,cAAA;EAEhF,SAASE,SAASC,KAAA,EAAyD;IACzE;QAAMC,QAAE;QAAA,GAAUC;MAAG,IAAQF,KAAI;MAAAG,KAG3B,GAAAT,KAAQ,CAAAU,OAAM,aAAc;QAClC,OAAOF,OAAA;MACT,GAAAG,MAAA,CAAAC,MAAA,CAAAJ,OAAA;IAEA,OAAS,eAAWT,IAAA,CAAAK,OAA0D,CAAAC,QAAA;MAC5EI,KAAM;MACNF;IACA;EAEA;EACF,SAAAM,WAAAC,YAAA;IAEA,IAAAN,OAAQ,GAAAR,KAAU,CAAAa,UAAU,CAAAT,OAAA;IAC9B,IAAAI,OAAA,SAAAA,OAAA;IAeO,IAAAL,cAAS,UACd,UACAA,cAAA;IAuBA,MAAI,IAAAY,KAAA,MAA0BD,YAAA,4BAAAZ,iBAAA;EAM9B;EAIE,QAEAG,QAAA,EAEAQ,UAAS,CAMP;AAIoB;AACZ,SACNG,kBAAcA,CAAAC,SAAO;EAAA,IACvBC,sBAAA,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,iBAAAA,SAAA;IAAAE,eAAA;EACA,SAAAC,cAAOA,CAAApB,iBAAS,EAAAC,cAAS,EAAe;I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AAA,CAAA,EAAQ;IAC1B,IAAIC,aAAO,GAAWZ,eAAU,CAAAa,GAAA,WAAA/B,cAAA;MAEhC,OAAM,eAAiCH,KAAA,CAAAC,aAAA,CAAAE,cAAA;IACrC;IAAgD,OAC9C,UAAUuB,KAAA;MACV,IAAAS,QAAW,GAAAT,KAAA,GAAAT,SAAY,KAAAgB,aAAA;MACvB,OAAAjC,KAAA,CAAAU,OAAA;QAEF,OAAO;UACL,WAAMO,SAAa;YAKjB,GAAMS,KAAA;YACN,CAAAT,SAAY,GAAAkB;UACV;QAEJ;MAAa,GACX,CACAT,KAAC,EACHS,QAAA,CACF;IACF;EAEA;EAEF,OAAAH,WAAA,CAAAf,SAAA,GAAAA,SAAA,G","ignoreList":[]}
1
+ {"version":3,"names":["jsx","_jsx","React","createContext","rootComponentName","defaultContext","Context","Provider","props","children","context","value","useMemo","Object","values","useContext","consumerName","Error","createContextScope","scopeName","createContextScopeDeps","arguments","length","defaultContexts","createContext2","BaseContext","index","_scope_scopeName","scope","options","missingContextMessage","fallback","warn","console","createScope","scopeContexts","map","useScope","contexts"],"sources":["../../src/create-context.tsx"],"sourcesContent":[null],"mappings":"AAGA,SAAAA,GAAY,IAAAC,IAAA,QAAW;AAkBZ,YAAAC,KAAA;AAdJ,SAASC,cACdC,iBAAA,EACAC,cAAA,EAIA;EACA,IAAAC,OAAM,kBAAgBJ,KAAA,CAA4CC,aAAA,CAAcE,cAAA;EAEhF,SAASE,SAASC,KAAA,EAAyD;IACzE;MAAMC,QAAE;MAAA,GAAUC;IAAG,IAAQF,KAAI;IAGjC,IAAAG,KAAM,GAAAT,KAAQ,CAAAU,OAAM,aAAc;MAClC,OAAOF,OAAA;IACT,GAAAG,MAAA,CAAAC,MAAA,CAAAJ,OAAA;IAEA,OAAS,eAAWT,IAAA,CAAAK,OAA0D,CAAAC,QAAA;MAC5EI,KAAM;MACNF;IACA;EAEA;EACF,SAAAM,WAAAC,YAAA;IAEA,IAAAN,OAAQ,GAAAR,KAAU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AA,gBAAA,CAAAD,KAAA,MAAAD,WAAA;MAC5D,IAAAf,OAAO,GAAMR,KAAA,CAAAa,UAAc,CAAAT,OAAA;MAC5B,IAAAI,OAAA,SAAAA,OAAA;MACD,IAAAL,cAAgB,KAAS,QAAc,OAAAA,cAAA;MACrC,IAAAyB,qBAAyB,QAAAd,YAAc,4BAAAZ,iBAAA;MACvC,IAAAyB,OAAO,KAAM,QAAAA,OAAA,uBAAAA,OAAA,CAAAE,QAAA;QACX,KAAAF,OAAU,SAAU,IAAAA,OAAW,KAAK,KAAG,IAAO,KAAC,IAAAA,OAAY,CAAAG,IAAA,MAAW;UACrEC,OAAO,CAAAD,IAAA,CAAAF,qBAAQ;QAClB;QACF,OAAAD,OAAA,CAAAE,QAAA;MACF;MAEA,UAAYd,KAAA,CAAAa,qBAAY;IAExB;IACE,QACAvB,QAAA,EACFQ,UAAA,CACF;EAMA;EACE,IAAAmB,WAAM,GAAY,SAAAA,CAAA,EAAQ;IAC1B,IAAIC,aAAO,GAAWZ,eAAU,CAAAa,GAAA,WAAA/B,cAAA;MAEhC,OAAM,eAAiCH,KAAA,CAAAC,aAAA,CAAAE,cAAA;IACrC;IAAgD,OAC9C,SAAUgC,SAAYT,KAAA;MACtB,IAAAU,QAAW,IAAAV,KAAA,KAAY,QAAAA,KAAA,uBAAAA,KAAA,CAAAT,SAAA,MAAAgB,aAAA;MACvB,OAAAjC,KAAA,CAAAU,OAAA;QAEF,OAAO;UACL,WAAMO,SAAa;YAIjB,GAAMS,KAAA;YACN,CAAAT,SAAM,GAAAmB;UACN;QACF,CAAG;MAEH,IACEV,KAAA,EACAU,QAAC,CACH;IACF;EACF;EAEAJ,WAAA,CAAYf,SAAA,GAAYA,SAAA;EACxB,OAAO,CACTK,cAAA,E","ignoreList":[]}
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./create-context";
1
+ export * from "./create-context.mjs";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,6 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "mappings": "AAAA,cAAc;",
5
- "names": []
6
- }
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/create-context",
3
- "version": "2.0.0-rc.4",
3
+ "version": "2.0.0-rc.40",
4
4
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
5
  "source": "src/index.ts",
6
6
  "files": [
@@ -17,15 +17,12 @@
17
17
  "./package.json": "./package.json",
18
18
  ".": {
19
19
  "types": "./types/index.d.ts",
20
- "react-native": {
21
- "module": "./dist/esm/index.native.js",
22
- "import": "./dist/esm/index.native.js",
23
- "require": "./dist/cjs/index.native.js"
24
- },
20
+ "react-native": "./dist/esm/index.native.js",
21
+ "browser": "./dist/esm/index.mjs",
25
22
  "module": "./dist/esm/index.mjs",
26
23
  "import": "./dist/esm/index.mjs",
27
24
  "require": "./dist/cjs/index.cjs",
28
- "default": "./dist/cjs/index.native.js"
25
+ "default": "./dist/esm/index.mjs"
29
26
  }
30
27
  },
31
28
  "publishConfig": {
@@ -38,7 +35,7 @@
38
35
  "clean:build": "tamagui-build clean:build"
39
36
  },
40
37
  "devDependencies": {
41
- "@tamagui/build": "2.0.0-rc.4",
38
+ "@tamagui/build": "2.0.0-rc.40",
42
39
  "react": ">=19"
43
40
  },
44
41
  "peerDependencies": {
@@ -4,8 +4,8 @@
4
4
  "sources": [
5
5
  "src/create-context.tsx"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
9
  "// from radix\n// https://github.com/radix-ui/primitives/blob/main/packages/react/context/src/createContext.tsx\n\nimport * as React from 'react'\n\nexport type ScopedProps<P, K extends string> = P & { [Key in `__scope${K}`]?: Scope }\n\nexport function createContext<ContextValueType extends object | null>(\n rootComponentName: string,\n defaultContext?: ContextValueType\n): readonly [\n (props: ContextValueType & { children: React.ReactNode }) => React.JSX.Element,\n (consumerName: string) => Exclude<ContextValueType | undefined, undefined>,\n] {\n const Context = React.createContext<ContextValueType | undefined>(defaultContext)\n\n function Provider(props: ContextValueType & { children: React.ReactNode }) {\n const { children, ...context } = props\n // Only re-memoize when prop values change\n\n const value = React.useMemo(() => context, Object.values(context)) as ContextValueType\n return <Context.Provider value={value}>{children}</Context.Provider>\n }\n\n function useContext(consumerName: string): Exclude<typeof context, undefined> {\n const context = React.useContext(Context)\n if (context) return context as any\n if (defaultContext !== undefined) return defaultContext as any\n // if a defaultContext wasn't specified, it's a required context.\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``)\n }\n\n return [Provider, useContext] as const\n}\n\n/* -------------------------------------------------------------------------------------------------\n * createContextScope\n * -----------------------------------------------------------------------------------------------*/\n\ntype ScopeHook = (scope: Scope) => { [__scopeProp: string]: Scope }\n\nexport type Scope<C = any> = { [scopeName: string]: React.Context<C>[] } | undefined\n\nexport interface CreateScope {\n scopeName: string\n (): ScopeHook\n}\n\nexport function createContextScope(\n scopeName: string,\n createContextScopeDeps: CreateScope[] = []\n): readonly [\n <ContextValueType extends object | null>(\n rootComponentName: string,\n defaultContext?: ContextValueType\n ) => readonly [\n (\n props: ContextValueType & {\n scope: Scope<ContextValueType>\n children: React.ReactNode\n }\n ) => import('react/jsx-runtime').JSX.Element,\n (\n consumerName: string,\n scope: Scope<ContextValueType | undefined>,\n options?: {\n warn?: boolean\n fallback?: Partial<ContextValueType>\n }\n ) => ContextValueType,\n ],\n CreateScope,\n] {\n let defaultContexts: any[] = []\n\n /* -----------------------------------------------------------------------------------------------\n * createContext\n * ---------------------------------------------------------------------------------------------*/\n\n function createContext<ContextValueType extends object | null>(\n rootComponentName: string,\n defaultContext?: ContextValueType\n ) {\n const BaseContext = React.createContext<ContextValueType | undefined>(defaultContext)\n const index = defaultContexts.length\n defaultContexts = [...defaultContexts, defaultContext]\n\n function Provider(\n props: ContextValueType & {\n scope: Scope<ContextValueType>\n children: React.ReactNode\n }\n ) {\n const { scope, children, ...context } = props\n const Context = scope?.[scopeName]?.[index] || BaseContext\n // Only re-memoize when prop values change\n\n const value = React.useMemo(\n () => context,\n Object.values(context)\n ) as ContextValueType\n return <Context.Provider value={value}>{children}</Context.Provider>\n }\n\n function useContext(\n consumerName: string,\n scope: Scope<ContextValueType | undefined>,\n options?: {\n warn?: boolean\n fallback?: Partial<ContextValueType>\n }\n ) {\n const Context = scope?.[scopeName]?.[index] || BaseContext\n const context = React.useContext(Context)\n if (context) return context\n // if a defaultContext wasn't specified, it's a required context.\n if (defaultContext !== undefined) return defaultContext\n const missingContextMessage = `\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``\n // fallback can be given per-hook as well\n if (options?.fallback) {\n if (options?.warn !== false) {\n console.warn(missingContextMessage)\n }\n return options.fallback as ContextValueType\n }\n throw new Error(missingContextMessage)\n }\n\n return [Provider, useContext] as const\n }\n\n /* -----------------------------------------------------------------------------------------------\n * createScope\n * ---------------------------------------------------------------------------------------------*/\n\n const createScope: CreateScope = () => {\n const scopeContexts = defaultContexts.map((defaultContext) => {\n return React.createContext(defaultContext)\n })\n return function useScope(scope: Scope) {\n const contexts = scope?.[scopeName] || scopeContexts\n return React.useMemo(\n () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),\n [scope, contexts]\n )\n }\n }\n\n createScope.scopeName = scopeName\n\n return [\n createContext,\n composeContextScopes(createScope, ...createContextScopeDeps),\n ] as const\n}\n\n/* -------------------------------------------------------------------------------------------------\n * composeContextScopes\n * -----------------------------------------------------------------------------------------------*/\n\nfunction composeContextScopes(...scopes: CreateScope[]) {\n const baseScope = scopes[0]\n if (scopes.length === 1) return baseScope\n\n const createScope: CreateScope = () => {\n const scopeHooks = scopes.map((createScope) => ({\n useScope: createScope(),\n scopeName: createScope.scopeName,\n }))\n\n return function useComposedScopes(overrideScopes) {\n const nextScopes = scopeHooks.reduce((nextScopes, { useScope, scopeName }) => {\n // We are calling a hook inside a callback which React warns against to avoid inconsistent\n // renders, however, scoping doesn't have render side effects so we ignore the rule.\n\n const scopeProps = useScope(overrideScopes)\n const currentScope = scopeProps[`__scope${scopeName}`]\n return { ...nextScopes, ...currentScope }\n }, {})\n\n return React.useMemo(\n () => ({ [`__scope${baseScope.scopeName}`]: nextScopes }),\n [nextScopes]\n )\n }\n }\n\n createScope.scopeName = baseScope.scopeName\n return createScope\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n"
9
- ],
10
- "version": 3
10
+ ]
11
11
  }
@@ -4,8 +4,8 @@
4
4
  "sources": [
5
5
  "src/index.ts"
6
6
  ],
7
+ "version": 3,
7
8
  "sourcesContent": [
8
9
  "export * from './create-context'\n"
9
- ],
10
- "version": 3
10
+ ]
11
11
  }
@@ -1,103 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var create_context_exports = {};
24
- __export(create_context_exports, {
25
- createContext: () => createContext,
26
- createContextScope: () => createContextScope
27
- });
28
- module.exports = __toCommonJS(create_context_exports);
29
- var React = __toESM(require("react"), 1), import_jsx_runtime = require("react/jsx-runtime");
30
- function createContext(rootComponentName, defaultContext) {
31
- const Context = React.createContext(defaultContext);
32
- function Provider(props) {
33
- const { children, ...context } = props, value = React.useMemo(() => context, Object.values(context));
34
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, { value, children });
35
- }
36
- function useContext(consumerName) {
37
- const context = React.useContext(Context);
38
- if (context) return context;
39
- if (defaultContext !== void 0) return defaultContext;
40
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
41
- }
42
- return [Provider, useContext];
43
- }
44
- function createContextScope(scopeName, createContextScopeDeps = []) {
45
- let defaultContexts = [];
46
- function createContext2(rootComponentName, defaultContext) {
47
- const BaseContext = React.createContext(defaultContext), index = defaultContexts.length;
48
- defaultContexts = [...defaultContexts, defaultContext];
49
- function Provider(props) {
50
- const { scope, children, ...context } = props, Context = scope?.[scopeName]?.[index] || BaseContext, value = React.useMemo(
51
- () => context,
52
- Object.values(context)
53
- );
54
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, { value, children });
55
- }
56
- function useContext(consumerName, scope, options) {
57
- const Context = scope?.[scopeName]?.[index] || BaseContext, context = React.useContext(Context);
58
- if (context) return context;
59
- if (defaultContext !== void 0) return defaultContext;
60
- const missingContextMessage = `\`${consumerName}\` must be used within \`${rootComponentName}\``;
61
- if (options?.fallback)
62
- return options?.warn !== !1 && console.warn(missingContextMessage), options.fallback;
63
- throw new Error(missingContextMessage);
64
- }
65
- return [Provider, useContext];
66
- }
67
- const createScope = () => {
68
- const scopeContexts = defaultContexts.map((defaultContext) => React.createContext(defaultContext));
69
- return function(scope) {
70
- const contexts = scope?.[scopeName] || scopeContexts;
71
- return React.useMemo(
72
- () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
73
- [scope, contexts]
74
- );
75
- };
76
- };
77
- return createScope.scopeName = scopeName, [
78
- createContext2,
79
- composeContextScopes(createScope, ...createContextScopeDeps)
80
- ];
81
- }
82
- function composeContextScopes(...scopes) {
83
- const baseScope = scopes[0];
84
- if (scopes.length === 1) return baseScope;
85
- const createScope = () => {
86
- const scopeHooks = scopes.map((createScope2) => ({
87
- useScope: createScope2(),
88
- scopeName: createScope2.scopeName
89
- }));
90
- return function(overrideScopes) {
91
- const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
92
- const currentScope = useScope(overrideScopes)[`__scope${scopeName}`];
93
- return { ...nextScopes2, ...currentScope };
94
- }, {});
95
- return React.useMemo(
96
- () => ({ [`__scope${baseScope.scopeName}`]: nextScopes }),
97
- [nextScopes]
98
- );
99
- };
100
- };
101
- return createScope.scopeName = baseScope.scopeName, createScope;
102
- }
103
- //# sourceMappingURL=create-context.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/create-context.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,YAAuB,8BAkBZ;AAdJ,SAAS,cACd,mBACA,gBAIA;AACA,QAAM,UAAU,MAAM,cAA4C,cAAc;AAEhF,WAAS,SAAS,OAAyD;AACzE,UAAM,EAAE,UAAU,GAAG,QAAQ,IAAI,OAG3B,QAAQ,MAAM,QAAQ,MAAM,SAAS,OAAO,OAAO,OAAO,CAAC;AACjE,WAAO,4CAAC,QAAQ,UAAR,EAAiB,OAAe,UAAS;AAAA,EACnD;AAEA,WAAS,WAAW,cAA0D;AAC5E,UAAM,UAAU,MAAM,WAAW,OAAO;AACxC,QAAI,QAAS,QAAO;AACpB,QAAI,mBAAmB,OAAW,QAAO;AAEzC,UAAM,IAAI,MAAM,KAAK,YAAY,4BAA4B,iBAAiB,IAAI;AAAA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,EACF;AAEA,qBAAY,YAAY,WAEjB;AAAA,IACLA;AAAA,IACA,qBAAqB,aAAa,GAAG,sBAAsB;AAAA,EAC7D;AACF;AAMA,SAAS,wBAAwB,QAAuB;AACtD,QAAM,YAAY,OAAO,CAAC;AAC1B,MAAI,OAAO,WAAW,EAAG,QAAO;AAEhC,QAAM,cAA2B,MAAM;AACrC,UAAM,aAAa,OAAO,IAAI,CAACC,kBAAiB;AAAA,MAC9C,UAAUA,aAAY;AAAA,MACtB,WAAWA,aAAY;AAAA,IACzB,EAAE;AAEF,WAAO,SAA2B,gBAAgB;AAChD,YAAM,aAAa,WAAW,OAAO,CAACC,aAAY,EAAE,UAAU,UAAU,MAAM;AAK5E,cAAM,eADa,SAAS,cAAc,EACV,UAAU,SAAS,EAAE;AACrD,eAAO,EAAE,GAAGA,aAAY,GAAG,aAAa;AAAA,MAC1C,GAAG,CAAC,CAAC;AAEL,aAAO,MAAM;AAAA,QACX,OAAO,EAAE,CAAC,UAAU,UAAU,SAAS,EAAE,GAAG,WAAW;AAAA,QACvD,CAAC,UAAU;AAAA,MACb;AAAA,IACF;AAAA,EACF;AAEA,qBAAY,YAAY,UAAU,WAC3B;AACT;",
5
- "names": ["createContext", "createScope", "nextScopes"]
6
- }
package/dist/cjs/index.js DELETED
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var index_exports = {};
13
- module.exports = __toCommonJS(index_exports);
14
- __reExport(index_exports, require("./create-context"), module.exports);
15
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,6BAAd;",
5
- "names": []
6
- }
@@ -1,80 +0,0 @@
1
- import * as React from "react";
2
- import { jsx } from "react/jsx-runtime";
3
- function createContext(rootComponentName, defaultContext) {
4
- const Context = React.createContext(defaultContext);
5
- function Provider(props) {
6
- const { children, ...context } = props, value = React.useMemo(() => context, Object.values(context));
7
- return /* @__PURE__ */ jsx(Context.Provider, { value, children });
8
- }
9
- function useContext(consumerName) {
10
- const context = React.useContext(Context);
11
- if (context) return context;
12
- if (defaultContext !== void 0) return defaultContext;
13
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
14
- }
15
- return [Provider, useContext];
16
- }
17
- function createContextScope(scopeName, createContextScopeDeps = []) {
18
- let defaultContexts = [];
19
- function createContext2(rootComponentName, defaultContext) {
20
- const BaseContext = React.createContext(defaultContext), index = defaultContexts.length;
21
- defaultContexts = [...defaultContexts, defaultContext];
22
- function Provider(props) {
23
- const { scope, children, ...context } = props, Context = scope?.[scopeName]?.[index] || BaseContext, value = React.useMemo(
24
- () => context,
25
- Object.values(context)
26
- );
27
- return /* @__PURE__ */ jsx(Context.Provider, { value, children });
28
- }
29
- function useContext(consumerName, scope, options) {
30
- const Context = scope?.[scopeName]?.[index] || BaseContext, context = React.useContext(Context);
31
- if (context) return context;
32
- if (defaultContext !== void 0) return defaultContext;
33
- const missingContextMessage = `\`${consumerName}\` must be used within \`${rootComponentName}\``;
34
- if (options?.fallback)
35
- return options?.warn !== !1 && console.warn(missingContextMessage), options.fallback;
36
- throw new Error(missingContextMessage);
37
- }
38
- return [Provider, useContext];
39
- }
40
- const createScope = () => {
41
- const scopeContexts = defaultContexts.map((defaultContext) => React.createContext(defaultContext));
42
- return function(scope) {
43
- const contexts = scope?.[scopeName] || scopeContexts;
44
- return React.useMemo(
45
- () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
46
- [scope, contexts]
47
- );
48
- };
49
- };
50
- return createScope.scopeName = scopeName, [
51
- createContext2,
52
- composeContextScopes(createScope, ...createContextScopeDeps)
53
- ];
54
- }
55
- function composeContextScopes(...scopes) {
56
- const baseScope = scopes[0];
57
- if (scopes.length === 1) return baseScope;
58
- const createScope = () => {
59
- const scopeHooks = scopes.map((createScope2) => ({
60
- useScope: createScope2(),
61
- scopeName: createScope2.scopeName
62
- }));
63
- return function(overrideScopes) {
64
- const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
65
- const currentScope = useScope(overrideScopes)[`__scope${scopeName}`];
66
- return { ...nextScopes2, ...currentScope };
67
- }, {});
68
- return React.useMemo(
69
- () => ({ [`__scope${baseScope.scopeName}`]: nextScopes }),
70
- [nextScopes]
71
- );
72
- };
73
- };
74
- return createScope.scopeName = baseScope.scopeName, createScope;
75
- }
76
- export {
77
- createContext,
78
- createContextScope
79
- };
80
- //# sourceMappingURL=create-context.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/create-context.tsx"],
4
- "mappings": "AAGA,YAAY,WAAW;AAkBZ;AAdJ,SAAS,cACd,mBACA,gBAIA;AACA,QAAM,UAAU,MAAM,cAA4C,cAAc;AAEhF,WAAS,SAAS,OAAyD;AACzE,UAAM,EAAE,UAAU,GAAG,QAAQ,IAAI,OAG3B,QAAQ,MAAM,QAAQ,MAAM,SAAS,OAAO,OAAO,OAAO,CAAC;AACjE,WAAO,oBAAC,QAAQ,UAAR,EAAiB,OAAe,UAAS;AAAA,EACnD;AAEA,WAAS,WAAW,cAA0D;AAC5E,UAAM,UAAU,MAAM,WAAW,OAAO;AACxC,QAAI,QAAS,QAAO;AACpB,QAAI,mB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