@sybz-components/utils 1.0.21 → 1.0.23

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/base.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  require('vue');
4
4
  require('consola');
5
5
  require('es-toolkit');
6
- const format = require('./shared/utils.nuyKxZXX.cjs');
6
+ const format = require('./shared/utils.CshLEFSw.cjs');
7
7
  require('./confirmSemantic.cjs');
8
8
  require('element-plus');
9
9
  require('axios');
package/dist/base.d.cts CHANGED
@@ -39,7 +39,7 @@ interface SybzUtilsConfig {
39
39
  http?: CreateHttpOptions;
40
40
  }
41
41
  interface ToastOptions extends Omit<Partial<MessageOptions>, 'icon'> {
42
- /** 是否解析 HTML 字符串,并将已全局注册的组件标签渲染为 Vue 组件;默认 false。仅传可信内容。 */
42
+ /** 是否解析 HTML 字符串,并将已全局注册的组件标签渲染为 Vue 组件;默认 true。仅传可信内容。 */
43
43
  dangerouslyUseHTMLString?: boolean;
44
44
  /** 图标组件,或由全局 SIcon 自动解析的图标名称。 */
45
45
  icon?: string | Component;
package/dist/base.d.mts CHANGED
@@ -39,7 +39,7 @@ interface SybzUtilsConfig {
39
39
  http?: CreateHttpOptions;
40
40
  }
41
41
  interface ToastOptions extends Omit<Partial<MessageOptions>, 'icon'> {
42
- /** 是否解析 HTML 字符串,并将已全局注册的组件标签渲染为 Vue 组件;默认 false。仅传可信内容。 */
42
+ /** 是否解析 HTML 字符串,并将已全局注册的组件标签渲染为 Vue 组件;默认 true。仅传可信内容。 */
43
43
  dangerouslyUseHTMLString?: boolean;
44
44
  /** 图标组件,或由全局 SIcon 自动解析的图标名称。 */
45
45
  icon?: string | Component;
package/dist/base.d.ts CHANGED
@@ -39,7 +39,7 @@ interface SybzUtilsConfig {
39
39
  http?: CreateHttpOptions;
40
40
  }
41
41
  interface ToastOptions extends Omit<Partial<MessageOptions>, 'icon'> {
42
- /** 是否解析 HTML 字符串,并将已全局注册的组件标签渲染为 Vue 组件;默认 false。仅传可信内容。 */
42
+ /** 是否解析 HTML 字符串,并将已全局注册的组件标签渲染为 Vue 组件;默认 true。仅传可信内容。 */
43
43
  dangerouslyUseHTMLString?: boolean;
44
44
  /** 图标组件,或由全局 SIcon 自动解析的图标名称。 */
45
45
  icon?: string | Component;
package/dist/base.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import 'vue';
2
2
  import 'consola';
3
3
  import 'es-toolkit';
4
- export { $ as $toast, c as clearStorage, a as clone, b as configureUtils, d as confirm, e as copy, f as debounce, g as delay, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.D0Voi5F1.mjs';
4
+ export { $ as $toast, c as clearStorage, a as clone, b as configureUtils, d as confirm, e as copy, f as debounce, g as delay, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.BNdsPonV.mjs';
5
5
  import './confirmSemantic.mjs';
6
6
  import 'element-plus';
7
7
  import 'axios';
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  function resolveConfirmSemantic(options = {}) {
4
- const variant = options.variant ?? "default";
4
+ var _a, _b, _c, _d, _e;
5
+ const variant = (_a = options.variant) != null ? _a : "default";
5
6
  const hasTarget = options.target !== void 0;
6
- const title = options.title ?? (variant === "delete" ? "\u5220\u9664\u786E\u8BA4" : variant === "warning" ? "\u8B66\u544A" : "\u63D0\u793A");
7
- const confirmButtonText = options.confirmButtonText ?? (variant === "delete" ? "\u5220\u9664" : "\u786E\u5B9A");
8
- const confirmButtonType = options.confirmButtonType ?? (variant === "delete" ? "danger" : variant === "warning" ? "warning" : "primary");
7
+ const title = (_b = options.title) != null ? _b : variant === "delete" ? "\u5220\u9664\u786E\u8BA4" : variant === "warning" ? "\u8B66\u544A" : "\u63D0\u793A";
8
+ const confirmButtonText = (_c = options.confirmButtonText) != null ? _c : variant === "delete" ? "\u5220\u9664" : "\u786E\u5B9A";
9
+ const confirmButtonType = (_d = options.confirmButtonType) != null ? _d : variant === "delete" ? "danger" : variant === "warning" ? "warning" : "primary";
9
10
  const defaultMessage = variant === "delete" ? hasTarget ? `\u786E\u8BA4\u8981\u5220\u9664${String(options.target)}\u5417\uFF1F\u5220\u9664\u540E\u4E0D\u53EF\u6062\u590D\u3002` : "\u5220\u9664\u540E\u6570\u636E\u5C06\u65E0\u6CD5\u6062\u590D\uFF0C\u786E\u5B9A\u7EE7\u7EED\u5417\uFF1F" : "";
10
- const theme = options.theme ?? "default";
11
+ const theme = (_e = options.theme) != null ? _e : "default";
11
12
  return {
12
13
  variant,
13
14
  target: options.target,
@@ -1,11 +1,12 @@
1
1
  function resolveConfirmSemantic(options = {}) {
2
- const variant = options.variant ?? "default";
2
+ var _a, _b, _c, _d, _e;
3
+ const variant = (_a = options.variant) != null ? _a : "default";
3
4
  const hasTarget = options.target !== void 0;
4
- const title = options.title ?? (variant === "delete" ? "\u5220\u9664\u786E\u8BA4" : variant === "warning" ? "\u8B66\u544A" : "\u63D0\u793A");
5
- const confirmButtonText = options.confirmButtonText ?? (variant === "delete" ? "\u5220\u9664" : "\u786E\u5B9A");
6
- const confirmButtonType = options.confirmButtonType ?? (variant === "delete" ? "danger" : variant === "warning" ? "warning" : "primary");
5
+ const title = (_b = options.title) != null ? _b : variant === "delete" ? "\u5220\u9664\u786E\u8BA4" : variant === "warning" ? "\u8B66\u544A" : "\u63D0\u793A";
6
+ const confirmButtonText = (_c = options.confirmButtonText) != null ? _c : variant === "delete" ? "\u5220\u9664" : "\u786E\u5B9A";
7
+ const confirmButtonType = (_d = options.confirmButtonType) != null ? _d : variant === "delete" ? "danger" : variant === "warning" ? "warning" : "primary";
7
8
  const defaultMessage = variant === "delete" ? hasTarget ? `\u786E\u8BA4\u8981\u5220\u9664${String(options.target)}\u5417\uFF1F\u5220\u9664\u540E\u4E0D\u53EF\u6062\u590D\u3002` : "\u5220\u9664\u540E\u6570\u636E\u5C06\u65E0\u6CD5\u6062\u590D\uFF0C\u786E\u5B9A\u7EE7\u7EED\u5417\uFF1F" : "";
8
- const theme = options.theme ?? "default";
9
+ const theme = (_e = options.theme) != null ? _e : "default";
9
10
  return {
10
11
  variant,
11
12
  target: options.target,
package/dist/format.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const format = require('./shared/utils.nuyKxZXX.cjs');
3
+ const format = require('./shared/utils.CshLEFSw.cjs');
4
4
  require('./is.cjs');
5
5
  require('consola');
6
6
  require('vue');
package/dist/format.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.D0Voi5F1.mjs';
1
+ export { z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.BNdsPonV.mjs';
2
2
  import './is.mjs';
3
3
  import 'consola';
4
4
  import 'vue';
@@ -15,7 +15,7 @@ const runGit = (cwd, args) => {
15
15
  encoding: "utf8",
16
16
  stdio: ["ignore", "pipe", "ignore"]
17
17
  }).trim();
18
- } catch {
18
+ } catch (e) {
19
19
  return "";
20
20
  }
21
21
  };
@@ -27,13 +27,14 @@ const getCommitUrl = (repository, hash) => {
27
27
  const readProjectPackage = (cwd) => {
28
28
  try {
29
29
  return JSON.parse(node_fs.readFileSync(node_path.resolve(cwd, "package.json"), "utf8"));
30
- } catch {
30
+ } catch (e) {
31
31
  return {};
32
32
  }
33
33
  };
34
34
  const createGitCommitLogInfo = (cwd, maxCommits, mode) => {
35
+ var _a;
35
36
  const packageInfo = readProjectPackage(cwd);
36
- const packageRepository = typeof packageInfo.repository === "string" ? packageInfo.repository : packageInfo.repository?.url || "";
37
+ const packageRepository = typeof packageInfo.repository === "string" ? packageInfo.repository : ((_a = packageInfo.repository) == null ? void 0 : _a.url) || "";
37
38
  const repository = normalizeRepositoryUrl(packageRepository || runGit(cwd, ["remote", "get-url", "origin"]));
38
39
  const output = runGit(cwd, ["log", `-${maxCommits}`, "--pretty=format:%H%x1f%h%x1f%an%x1f%ae%x1f%aI%x1f%s"]);
39
40
  const commits = output.split("\n").filter(Boolean).map((line) => {
@@ -134,12 +135,13 @@ const gitCommitLog = (options = {}) => {
134
135
  transformIndexHtml: {
135
136
  order: "pre",
136
137
  handler() {
138
+ var _a, _b;
137
139
  const cwd = node_path.resolve(options.cwd || viteRoot);
138
140
  const info = createGitCommitLogInfo(cwd, maxCommits, viteMode);
139
141
  return [
140
142
  {
141
143
  tag: "script",
142
- children: createClientCode(info, defaultLimit, options.autoPrint ?? true, options.expanded ?? false),
144
+ children: createClientCode(info, defaultLimit, (_a = options.autoPrint) != null ? _a : true, (_b = options.expanded) != null ? _b : false),
143
145
  injectTo: "head-prepend"
144
146
  }
145
147
  ];
@@ -13,7 +13,7 @@ const runGit = (cwd, args) => {
13
13
  encoding: "utf8",
14
14
  stdio: ["ignore", "pipe", "ignore"]
15
15
  }).trim();
16
- } catch {
16
+ } catch (e) {
17
17
  return "";
18
18
  }
19
19
  };
@@ -25,13 +25,14 @@ const getCommitUrl = (repository, hash) => {
25
25
  const readProjectPackage = (cwd) => {
26
26
  try {
27
27
  return JSON.parse(readFileSync(resolve(cwd, "package.json"), "utf8"));
28
- } catch {
28
+ } catch (e) {
29
29
  return {};
30
30
  }
31
31
  };
32
32
  const createGitCommitLogInfo = (cwd, maxCommits, mode) => {
33
+ var _a;
33
34
  const packageInfo = readProjectPackage(cwd);
34
- const packageRepository = typeof packageInfo.repository === "string" ? packageInfo.repository : packageInfo.repository?.url || "";
35
+ const packageRepository = typeof packageInfo.repository === "string" ? packageInfo.repository : ((_a = packageInfo.repository) == null ? void 0 : _a.url) || "";
35
36
  const repository = normalizeRepositoryUrl(packageRepository || runGit(cwd, ["remote", "get-url", "origin"]));
36
37
  const output = runGit(cwd, ["log", `-${maxCommits}`, "--pretty=format:%H%x1f%h%x1f%an%x1f%ae%x1f%aI%x1f%s"]);
37
38
  const commits = output.split("\n").filter(Boolean).map((line) => {
@@ -132,12 +133,13 @@ const gitCommitLog = (options = {}) => {
132
133
  transformIndexHtml: {
133
134
  order: "pre",
134
135
  handler() {
136
+ var _a, _b;
135
137
  const cwd = resolve(options.cwd || viteRoot);
136
138
  const info = createGitCommitLogInfo(cwd, maxCommits, viteMode);
137
139
  return [
138
140
  {
139
141
  tag: "script",
140
- children: createClientCode(info, defaultLimit, options.autoPrint ?? true, options.expanded ?? false),
142
+ children: createClientCode(info, defaultLimit, (_a = options.autoPrint) != null ? _a : true, (_b = options.expanded) != null ? _b : false),
141
143
  injectTo: "head-prepend"
142
144
  }
143
145
  ];
package/dist/http.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  require('axios');
4
- const format = require('./shared/utils.nuyKxZXX.cjs');
4
+ const format = require('./shared/utils.CshLEFSw.cjs');
5
5
  require('vue');
6
6
  require('consola');
7
7
  require('es-toolkit');
package/dist/http.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import 'axios';
2
- export { H as HttpError, G as configureHttp, I as createHttp, J as http } from './shared/utils.D0Voi5F1.mjs';
2
+ export { H as HttpError, G as configureHttp, I as createHttp, J as http } from './shared/utils.BNdsPonV.mjs';
3
3
  import 'vue';
4
4
  import 'consola';
5
5
  import 'es-toolkit';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const format = require('./shared/utils.nuyKxZXX.cjs');
3
+ const format = require('./shared/utils.CshLEFSw.cjs');
4
4
  const confirmSemantic = require('./confirmSemantic.cjs');
5
5
  const is = require('./is.cjs');
6
6
  const theme = require('./theme.cjs');
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { $ as $toast, H as HttpError, c as clearStorage, a as clone, G as configureHttp, b as configureUtils, d as confirm, e as copy, I as createHttp, f as debounce, g as delay, z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, J as http, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.D0Voi5F1.mjs';
1
+ export { $ as $toast, H as HttpError, c as clearStorage, a as clone, G as configureHttp, b as configureUtils, d as confirm, e as copy, I as createHttp, f as debounce, g as delay, z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, J as http, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.BNdsPonV.mjs';
2
2
  export { resolveConfirmSemantic } from './confirmSemantic.mjs';
3
3
  export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.mjs';
4
4
  export { SYBZ_THEME_PREFIX, isSybzTheme, resolveSybzComponentTheme } from './theme.mjs';
@@ -0,0 +1,99 @@
1
+ 'use strict';
2
+
3
+ const node_module = require('node:module');
4
+
5
+ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
6
+ const require2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('postcss.cjs', document.baseURI).href)));
7
+ const postcssPresetEnv = require2("postcss-preset-env");
8
+ const SYBZ_COMPAT_BROWSERS = ["chrome >= 60", "safari >= 12", "firefox >= 60", "edge >= 79"];
9
+ const viewportUnitFallbacks = () => ({
10
+ postcssPlugin: "sybz-viewport-unit-fallbacks",
11
+ Declaration(decl) {
12
+ if (decl.prop.startsWith("--")) return;
13
+ if (!/\d(?:dvh|dvw|svh|svw|lvh|lvw)\b/.test(decl.value)) return;
14
+ const fallback = decl.value.replace(
15
+ /(\d*\.?\d+)(dvh|dvw|svh|svw|lvh|lvw)\b/g,
16
+ (_match, value, unit) => `${value}${unit.endsWith("h") ? "vh" : "vw"}`
17
+ );
18
+ if (fallback === decl.value) return;
19
+ decl.cloneBefore({ value: fallback });
20
+ }
21
+ });
22
+ const insetFallbacks = () => ({
23
+ postcssPlugin: "sybz-inset-fallbacks",
24
+ Declaration(decl) {
25
+ if (decl.prop !== "inset") return;
26
+ const values = decl.value.trim().split(/\s+(?![^(]*\))/);
27
+ if (!values.length || values.length > 4) return;
28
+ const [top, right = top, bottom = top, left = right] = values;
29
+ decl.cloneBefore({ prop: "top", value: top });
30
+ decl.cloneBefore({ prop: "right", value: right });
31
+ decl.cloneBefore({ prop: "bottom", value: bottom });
32
+ decl.cloneBefore({ prop: "left", value: left });
33
+ }
34
+ });
35
+ const UNSUPPORTED_SELECTOR_RE = /:(?:focus-visible|where|has)\b/i;
36
+ const splitSelectorList = (selector) => {
37
+ const selectors = [];
38
+ let start = 0;
39
+ let depth = 0;
40
+ let quote = "";
41
+ for (let index = 0; index < selector.length; index += 1) {
42
+ const char = selector[index];
43
+ if (quote) {
44
+ if (char === "\\") index += 1;
45
+ else if (char === quote) quote = "";
46
+ continue;
47
+ }
48
+ if (char === '"' || char === "'") {
49
+ quote = char;
50
+ continue;
51
+ }
52
+ if (char === "\\") {
53
+ index += 1;
54
+ continue;
55
+ }
56
+ if (char === "(" || char === "[") {
57
+ depth += 1;
58
+ continue;
59
+ }
60
+ if (char === ")" || char === "]") {
61
+ depth = Math.max(0, depth - 1);
62
+ continue;
63
+ }
64
+ if (char === "," && depth === 0) {
65
+ selectors.push(selector.slice(start, index).trim());
66
+ start = index + 1;
67
+ }
68
+ }
69
+ selectors.push(selector.slice(start).trim());
70
+ return selectors.filter(Boolean);
71
+ };
72
+ const selectorListFallbacks = () => ({
73
+ postcssPlugin: "sybz-selector-list-fallbacks",
74
+ Rule(rule) {
75
+ if (!UNSUPPORTED_SELECTOR_RE.test(rule.selector)) return;
76
+ const selectors = splitSelectorList(rule.selector);
77
+ if (selectors.length < 2) return;
78
+ rule.replaceWith(...selectors.map((selector) => rule.clone({ selector })));
79
+ }
80
+ });
81
+ const createSybzCompatPostcssPlugins = (options = {}) => {
82
+ var _a;
83
+ return [
84
+ postcssPresetEnv({
85
+ stage: 2,
86
+ browsers: (_a = options.browsers) != null ? _a : SYBZ_COMPAT_BROWSERS,
87
+ features: {
88
+ "nesting-rules": false,
89
+ "custom-properties": false
90
+ }
91
+ }),
92
+ selectorListFallbacks(),
93
+ viewportUnitFallbacks(),
94
+ insetFallbacks()
95
+ ];
96
+ };
97
+
98
+ exports.SYBZ_COMPAT_BROWSERS = SYBZ_COMPAT_BROWSERS;
99
+ exports.createSybzCompatPostcssPlugins = createSybzCompatPostcssPlugins;
@@ -0,0 +1,16 @@
1
+ import { Plugin } from 'postcss';
2
+
3
+ /** 与组件库、`scripts/build-compat.mjs` 保持一致。 */
4
+ declare const SYBZ_COMPAT_BROWSERS: string[];
5
+ interface SybzCompatPostcssOptions {
6
+ /** PostCSS 的目标浏览器,默认 Chrome 60+。 */
7
+ browsers?: string[];
8
+ }
9
+ /**
10
+ * 业务项目使用 `sybzVitePlugins({ compat: true })` 时自动注入的 PostCSS 兼容插件。
11
+ * 单独导出是为了兼容已有 postcss.config 的项目手动合并。
12
+ */
13
+ declare const createSybzCompatPostcssPlugins: (options?: SybzCompatPostcssOptions) => Plugin[];
14
+
15
+ export { SYBZ_COMPAT_BROWSERS, createSybzCompatPostcssPlugins };
16
+ export type { SybzCompatPostcssOptions };
@@ -0,0 +1,16 @@
1
+ import { Plugin } from 'postcss';
2
+
3
+ /** 与组件库、`scripts/build-compat.mjs` 保持一致。 */
4
+ declare const SYBZ_COMPAT_BROWSERS: string[];
5
+ interface SybzCompatPostcssOptions {
6
+ /** PostCSS 的目标浏览器,默认 Chrome 60+。 */
7
+ browsers?: string[];
8
+ }
9
+ /**
10
+ * 业务项目使用 `sybzVitePlugins({ compat: true })` 时自动注入的 PostCSS 兼容插件。
11
+ * 单独导出是为了兼容已有 postcss.config 的项目手动合并。
12
+ */
13
+ declare const createSybzCompatPostcssPlugins: (options?: SybzCompatPostcssOptions) => Plugin[];
14
+
15
+ export { SYBZ_COMPAT_BROWSERS, createSybzCompatPostcssPlugins };
16
+ export type { SybzCompatPostcssOptions };
@@ -0,0 +1,16 @@
1
+ import { Plugin } from 'postcss';
2
+
3
+ /** 与组件库、`scripts/build-compat.mjs` 保持一致。 */
4
+ declare const SYBZ_COMPAT_BROWSERS: string[];
5
+ interface SybzCompatPostcssOptions {
6
+ /** PostCSS 的目标浏览器,默认 Chrome 60+。 */
7
+ browsers?: string[];
8
+ }
9
+ /**
10
+ * 业务项目使用 `sybzVitePlugins({ compat: true })` 时自动注入的 PostCSS 兼容插件。
11
+ * 单独导出是为了兼容已有 postcss.config 的项目手动合并。
12
+ */
13
+ declare const createSybzCompatPostcssPlugins: (options?: SybzCompatPostcssOptions) => Plugin[];
14
+
15
+ export { SYBZ_COMPAT_BROWSERS, createSybzCompatPostcssPlugins };
16
+ export type { SybzCompatPostcssOptions };
@@ -0,0 +1,95 @@
1
+ import { createRequire } from 'node:module';
2
+
3
+ const require2 = createRequire(import.meta.url);
4
+ const postcssPresetEnv = require2("postcss-preset-env");
5
+ const SYBZ_COMPAT_BROWSERS = ["chrome >= 60", "safari >= 12", "firefox >= 60", "edge >= 79"];
6
+ const viewportUnitFallbacks = () => ({
7
+ postcssPlugin: "sybz-viewport-unit-fallbacks",
8
+ Declaration(decl) {
9
+ if (decl.prop.startsWith("--")) return;
10
+ if (!/\d(?:dvh|dvw|svh|svw|lvh|lvw)\b/.test(decl.value)) return;
11
+ const fallback = decl.value.replace(
12
+ /(\d*\.?\d+)(dvh|dvw|svh|svw|lvh|lvw)\b/g,
13
+ (_match, value, unit) => `${value}${unit.endsWith("h") ? "vh" : "vw"}`
14
+ );
15
+ if (fallback === decl.value) return;
16
+ decl.cloneBefore({ value: fallback });
17
+ }
18
+ });
19
+ const insetFallbacks = () => ({
20
+ postcssPlugin: "sybz-inset-fallbacks",
21
+ Declaration(decl) {
22
+ if (decl.prop !== "inset") return;
23
+ const values = decl.value.trim().split(/\s+(?![^(]*\))/);
24
+ if (!values.length || values.length > 4) return;
25
+ const [top, right = top, bottom = top, left = right] = values;
26
+ decl.cloneBefore({ prop: "top", value: top });
27
+ decl.cloneBefore({ prop: "right", value: right });
28
+ decl.cloneBefore({ prop: "bottom", value: bottom });
29
+ decl.cloneBefore({ prop: "left", value: left });
30
+ }
31
+ });
32
+ const UNSUPPORTED_SELECTOR_RE = /:(?:focus-visible|where|has)\b/i;
33
+ const splitSelectorList = (selector) => {
34
+ const selectors = [];
35
+ let start = 0;
36
+ let depth = 0;
37
+ let quote = "";
38
+ for (let index = 0; index < selector.length; index += 1) {
39
+ const char = selector[index];
40
+ if (quote) {
41
+ if (char === "\\") index += 1;
42
+ else if (char === quote) quote = "";
43
+ continue;
44
+ }
45
+ if (char === '"' || char === "'") {
46
+ quote = char;
47
+ continue;
48
+ }
49
+ if (char === "\\") {
50
+ index += 1;
51
+ continue;
52
+ }
53
+ if (char === "(" || char === "[") {
54
+ depth += 1;
55
+ continue;
56
+ }
57
+ if (char === ")" || char === "]") {
58
+ depth = Math.max(0, depth - 1);
59
+ continue;
60
+ }
61
+ if (char === "," && depth === 0) {
62
+ selectors.push(selector.slice(start, index).trim());
63
+ start = index + 1;
64
+ }
65
+ }
66
+ selectors.push(selector.slice(start).trim());
67
+ return selectors.filter(Boolean);
68
+ };
69
+ const selectorListFallbacks = () => ({
70
+ postcssPlugin: "sybz-selector-list-fallbacks",
71
+ Rule(rule) {
72
+ if (!UNSUPPORTED_SELECTOR_RE.test(rule.selector)) return;
73
+ const selectors = splitSelectorList(rule.selector);
74
+ if (selectors.length < 2) return;
75
+ rule.replaceWith(...selectors.map((selector) => rule.clone({ selector })));
76
+ }
77
+ });
78
+ const createSybzCompatPostcssPlugins = (options = {}) => {
79
+ var _a;
80
+ return [
81
+ postcssPresetEnv({
82
+ stage: 2,
83
+ browsers: (_a = options.browsers) != null ? _a : SYBZ_COMPAT_BROWSERS,
84
+ features: {
85
+ "nesting-rules": false,
86
+ "custom-properties": false
87
+ }
88
+ }),
89
+ selectorListFallbacks(),
90
+ viewportUnitFallbacks(),
91
+ insetFallbacks()
92
+ ];
93
+ };
94
+
95
+ export { SYBZ_COMPAT_BROWSERS, createSybzCompatPostcssPlugins };