@tamagui/create-context 2.7.7 → 3.0.0-beta.643.1

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 +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","BaseContext","index","length","scope","options","missingContextMessage","fallback","warn","console","createScope","scopeContexts","map","useScope","contexts","composeContextScopes","scopes","baseScope","scopeHooks","useComposedScopes","overrideScopes","nextScopes","reduce","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,MAAMN,OAAA,GAAUT,KAAA,CAAMc,UAAA,CAAWT,OAAO;IACxC,IAAII,OAAA,EAAS,OAAOA,OAAA;IACpB,IAAIL,cAAA,KAAmB,QAAW,OAAOA,cAAA;IAEzC,MAAM,IAAIY,KAAA,CAAM,KAAKD,YAAY,4BAA4BZ,iBAAiB,IAAI;EACpF;EAEA,OAAO,CAACG,QAAA,EAAUQ,UAAU;AAC9B;AAeO,SAASG,mBACdC,SAAA,EACAC,sBAAA,GAAwC,EA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AG,CAAC,CAAC;MAEL,OAAO5C,KAAA,CAAMW,OAAA,CACX,OAAO;QAAE,CAAC,UAAU0B,SAAA,CAAUnB,SAAS,EAAE,GAAGuB;MAAW,IACvD,CAACA,UAAU,CACb;IACF;EACF;EAEAX,WAAA,CAAYZ,SAAA,GAAYmB,SAAA,CAAUnB,SAAA;EAClC,OAAOY,WAAA;AACT","ignoreList":[]}
1
+ {"version":3,"file":"create-context.js","names":[],"sources":["esm/create-context.js"],"sourcesContent":["import * as React from \"react\";\nimport { jsx } from \"react/jsx-runtime\";\nfunction createContext(rootComponentName, defaultContext) {\n const Context = React.createContext(defaultContext);\n function Provider(props) {\n const { children, ...context } = props;\n const value = React.useMemo(() => context, Object.values(context));\n return /* @__PURE__ */ jsx(Context.Provider, { value, children });\n }\n function useContext(consumerName) {\n const context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== void 0) return defaultContext;\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n return [Provider, useContext];\n}\nfunction createContextScope(scopeName, createContextScopeDeps = []) {\n let defaultContexts = [];\n function createContext2(rootComponentName, defaultContext) {\n const BaseContext = React.createContext(defaultContext);\n const index = defaultContexts.length;\n defaultContexts = [...defaultContexts, defaultContext];\n function Provider(props) {\n const { scope, children, ...context } = props;\n const Context = scope?.[scopeName]?.[index] || BaseContext;\n const value = React.useMemo(\n () => context,\n Object.values(context)\n );\n return /* @__PURE__ */ jsx(Context.Provider, { value, children });\n }\n function useContext(consumerName, scope, options) {\n const Context = scope?.[scopeName]?.[index] || BaseContext;\n const context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== void 0) return defaultContext;\n const missingContextMessage = `\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``;\n if (options?.fallback) {\n if (options?.warn !== false) {\n console.warn(missingContextMessage);\n }\n return options.fallback;\n }\n throw new Error(missingContextMessage);\n }\n return [Provider, useContext];\n }\n const createScope = () => {\n const scopeContexts = defaultContexts.map((defaultContext) => {\n return React.createContext(defaultContext);\n });\n return function useScope(scope) {\n const contexts = scope?.[scopeName] || scopeContexts;\n return React.useMemo(\n () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),\n [scope, contexts]\n );\n };\n };\n createScope.scopeName = scopeName;\n return [\n createContext2,\n composeContextScopes(createScope, ...createContextScopeDeps)\n ];\n}\nfunction composeContextScopes(...scopes) {\n const baseScope = scopes[0];\n if (scopes.length === 1) return baseScope;\n const createScope = () => {\n const scopeHooks = scopes.map((createScope2) => ({\n useScope: createScope2(),\n scopeName: createScope2.scopeName\n }));\n return function useComposedScopes(overrideScopes) {\n const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {\n const scopeProps = useScope(overrideScopes);\n const currentScope = scopeProps[`__scope${scopeName}`];\n return { ...nextScopes2, ...currentScope };\n }, {});\n return React.useMemo(\n () => ({ [`__scope${baseScope.scopeName}`]: nextScopes }),\n [nextScopes]\n );\n };\n };\n createScope.scopeName = baseScope.scopeName;\n return createScope;\n}\nexport {\n createContext,\n createContextScope\n};\n//# sourceMappingURL=create-context.js.map\n"],"mappings":";;;;AAEA,SAAS,cAAc,mBAAmB,gBAAgB;CACxD,MAAM,UAAU,MAAM,cAAc,cAAc;CAClD,SAAS,SAAS,OAAO;EACvB,MAAM,EAAE,UAAU,GAAG,YAAY;EACjC,MAAM,QAAQ,MAAM,cAAc,SAAS,OAAO,OAAO,OAAO,CAAC;EACjE,OAAuB,oBAAI,QAAQ,UAAU;GAAE;GAAO;EAAS,CAAC;CAClE;CACA,SAAS,WAAW,cAAc;EAChC,MAAM,UAAU,MAAM,WAAW,OAAO;EACxC,IAAI,SAAS,OAAO;EACpB,IAAI,mBAAmB,KAAK,GAAG,OAAO;EACtC,MAAM,IAAI,MAAM,KAAK,aAAa,2BAA2B,kBAAkB,GAAG;CACpF;CACA,OAAO,CAAC,UAAU,UAAU;AAC9B;AACA,SAAS,mBAAmB,WAAW,yBAAyB,CAAC,GAAG;CAClE,IAAI,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AO,WAAW,GAAG,OAAO;CAChC,MAAM,oBAAoB;EACxB,MAAM,aAAa,OAAO,KAAK,kBAAkB;GAC/C,UAAU,aAAa;GACvB,WAAW,aAAa;EAC1B,EAAE;EACF,OAAO,SAAS,kBAAkB,gBAAgB;GAChD,MAAM,aAAa,WAAW,QAAQ,aAAa,EAAE,UAAU,gBAAgB;IAC7E,MAAM,aAAa,SAAS,cAAc;IAC1C,MAAM,eAAe,WAAW,UAAU;IAC1C,OAAO;KAAE,GAAG;KAAa,GAAG;IAAa;GAC3C,GAAG,CAAC,CAAC;GACL,OAAO,MAAM,eACJ,GAAG,UAAU,UAAU,cAAc,WAAW,IACvD,CAAC,UAAU,CACb;EACF;CACF;CACA,YAAY,YAAY,UAAU;CAClC,OAAO;AACT"}
@@ -1,122 +1,110 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
+
3
4
  function createContext(rootComponentName, defaultContext) {
4
- var Context = /* @__PURE__ */React.createContext(defaultContext);
5
- function Provider(props) {
6
- var {
7
- children,
8
- ...context
9
- } = props;
10
- var value = React.useMemo(function () {
11
- return context;
12
- }, Object.values(context));
13
- return /* @__PURE__ */_jsx(Context.Provider, {
14
- value,
15
- children
16
- });
17
- }
18
- function useContext(consumerName) {
19
- var context = React.useContext(Context);
20
- if (context) return context;
21
- if (defaultContext !== void 0) return defaultContext;
22
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
23
- }
24
- return [Provider, useContext];
5
+ var Context = /* @__PURE__ */ React.createContext(defaultContext);
6
+ function Provider(props) {
7
+ var { children, ...context } = props;
8
+ var value = React.useMemo(function() {
9
+ return context;
10
+ }, Object.values(context));
11
+ return /* @__PURE__ */ jsx(Context.Provider, {
12
+ value,
13
+ children
14
+ });
15
+ }
16
+ function useContext(consumerName) {
17
+ var context = React.useContext(Context);
18
+ if (context) return context;
19
+ if (defaultContext !== void 0) return defaultContext;
20
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
21
+ }
22
+ return [Provider, useContext];
25
23
  }
