@tamagui/create-context 2.0.0-rc.26 → 2.0.0-rc.26-1773452370596

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/create-context",
3
- "version": "2.0.0-rc.26",
3
+ "version": "2.0.0-rc.26-1773452370596",
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.0.0-rc.26",
38
+ "@tamagui/build": "2.0.0-rc.26-1773452370596",
39
39
  "react": ">=19"
40
40
  },
41
41
  "peerDependencies": {
@@ -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,KAA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,QAAQ;AAAA,MAClB;AAAA,IACF;AAAA,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
- }
@@ -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,mBAAmB,OAAW,QAAO;AAEzC,UAAM,IAAI,MAAM,KAAK,YAAY,4BAA4B,iBAAiB,IAAI;AAAA,EACpF;AAEA,SAAO,CAAC,UAAU,UAAU;AAC9B;AAeO,SAAS,mBACd,WACA,yBAAwC,CAAC,GAsBzC;AACA,MAAI,kBAAyB,CAAC;AAM9B,WAASA,eACP,mBACA,gBACA;AACA,UAAM,cAAc,MAAM,cAA4C,cAAc,GAC9E,QAAQ,gBAAgB;AAC9B,sBAAkB,CAAC,GAAG,iBAAiB,cAAc;AAErD,aAAS,SACP,OAIA;AACA,YAAM,EAAE,OAAO,UAAU,GAAG,QAAQ,IAAI,OAClC,UAAU,QAAQ,SAAS,IAAI,KAAK,KAAK,aAGzC,QAAQ,MAAM;AAAA,QAClB,MAAM;AAAA,QACN,OAAO,OAAO,OAAO;AAAA,MACvB;AACA,aAAO,oBAAC,QAAQ,UAAR,EAAiB,OAAe,UAAS;AAAA,IACnD;AAEA,aAAS,WACP,cACA,OACA,SAIA;AACA,YAAM,UAAU,QAAQ,SAAS,IAAI,KAAK,KAAK,aACzC,UAAU,MAAM,WAAW,OA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