@windrun-huaiin/third-ui 31.3.2 → 31.3.4

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.
@@ -262,6 +262,13 @@ function applyHandDrawnStyle(svg) {
262
262
  target.setAttribute(attr, (_a = source.getAttribute(attr)) !== null && _a !== void 0 ? _a : '');
263
263
  }
264
264
  };
265
+ const shouldSkipHandDrawn = (element) => {
266
+ if (element.closest('defs'))
267
+ return true;
268
+ if (element.hasAttribute('marker-start') || element.hasAttribute('marker-end') || element.hasAttribute('marker-mid'))
269
+ return true;
270
+ return false;
271
+ };
265
272
  const createOptions = (element) => {
266
273
  var _a, _b;
267
274
  const stroke = (_a = getStyleValue(element, 'stroke')) !== null && _a !== void 0 ? _a : '#000';
@@ -294,6 +301,8 @@ function applyHandDrawnStyle(svg) {
294
301
  element.parentNode.replaceChild(node, element);
295
302
  };
296
303
  svgElement.querySelectorAll('rect').forEach((element) => {
304
+ if (shouldSkipHandDrawn(element))
305
+ return;
297
306
  const x = getNumber(element.getAttribute('x'));
298
307
  const y = getNumber(element.getAttribute('y'));
299
308
  const width = getNumber(element.getAttribute('width'));
@@ -315,11 +324,15 @@ function applyHandDrawnStyle(svg) {
315
324
  replaceShape(element, node);
316
325
  });
317
326
  svgElement.querySelectorAll('line').forEach((element) => {
327
+ if (shouldSkipHandDrawn(element))
328
+ return;
318
329
  const node = rc.line(getNumber(element.getAttribute('x1')), getNumber(element.getAttribute('y1')), getNumber(element.getAttribute('x2')), getNumber(element.getAttribute('y2')), createOptions(element));
319
330
  replaceShape(element, node);
320
331
  });
321
332
  svgElement.querySelectorAll('polyline').forEach((element) => {
322
333
  var _a;
334
+ if (shouldSkipHandDrawn(element))
335
+ return;
323
336
  const points = ((_a = element.getAttribute('points')) !== null && _a !== void 0 ? _a : '')
324
337
  .trim()
325
338
  .split(/\s+/)
@@ -332,6 +345,8 @@ function applyHandDrawnStyle(svg) {
332
345
  });
333
346
  svgElement.querySelectorAll('polygon').forEach((element) => {
334
347
  var _a;
348
+ if (shouldSkipHandDrawn(element))
349
+ return;
335
350
  const points = ((_a = element.getAttribute('points')) !== null && _a !== void 0 ? _a : '')
336
351
  .trim()
337
352
  .split(/\s+/)
@@ -343,6 +358,8 @@ function applyHandDrawnStyle(svg) {
343
358
  replaceShape(element, node);
344
359
  });
345
360
  svgElement.querySelectorAll('path').forEach((element) => {
361
+ if (shouldSkipHandDrawn(element))
362
+ return;
346
363
  const d = element.getAttribute('d');
347
364
  if (!d)
348
365
  return;
@@ -260,6 +260,13 @@ function applyHandDrawnStyle(svg) {
260
260
  target.setAttribute(attr, (_a = source.getAttribute(attr)) !== null && _a !== void 0 ? _a : '');
261
261
  }
262
262
  };
263
+ const shouldSkipHandDrawn = (element) => {
264
+ if (element.closest('defs'))
265
+ return true;
266
+ if (element.hasAttribute('marker-start') || element.hasAttribute('marker-end') || element.hasAttribute('marker-mid'))
267
+ return true;
268
+ return false;
269
+ };
263
270
  const createOptions = (element) => {
264
271
  var _a, _b;
265
272
  const stroke = (_a = getStyleValue(element, 'stroke')) !== null && _a !== void 0 ? _a : '#000';
@@ -292,6 +299,8 @@ function applyHandDrawnStyle(svg) {
292
299
  element.parentNode.replaceChild(node, element);
293
300
  };
294
301
  svgElement.querySelectorAll('rect').forEach((element) => {
302
+ if (shouldSkipHandDrawn(element))
303
+ return;
295
304
  const x = getNumber(element.getAttribute('x'));
296
305
  const y = getNumber(element.getAttribute('y'));
297
306
  const width = getNumber(element.getAttribute('width'));
@@ -313,11 +322,15 @@ function applyHandDrawnStyle(svg) {
313
322
  replaceShape(element, node);
314
323
  });
315
324
  svgElement.querySelectorAll('line').forEach((element) => {
325
+ if (shouldSkipHandDrawn(element))
326
+ return;
316
327
  const node = rc.line(getNumber(element.getAttribute('x1')), getNumber(element.getAttribute('y1')), getNumber(element.getAttribute('x2')), getNumber(element.getAttribute('y2')), createOptions(element));
317
328
  replaceShape(element, node);
318
329
  });
319
330
  svgElement.querySelectorAll('polyline').forEach((element) => {
320
331
  var _a;
332
+ if (shouldSkipHandDrawn(element))
333
+ return;
321
334
  const points = ((_a = element.getAttribute('points')) !== null && _a !== void 0 ? _a : '')
322
335
  .trim()
323
336
  .split(/\s+/)
@@ -330,6 +343,8 @@ function applyHandDrawnStyle(svg) {
330
343
  });
331
344
  svgElement.querySelectorAll('polygon').forEach((element) => {
332
345
  var _a;
346
+ if (shouldSkipHandDrawn(element))
347
+ return;
333
348
  const points = ((_a = element.getAttribute('points')) !== null && _a !== void 0 ? _a : '')
334
349
  .trim()
335
350
  .split(/\s+/)
@@ -341,6 +356,8 @@ function applyHandDrawnStyle(svg) {
341
356
  replaceShape(element, node);
342
357
  });
343
358
  svgElement.querySelectorAll('path').forEach((element) => {
359
+ if (shouldSkipHandDrawn(element))
360
+ return;
344
361
  const d = element.getAttribute('d');
345
362
  if (!d)
346
363
  return;
@@ -11,16 +11,22 @@ const DEFAULT_SITE_ICONS = [
11
11
  { rel: 'apple-touch-icon', sizes: '180x180', url: '/favicon-180x180.png' },
12
12
  { rel: 'android-chrome', sizes: '512x512', url: '/favicon-512x512.png' },
13
13
  ];
14
+ function joinBaseUrl(baseUrl, path) {
15
+ const normalizedBaseUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
16
+ if (path === '/') {
17
+ return `${normalizedBaseUrl}/`;
18
+ }
19
+ return `${normalizedBaseUrl}${path}`;
20
+ }
14
21
  function buildAlternateUrls(options) {
15
22
  const { baseUrl, defaultLocale, locale, localePrefixAsNeeded, locales, pathname } = options;
16
23
  const canonicalPath = utils.getAsNeededLocalizedUrl(locale, pathname, localePrefixAsNeeded, defaultLocale);
17
- const canonical = `${baseUrl}${canonicalPath}`;
18
24
  const languages = Object.fromEntries(locales.map((siteLocale) => [
19
25
  siteLocale,
20
- `${baseUrl}${utils.getAsNeededLocalizedUrl(siteLocale, pathname, localePrefixAsNeeded, defaultLocale)}`,
26
+ joinBaseUrl(baseUrl, utils.getAsNeededLocalizedUrl(siteLocale, pathname, localePrefixAsNeeded, defaultLocale)),
21
27
  ]));
22
28
  return {
23
- canonical,
29
+ canonical: joinBaseUrl(baseUrl, canonicalPath),
24
30
  languages,
25
31
  };
26
32
  }
@@ -52,6 +58,12 @@ function getEnvText(value) {
52
58
  const trimmed = value === null || value === void 0 ? void 0 : value.trim();
53
59
  return trimmed ? trimmed : undefined;
54
60
  }
61
+ function omitUndefined(value) {
62
+ if (!value)
63
+ return undefined;
64
+ const entries = Object.entries(value).filter(([, item]) => item !== undefined);
65
+ return entries.length > 0 ? Object.fromEntries(entries) : undefined;
66
+ }
55
67
  function resolveMetadataOverrides(options) {
56
68
  return tslib.__awaiter(this, void 0, void 0, function* () {
57
69
  var _a, _b, _c;
@@ -98,12 +110,14 @@ function createLocalizedSiteMetadata(options) {
98
110
  function createLocalizedPageMetadata(options) {
99
111
  var _a, _b, _c, _d;
100
112
  const { page, site, url } = options;
101
- const { baseUrl } = url;
102
113
  const alternates = buildAlternateUrls(url);
103
- const openGraph = Object.assign(Object.assign(Object.assign({}, site === null || site === void 0 ? void 0 : site.openGraph), page === null || page === void 0 ? void 0 : page.openGraph), { url: alternates.canonical });
104
- const twitter = Object.assign(Object.assign({}, site === null || site === void 0 ? void 0 : site.twitter), page === null || page === void 0 ? void 0 : page.twitter);
114
+ const siteOpenGraph = omitUndefined(site === null || site === void 0 ? void 0 : site.openGraph);
115
+ const pageOpenGraph = omitUndefined(page === null || page === void 0 ? void 0 : page.openGraph);
116
+ const openGraph = Object.assign(Object.assign(Object.assign({}, siteOpenGraph), pageOpenGraph), { url: alternates.canonical });
117
+ const siteTwitter = omitUndefined(site === null || site === void 0 ? void 0 : site.twitter);
118
+ const pageTwitter = omitUndefined(page === null || page === void 0 ? void 0 : page.twitter);
119
+ const twitter = Object.assign(Object.assign({}, siteTwitter), pageTwitter);
105
120
  return {
106
- metadataBase: new URL(baseUrl),
107
121
  title: (_a = page === null || page === void 0 ? void 0 : page.title) !== null && _a !== void 0 ? _a : site === null || site === void 0 ? void 0 : site.title,
108
122
  description: (_b = page === null || page === void 0 ? void 0 : page.description) !== null && _b !== void 0 ? _b : site === null || site === void 0 ? void 0 : site.description,
109
123
  keywords: (_c = page === null || page === void 0 ? void 0 : page.keywords) !== null && _c !== void 0 ? _c : site === null || site === void 0 ? void 0 : site.keywords,
@@ -9,16 +9,22 @@ const DEFAULT_SITE_ICONS = [
9
9
  { rel: 'apple-touch-icon', sizes: '180x180', url: '/favicon-180x180.png' },
10
10
  { rel: 'android-chrome', sizes: '512x512', url: '/favicon-512x512.png' },
11
11
  ];
12
+ function joinBaseUrl(baseUrl, path) {
13
+ const normalizedBaseUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
14
+ if (path === '/') {
15
+ return `${normalizedBaseUrl}/`;
16
+ }
17
+ return `${normalizedBaseUrl}${path}`;
18
+ }
12
19
  function buildAlternateUrls(options) {
13
20
  const { baseUrl, defaultLocale, locale, localePrefixAsNeeded, locales, pathname } = options;
14
21
  const canonicalPath = getAsNeededLocalizedUrl(locale, pathname, localePrefixAsNeeded, defaultLocale);
15
- const canonical = `${baseUrl}${canonicalPath}`;
16
22
  const languages = Object.fromEntries(locales.map((siteLocale) => [
17
23
  siteLocale,
18
- `${baseUrl}${getAsNeededLocalizedUrl(siteLocale, pathname, localePrefixAsNeeded, defaultLocale)}`,
24
+ joinBaseUrl(baseUrl, getAsNeededLocalizedUrl(siteLocale, pathname, localePrefixAsNeeded, defaultLocale)),
19
25
  ]));
20
26
  return {
21
- canonical,
27
+ canonical: joinBaseUrl(baseUrl, canonicalPath),
22
28
  languages,
23
29
  };
24
30
  }
@@ -50,6 +56,12 @@ function getEnvText(value) {
50
56
  const trimmed = value === null || value === void 0 ? void 0 : value.trim();
51
57
  return trimmed ? trimmed : undefined;
52
58
  }
59
+ function omitUndefined(value) {
60
+ if (!value)
61
+ return undefined;
62
+ const entries = Object.entries(value).filter(([, item]) => item !== undefined);
63
+ return entries.length > 0 ? Object.fromEntries(entries) : undefined;
64
+ }
53
65
  function resolveMetadataOverrides(options) {
54
66
  return __awaiter(this, void 0, void 0, function* () {
55
67
  var _a, _b, _c;
@@ -96,12 +108,14 @@ function createLocalizedSiteMetadata(options) {
96
108
  function createLocalizedPageMetadata(options) {
97
109
  var _a, _b, _c, _d;
98
110
  const { page, site, url } = options;
99
- const { baseUrl } = url;
100
111
  const alternates = buildAlternateUrls(url);
101
- const openGraph = Object.assign(Object.assign(Object.assign({}, site === null || site === void 0 ? void 0 : site.openGraph), page === null || page === void 0 ? void 0 : page.openGraph), { url: alternates.canonical });
102
- const twitter = Object.assign(Object.assign({}, site === null || site === void 0 ? void 0 : site.twitter), page === null || page === void 0 ? void 0 : page.twitter);
112
+ const siteOpenGraph = omitUndefined(site === null || site === void 0 ? void 0 : site.openGraph);
113
+ const pageOpenGraph = omitUndefined(page === null || page === void 0 ? void 0 : page.openGraph);
114
+ const openGraph = Object.assign(Object.assign(Object.assign({}, siteOpenGraph), pageOpenGraph), { url: alternates.canonical });
115
+ const siteTwitter = omitUndefined(site === null || site === void 0 ? void 0 : site.twitter);
116
+ const pageTwitter = omitUndefined(page === null || page === void 0 ? void 0 : page.twitter);
117
+ const twitter = Object.assign(Object.assign({}, siteTwitter), pageTwitter);
103
118
  return {
104
- metadataBase: new URL(baseUrl),
105
119
  title: (_a = page === null || page === void 0 ? void 0 : page.title) !== null && _a !== void 0 ? _a : site === null || site === void 0 ? void 0 : site.title,
106
120
  description: (_b = page === null || page === void 0 ? void 0 : page.description) !== null && _b !== void 0 ? _b : site === null || site === void 0 ? void 0 : site.description,
107
121
  keywords: (_c = page === null || page === void 0 ? void 0 : page.keywords) !== null && _c !== void 0 ? _c : site === null || site === void 0 ? void 0 : site.keywords,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/third-ui",
3
- "version": "31.3.2",
3
+ "version": "31.3.4",
4
4
  "description": "Third-party integrated UI components for windrun-huaiin projects",
5
5
  "exports": {
6
6
  "./clerk": {
@@ -439,6 +439,11 @@ function applyHandDrawnStyle(svg: string) {
439
439
  target.setAttribute(attr, source.getAttribute(attr) ?? '');
440
440
  }
441
441
  };
442
+ const shouldSkipHandDrawn = (element: Element) => {
443
+ if (element.closest('defs')) return true;
444
+ if (element.hasAttribute('marker-start') || element.hasAttribute('marker-end') || element.hasAttribute('marker-mid')) return true;
445
+ return false;
446
+ };
442
447
  const createOptions = (element: Element) => {
443
448
  const stroke = getStyleValue(element, 'stroke') ?? '#000';
444
449
  const fill = getStyleValue(element, 'fill') ?? 'none';
@@ -469,6 +474,7 @@ function applyHandDrawnStyle(svg: string) {
469
474
  };
470
475
 
471
476
  svgElement.querySelectorAll('rect').forEach((element) => {
477
+ if (shouldSkipHandDrawn(element)) return;
472
478
  const x = getNumber(element.getAttribute('x'));
473
479
  const y = getNumber(element.getAttribute('y'));
474
480
  const width = getNumber(element.getAttribute('width'));
@@ -500,6 +506,7 @@ function applyHandDrawnStyle(svg: string) {
500
506
  });
501
507
 
502
508
  svgElement.querySelectorAll('line').forEach((element) => {
509
+ if (shouldSkipHandDrawn(element)) return;
503
510
  const node = rc.line(
504
511
  getNumber(element.getAttribute('x1')),
505
512
  getNumber(element.getAttribute('y1')),
@@ -511,6 +518,7 @@ function applyHandDrawnStyle(svg: string) {
511
518
  });
512
519
 
513
520
  svgElement.querySelectorAll('polyline').forEach((element) => {
521
+ if (shouldSkipHandDrawn(element)) return;
514
522
  const points = (element.getAttribute('points') ?? '')
515
523
  .trim()
516
524
  .split(/\s+/)
@@ -522,6 +530,7 @@ function applyHandDrawnStyle(svg: string) {
522
530
  });
523
531
 
524
532
  svgElement.querySelectorAll('polygon').forEach((element) => {
533
+ if (shouldSkipHandDrawn(element)) return;
525
534
  const points = (element.getAttribute('points') ?? '')
526
535
  .trim()
527
536
  .split(/\s+/)
@@ -533,6 +542,7 @@ function applyHandDrawnStyle(svg: string) {
533
542
  });
534
543
 
535
544
  svgElement.querySelectorAll('path').forEach((element) => {
545
+ if (shouldSkipHandDrawn(element)) return;
536
546
  const d = element.getAttribute('d');
537
547
  if (!d) return;
538
548
  const node = rc.path(d, createOptions(element));
@@ -53,19 +53,30 @@ const DEFAULT_SITE_ICONS = [
53
53
  { rel: 'android-chrome', sizes: '512x512', url: '/favicon-512x512.png' },
54
54
  ];
55
55
 
56
+ function joinBaseUrl(baseUrl: string, path: string): string {
57
+ const normalizedBaseUrl = baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;
58
+ if (path === '/') {
59
+ return `${normalizedBaseUrl}/`;
60
+ }
61
+
62
+ return `${normalizedBaseUrl}${path}`;
63
+ }
64
+
56
65
  function buildAlternateUrls(options: LocalizedPageUrlOptions) {
57
66
  const { baseUrl, defaultLocale, locale, localePrefixAsNeeded, locales, pathname } = options;
58
67
  const canonicalPath = getAsNeededLocalizedUrl(locale, pathname, localePrefixAsNeeded, defaultLocale);
59
- const canonical = `${baseUrl}${canonicalPath}`;
60
68
  const languages = Object.fromEntries(
61
69
  locales.map((siteLocale) => [
62
70
  siteLocale,
63
- `${baseUrl}${getAsNeededLocalizedUrl(siteLocale, pathname, localePrefixAsNeeded, defaultLocale)}`,
71
+ joinBaseUrl(
72
+ baseUrl,
73
+ getAsNeededLocalizedUrl(siteLocale, pathname, localePrefixAsNeeded, defaultLocale),
74
+ ),
64
75
  ]),
65
76
  );
66
77
 
67
78
  return {
68
- canonical,
79
+ canonical: joinBaseUrl(baseUrl, canonicalPath),
69
80
  languages,
70
81
  };
71
82
  }
@@ -109,6 +120,13 @@ function getEnvText(value?: string): string | undefined {
109
120
  return trimmed ? trimmed : undefined;
110
121
  }
111
122
 
123
+ function omitUndefined<T extends Record<string, unknown>>(value: T | undefined): Partial<T> | undefined {
124
+ if (!value) return undefined;
125
+
126
+ const entries = Object.entries(value).filter(([, item]) => item !== undefined);
127
+ return entries.length > 0 ? Object.fromEntries(entries) as Partial<T> : undefined;
128
+ }
129
+
112
130
  export async function resolveMetadataOverrides(options: {
113
131
  locale: string;
114
132
  namespace: string;
@@ -185,20 +203,22 @@ export function createLocalizedPageMetadata(
185
203
  options: CreateLocalizedPageMetadataOptions,
186
204
  ): Metadata {
187
205
  const { page, site, url } = options;
188
- const { baseUrl } = url;
189
206
  const alternates = buildAlternateUrls(url);
207
+ const siteOpenGraph = omitUndefined(site?.openGraph as Record<string, unknown> | undefined);
208
+ const pageOpenGraph = omitUndefined(page?.openGraph as Record<string, unknown> | undefined);
190
209
  const openGraph = {
191
- ...site?.openGraph,
192
- ...page?.openGraph,
210
+ ...siteOpenGraph,
211
+ ...pageOpenGraph,
193
212
  url: alternates.canonical,
194
213
  } as Metadata['openGraph'];
214
+ const siteTwitter = omitUndefined(site?.twitter as Record<string, unknown> | undefined);
215
+ const pageTwitter = omitUndefined(page?.twitter as Record<string, unknown> | undefined);
195
216
  const twitter = {
196
- ...site?.twitter,
197
- ...page?.twitter,
217
+ ...siteTwitter,
218
+ ...pageTwitter,
198
219
  } as Metadata['twitter'];
199
220
 
200
221
  return {
201
- metadataBase: new URL(baseUrl),
202
222
  title: page?.title ?? site?.title,
203
223
  description: page?.description ?? site?.description,
204
224
  keywords: page?.keywords ?? site?.keywords,