@tamagui/web 2.4.1 → 2.4.2

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,2 +1,2 @@
1
1
  $ tamagui-build
2
- built @tamagui/web in 26283 ms
2
+ built @tamagui/web in 2178 ms
@@ -27,16 +27,40 @@ __export(wrapStyleTags_exports, {
27
27
  module.exports = __toCommonJS(wrapStyleTags_exports);
28
28
  var import_helpers = require("@tamagui/helpers");
29
29
  var import_jsx_runtime = require("react/jsx-runtime");
30
- function getStyleTags(styles) {
31
- if (styles.length) return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
32
- children: styles.map(styleObject => {
33
- const identifier = styleObject[import_helpers.StyleObjectIdentifier];
34
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)("style", {
35
- href: `t_${identifier}`,
36
- precedence: "default",
37
- suppressHydrationWarning: true,
38
- children: styleObject[import_helpers.StyleObjectRules].join("\n")
39
- }, identifier);
40
- })
30
+ const styleTagCache = /* @__PURE__ */new Map();
31
+ let clearStyleTagCacheQueued = false;
32
+ function queueStyleTagCacheClear() {
33
+ if (clearStyleTagCacheQueued) return;
34
+ clearStyleTagCacheQueued = true;
35
+ queueMicrotask(() => {
36
+ styleTagCache.clear();
37
+ clearStyleTagCacheQueued = false;
38
+ });
39
+ }
40
+ function getCachedStyleTag(styleObject) {
41
+ const identifier = styleObject[import_helpers.StyleObjectIdentifier];
42
+ const rules = styleObject[import_helpers.StyleObjectRules];
43
+ const cached = styleTagCache.get(identifier);
44
+ if (cached && cached.len === rules.length && cached.first === rules[0] && cached.last === rules[rules.length - 1]) return cached.element;
45
+ const element = /* @__PURE__ */(0, import_jsx_runtime.jsx)("style", {
46
+ href: `t_${identifier}`,
47
+ precedence: "default",
48
+ suppressHydrationWarning: true,
49
+ children: rules.join("\n")
50
+ }, identifier);
51
+ styleTagCache.set(identifier, {
52
+ element,
53
+ len: rules.length,
54
+ first: rules[0],
55
+ last: rules[rules.length - 1]
41
56
  });
57
+ return element;
58
+ }
59
+ function getStyleTags(styles) {
60
+ if (styles.length) {
61
+ queueStyleTagCacheClear();
62
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
63
+ children: styles.map(getCachedStyleTag)
64
+ });
65
+ }
42
66
  }
