tailwindcss-patch 2.2.2 → 2.2.3

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
@@ -194,11 +194,25 @@ class CacheManager {
194
194
  }
195
195
  }
196
196
 
197
- function isObject(value) {
198
- return value !== null && typeof value === "object";
197
+ function isPlainObject(value) {
198
+ if (value === null || typeof value !== "object") {
199
+ return false;
200
+ }
201
+ const prototype = Object.getPrototypeOf(value);
202
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
203
+ return false;
204
+ }
205
+ if (Symbol.iterator in value) {
206
+ return false;
207
+ }
208
+ if (Symbol.toStringTag in value) {
209
+ return Object.prototype.toString.call(value) === "[object Module]";
210
+ }
211
+ return true;
199
212
  }
213
+
200
214
  function _defu(baseObject, defaults, namespace = ".", merger) {
201
- if (!isObject(defaults)) {
215
+ if (!isPlainObject(defaults)) {
202
216
  return _defu(baseObject, {}, namespace, merger);
203
217
  }
204
218
  const object = Object.assign({}, defaults);
@@ -215,7 +229,7 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
215
229
  }
216
230
  if (Array.isArray(value) && Array.isArray(object[key])) {
217
231
  object[key] = [...value, ...object[key]];
218
- } else if (isObject(value) && isObject(object[key])) {
232
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
219
233
  object[key] = _defu(
220
234
  value,
221
235
  object[key],
@@ -246,7 +260,7 @@ function inspectProcessTailwindFeaturesReturnContext(content) {
246
260
  const rts = n.body.body[0];
247
261
  if (t__namespace.isFunctionExpression(rts.argument)) {
248
262
  const body = rts.argument.body.body;
249
- const lastStatement = body.at(-1);
263
+ const lastStatement = body[body.length - 1];
250
264
  hasPatched = t__namespace.isReturnStatement(lastStatement) && t__namespace.isIdentifier(lastStatement.argument) && lastStatement.argument.name === "context";
251
265
  if (!hasPatched) {
252
266
  const rts2 = t__namespace.returnStatement(t__namespace.identifier("context"));
@@ -275,7 +289,7 @@ function inspectPostcssPlugin(content) {
275
289
  });
276
290
  if (idx > -1) {
277
291
  const prevStatement = n.body[idx - 1];
278
- const lastStatement = n.body.at(-1);
292
+ const lastStatement = n.body[n.body.length - 1];
279
293
  const hasPatchedCondition0 = prevStatement && t__namespace.isVariableDeclaration(prevStatement) && prevStatement.declarations.length === 1 && t__namespace.isIdentifier(prevStatement.declarations[0].id) && prevStatement.declarations[0].id.name === variableName;
280
294
  const hasPatchedCondition1 = t__namespace.isExpressionStatement(lastStatement) && t__namespace.isAssignmentExpression(lastStatement.expression) && t__namespace.isIdentifier(lastStatement.expression.right) && lastStatement.expression.right.name === variableName;
281
295
  hasPatched = hasPatchedCondition0 || hasPatchedCondition1;
@@ -312,7 +326,7 @@ function inspectPostcssPlugin(content) {
312
326
  const pluginsCode = properties[1].value.callee.object.elements;
313
327
  if (pluginsCode[1] && t__namespace.isFunctionExpression(pluginsCode[1])) {
314
328
  const targetBlockStatement = pluginsCode[1].body;
315
- const lastStatement = targetBlockStatement.body.at(-1);
329
+ const lastStatement = targetBlockStatement.body[targetBlockStatement.body.length - 1];
316
330
  if (t__namespace.isExpressionStatement(lastStatement)) {
317
331
  const newExpressionStatement = t__namespace.expressionStatement(
318
332
  t__namespace.callExpression(
package/dist/index.mjs CHANGED
@@ -177,11 +177,25 @@ class CacheManager {
177
177
  }
178
178
  }
179
179
 
180
- function isObject(value) {
181
- return value !== null && typeof value === "object";
180
+ function isPlainObject(value) {
181
+ if (value === null || typeof value !== "object") {
182
+ return false;
183
+ }
184
+ const prototype = Object.getPrototypeOf(value);
185
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
186
+ return false;
187
+ }
188
+ if (Symbol.iterator in value) {
189
+ return false;
190
+ }
191
+ if (Symbol.toStringTag in value) {
192
+ return Object.prototype.toString.call(value) === "[object Module]";
193
+ }
194
+ return true;
182
195
  }
196
+
183
197
  function _defu(baseObject, defaults, namespace = ".", merger) {
184
- if (!isObject(defaults)) {
198
+ if (!isPlainObject(defaults)) {
185
199
  return _defu(baseObject, {}, namespace, merger);
186
200
  }
187
201
  const object = Object.assign({}, defaults);
@@ -198,7 +212,7 @@ function _defu(baseObject, defaults, namespace = ".", merger) {
198
212
  }
199
213
  if (Array.isArray(value) && Array.isArray(object[key])) {
200
214
  object[key] = [...value, ...object[key]];
201
- } else if (isObject(value) && isObject(object[key])) {
215
+ } else if (isPlainObject(value) && isPlainObject(object[key])) {
202
216
  object[key] = _defu(
203
217
  value,
204
218
  object[key],
@@ -229,7 +243,7 @@ function inspectProcessTailwindFeaturesReturnContext(content) {
229
243
  const rts = n.body.body[0];
230
244
  if (t.isFunctionExpression(rts.argument)) {
231
245
  const body = rts.argument.body.body;
232
- const lastStatement = body.at(-1);
246
+ const lastStatement = body[body.length - 1];
233
247
  hasPatched = t.isReturnStatement(lastStatement) && t.isIdentifier(lastStatement.argument) && lastStatement.argument.name === "context";
234
248
  if (!hasPatched) {
235
249
  const rts2 = t.returnStatement(t.identifier("context"));
@@ -258,7 +272,7 @@ function inspectPostcssPlugin(content) {
258
272
  });
259
273
  if (idx > -1) {
260
274
  const prevStatement = n.body[idx - 1];
261
- const lastStatement = n.body.at(-1);
275
+ const lastStatement = n.body[n.body.length - 1];
262
276
  const hasPatchedCondition0 = prevStatement && t.isVariableDeclaration(prevStatement) && prevStatement.declarations.length === 1 && t.isIdentifier(prevStatement.declarations[0].id) && prevStatement.declarations[0].id.name === variableName;
263
277
  const hasPatchedCondition1 = t.isExpressionStatement(lastStatement) && t.isAssignmentExpression(lastStatement.expression) && t.isIdentifier(lastStatement.expression.right) && lastStatement.expression.right.name === variableName;
264
278
  hasPatched = hasPatchedCondition0 || hasPatchedCondition1;
@@ -295,7 +309,7 @@ function inspectPostcssPlugin(content) {
295
309
  const pluginsCode = properties[1].value.callee.object.elements;
296
310
  if (pluginsCode[1] && t.isFunctionExpression(pluginsCode[1])) {
297
311
  const targetBlockStatement = pluginsCode[1].body;
298
- const lastStatement = targetBlockStatement.body.at(-1);
312
+ const lastStatement = targetBlockStatement.body[targetBlockStatement.body.length - 1];
299
313
  if (t.isExpressionStatement(lastStatement)) {
300
314
  const newExpressionStatement = t.expressionStatement(
301
315
  t.callExpression(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss-patch",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "patch tailwindcss for exposing context and extract classes",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.ts",
@@ -33,24 +33,24 @@
33
33
  }
34
34
  },
35
35
  "devDependencies": {
36
- "@types/babel__generator": "^7.6.4",
37
- "@types/babel__traverse": "^7.20.1",
38
- "@types/resolve": "^1.20.2",
39
- "@types/semver": "^7.5.2",
36
+ "@types/babel__generator": "^7.6.8",
37
+ "@types/babel__traverse": "^7.20.5",
38
+ "@types/resolve": "^1.20.6",
39
+ "@types/semver": "^7.5.6",
40
40
  "pkg-types": "^1.0.3",
41
- "tailwindcss": "^3.3.3"
41
+ "tailwindcss": "^3.4.1"
42
42
  },
43
43
  "dependencies": {
44
- "@babel/generator": "^7.22.15",
45
- "@babel/parser": "^7.22.16",
46
- "@babel/traverse": "^7.22.19",
47
- "@babel/types": "^7.22.19",
44
+ "@babel/generator": "^7.23.6",
45
+ "@babel/parser": "^7.23.9",
46
+ "@babel/traverse": "^7.23.9",
47
+ "@babel/types": "^7.23.9",
48
48
  "cac": "^6.7.14",
49
- "jiti": "^1.20.0",
50
- "lilconfig": "^2.1.0",
51
- "postcss": "^8.4.29",
52
- "resolve": "^1.22.5",
53
- "semver": "^7.5.4",
49
+ "jiti": "^1.21.0",
50
+ "lilconfig": "^3.0.0",
51
+ "postcss": "^8.4.34",
52
+ "resolve": "^1.22.8",
53
+ "semver": "^7.6.0",
54
54
  "@tailwindcss-mangle/config": "^2.2.2"
55
55
  },
56
56
  "homepage": "https://github.com/sonofmagic/tailwindcss-mangle",