react-native-web-tailwind-compat 1.0.0 → 1.0.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.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- require('./ReactNativeWebTailwindCompat.cjs');
1
+ require('./reactNativeWebTailwindCompat.cjs');
2
2
  const require_getServerStyleSheet = require('./getServerStyleSheet.cjs');
3
3
 
4
4
  exports.getServerStyleSheet = require_getServerStyleSheet.getServerStyleSheet;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import "./ReactNativeWebTailwindCompat.mjs";
1
+ import "./reactNativeWebTailwindCompat.mjs";
2
2
  import { getServerStyleSheet } from "./getServerStyleSheet.mjs";
3
3
 
4
4
  export { getServerStyleSheet };
@@ -1,6 +1,8 @@
1
+ "use client";
2
+
1
3
  const require_utils = require('./utils.cjs');
2
4
 
3
- //#region src/ReactNativeWebTailwindCompat.ts
5
+ //#region src/reactNativeWebTailwindCompat.ts
4
6
  if (typeof window !== "undefined") {
5
7
  let elemProxy;
6
8
  const _getElementById = document.getElementById;
@@ -1,6 +1,8 @@
1
+ "use client";
2
+
1
3
  import { NEW_SHEET_ID, layerBoundaryRegex } from "./utils.mjs";
2
4
 
3
- //#region src/ReactNativeWebTailwindCompat.ts
5
+ //#region src/reactNativeWebTailwindCompat.ts
4
6
  if (typeof window !== "undefined") {
5
7
  let elemProxy;
6
8
  const _getElementById = document.getElementById;
@@ -40,4 +42,4 @@ if (typeof window !== "undefined") {
40
42
 
41
43
  //#endregion
42
44
  export { };
43
- //# sourceMappingURL=ReactNativeWebTailwindCompat.mjs.map
45
+ //# sourceMappingURL=reactNativeWebTailwindCompat.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactNativeWebTailwindCompat.mjs","names":["elemProxy: HTMLStyleElement"],"sources":["../src/reactNativeWebTailwindCompat.ts"],"sourcesContent":["\"use client\";\nimport { layerBoundaryRegex, NEW_SHEET_ID } from \"./utils\";\n\nif (typeof window !== \"undefined\") {\n let elemProxy: HTMLStyleElement;\n const _getElementById = document.getElementById;\n document.getElementById = function (id: string) {\n return id !== \"react-native-stylesheet\"\n ? _getElementById.call(document, id)\n : (elemProxy ??= { sheet: buildRNWProxy() } as HTMLStyleElement);\n };\n\n function buildRNWProxy() {\n const flattenedSheet = new CSSStyleSheet();\n let layeredSheet = (\n document.getElementById(NEW_SHEET_ID) as HTMLStyleElement\n )?.sheet;\n\n if (!layeredSheet) {\n const styleElem = document.createElement(\"style\");\n styleElem.id = NEW_SHEET_ID;\n document.head.prepend(styleElem);\n layeredSheet = styleElem.sheet;\n }\n if (!layeredSheet) return flattenedSheet;\n // ensure that the first rule in the layered sheet is a layer\n if (!(layeredSheet.cssRules[0] instanceof CSSLayerBlockRule)) {\n layeredSheet.insertRule(\"@layer rnw {}\", 0);\n }\n // Traverse the layered sheet to build the flattened sheet\n flattenRules(layeredSheet.cssRules, flattenedSheet);\n\n return new Proxy(flattenedSheet, {\n get(target, prop) {\n if (prop === \"insertRule\") {\n return function insertRule(text: string, index: number) {\n flattenedSheet.insertRule(text, index);\n // find the index of the groups\n const cutoffIndex = [...flattenedSheet.cssRules].findIndex((rule) =>\n layerBoundaryRegex.exec(rule.cssText),\n );\n if (cutoffIndex === -1 || index <= cutoffIndex) {\n // insert into the layer\n const layerRule = layeredSheet.cssRules[0] as CSSLayerBlockRule;\n layerRule.insertRule(text, layerRule.cssRules.length);\n } else {\n // insert into the sheet normally\n layeredSheet.insertRule(text, layeredSheet.cssRules.length);\n }\n };\n }\n const value = (target as any)[prop];\n return typeof value === \"function\" ? value.bind(target) : value;\n },\n });\n }\n\n function flattenRules(\n rules: CSSRuleList | CSSRule[],\n targetSheet: CSSStyleSheet,\n ) {\n for (const rule of rules) {\n if (rule instanceof CSSLayerBlockRule) {\n flattenRules(rule.cssRules, targetSheet);\n } else {\n targetSheet.insertRule(rule.cssText, targetSheet.cssRules.length);\n }\n }\n }\n}\n"],"mappings":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@
1
1
  {
2
2
  "name": "react-native-web-tailwind-compat",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "author": "Alexander Nicholson",
5
5
  "description": "Adds CSS layers to react native web styles, allowing it to be used with TailwindCSS v4",
6
6
  "homepage": "https://github.com/a16n-dev/uniwind-plugin-next#readme",
@@ -1 +0,0 @@
1
- {"version":3,"file":"ReactNativeWebTailwindCompat.mjs","names":["elemProxy: HTMLStyleElement"],"sources":["../src/ReactNativeWebTailwindCompat.ts"],"sourcesContent":["import { layerBoundaryRegex, NEW_SHEET_ID } from \"./utils\";\n\nif (typeof window !== \"undefined\") {\n let elemProxy: HTMLStyleElement;\n const _getElementById = document.getElementById;\n document.getElementById = function (id: string) {\n return id !== \"react-native-stylesheet\"\n ? _getElementById.call(document, id)\n : (elemProxy ??= { sheet: buildRNWProxy() } as HTMLStyleElement);\n };\n\n function buildRNWProxy() {\n const flattenedSheet = new CSSStyleSheet();\n let layeredSheet = (\n document.getElementById(NEW_SHEET_ID) as HTMLStyleElement\n )?.sheet;\n\n if (!layeredSheet) {\n const styleElem = document.createElement(\"style\");\n styleElem.id = NEW_SHEET_ID;\n document.head.prepend(styleElem);\n layeredSheet = styleElem.sheet;\n }\n if (!layeredSheet) return flattenedSheet;\n // ensure that the first rule in the layered sheet is a layer\n if (!(layeredSheet.cssRules[0] instanceof CSSLayerBlockRule)) {\n layeredSheet.insertRule(\"@layer rnw {}\", 0);\n }\n // Traverse the layered sheet to build the flattened sheet\n flattenRules(layeredSheet.cssRules, flattenedSheet);\n\n return new Proxy(flattenedSheet, {\n get(target, prop) {\n if (prop === \"insertRule\") {\n return function insertRule(text: string, index: number) {\n flattenedSheet.insertRule(text, index);\n // find the index of the groups\n const cutoffIndex = [...flattenedSheet.cssRules].findIndex((rule) =>\n layerBoundaryRegex.exec(rule.cssText),\n );\n if (cutoffIndex === -1 || index <= cutoffIndex) {\n // insert into the layer\n const layerRule = layeredSheet.cssRules[0] as CSSLayerBlockRule;\n layerRule.insertRule(text, layerRule.cssRules.length);\n } else {\n // insert into the sheet normally\n layeredSheet.insertRule(text, layeredSheet.cssRules.length);\n }\n };\n }\n const value = (target as any)[prop];\n return typeof value === \"function\" ? value.bind(target) : value;\n },\n });\n }\n\n function flattenRules(\n rules: CSSRuleList | CSSRule[],\n targetSheet: CSSStyleSheet,\n ) {\n for (const rule of rules) {\n if (rule instanceof CSSLayerBlockRule) {\n flattenRules(rule.cssRules, targetSheet);\n } else {\n targetSheet.insertRule(rule.cssText, targetSheet.cssRules.length);\n }\n }\n }\n}\n"],"mappings":";;;AAEA,IAAI,OAAO,WAAW,aAAa;CACjC,IAAIA;CACJ,MAAM,kBAAkB,SAAS;AACjC,UAAS,iBAAiB,SAAU,IAAY;AAC9C,SAAO,OAAO,4BACV,gBAAgB,KAAK,UAAU,GAAG,GACjC,cAAc,EAAE,OAAO,eAAe,EAAE;;CAG/C,SAAS,gBAAgB;EACvB,MAAM,iBAAiB,IAAI,eAAe;EAC1C,IAAI,eACF,SAAS,eAAe,aAAa,EACpC;AAEH,MAAI,CAAC,cAAc;GACjB,MAAM,YAAY,SAAS,cAAc,QAAQ;AACjD,aAAU,KAAK;AACf,YAAS,KAAK,QAAQ,UAAU;AAChC,kBAAe,UAAU;;AAE3B,MAAI,CAAC,aAAc,QAAO;AAE1B,MAAI,EAAE,aAAa,SAAS,cAAc,mBACxC,cAAa,WAAW,iBAAiB,EAAE;AAG7C,eAAa,aAAa,UAAU,eAAe;AAEnD,SAAO,IAAI,MAAM,gBAAgB,EAC/B,IAAI,QAAQ,MAAM;AAChB,OAAI,SAAS,aACX,QAAO,SAAS,WAAW,MAAc,OAAe;AACtD,mBAAe,WAAW,MAAM,MAAM;IAEtC,MAAM,cAAc,CAAC,GAAG,eAAe,SAAS,CAAC,WAAW,SAC1D,mBAAmB,KAAK,KAAK,QAAQ,CACtC;AACD,QAAI,gBAAgB,MAAM,SAAS,aAAa;KAE9C,MAAM,YAAY,aAAa,SAAS;AACxC,eAAU,WAA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