prettier 3.0.2 → 3.0.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/internal/cli.mjs CHANGED
@@ -1197,6 +1197,264 @@ var require_common_path_prefix = __commonJS({
1197
1197
  }
1198
1198
  });
1199
1199
 
1200
+ // node_modules/json-buffer/index.js
1201
+ var require_json_buffer = __commonJS({
1202
+ "node_modules/json-buffer/index.js"(exports) {
1203
+ exports.stringify = function stringify4(o) {
1204
+ if ("undefined" == typeof o)
1205
+ return o;
1206
+ if (o && Buffer.isBuffer(o))
1207
+ return JSON.stringify(":base64:" + o.toString("base64"));
1208
+ if (o && o.toJSON)
1209
+ o = o.toJSON();
1210
+ if (o && "object" === typeof o) {
1211
+ var s = "";
1212
+ var array2 = Array.isArray(o);
1213
+ s = array2 ? "[" : "{";
1214
+ var first = true;
1215
+ for (var k in o) {
1216
+ var ignore = "function" == typeof o[k] || !array2 && "undefined" === typeof o[k];
1217
+ if (Object.hasOwnProperty.call(o, k) && !ignore) {
1218
+ if (!first)
1219
+ s += ",";
1220
+ first = false;
1221
+ if (array2) {
1222
+ if (o[k] == void 0)
1223
+ s += "null";
1224
+ else
1225
+ s += stringify4(o[k]);
1226
+ } else if (o[k] !== void 0) {
1227
+ s += stringify4(k) + ":" + stringify4(o[k]);
1228
+ }
1229
+ }
1230
+ }
1231
+ s += array2 ? "]" : "}";
1232
+ return s;
1233
+ } else if ("string" === typeof o) {
1234
+ return JSON.stringify(/^:/.test(o) ? ":" + o : o);
1235
+ } else if ("undefined" === typeof o) {
1236
+ return "null";
1237
+ } else
1238
+ return JSON.stringify(o);
1239
+ };
1240
+ exports.parse = function(s) {
1241
+ return JSON.parse(s, function(key, value) {
1242
+ if ("string" === typeof value) {
1243
+ if (/^:base64:/.test(value))
1244
+ return Buffer.from(value.substring(8), "base64");
1245
+ else
1246
+ return /^:/.test(value) ? value.substring(1) : value;
1247
+ }
1248
+ return value;
1249
+ });
1250
+ };
1251
+ }
1252
+ });
1253
+
1254
+ // node_modules/keyv/src/index.js
1255
+ var require_src = __commonJS({
1256
+ "node_modules/keyv/src/index.js"(exports, module) {
1257
+ "use strict";
1258
+ var EventEmitter = __require("events");
1259
+ var JSONB = require_json_buffer();
1260
+ var loadStore = (options) => {
1261
+ const adapters = {
1262
+ redis: "@keyv/redis",
1263
+ rediss: "@keyv/redis",
1264
+ mongodb: "@keyv/mongo",
1265
+ mongo: "@keyv/mongo",
1266
+ sqlite: "@keyv/sqlite",
1267
+ postgresql: "@keyv/postgres",
1268
+ postgres: "@keyv/postgres",
1269
+ mysql: "@keyv/mysql",
1270
+ etcd: "@keyv/etcd",
1271
+ offline: "@keyv/offline",
1272
+ tiered: "@keyv/tiered"
1273
+ };
1274
+ if (options.adapter || options.uri) {
1275
+ const adapter = options.adapter || /^[^:+]*/.exec(options.uri)[0];
1276
+ return new (__require(adapters[adapter]))(options);
1277
+ }
1278
+ return /* @__PURE__ */ new Map();
1279
+ };
1280
+ var iterableAdapters = [
1281
+ "sqlite",
1282
+ "postgres",
1283
+ "mysql",
1284
+ "mongo",
1285
+ "redis",
1286
+ "tiered"
1287
+ ];
1288
+ var Keyv = class extends EventEmitter {
1289
+ constructor(uri, { emitErrors = true, ...options } = {}) {
1290
+ super();
1291
+ this.opts = {
1292
+ namespace: "keyv",
1293
+ serialize: JSONB.stringify,
1294
+ deserialize: JSONB.parse,
1295
+ ...typeof uri === "string" ? { uri } : uri,
1296
+ ...options
1297
+ };
1298
+ if (!this.opts.store) {
1299
+ const adapterOptions = { ...this.opts };
1300
+ this.opts.store = loadStore(adapterOptions);
1301
+ }
1302
+ if (this.opts.compression) {
1303
+ const compression = this.opts.compression;
1304
+ this.opts.serialize = compression.serialize.bind(compression);
1305
+ this.opts.deserialize = compression.deserialize.bind(compression);
1306
+ }
1307
+ if (typeof this.opts.store.on === "function" && emitErrors) {
1308
+ this.opts.store.on("error", (error) => this.emit("error", error));
1309
+ }
1310
+ this.opts.store.namespace = this.opts.namespace;
1311
+ const generateIterator = (iterator) => async function* () {
1312
+ for await (const [key, raw] of typeof iterator === "function" ? iterator(this.opts.store.namespace) : iterator) {
1313
+ const data = await this.opts.deserialize(raw);
1314
+ if (this.opts.store.namespace && !key.includes(this.opts.store.namespace)) {
1315
+ continue;
1316
+ }
1317
+ if (typeof data.expires === "number" && Date.now() > data.expires) {
1318
+ this.delete(key);
1319
+ continue;
1320
+ }
1321
+ yield [this._getKeyUnprefix(key), data.value];
1322
+ }
1323
+ };
1324
+ if (typeof this.opts.store[Symbol.iterator] === "function" && this.opts.store instanceof Map) {
1325
+ this.iterator = generateIterator(this.opts.store);
1326
+ } else if (typeof this.opts.store.iterator === "function" && this.opts.store.opts && this._checkIterableAdaptar()) {
1327
+ this.iterator = generateIterator(this.opts.store.iterator.bind(this.opts.store));
1328
+ }
1329
+ }
1330
+ _checkIterableAdaptar() {
1331
+ return iterableAdapters.includes(this.opts.store.opts.dialect) || iterableAdapters.findIndex((element) => this.opts.store.opts.url.includes(element)) >= 0;
1332
+ }
1333
+ _getKeyPrefix(key) {
1334
+ return `${this.opts.namespace}:${key}`;
1335
+ }
1336
+ _getKeyPrefixArray(keys) {
1337
+ return keys.map((key) => `${this.opts.namespace}:${key}`);
1338
+ }
1339
+ _getKeyUnprefix(key) {
1340
+ return key.split(":").splice(1).join(":");
1341
+ }
1342
+ get(key, options) {
1343
+ const { store } = this.opts;
1344
+ const isArray = Array.isArray(key);
1345
+ const keyPrefixed = isArray ? this._getKeyPrefixArray(key) : this._getKeyPrefix(key);
1346
+ if (isArray && store.getMany === void 0) {
1347
+ const promises = [];
1348
+ for (const key2 of keyPrefixed) {
1349
+ promises.push(
1350
+ Promise.resolve().then(() => store.get(key2)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
1351
+ if (data === void 0 || data === null) {
1352
+ return void 0;
1353
+ }
1354
+ if (typeof data.expires === "number" && Date.now() > data.expires) {
1355
+ return this.delete(key2).then(() => void 0);
1356
+ }
1357
+ return options && options.raw ? data : data.value;
1358
+ })
1359
+ );
1360
+ }
1361
+ return Promise.allSettled(promises).then((values) => {
1362
+ const data = [];
1363
+ for (const value of values) {
1364
+ data.push(value.value);
1365
+ }
1366
+ return data;
1367
+ });
1368
+ }
1369
+ return Promise.resolve().then(() => isArray ? store.getMany(keyPrefixed) : store.get(keyPrefixed)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
1370
+ if (data === void 0 || data === null) {
1371
+ return void 0;
1372
+ }
1373
+ if (isArray) {
1374
+ const result = [];
1375
+ for (let row of data) {
1376
+ if (typeof row === "string") {
1377
+ row = this.opts.deserialize(row);
1378
+ }
1379
+ if (row === void 0 || row === null) {
1380
+ result.push(void 0);
1381
+ continue;
1382
+ }
1383
+ if (typeof row.expires === "number" && Date.now() > row.expires) {
1384
+ this.delete(key).then(() => void 0);
1385
+ result.push(void 0);
1386
+ } else {
1387
+ result.push(options && options.raw ? row : row.value);
1388
+ }
1389
+ }
1390
+ return result;
1391
+ }
1392
+ if (typeof data.expires === "number" && Date.now() > data.expires) {
1393
+ return this.delete(key).then(() => void 0);
1394
+ }
1395
+ return options && options.raw ? data : data.value;
1396
+ });
1397
+ }
1398
+ set(key, value, ttl) {
1399
+ const keyPrefixed = this._getKeyPrefix(key);
1400
+ if (typeof ttl === "undefined") {
1401
+ ttl = this.opts.ttl;
1402
+ }
1403
+ if (ttl === 0) {
1404
+ ttl = void 0;
1405
+ }
1406
+ const { store } = this.opts;
1407
+ return Promise.resolve().then(() => {
1408
+ const expires = typeof ttl === "number" ? Date.now() + ttl : null;
1409
+ if (typeof value === "symbol") {
1410
+ this.emit("error", "symbol cannot be serialized");
1411
+ }
1412
+ value = { value, expires };
1413
+ return this.opts.serialize(value);
1414
+ }).then((value2) => store.set(keyPrefixed, value2, ttl)).then(() => true);
1415
+ }
1416
+ delete(key) {
1417
+ const { store } = this.opts;
1418
+ if (Array.isArray(key)) {
1419
+ const keyPrefixed2 = this._getKeyPrefixArray(key);
1420
+ if (store.deleteMany === void 0) {
1421
+ const promises = [];
1422
+ for (const key2 of keyPrefixed2) {
1423
+ promises.push(store.delete(key2));
1424
+ }
1425
+ return Promise.allSettled(promises).then((values) => values.every((x) => x.value === true));
1426
+ }
1427
+ return Promise.resolve().then(() => store.deleteMany(keyPrefixed2));
1428
+ }
1429
+ const keyPrefixed = this._getKeyPrefix(key);
1430
+ return Promise.resolve().then(() => store.delete(keyPrefixed));
1431
+ }
1432
+ clear() {
1433
+ const { store } = this.opts;
1434
+ return Promise.resolve().then(() => store.clear());
1435
+ }
1436
+ has(key) {
1437
+ const keyPrefixed = this._getKeyPrefix(key);
1438
+ const { store } = this.opts;
1439
+ return Promise.resolve().then(async () => {
1440
+ if (typeof store.has === "function") {
1441
+ return store.has(keyPrefixed);
1442
+ }
1443
+ const value = await store.get(keyPrefixed);
1444
+ return value !== void 0;
1445
+ });
1446
+ }
1447
+ disconnect() {
1448
+ const { store } = this.opts;
1449
+ if (typeof store.disconnect === "function") {
1450
+ return store.disconnect();
1451
+ }
1452
+ }
1453
+ };
1454
+ module.exports = Keyv;
1455
+ }
1456
+ });
1457
+
1200
1458
  // node_modules/flatted/cjs/index.js
