svelora 3.0.13 → 3.0.14

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.
@@ -1,5 +1,10 @@
1
1
  import type { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  export type UrlSchema = StandardSchemaV1<string, string>;
3
+ export declare function createUrlSchema(validateFn: (input: unknown) => {
4
+ issues: readonly StandardSchemaV1.Issue[];
5
+ } | {
6
+ value: string;
7
+ }): UrlSchema;
3
8
  export declare const httpUrlSchema: UrlSchema;
4
9
  export declare function isSafeImageSrc(src: string): boolean;
5
10
  export declare const youtubeUrlSchema: UrlSchema;
@@ -1,5 +1,31 @@
1
- import * as v from 'valibot';
2
- export const httpUrlSchema = v.pipe(v.string(), v.trim(), v.nonEmpty('URL is required'), v.url('Please enter a valid URL'), v.regex(/^https?:\/\//i, 'URL must start with http:// or https://'));
1
+ export function createUrlSchema(validateFn) {
2
+ return {
3
+ '~standard': {
4
+ version: 1,
5
+ vendor: 'svelora',
6
+ validate: validateFn,
7
+ }
8
+ };
9
+ }
10
+ export const httpUrlSchema = createUrlSchema((input) => {
11
+ if (typeof input !== 'string') {
12
+ return { issues: [{ message: 'Expected a string' }] };
13
+ }
14
+ const trimmed = input.trim();
15
+ if (!trimmed) {
16
+ return { issues: [{ message: 'URL is required' }] };
17
+ }
18
+ try {
19
+ new URL(trimmed);
20
+ }
21
+ catch {
22
+ return { issues: [{ message: 'Please enter a valid URL' }] };
23
+ }
24
+ if (!/^https?:\/\//i.test(trimmed)) {
25
+ return { issues: [{ message: 'URL must start with http:// or https://' }] };
26
+ }
27
+ return { value: trimmed };
28
+ });
3
29
  function normalizeUrl(src) {
4
30
  const s = src.replace(/[\t\n\r]/g, '');
5
31
  let start = 0;
@@ -24,4 +50,22 @@ export function isSafeImageSrc(src) {
24
50
  }
25
51
  return false;
26
52
  }
27
- export const youtubeUrlSchema = v.pipe(v.string(), v.trim(), v.nonEmpty('URL is required'), v.url('Please enter a valid URL'), v.regex(/^https?:\/\/(?:www\.|m\.)?(?:youtube\.com|youtu\.be|youtube-nocookie\.com)\//i, 'Must be a YouTube URL (youtube.com or youtu.be)'));
53
+ export const youtubeUrlSchema = createUrlSchema((input) => {
54
+ if (typeof input !== 'string') {
55
+ return { issues: [{ message: 'Expected a string' }] };
56
+ }
57
+ const trimmed = input.trim();
58
+ if (!trimmed) {
59
+ return { issues: [{ message: 'URL is required' }] };
60
+ }
61
+ try {
62
+ new URL(trimmed);
63
+ }
64
+ catch {
65
+ return { issues: [{ message: 'Please enter a valid URL' }] };
66
+ }
67
+ if (!/^https?:\/\/(?:www\.|m\.)?(?:youtube\.com|youtu\.be|youtube-nocookie\.com)\//i.test(trimmed)) {
68
+ return { issues: [{ message: 'Must be a YouTube URL (youtube.com or youtu.be)' }] };
69
+ }
70
+ return { value: trimmed };
71
+ });
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "version": 1,
3
3
  "packageName": "svelora",
4
- "packageVersion": "3.0.13",
5
- "generatedAt": "2026-06-27T06:22:41.961Z",
4
+ "packageVersion": "3.0.14",
5
+ "generatedAt": "2026-06-27T06:43:34.953Z",
6
6
  "slugs": {
7
7
  "components": [
8
8
  "button",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelora",
3
- "version": "3.0.13",
3
+ "version": "3.0.14",
4
4
  "description": "Modern primitive-based UI component library for Svelte 5",
5
5
  "packageManager": "bun@1.3.14",
6
6
  "author": "asphum",