@tamagui/create-context 3.0.7 → 3.0.8
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.
|
@@ -90,7 +90,7 @@ function createContextScope(scopeName) {
|
|
|
90
90
|
}
|
|
91
91
|
return [Provider, useContext];
|
|
92
92
|
}
|
|
93
|
-
var createScope = function() {
|
|
93
|
+
var createScope = function createScope2() {
|
|
94
94
|
var scopeContexts = defaultContexts.map(function(defaultContext) {
|
|
95
95
|
return /* @__PURE__ */ React.createContext(defaultContext);
|
|
96
96
|
});
|
|
@@ -113,11 +113,11 @@ function composeContextScopes() {
|
|
|
113
113
|
}
|
|
114
114
|
var baseScope = scopes[0];
|
|
115
115
|
if (scopes.length === 1) return baseScope;
|
|
116
|
-
var createScope = function() {
|
|
117
|
-
var scopeHooks = scopes.map(function(
|
|
116
|
+
var createScope = function createScope2() {
|
|
117
|
+
var scopeHooks = scopes.map(function(createScope3) {
|
|
118
118
|
return {
|
|
119
|
-
useScope:
|
|
120
|
-
scopeName:
|
|
119
|
+
useScope: createScope3(),
|
|
120
|
+
scopeName: createScope3.scopeName
|
|
121
121
|
};
|
|
122
122
|
});
|
|
123
123
|
return function useComposedScopes(overrideScopes) {
|
|
@@ -90,7 +90,7 @@ function createContextScope(scopeName) {
|
|
|
90
90
|
}
|
|
91
91
|
return [Provider, useContext];
|
|
92
92
|
}
|
|
93
|
-
var createScope = function() {
|
|
93
|
+
var createScope = function createScope2() {
|
|
94
94
|
var scopeContexts = defaultContexts.map(function(defaultContext) {
|
|
95
95
|
return /* @__PURE__ */ React.createContext(defaultContext);
|
|
96
96
|
});
|
|
@@ -113,11 +113,11 @@ function composeContextScopes() {
|
|
|
113
113
|
}
|
|
114
114
|
var baseScope = scopes[0];
|
|
115
115
|
if (scopes.length === 1) return baseScope;
|
|
116
|
-
var createScope = function() {
|
|
117
|
-
var scopeHooks = scopes.map(function(
|
|
116
|
+
var createScope = function createScope2() {
|
|
117
|
+
var scopeHooks = scopes.map(function(createScope3) {
|
|
118
118
|
return {
|
|
119
|
-
useScope:
|
|
120
|
-
scopeName:
|
|
119
|
+
useScope: createScope3(),
|
|
120
|
+
scopeName: createScope3.scopeName
|
|
121
121
|
};
|
|
122
122
|
});
|
|
123
123
|
return function useComposedScopes(overrideScopes) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-context.native.js","names":[],"sources":["cjs/create-context.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar create_context_exports = {};\n__export(create_context_exports, {\n createContext: () => createContext,\n createContextScope: () => createContextScope\n});\nmodule.exports = __toCommonJS(create_context_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar React = __toESM(require(\"react\"), 1);\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__ */ (0, import_jsx_runtime.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__ */ (0, import_jsx_runtime.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(
|
|
1
|
+
{"version":3,"file":"create-context.native.js","names":[],"sources":["cjs/create-context.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar create_context_exports = {};\n__export(create_context_exports, {\n createContext: () => createContext,\n createContextScope: () => createContextScope\n});\nmodule.exports = __toCommonJS(create_context_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar React = __toESM(require(\"react\"), 1);\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__ */ (0, import_jsx_runtime.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__ */ (0, import_jsx_runtime.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 createScope2() {\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 createScope2() {\n var scopeHooks = scopes.map(function(createScope3) {\n return {\n useScope: createScope3(),\n scopeName: createScope3.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}\n//# sourceMappingURL=create-context.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QA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;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"}
|
|
@@ -57,7 +57,7 @@ function createContextScope(scopeName) {
|
|
|
57
57
|
}
|
|
58
58
|
return [Provider, useContext];
|
|
59
59
|
}
|
|
60
|
-
var createScope = function() {
|
|
60
|
+
var createScope = function createScope2() {
|
|
61
61
|
var scopeContexts = defaultContexts.map(function(defaultContext) {
|
|
62
62
|
return /* @__PURE__ */ React.createContext(defaultContext);
|
|
63
63
|
});
|
|
@@ -80,11 +80,11 @@ function composeContextScopes() {
|
|
|
80
80
|
}
|
|
81
81
|
var baseScope = scopes[0];
|
|
82
82
|
if (scopes.length === 1) return baseScope;
|
|
83
|
-
var createScope = function() {
|
|
84
|
-
var scopeHooks = scopes.map(function(
|
|
83
|
+
var createScope = function createScope2() {
|
|
84
|
+
var scopeHooks = scopes.map(function(createScope3) {
|
|
85
85
|
return {
|
|
86
|
-
useScope:
|
|
87
|
-
scopeName:
|
|
86
|
+
useScope: createScope3(),
|
|
87
|
+
scopeName: createScope3.scopeName
|
|
88
88
|
};
|
|
89
89
|
});
|
|
90
90
|
return function useComposedScopes(overrideScopes) {
|
|
@@ -1 +1 @@
|
|
|
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(
|
|
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 createScope2() {\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 createScope2() {\n var scopeHooks = scopes.map(function(createScope3) {\n return {\n useScope: createScope3(),\n scopeName: createScope3.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,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;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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/create-context",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"clean:build": "tamagui-build clean:build"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@tamagui/build": "3.0.
|
|
39
|
+
"@tamagui/build": "3.0.8",
|
|
40
40
|
"react": "19.2.3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"url": "git+https://github.com/tamagui/tamagui.git",
|
|
48
48
|
"directory": "code/core/create-context"
|
|
49
49
|
},
|
|
50
|
-
"releaseSourceCommit": "
|
|
50
|
+
"releaseSourceCommit": "b723356193510591d9ad15877b8937e8e6a31910"
|
|
51
51
|
}
|