26
24
  function createContextScope(scopeName) {
27
- var createContextScopeDeps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
28
- var defaultContexts = [];
29
- function createContext2(rootComponentName, defaultContext) {
30
- var BaseContext = /* @__PURE__ */React.createContext(defaultContext);
31
- var index = defaultContexts.length;
32
- defaultContexts = [...defaultContexts, defaultContext];
33
- function Provider(props) {
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
- return /* @__PURE__ */_jsx(Context.Provider, {
45
- value,
46
- children
47
- });
48
- }
49
- function useContext(consumerName, scope, options) {
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
- if (context) return context;
54
- if (defaultContext !== void 0) return defaultContext;
55
- var missingContextMessage = `\`${consumerName}\` must be used within \`${rootComponentName}\``;
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
- }
62
- throw new Error(missingContextMessage);
63
- }
64
- return [Provider, useContext];
65
- }
66
- var createScope = function () {
67
- var scopeContexts = defaultContexts.map(function (defaultContext) {
68
- return /* @__PURE__ */React.createContext(defaultContext);
69
- });
70
- return function useScope(scope) {
71
- var contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
72
- return React.useMemo(function () {
73
- return {
74
- [`__scope${scopeName}`]: {
75
- ...scope,
76
- [scopeName]: contexts
77
- }
78
- };
79
- }, [scope, contexts]);
80
- };
81
- };
82
- createScope.scopeName = scopeName;
83
- return [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
25
+ var createContextScopeDeps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
26
+ var defaultContexts = [];
27
+ function createContext2(rootComponentName, defaultContext) {
28
+ var BaseContext = /* @__PURE__ */ React.createContext(defaultContext);
29
+ var index = defaultContexts.length;
30
+ defaultContexts = [...defaultContexts, defaultContext];
31
+ function Provider(props) {
32
+ var _scope_scopeName;
33
+ var { scope, children, ...context } = props;
34
+ var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;
35
+ var value = React.useMemo(function() {
36
+ return context;
37
+ }, Object.values(context));
38
+ return /* @__PURE__ */ jsx(Context.Provider, {
39
+ value,
40
+ children
41
+ });
42
+ }
43
+ function useContext(consumerName, scope, options) {
44
+ var _scope_scopeName;
45
+ var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;
46
+ var context = React.useContext(Context);
47
+ if (context) return context;
48
+ if (defaultContext !== void 0) return defaultContext;
49
+ var missingContextMessage = `\`${consumerName}\` must be used within \`${rootComponentName}\``;
50
+ if (options === null || options === void 0 ? void 0 : options.fallback) {
51
+ if ((options === null || options === void 0 ? void 0 : options.warn) !== false) {
52
+ console.warn(missingContextMessage);
53
+ }
54
+ return options.fallback;
55
+ }
56
+ throw new Error(missingContextMessage);
57
+ }
58
+ return [Provider, useContext];
59
+ }
60
+ var createScope = function() {
61
+ var scopeContexts = defaultContexts.map(function(defaultContext) {
62
+ return /* @__PURE__ */ React.createContext(defaultContext);
63
+ });
64
+ return function useScope(scope) {
65
+ var contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;
66
+ return React.useMemo(function() {
67
+ return { [`__scope${scopeName}`]: {
68
+ ...scope,
69
+ [scopeName]: contexts
70
+ } };
71
+ }, [scope, contexts]);
72
+ };
73
+ };
74
+ createScope.scopeName = scopeName;
75
+ return [createContext2, composeContextScopes(createScope, ...createContextScopeDeps)];
84
76
  }