1201
1459
  var require_cjs = __commonJS({
1202
1460
  "node_modules/flatted/cjs/index.js"(exports) {
@@ -4008,6 +4266,7 @@ var require_cache = __commonJS({
4008
4266
  "node_modules/flat-cache/src/cache.js"(exports, module) {
4009
4267
  var path10 = __require("path");
4010
4268
  var fs6 = __require("fs");
4269
+ var Keyv = require_src();
4011
4270
  var utils = require_utils();
4012
4271
  var del = require_del();
4013
4272
  var writeJSON = utils.writeJSON;
@@ -4023,13 +4282,28 @@ var require_cache = __commonJS({
4023
4282
  */
4024
4283
  load: function(docId, cacheDir) {
4025
4284
  var me = this;
4026
- me._visited = {};
4027
- me._persisted = {};
4285
+ me.keyv = new Keyv();
4286
+ me.__visited = {};
4287
+ me.__persisted = {};
4028
4288
  me._pathToFile = cacheDir ? path10.resolve(cacheDir, docId) : path10.resolve(__dirname, "../.cache/", docId);
4029
4289
  if (fs6.existsSync(me._pathToFile)) {
4030
4290
  me._persisted = utils.tryParse(me._pathToFile, {});
4031
4291
  }
4032
4292
  },
4293
+ get _persisted() {
4294
+ return this.__persisted;
4295
+ },
4296
+ set _persisted(value) {
4297
+ this.__persisted = value;
4298
+ this.keyv.set("persisted", value);
4299
+ },
4300
+ get _visited() {
4301
+ return this.__visited;
4302
+ },
4303
+ set _visited(value) {
4304
+ this.__visited = value;
4305
+ this.keyv.set("visited", value);
4306
+ },
4033
4307
  /**
4034
4308
  * Load the cache from the provided file
4035
4309
  * @method loadFile
@@ -5981,9 +6255,10 @@ async function* expandPatternsInternal(context) {
5981
6255
  });
5982
6256
  } else if (stat.isDirectory()) {
5983
6257
  const relativePath = path2.relative(cwd2, absolutePath) || ".";
6258
+ const prefix = escapePathForGlob(fixWindowsSlashes(relativePath));
5984
6259
  entries.push({
5985
6260
  type: "dir",
5986
- glob: escapePathForGlob(fixWindowsSlashes(relativePath)) + "/" + getSupportedFilesGlob(),
6261
+ glob: getSupportedFilesGlob().map((pattern2) => `${prefix}/**/${pattern2}`),
5987
6262
  input: pattern
5988
6263
  });
5989
6264
  }
@@ -6025,13 +6300,20 @@ ${message}`
6025
6300
  }
6026
6301
  }
6027
6302
  function getSupportedFilesGlob() {
6028
- if (!supportedFilesGlob) {
6029
- const extensions = context.languages.flatMap((lang) => lang.extensions || []);
6030
- const filenames = context.languages.flatMap((lang) => lang.filenames || []);
6031
- supportedFilesGlob = `**/{${[...extensions.map((ext) => "*" + (ext[0] === "." ? ext : "." + ext)), ...filenames]}}`;
6032
- }
6303
+ supportedFilesGlob ?? (supportedFilesGlob = [...getSupportedFilesGlobWithoutCache()]);
6033
6304
  return supportedFilesGlob;
6034
6305
  }
6306
+ function* getSupportedFilesGlobWithoutCache() {
6307
+ for (const {
6308
+ extensions = [],
6309
+ filenames = []
6310
+ } of context.languages) {
6311
+ yield* filenames;
6312
+ for (const extension of extensions) {
6313
+ yield `*${extension.startsWith(".") ? extension : `.${extension}`}`;
6314
+ }
6315
+ }
6316
+ }
6035
6317
  }
6036
6318
  var errorMessages = {
6037
6319
  globError: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Prettier is an opinionated code formatter",
5
5
  "bin": "./bin/prettier.cjs",
6
6
  "repository": "prettier/prettier",
@@ -190,5 +190,6 @@
190
190
  "standalone.d.ts",
191
191
  "standalone.js",
192
192
  "standalone.mjs"
193
- ]
193
+ ],
194
+ "preferUnplugged": true
194
195
  }