@@ -1 +1 @@
1
- {"version":3,"names":["to","__toCommonJS","mod","__copyProps","__defProp","value","wrapStyleTags_exports","__export","getStyleTags","module","exports","require","styles"],"sources":["../../../src/helpers/wrapStyleTags.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;EAAA;EAAA,OAAAA,EAAA;AAAA;AAAA,IAAAC,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AAAAC,QAAA,CAAAD,qBAAwD;EAAAE,YAAA,EAAAA,CAAA,KAAAA;AAAA;AAShDC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAAAK,qBAAA;AAJDK,OAAA,oBAAsB;AAC3BA,OAAI,mBAAY;AACd,SAAIH,YAAOA,CAAAI,MAAQ","ignoreList":[]}
1
+ {"version":3,"names":["to","__toCommonJS","mod","__copyProps","__defProp","value","wrapStyleTags_exports","__export","getStyleTags","module","exports","require","styles"],"sources":["../../../src/helpers/wrapStyleTags.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;EAAA;EAAA,OAAAA,EAAA;AAAA;AAAA,IAAAC,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AACAC,QAAA,CAAAD,qBAAwD;EAAAE,YAAA,EAAAA,CAAA,KAAAA;AAAA;AA0CpDC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAAAK,qBAAA;AArCJK,OAAM,oBAAgB;AAUtBA,OAAI;AAEJ,SAASH,aAAAI,MAAA","ignoreList":[]}
@@ -1,17 +1,41 @@
1
1
  import { StyleObjectIdentifier, StyleObjectRules } from "@tamagui/helpers";
2
2
  import { Fragment, jsx } from "react/jsx-runtime";
3
- function getStyleTags(styles) {
4
- if (styles.length) return /* @__PURE__ */jsx(Fragment, {
5
- children: styles.map(styleObject => {
6
- const identifier = styleObject[StyleObjectIdentifier];
7
- return /* @__PURE__ */jsx("style", {
8
- href: `t_${identifier}`,
9
- precedence: "default",
10
- suppressHydrationWarning: true,
11
- children: styleObject[StyleObjectRules].join("\n")
12
- }, identifier);
13
- })
3
+ const styleTagCache = /* @__PURE__ */new Map();
4
+ let clearStyleTagCacheQueued = false;
5
+ function queueStyleTagCacheClear() {
6
+ if (clearStyleTagCacheQueued) return;
7
+ clearStyleTagCacheQueued = true;
8
+ queueMicrotask(() => {
9
+ styleTagCache.clear();
10
+ clearStyleTagCacheQueued = false;
11
+ });
12
+ }
13
+ function getCachedStyleTag(styleObject) {
14
+ const identifier = styleObject[StyleObjectIdentifier];
15
+ const rules = styleObject[StyleObjectRules];
16
+ const cached = styleTagCache.get(identifier);
17
+ if (cached && cached.len === rules.length && cached.first === rules[0] && cached.last === rules[rules.length - 1]) return cached.element;
18
+ const element = /* @__PURE__ */jsx("style", {
19
+ href: `t_${identifier}`,
20
+ precedence: "default",
21
+ suppressHydrationWarning: true,
22
+ children: rules.join("\n")
23
+ }, identifier);
24
+ styleTagCache.set(identifier, {
25
+ element,
26
+ len: rules.length,
27
+ first: rules[0],
28
+ last: rules[rules.length - 1]
14
29
  });
30
+ return element;
31
+ }
32
+ function getStyleTags(styles) {
33
+ if (styles.length) {
34
+ queueStyleTagCacheClear();
35
+ return /* @__PURE__ */jsx(Fragment, {
36
+ children: styles.map(getCachedStyleTag)
37
+ });
38
+ }
15
39
  }
16
40
  export { getStyleTags };
17
41
  //# sourceMappingURL=wrapStyleTags.mjs.map
@@ -1 +1 @@
1
- {"version":3,"names":["StyleObjectIdentifier","StyleObjectRules","Fragment","jsx","getStyleTags","styles","length","children","map","styleObject","identifier","href","precedence","suppressHydrationWarning","join"],"sources":["wrapStyleTags.mjs"],"sourcesContent":["import { StyleObjectIdentifier, StyleObjectRules } from \"@tamagui/helpers\";\nimport { Fragment, jsx } from \"react/jsx-runtime\";\n\nfunction getStyleTags(styles) {\n\tif (styles.length) return /* @__PURE__ */ jsx(Fragment, { children: styles.map((styleObject) => {\n\t\tconst identifier = styleObject[StyleObjectIdentifier];\n\t\treturn /* @__PURE__ */ jsx(\"style\", {\n\t\t\thref: `t_${identifier}`,\n\t\t\tprecedence: \"default\",\n\t\t\tsuppressHydrationWarning: true,\n\t\t\tchildren: styleObject[StyleObjectRules].join(\"\\n\")\n\t\t}, identifier);\n\t}) });\n}\n\nexport { getStyleTags };"],"mappings":"AAAA,SAASA,qBAAqB,EAAEC,gBAAgB,QAAQ,kBAAkB;AAC1E,SAASC,QAAQ,EAAEC,GAAG,QAAQ,mBAAmB;AAEjD,SAASC,YAAYA,CAACC,MAAM,EAAE;EAC7B,IAAIA,MAAM,CAACC,MAAM,EAAE,OAAO,eAAgBH,GAAG,CAACD,QAAQ,EAAE;IAAEK,QAAQ,EAAEF,MAAM,CAACG,GAAG,CAAEC,WAAW,IAAK;MAC/F,MAAMC,UAAU,GAAGD,WAAW,CAACT,qBAAqB,CAAC;MACrD,OAAO,eAAgBG,GAAG,CAAC,OAAO,EAAE;QACnCQ,IAAI,EAAE,KAAKD,UAAU,EAAE;QACvBE,UAAU,EAAE,SAAS;QACrBC,wBAAwB,EAAE,IAAI;QAC9BN,QAAQ,EAAEE,WAAW,CAACR,gBAAgB,CAAC,CAACa,IAAI,CAAC,IAAI;MAClD,CAAC,EAAEJ,UAAU,CAAC;IACf,CAAC;EAAE,CAAC,CAAC;AACN;AAEA,SAASN,YAAY","ignoreList":[]}
1
+ {"version":3,"names":["StyleObjectIdentifier","StyleObjectRules","Fragment","jsx","styleTagCache","Map","clearStyleTagCacheQueued","queueStyleTagCacheClear","queueMicrotask","clear","getCachedStyleTag","styleObject","identifier","rules","cached","get","len","length","first","last","element","href","precedence","suppressHydrationWarning","children","join","set","getStyleTags","styles","map"],"sources":["wrapStyleTags.mjs"],"sourcesContent":["import { StyleObjectIdentifier, StyleObjectRules } from \"@tamagui/helpers\";\nimport { Fragment, jsx } from \"react/jsx-runtime\";\n\nconst styleTagCache = /* @__PURE__ */ new Map();\nlet clearStyleTagCacheQueued = false;\nfunction queueStyleTagCacheClear() {\n\tif (clearStyleTagCacheQueued) return;\n\tclearStyleTagCacheQueued = true;\n\tqueueMicrotask(() => {\n\t\tstyleTagCache.clear();\n\t\tclearStyleTagCacheQueued = false;\n\t});\n}\nfunction getCachedStyleTag(styleObject) {\n\tconst identifier = styleObject[StyleObjectIdentifier];\n\tconst rules = styleObject[StyleObjectRules];\n\tconst cached = styleTagCache.get(identifier);\n\tif (cached && cached.len === rules.length && cached.first === rules[0] && cached.last === rules[rules.length - 1]) return cached.element;\n\tconst element = /* @__PURE__ */ jsx(\"style\", {\n\t\thref: `t_${identifier}`,\n\t\tprecedence: \"default\",\n\t\tsuppressHydrationWarning: true,\n\t\tchildren: rules.join(\"\\n\")\n\t}, identifier);\n\tstyleTagCache.set(identifier, {\n\t\telement,\n\t\tlen: rules.length,\n\t\tfirst: rules[0],\n\t\tlast: rules[rules.length - 1]\n\t});\n\treturn element;\n}\nfunction getStyleTags(styles) {\n\tif (styles.length) {\n\t\tqueueStyleTagCacheClear();\n\t\treturn /* @__PURE__ */ jsx(Fragment, { children: styles.map(getCachedStyleTag) });\n\t}\n}\n\nexport { getStyleTags };"],"mappings":"AAAA,SAASA,qBAAqB,EAAEC,gBAAgB,QAAQ,kBAAkB;AAC1E,SAASC,QAAQ,EAAEC,GAAG,QAAQ,mBAAmB;AAEjD,MAAMC,aAAa,GAAG,eAAgB,IAAIC,GAAG,CAAC,CAAC;AAC/C,IAAIC,wBAAwB,GAAG,KAAK;AACpC,SAASC,uBAAuBA,CAAA,EAAG;EAClC,IAAID,wBAAwB,EA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EsB,QAAQ,EAAEI,MAAM,CAACC,GAAG,CAACnB,iBAAiB;IAAE,CAAC,CAAC;EAClF;AACD;AAEA,SAASiB,YAAY","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/web",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Nate Wienert"
@@ -51,20 +51,20 @@
51
51
  "test:web": "vitest --typecheck --run"
52
52
  },
53
53
  "dependencies": {
54
- "@tamagui/compose-refs": "2.4.1",
55
- "@tamagui/constants": "2.4.1",
56
- "@tamagui/helpers": "2.4.1",
57
- "@tamagui/is-equal-shallow": "2.4.1",
58
- "@tamagui/native": "2.4.1",
59
- "@tamagui/normalize-css-color": "2.4.1",
60
- "@tamagui/timer": "2.4.1",
61
- "@tamagui/types": "2.4.1",
62
- "@tamagui/use-did-finish-ssr": "2.4.1",
63
- "@tamagui/use-event": "2.4.1",
64
- "@tamagui/use-force-update": "2.4.1"
54
+ "@tamagui/compose-refs": "2.4.2",
55
+ "@tamagui/constants": "2.4.2",
56
+ "@tamagui/helpers": "2.4.2",
57
+ "@tamagui/is-equal-shallow": "2.4.2",
58
+ "@tamagui/native": "2.4.2",
59
+ "@tamagui/normalize-css-color": "2.4.2",
60
+ "@tamagui/timer": "2.4.2",
61
+ "@tamagui/types": "2.4.2",
62
+ "@tamagui/use-did-finish-ssr": "2.4.2",
63
+ "@tamagui/use-event": "2.4.2",
64
+ "@tamagui/use-force-update": "2.4.2"
65
65
  },
66
66
  "devDependencies": {
67
- "@tamagui/build": "2.4.1",
67
+ "@tamagui/build": "2.4.2",
68
68
  "@testing-library/react": "^16.1.0",
69
69
  "csstype": "^3.0.10",
70
70
  "react": ">=19",
@@ -1,31 +1,74 @@
1
+ import type { ReactNode } from 'react'
1
2
  import { StyleObjectIdentifier, StyleObjectRules } from '@tamagui/helpers'
2
3
  import type { StyleObject } from '../types'
3
4
 
4
5
  // turns out this is pretty slow, creating a bunch of extra tags...
5
6
 
7
+ const styleTagCache = new Map<
8
+ string,
9
+ {
10
+ element: ReactNode
11
+ len: number
12
+ first: string | undefined
13
+ last: string | undefined
14
+ }
15
+ >()
16
+
17
+ let clearStyleTagCacheQueued = false
18
+
19
+ function queueStyleTagCacheClear() {
20
+ if (clearStyleTagCacheQueued) return
21
+
22
+ clearStyleTagCacheQueued = true
23
+ queueMicrotask(() => {
24
+ styleTagCache.clear()
25
+ clearStyleTagCacheQueued = false
26
+ })
27
+ }
28
+
29
+ function getCachedStyleTag(styleObject: StyleObject) {
30
+ const identifier = styleObject[StyleObjectIdentifier]
31
+ const rules = styleObject[StyleObjectRules]
32
+ const cached = styleTagCache.get(identifier)
33
+
34
+ if (
35
+ cached &&
36
+ cached.len === rules.length &&
37
+ cached.first === rules[0] &&
38
+ cached.last === rules[rules.length - 1]
39
+ ) {
40
+ return cached.element
41
+ }
42
+
43
+ const element = (
44
+ <style
45
+ key={identifier}
46
+ // @ts-ignore
47
+ href={`t_${identifier}`}
48
+ // @ts-ignore
49
+ precedence="default"
50
+ // we remove after first render in favor of inserting to a global stylesheet (faster)
51
+ suppressHydrationWarning
52
+ >
53
+ {rules.join('\n')}
54
+ </style>
55
+ )
56
+
57
+ styleTagCache.set(identifier, {
58
+ element,
59
+ len: rules.length,
60
+ first: rules[0],
61
+ last: rules[rules.length - 1],
62
+ })
63
+
64
+ return element
65
+ }
66
+
6
67
  export function getStyleTags(styles: StyleObject[]) {
7
68
  if (process.env.TAMAGUI_TARGET !== 'native') {
8
69
  if (styles.length) {
9
- return (
10
- <>
11
- {styles.map((styleObject) => {
12
- const identifier = styleObject[StyleObjectIdentifier]
13
- return (
14
- <style
15
- key={identifier}
16
- // @ts-ignore
17
- href={`t_${identifier}`}
18
- // @ts-ignore
19
- precedence="default"
20
- // we remove after first render in favor of inserting to a global stylesheet (faster)
21
- suppressHydrationWarning
22
- >
23
- {styleObject[StyleObjectRules].join('\n')}
24
- </style>
25
- )
26
- })}
27
- </>
28
- )
70
+ queueStyleTagCacheClear()
71
+ return <>{styles.map(getCachedStyleTag)}</>
29
72
  }
30
73
  }
31
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wrapStyleTags.d.ts","sourceRoot":"","sources":["../../src/helpers/wrapStyleTags.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAI3C,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,uDAyBjD"}
1
+ {"version":3,"file":"wrapStyleTags.d.ts","sourceRoot":"","sources":["../../src/helpers/wrapStyleTags.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAgE3C,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,uDAOjD"}