85
77
  function composeContextScopes() {
86
- for (var _len = arguments.length, scopes = new Array(_len), _key = 0; _key < _len; _key++) {
87
- scopes[_key] = arguments[_key];
88
- }
89
- var baseScope = scopes[0];
90
- if (scopes.length === 1) return baseScope;
91
- var createScope = function () {
92
- var scopeHooks = scopes.map(function (createScope2) {
93
- return {
94
- useScope: createScope2(),
95
- scopeName: createScope2.scopeName
96
- };
97
- });
98
- return function useComposedScopes(overrideScopes) {
99
- var nextScopes = scopeHooks.reduce(function (nextScopes2, param) {
100
- var {
101
- useScope,
102
- scopeName
103
- } = param;
104
- var scopeProps = useScope(overrideScopes);
105
- var currentScope = scopeProps[`__scope${scopeName}`];
106
- return {
107
- ...nextScopes2,
108
- ...currentScope
109
- };
110
- }, {});
111
- return React.useMemo(function () {
112
- return {
113
- [`__scope${baseScope.scopeName}`]: nextScopes
114
- };
115
- }, [nextScopes]);
116
- };
117
- };
118
- createScope.scopeName = baseScope.scopeName;
119
- return createScope;
78
+ for (var _len = arguments.length, scopes = new Array(_len), _key = 0; _key < _len; _key++) {
79
+ scopes[_key] = arguments[_key];
80
+ }
81
+ var baseScope = scopes[0];
82
+ if (scopes.length === 1) return baseScope;
83
+ var createScope = function() {
84
+ var scopeHooks = scopes.map(function(createScope2) {
85
+ return {
86
+ useScope: createScope2(),
87
+ scopeName: createScope2.scopeName
88
+ };
89
+ });
90
+ return function useComposedScopes(overrideScopes) {
91
+ var nextScopes = scopeHooks.reduce(function(nextScopes2, param) {
92
+ var { useScope, scopeName } = param;
93
+ var scopeProps = useScope(overrideScopes);
94
+ var currentScope = scopeProps[`__scope${scopeName}`];
95
+ return {
96
+ ...nextScopes2,
97
+ ...currentScope
98
+ };
99
+ }, {});
100
+ return React.useMemo(function() {
101
+ return { [`__scope${baseScope.scopeName}`]: nextScopes };
102
+ }, [nextScopes]);
103
+ };
104
+ };
105
+ createScope.scopeName = baseScope.scopeName;
106
+ return createScope;
120
107
  }
