You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.6 KiB

2 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. function _export(target, all) {
  6. for(var name in all)Object.defineProperty(target, name, {
  7. enumerable: true,
  8. get: all[name]
  9. });
  10. }
  11. _export(exports, {
  12. flagEnabled: ()=>flagEnabled,
  13. issueFlagNotices: ()=>issueFlagNotices,
  14. default: ()=>_default
  15. });
  16. const _picocolors = /*#__PURE__*/ _interopRequireDefault(require("picocolors"));
  17. const _log = /*#__PURE__*/ _interopRequireDefault(require("./util/log"));
  18. function _interopRequireDefault(obj) {
  19. return obj && obj.__esModule ? obj : {
  20. default: obj
  21. };
  22. }
  23. let defaults = {
  24. optimizeUniversalDefaults: false
  25. };
  26. let featureFlags = {
  27. future: [
  28. "hoverOnlyWhenSupported",
  29. "respectDefaultRingColorOpacity"
  30. ],
  31. experimental: [
  32. "optimizeUniversalDefaults",
  33. "matchVariant" /* , 'variantGrouping' */
  34. ]
  35. };
  36. function flagEnabled(config, flag) {
  37. if (featureFlags.future.includes(flag)) {
  38. var ref;
  39. var ref1, ref2;
  40. return config.future === "all" || ((ref2 = (ref1 = config === null || config === void 0 ? void 0 : (ref = config.future) === null || ref === void 0 ? void 0 : ref[flag]) !== null && ref1 !== void 0 ? ref1 : defaults[flag]) !== null && ref2 !== void 0 ? ref2 : false);
  41. }
  42. if (featureFlags.experimental.includes(flag)) {
  43. var ref3;
  44. var ref4, ref5;
  45. return config.experimental === "all" || ((ref5 = (ref4 = config === null || config === void 0 ? void 0 : (ref3 = config.experimental) === null || ref3 === void 0 ? void 0 : ref3[flag]) !== null && ref4 !== void 0 ? ref4 : defaults[flag]) !== null && ref5 !== void 0 ? ref5 : false);
  46. }
  47. return false;
  48. }
  49. function experimentalFlagsEnabled(config) {
  50. if (config.experimental === "all") {
  51. return featureFlags.experimental;
  52. }
  53. var ref;
  54. return Object.keys((ref = config === null || config === void 0 ? void 0 : config.experimental) !== null && ref !== void 0 ? ref : {}).filter((flag)=>featureFlags.experimental.includes(flag) && config.experimental[flag]);
  55. }
  56. function issueFlagNotices(config) {
  57. if (process.env.JEST_WORKER_ID !== undefined) {
  58. return;
  59. }
  60. if (experimentalFlagsEnabled(config).length > 0) {
  61. let changes = experimentalFlagsEnabled(config).map((s)=>_picocolors.default.yellow(s)).join(", ");
  62. _log.default.warn("experimental-flags-enabled", [
  63. `You have enabled experimental features: ${changes}`,
  64. "Experimental features in Tailwind CSS are not covered by semver, may introduce breaking changes, and can change at any time.",
  65. ]);
  66. }
  67. }
  68. const _default = featureFlags;