108
+
121
109
  export { createContext, createContextScope };
122
110
  //# 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","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,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,QACAG,QAAM,EACNQ,UAAA,CAEA;AAME;AACA,SAAAG,kBAAgBA,CAAAC,SAAQ,EAAS;EAGjC,IAAA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AA,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,QAAAH,CAAYN,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":[]}
1
+ {"version":3,"file":"create-context.native.js","names":[],"sources":["esm/create-context.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport * as React from \"react\";\nfunction createContext(rootComponentName, defaultContext) {\n var Context = /* @__PURE__ */ React.createContext(defaultContext);\n function Provider(props) {\n var { children, ...context } = props;\n var value = React.useMemo(function() {\n return context;\n }, Object.values(context));\n return /* @__PURE__ */ _jsx(Context.Provider, {\n value,\n children\n });\n }\n function useContext(consumerName) {\n var context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== void 0) return defaultContext;\n throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n }\n return [\n Provider,\n useContext\n ];\n}\nfunction createContextScope(scopeName) {\n var createContextScopeDeps = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];\n var defaultContexts = [];\n function createContext2(rootComponentName, defaultContext) {\n var BaseContext = /* @__PURE__ */ React.createContext(defaultContext);\n var index = defaultContexts.length;\n defaultContexts = [\n ...defaultContexts,\n defaultContext\n ];\n function Provider(props) {\n var _scope_scopeName;\n var { scope, children, ...context } = props;\n var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;\n var value = React.useMemo(function() {\n return context;\n }, Object.values(context));\n return /* @__PURE__ */ _jsx(Context.Provider, {\n value,\n children\n });\n }\n function useContext(consumerName, scope, options) {\n var _scope_scopeName;\n var Context = (scope === null || scope === void 0 ? void 0 : (_scope_scopeName = scope[scopeName]) === null || _scope_scopeName === void 0 ? void 0 : _scope_scopeName[index]) || BaseContext;\n var context = React.useContext(Context);\n if (context) return context;\n if (defaultContext !== void 0) return defaultContext;\n var missingContextMessage = `\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``;\n if (options === null || options === void 0 ? void 0 : options.fallback) {\n if ((options === null || options === void 0 ? void 0 : options.warn) !== false) {\n console.warn(missingContextMessage);\n }\n return options.fallback;\n }\n throw new Error(missingContextMessage);\n }\n return [\n Provider,\n useContext\n ];\n }\n var createScope = function() {\n var scopeContexts = defaultContexts.map(function(defaultContext) {\n return /* @__PURE__ */ React.createContext(defaultContext);\n });\n return function useScope(scope) {\n var contexts = (scope === null || scope === void 0 ? void 0 : scope[scopeName]) || scopeContexts;\n return React.useMemo(function() {\n return {\n [`__scope${scopeName}`]: {\n ...scope,\n [scopeName]: contexts\n }\n };\n }, [\n scope,\n contexts\n ]);\n };\n };\n createScope.scopeName = scopeName;\n return [\n createContext2,\n composeContextScopes(createScope, ...createContextScopeDeps)\n ];\n}\nfunction composeContextScopes() {\n for (var _len = arguments.length, scopes = new Array(_len), _key = 0; _key < _len; _key++) {\n scopes[_key] = arguments[_key];\n }\n var baseScope = scopes[0];\n if (scopes.length === 1) return baseScope;\n var createScope = function() {\n var scopeHooks = scopes.map(function(createScope2) {\n return {\n useScope: createScope2(),\n scopeName: createScope2.scopeName\n };\n });\n return function useComposedScopes(overrideScopes) {\n var nextScopes = scopeHooks.reduce(function(nextScopes2, param) {\n var { useScope, scopeName } = param;\n var scopeProps = useScope(overrideScopes);\n var currentScope = scopeProps[`__scope${scopeName}`];\n return {\n ...nextScopes2,\n ...currentScope\n };\n }, {});\n return React.useMemo(function() {\n return {\n [`__scope${baseScope.scopeName}`]: nextScopes\n };\n }, [\n nextScopes\n ]);\n };\n };\n createScope.scopeName = baseScope.scopeName;\n return createScope;\n}\nexport {\n createContext,\n createContextScope\n};\n//# sourceMappingURL=create-context.js.map\n"],"mappings":";;;;AAEA,SAAS,cAAc,mBAAmB,gBAAgB;CACxD,IAAI,UAA0B,sBAAM,cAAc,cAAc;CAChE,SAAS,SAAS,OAAO;EACvB,IAAI,EAAE,UAAU,GAAG,YAAY;EAC/B,IAAI,QAAQ,MAAM,QAAQ,WAAW;GACnC,OAAO;EACT,GAAG,OAAO,OAAO,OAAO,CAAC;EACzB,OAAuB,oBAAK,QAAQ,UAAU;GAC5C;GACA;EACF,CAAC;CACH;CACA,SAAS,WAAW,cAAc;EAChC,IAAI,UAAU,MAAM,WAAW,OAAO;EACtC,IAAI,SAAS,OAAO;EACpB,IAAI,mBAAmB,KAAK,GAAG,OAAO;EACtC,MAAM,IAAI,MAAM,KAAK,aAAa,2BAA2B,kBAAkB,GAAG;CACpF;CACA,OAAO,CACL,UACA,UACF;AACF;AACA,SAAS,mBAAmB,WAAW;CACrC,IAAI,yBAAyB,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK,CAAC;CAC/F,IAAI,kBAAkB,CAAC;CACvB,SAAS,eAAe,mBAAmB,g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B,IAAI,YAAY,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,eAAe;GACnF,OAAO,MAAM,QAAQ,WAAW;IAC9B,OAAO,GACJ,UAAU,cAAc;KACvB,GAAG;MACF,YAAY;IACf,EACF;GACF,GAAG,CACD,OACA,QACF,CAAC;EACH;CACF;CACA,YAAY,YAAY;CACxB,OAAO,CACL,gBACA,qBAAqB,aAAa,GAAG,sBAAsB,CAC7D;AACF;AACA,SAAS,uBAAuB;CAC9B,KAAK,IAAI,OAAO,UAAU,QAAQ,SAAS,IAAI,MAAM,IAAI,GAAG,OAAO,GAAG,OAAO,MAAM,QAAQ;EACzF,OAAO,QAAQ,UAAU;CAC3B;CACA,IAAI,YAAY,OAAO;CACvB,IAAI,OAAO,WAAW,GAAG,OAAO;CAChC,IAAI,cAAc,WAAW;EAC3B,IAAI,aAAa,OAAO,IAAI,SAAS,cAAc;GACjD,OAAO;IACL,UAAU,aAAa;IACvB,WAAW,aAAa;GAC1B;EACF,CAAC;EACD,OAAO,SAAS,kBAAkB,gBAAgB;GAChD,IAAI,aAAa,WAAW,OAAO,SAAS,aAAa,OAAO;IAC9D,IAAI,EAAE,UAAU,cAAc;IAC9B,IAAI,aAAa,SAAS,cAAc;IACxC,IAAI,eAAe,WAAW,UAAU;IACxC,OAAO;KACL,GAAG;KACH,GAAG;IACL;GACF,GAAG,CAAC,CAAC;GACL,OAAO,MAAM,QAAQ,WAAW;IAC9B,OAAO,GACJ,UAAU,UAAU,cAAc,WACrC;GACF,GAAG,CACD,UACF,CAAC;EACH;CACF;CACA,YAAY,YAAY,UAAU;CAClC,OAAO;AACT"}
package/dist/esm/index.js CHANGED
@@ -1,2 +1 @@
1
- export * from "./create-context.mjs";
2
- //# sourceMappingURL=index.js.map
1
+ export * from "./create-context.mjs"
@@ -1,2 +1 @@
1
- export * from "./create-context.mjs";
2
- //# sourceMappingURL=index.mjs.map
1
+ export * from "./create-context.mjs"
@@ -1,2 +1 @@
1
- export * from "./create-context.native.js";
2
- //# sourceMappingURL=index.native.js.map
1
+ export * from "./create-context.native.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/create-context",
3
- "version": "2.7.7",
3
+ "version": "3.0.0-beta.643.1",
4
4
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
5
5
  "source": "src/index.ts",
6
6
  "files": [
@@ -35,7 +35,7 @@
35
35
  "clean:build": "tamagui-build clean:build"
36
36
  },
37
37
  "devDependencies": {
38
- "@tamagui/build": "2.7.7",
38
+ "@tamagui/build": "3.0.0-beta.643.1",
39
39
  "react": ">=19"
40
40
  },
41
41
  "peerDependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc","ignoreList":[]}