@nonphoto/sanity-image 0.0.4 → 0.0.6

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Jonas Luebbers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/dev.cjs ADDED
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+
3
+ var imageUrlBuilder = require('@sanity/image-url');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var imageUrlBuilder__default = /*#__PURE__*/_interopDefault(imageUrlBuilder);
8
+
9
+ // src/index.ts
10
+ exports.defaultWidths = [
11
+ 6016,
12
+ // 6K
13
+ 5120,
14
+ // 5K
15
+ 4480,
16
+ // 4.5K
17
+ 3840,
18
+ // 4K
19
+ 3200,
20
+ // QHD+
21
+ 2560,
22
+ // WQXGA
23
+ 2048,
24
+ // QXGA
25
+ 1920,
26
+ // 1080p
27
+ 1668,
28
+ // iPad
29
+ 1280,
30
+ // 720p
31
+ 1080,
32
+ // iPhone 6-8 Plus
33
+ 960,
34
+ 720,
35
+ // iPhone 6-8
36
+ 640,
37
+ // 480p
38
+ 480,
39
+ 360,
40
+ 240
41
+ ];
42
+ exports.lowResWidth = 24;
43
+ exports.defaultMetaImageWidth = 1200;
44
+ exports.defaultQuality = 90;
45
+ function cropAxis(length, insetStart, insetEnd) {
46
+ return length ? length * (1 - (insetStart ?? 0) - (insetEnd ?? 0)) : void 0;
47
+ }
48
+ function imageProps({
49
+ image,
50
+ client,
51
+ widths,
52
+ quality = exports.defaultQuality
53
+ }) {
54
+ const sortedWidths = Array.from(widths).sort((a, b) => a - b);
55
+ const builder = imageUrlBuilder__default.default(client).image(image).quality(quality).auto("format");
56
+ const metadata = typeof image === "object" && "asset" in image ? image.asset.metadata : void 0;
57
+ const crop = typeof image === "object" && "crop" in image ? image.crop : void 0;
58
+ return {
59
+ src: metadata?.lqip ?? builder.width(exports.lowResWidth).url().toString(),
60
+ srcset: sortedWidths.map((width) => `${builder.width(width).url()} ${width}w`).join(","),
61
+ naturalWidth: cropAxis(
62
+ metadata?.dimensions?.width,
63
+ crop?.left,
64
+ crop?.right
65
+ ),
66
+ naturalHeight: cropAxis(
67
+ metadata?.dimensions?.height,
68
+ crop?.top,
69
+ crop?.bottom
70
+ )
71
+ };
72
+ }
73
+ function metaImageUrl({
74
+ image,
75
+ client,
76
+ width = exports.defaultMetaImageWidth,
77
+ quality = exports.defaultQuality
78
+ }) {
79
+ return imageUrlBuilder__default.default(client).image(image).quality(quality).auto("format").width(width).url();
80
+ }
81
+
82
+ exports.imageProps = imageProps;
83
+ exports.metaImageUrl = metaImageUrl;
package/dist/dev.js ADDED
@@ -0,0 +1,76 @@
1
+ import imageUrlBuilder from '@sanity/image-url';
2
+
3
+ // src/index.ts
4
+ var defaultWidths = [
5
+ 6016,
6
+ // 6K
7
+ 5120,
8
+ // 5K
9
+ 4480,
10
+ // 4.5K
11
+ 3840,
12
+ // 4K
13
+ 3200,
14
+ // QHD+
15
+ 2560,
16
+ // WQXGA
17
+ 2048,
18
+ // QXGA
19
+ 1920,
20
+ // 1080p
21
+ 1668,
22
+ // iPad
23
+ 1280,
24
+ // 720p
25
+ 1080,
26
+ // iPhone 6-8 Plus
27
+ 960,
28
+ 720,
29
+ // iPhone 6-8
30
+ 640,
31
+ // 480p
32
+ 480,
33
+ 360,
34
+ 240
35
+ ];
36
+ var lowResWidth = 24;
37
+ var defaultMetaImageWidth = 1200;
38
+ var defaultQuality = 90;
39
+ function cropAxis(length, insetStart, insetEnd) {
40
+ return length ? length * (1 - (insetStart ?? 0) - (insetEnd ?? 0)) : void 0;
41
+ }
42
+ function imageProps({
43
+ image,
44
+ client,
45
+ widths,
46
+ quality = defaultQuality
47
+ }) {
48
+ const sortedWidths = Array.from(widths).sort((a, b) => a - b);
49
+ const builder = imageUrlBuilder(client).image(image).quality(quality).auto("format");
50
+ const metadata = typeof image === "object" && "asset" in image ? image.asset.metadata : void 0;
51
+ const crop = typeof image === "object" && "crop" in image ? image.crop : void 0;
52
+ return {
53
+ src: metadata?.lqip ?? builder.width(lowResWidth).url().toString(),
54
+ srcset: sortedWidths.map((width) => `${builder.width(width).url()} ${width}w`).join(","),
55
+ naturalWidth: cropAxis(
56
+ metadata?.dimensions?.width,
57
+ crop?.left,
58
+ crop?.right
59
+ ),
60
+ naturalHeight: cropAxis(
61
+ metadata?.dimensions?.height,
62
+ crop?.top,
63
+ crop?.bottom
64
+ )
65
+ };
66
+ }
67
+ function metaImageUrl({
68
+ image,
69
+ client,
70
+ width = defaultMetaImageWidth,
71
+ quality = defaultQuality
72
+ }) {
73
+ return imageUrlBuilder(client).image(image).quality(quality).auto("format").width(width).url();
74
+ }
75
+
76
+ export { defaultMetaImageWidth, defaultQuality, defaultWidths, imageProps, lowResWidth, metaImageUrl };
package/dist/index.cjs ADDED
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+
3
+ var imageUrlBuilder = require('@sanity/image-url');
4
+
5
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
+
7
+ var imageUrlBuilder__default = /*#__PURE__*/_interopDefault(imageUrlBuilder);
8
+
9
+ // src/index.ts
10
+ exports.defaultWidths = [
11
+ 6016,
12
+ // 6K
13
+ 5120,
14
+ // 5K
15
+ 4480,
16
+ // 4.5K
17
+ 3840,
18
+ // 4K
19
+ 3200,
20
+ // QHD+
21
+ 2560,
22
+ // WQXGA
23
+ 2048,
24
+ // QXGA
25
+ 1920,
26
+ // 1080p
27
+ 1668,
28
+ // iPad
29
+ 1280,
30
+ // 720p
31
+ 1080,
32
+ // iPhone 6-8 Plus
33
+ 960,
34
+ 720,
35
+ // iPhone 6-8
36
+ 640,
37
+ // 480p
38
+ 480,
39
+ 360,
40
+ 240
41
+ ];
42
+ exports.lowResWidth = 24;
43
+ exports.defaultMetaImageWidth = 1200;
44
+ exports.defaultQuality = 90;
45
+ function cropAxis(length, insetStart, insetEnd) {
46
+ return length ? length * (1 - (insetStart ?? 0) - (insetEnd ?? 0)) : void 0;
47
+ }
48
+ function imageProps({
49
+ image,
50
+ client,
51
+ widths,
52
+ quality = exports.defaultQuality
53
+ }) {
54
+ const sortedWidths = Array.from(widths).sort((a, b) => a - b);
55
+ const builder = imageUrlBuilder__default.default(client).image(image).quality(quality).auto("format");
56
+ const metadata = typeof image === "object" && "asset" in image ? image.asset.metadata : void 0;
57
+ const crop = typeof image === "object" && "crop" in image ? image.crop : void 0;
58
+ return {
59
+ src: metadata?.lqip ?? builder.width(exports.lowResWidth).url().toString(),
60
+ srcset: sortedWidths.map((width) => `${builder.width(width).url()} ${width}w`).join(","),
61
+ naturalWidth: cropAxis(
62
+ metadata?.dimensions?.width,
63
+ crop?.left,
64
+ crop?.right
65
+ ),
66
+ naturalHeight: cropAxis(
67
+ metadata?.dimensions?.height,
68
+ crop?.top,
69
+ crop?.bottom
70
+ )
71
+ };
72
+ }
73
+ function metaImageUrl({
74
+ image,
75
+ client,
76
+ width = exports.defaultMetaImageWidth,
77
+ quality = exports.defaultQuality
78
+ }) {
79
+ return imageUrlBuilder__default.default(client).image(image).quality(quality).auto("format").width(width).url();
80
+ }
81
+
82
+ exports.imageProps = imageProps;
83
+ exports.metaImageUrl = metaImageUrl;
@@ -0,0 +1,25 @@
1
+ import { SanityImageSource, SanityClientLike, SanityProjectDetails, SanityModernClientLike } from '@sanity/image-url/lib/types/types.js';
2
+
3
+ declare const defaultWidths: number[];
4
+ declare const lowResWidth = 24;
5
+ declare const defaultMetaImageWidth = 1200;
6
+ declare const defaultQuality = 90;
7
+ declare function imageProps({ image, client, widths, quality, }: {
8
+ image: SanityImageSource;
9
+ client: SanityClientLike | SanityProjectDetails | SanityModernClientLike;
10
+ widths: number[];
11
+ quality?: number;
12
+ }): {
13
+ src: string;
14
+ srcset: string;
15
+ naturalWidth?: number;
16
+ naturalHeight?: number;
17
+ };
18
+ declare function metaImageUrl({ image, client, width, quality, }: {
19
+ image: SanityImageSource;
20
+ client: SanityClientLike | SanityProjectDetails | SanityModernClientLike;
21
+ width: number;
22
+ quality?: number;
23
+ }): string;
24
+
25
+ export { defaultMetaImageWidth, defaultQuality, defaultWidths, imageProps, lowResWidth, metaImageUrl };
package/dist/index.js ADDED
@@ -0,0 +1,76 @@
1
+ import imageUrlBuilder from '@sanity/image-url';
2
+
3
+ // src/index.ts
4
+ var defaultWidths = [
5
+ 6016,
6
+ // 6K
7
+ 5120,
8
+ // 5K
9
+ 4480,
10
+ // 4.5K
11
+ 3840,
12
+ // 4K
13
+ 3200,
14
+ // QHD+
15
+ 2560,
16
+ // WQXGA
17
+ 2048,
18
+ // QXGA
19
+ 1920,
20
+ // 1080p
21
+ 1668,
22
+ // iPad
23
+ 1280,
24
+ // 720p
25
+ 1080,
26
+ // iPhone 6-8 Plus
27
+ 960,
28
+ 720,
29
+ // iPhone 6-8
30
+ 640,
31
+ // 480p
32
+ 480,
33
+ 360,
34
+ 240
35
+ ];
36
+ var lowResWidth = 24;
37
+ var defaultMetaImageWidth = 1200;
38
+ var defaultQuality = 90;
39
+ function cropAxis(length, insetStart, insetEnd) {
40
+ return length ? length * (1 - (insetStart ?? 0) - (insetEnd ?? 0)) : void 0;
41
+ }
42
+ function imageProps({
43
+ image,
44
+ client,
45
+ widths,
46
+ quality = defaultQuality
47
+ }) {
48
+ const sortedWidths = Array.from(widths).sort((a, b) => a - b);
49
+ const builder = imageUrlBuilder(client).image(image).quality(quality).auto("format");
50
+ const metadata = typeof image === "object" && "asset" in image ? image.asset.metadata : void 0;
51
+ const crop = typeof image === "object" && "crop" in image ? image.crop : void 0;
52
+ return {
53
+ src: metadata?.lqip ?? builder.width(lowResWidth).url().toString(),
54
+ srcset: sortedWidths.map((width) => `${builder.width(width).url()} ${width}w`).join(","),
55
+ naturalWidth: cropAxis(
56
+ metadata?.dimensions?.width,
57
+ crop?.left,
58
+ crop?.right
59
+ ),
60
+ naturalHeight: cropAxis(
61
+ metadata?.dimensions?.height,
62
+ crop?.top,
63
+ crop?.bottom
64
+ )
65
+ };
66
+ }
67
+ function metaImageUrl({
68
+ image,
69
+ client,
70
+ width = defaultMetaImageWidth,
71
+ quality = defaultQuality
72
+ }) {
73
+ return imageUrlBuilder(client).image(image).quality(quality).auto("format").width(width).url();
74
+ }
75
+
76
+ export { defaultMetaImageWidth, defaultQuality, defaultWidths, imageProps, lowResWidth, metaImageUrl };
package/package.json CHANGED
@@ -1,41 +1,54 @@
1
1
  {
2
2
  "name": "@nonphoto/sanity-image",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "files": [
6
- "dist",
7
- "index.d.ts"
6
+ "dist"
8
7
  ],
9
- "main": "./dist/counter.umd.cjs",
10
- "module": "./dist/counter.js",
11
- "types": "./index.d.ts",
12
- "exports": {
13
- "types": "./index.d.ts",
14
- "import": "./dist/counter.js",
15
- "require": "./dist/counter.umd.cjs"
16
- },
17
- "scripts": {
18
- "dev": "vite",
19
- "build": "tsc && vite build"
20
- },
8
+ "private": false,
9
+ "sideEffects": false,
21
10
  "devDependencies": {
11
+ "@changesets/cli": "2.26.1",
22
12
  "@types/node": "18.14.6",
23
- "auto": "10.43.0",
13
+ "prettier": "2.8.7",
14
+ "tsup": "6.7.0",
15
+ "tsup-preset-solid": "0.1.8",
24
16
  "typescript": "^4.9.4",
25
- "vite": "^4.0.4"
17
+ "vite": "^4.0.4",
18
+ "vitest": "0.29.8"
26
19
  },
27
20
  "dependencies": {
28
21
  "@sanity/image-url": "1.0.2"
29
22
  },
30
23
  "packageManager": "pnpm@7.29.1",
31
- "repository": "nonphoto/sanity-image",
32
- "author": "Jonas Luebbers <jonas@jonasluebbers.com>",
33
24
  "publishConfig": {
34
25
  "access": "public"
35
26
  },
36
- "auto": {
37
- "plugins": [
38
- "npm"
39
- ]
27
+ "browser": {},
28
+ "exports": {
29
+ "development": {
30
+ "import": {
31
+ "types": "./dist/index.d.ts",
32
+ "default": "./dist/dev.js"
33
+ },
34
+ "require": "./dist/dev.cjs"
35
+ },
36
+ "import": {
37
+ "types": "./dist/index.d.ts",
38
+ "default": "./dist/index.js"
39
+ },
40
+ "require": "./dist/index.cjs"
41
+ },
42
+ "typesVersions": {},
43
+ "main": "./dist/index.cjs",
44
+ "module": "./dist/index.js",
45
+ "types": "./dist/index.d.ts",
46
+ "scripts": {
47
+ "dev": "vite serve dev",
48
+ "build": "tsup",
49
+ "test": "vitest",
50
+ "format": "prettier --ignore-path .gitignore -w \"src/**/*.{js,ts,json,css,tsx,jsx}\" \"dev/**/*.{js,ts,json,css,tsx,jsx}\"",
51
+ "update-deps": "pnpm up -Li",
52
+ "typecheck": "tsc --noEmit"
40
53
  }
41
- }
54
+ }
@@ -1,481 +0,0 @@
1
- var $ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, P = {}, k = {
2
- get exports() {
3
- return P;
4
- },
5
- set exports(f) {
6
- P = f;
7
- }
8
- };
9
- (function(f, y) {
10
- (function(s, v) {
11
- f.exports = v();
12
- })($, function() {
13
- function s() {
14
- return s = Object.assign || function(t) {
15
- for (var i = 1; i < arguments.length; i++) {
16
- var n = arguments[i];
17
- for (var r in n)
18
- Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r]);
19
- }
20
- return t;
21
- }, s.apply(this, arguments);
22
- }
23
- function v(t, i) {
24
- if (t) {
25
- if (typeof t == "string")
26
- return I(t, i);
27
- var n = Object.prototype.toString.call(t).slice(8, -1);
28
- if (n === "Object" && t.constructor && (n = t.constructor.name), n === "Map" || n === "Set")
29
- return Array.from(t);
30
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
31
- return I(t, i);
32
- }
33
- }
34
- function I(t, i) {
35
- (i == null || i > t.length) && (i = t.length);
36
- for (var n = 0, r = new Array(i); n < i; n++)
37
- r[n] = t[n];
38
- return r;
39
- }
40
- function M(t, i) {
41
- var n = typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
42
- if (n)
43
- return (n = n.call(t)).next.bind(n);
44
- if (Array.isArray(t) || (n = v(t)) || i && t && typeof t.length == "number") {
45
- n && (t = n);
46
- var r = 0;
47
- return function() {
48
- return r >= t.length ? {
49
- done: !0
50
- } : {
51
- done: !1,
52
- value: t[r++]
53
- };
54
- };
55
- }
56
- throw new TypeError(`Invalid attempt to iterate non-iterable instance.
57
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
58
- }
59
- var d = "image-Tb9Ew8CXIwaY6R1kjMvI0uRR-2000x3000-jpg";
60
- function u(t) {
61
- var i = t.split("-"), n = i[1], r = i[2], o = i[3];
62
- if (!n || !r || !o)
63
- throw new Error("Malformed asset _ref '" + t + `'. Expected an id like "` + d + '".');
64
- var e = r.split("x"), a = e[0], h = e[1], c = +a, l = +h, p = isFinite(c) && isFinite(l);
65
- if (!p)
66
- throw new Error("Malformed asset _ref '" + t + `'. Expected an id like "` + d + '".');
67
- return {
68
- id: n,
69
- width: c,
70
- height: l,
71
- format: o
72
- };
73
- }
74
- var S = function(i) {
75
- var n = i;
76
- return n ? typeof n._ref == "string" : !1;
77
- }, U = function(i) {
78
- var n = i;
79
- return n ? typeof n._id == "string" : !1;
80
- }, O = function(i) {
81
- var n = i;
82
- return n && n.asset ? typeof n.asset.url == "string" : !1;
83
- };
84
- function A(t) {
85
- if (!t)
86
- return null;
87
- var i;
88
- if (typeof t == "string" && q(t))
89
- i = {
90
- asset: {
91
- _ref: E(t)
92
- }
93
- };
94
- else if (typeof t == "string")
95
- i = {
96
- asset: {
97
- _ref: t
98
- }
99
- };
100
- else if (S(t))
101
- i = {
102
- asset: t
103
- };
104
- else if (U(t))
105
- i = {
106
- asset: {
107
- _ref: t._id || ""
108
- }
109
- };
110
- else if (O(t))
111
- i = {
112
- asset: {
113
- _ref: E(t.asset.url)
114
- }
115
- };
116
- else if (typeof t.asset == "object")
117
- i = s({}, t);
118
- else
119
- return null;
120
- var n = t;
121
- return n.crop && (i.crop = n.crop), n.hotspot && (i.hotspot = n.hotspot), z(i);
122
- }
123
- function q(t) {
124
- return /^https?:\/\//.test("" + t);
125
- }
126
- function E(t) {
127
- var i = t.split("/").slice(-1);
128
- return ("image-" + i[0]).replace(/\.([a-z]+)$/, "-$1");
129
- }
130
- function z(t) {
131
- if (t.crop && t.hotspot)
132
- return t;
133
- var i = s({}, t);
134
- return i.crop || (i.crop = {
135
- left: 0,
136
- top: 0,
137
- bottom: 0,
138
- right: 0
139
- }), i.hotspot || (i.hotspot = {
140
- x: 0.5,
141
- y: 0.5,
142
- height: 1,
143
- width: 1
144
- }), i;
145
- }
146
- var R = [["width", "w"], ["height", "h"], ["format", "fm"], ["download", "dl"], ["blur", "blur"], ["sharpen", "sharp"], ["invert", "invert"], ["orientation", "or"], ["minHeight", "min-h"], ["maxHeight", "max-h"], ["minWidth", "min-w"], ["maxWidth", "max-w"], ["quality", "q"], ["fit", "fit"], ["crop", "crop"], ["saturation", "sat"], ["auto", "auto"], ["dpr", "dpr"], ["pad", "pad"]];
147
- function _(t) {
148
- var i = s({}, t || {}), n = i.source;
149
- delete i.source;
150
- var r = A(n);
151
- if (!r)
152
- throw new Error("Unable to resolve image URL from source (" + JSON.stringify(n) + ")");
153
- var o = r.asset._ref || r.asset._id || "", e = u(o), a = Math.round(r.crop.left * e.width), h = Math.round(r.crop.top * e.height), c = {
154
- left: a,
155
- top: h,
156
- width: Math.round(e.width - r.crop.right * e.width - a),
157
- height: Math.round(e.height - r.crop.bottom * e.height - h)
158
- }, l = r.hotspot.height * e.height / 2, p = r.hotspot.width * e.width / 2, m = r.hotspot.x * e.width, w = r.hotspot.y * e.height, g = {
159
- left: m - p,
160
- top: w - l,
161
- right: m + p,
162
- bottom: w + l
163
- };
164
- return i.rect || i.focalPoint || i.ignoreImageParams || i.crop || (i = s({}, i, V({
165
- crop: c,
166
- hotspot: g
167
- }, i))), L(s({}, i, {
168
- asset: e
169
- }));
170
- }
171
- function L(t) {
172
- var i = (t.baseUrl || "https://cdn.sanity.io").replace(/\/+$/, ""), n = t.asset.id + "-" + t.asset.width + "x" + t.asset.height + "." + t.asset.format, r = i + "/images/" + t.projectId + "/" + t.dataset + "/" + n, o = [];
173
- if (t.rect) {
174
- var e = t.rect, a = e.left, h = e.top, c = e.width, l = e.height, p = a !== 0 || h !== 0 || l !== t.asset.height || c !== t.asset.width;
175
- p && o.push("rect=" + a + "," + h + "," + c + "," + l);
176
- }
177
- t.bg && o.push("bg=" + t.bg), t.focalPoint && (o.push("fp-x=" + t.focalPoint.x), o.push("fp-y=" + t.focalPoint.y));
178
- var m = [t.flipHorizontal && "h", t.flipVertical && "v"].filter(Boolean).join("");
179
- return m && o.push("flip=" + m), R.forEach(function(w) {
180
- var g = w[0], b = w[1];
181
- typeof t[g] < "u" ? o.push(b + "=" + encodeURIComponent(t[g])) : typeof t[b] < "u" && o.push(b + "=" + encodeURIComponent(t[b]));
182
- }), o.length === 0 ? r : r + "?" + o.join("&");
183
- }
184
- function V(t, i) {
185
- var n, r = i.width, o = i.height;
186
- if (!(r && o))
187
- return {
188
- width: r,
189
- height: o,
190
- rect: t.crop
191
- };
192
- var e = t.crop, a = t.hotspot, h = r / o, c = e.width / e.height;
193
- if (c > h) {
194
- var l = Math.round(e.height), p = Math.round(l * h), m = Math.max(0, Math.round(e.top)), w = Math.round((a.right - a.left) / 2 + a.left), g = Math.max(0, Math.round(w - p / 2));
195
- g < e.left ? g = e.left : g + p > e.left + e.width && (g = e.left + e.width - p), n = {
196
- left: g,
197
- top: m,
198
- width: p,
199
- height: l
200
- };
201
- } else {
202
- var b = e.width, j = Math.round(b / h), J = Math.max(0, Math.round(e.left)), Q = Math.round((a.bottom - a.top) / 2 + a.top), x = Math.max(0, Math.round(Q - j / 2));
203
- x < e.top ? x = e.top : x + j > e.top + e.height && (x = e.top + e.height - j), n = {
204
- left: J,
205
- top: x,
206
- width: b,
207
- height: j
208
- };
209
- }
210
- return {
211
- width: r,
212
- height: o,
213
- rect: n
214
- };
215
- }
216
- var B = ["clip", "crop", "fill", "fillmax", "max", "scale", "min"], F = ["top", "bottom", "left", "right", "center", "focalpoint", "entropy"], N = ["format"];
217
- function D(t) {
218
- return t && "config" in t ? typeof t.config == "function" : !1;
219
- }
220
- function G(t) {
221
- return t && "clientConfig" in t ? typeof t.clientConfig == "object" : !1;
222
- }
223
- function X(t) {
224
- for (var i = R, n = M(i), r; !(r = n()).done; ) {
225
- var o = r.value, e = o[0], a = o[1];
226
- if (t === e || t === a)
227
- return e;
228
- }
229
- return t;
230
- }
231
- function Y(t) {
232
- if (D(t)) {
233
- var i = t.config(), n = i.apiHost, r = i.projectId, o = i.dataset, e = n || "https://api.sanity.io";
234
- return new H(null, {
235
- baseUrl: e.replace(/^https:\/\/api\./, "https://cdn."),
236
- projectId: r,
237
- dataset: o
238
- });
239
- }
240
- var a = t;
241
- if (G(a)) {
242
- var h = a.clientConfig, c = h.apiHost, l = h.projectId, p = h.dataset, m = c || "https://api.sanity.io";
243
- return new H(null, {
244
- baseUrl: m.replace(/^https:\/\/api\./, "https://cdn."),
245
- projectId: l,
246
- dataset: p
247
- });
248
- }
249
- return new H(null, t);
250
- }
251
- var H = /* @__PURE__ */ function() {
252
- function t(n, r) {
253
- this.options = void 0, this.options = n ? s({}, n.options || {}, r || {}) : s({}, r || {});
254
- }
255
- var i = t.prototype;
256
- return i.withOptions = function(r) {
257
- var o = r.baseUrl || this.options.baseUrl, e = {
258
- baseUrl: o
259
- };
260
- for (var a in r)
261
- if (r.hasOwnProperty(a)) {
262
- var h = X(a);
263
- e[h] = r[a];
264
- }
265
- return new t(this, s({
266
- baseUrl: o
267
- }, e));
268
- }, i.image = function(r) {
269
- return this.withOptions({
270
- source: r
271
- });
272
- }, i.dataset = function(r) {
273
- return this.withOptions({
274
- dataset: r
275
- });
276
- }, i.projectId = function(r) {
277
- return this.withOptions({
278
- projectId: r
279
- });
280
- }, i.bg = function(r) {
281
- return this.withOptions({
282
- bg: r
283
- });
284
- }, i.dpr = function(r) {
285
- return this.withOptions(r && r !== 1 ? {
286
- dpr: r
287
- } : {});
288
- }, i.width = function(r) {
289
- return this.withOptions({
290
- width: r
291
- });
292
- }, i.height = function(r) {
293
- return this.withOptions({
294
- height: r
295
- });
296
- }, i.focalPoint = function(r, o) {
297
- return this.withOptions({
298
- focalPoint: {
299
- x: r,
300
- y: o
301
- }
302
- });
303
- }, i.maxWidth = function(r) {
304
- return this.withOptions({
305
- maxWidth: r
306
- });
307
- }, i.minWidth = function(r) {
308
- return this.withOptions({
309
- minWidth: r
310
- });
311
- }, i.maxHeight = function(r) {
312
- return this.withOptions({
313
- maxHeight: r
314
- });
315
- }, i.minHeight = function(r) {
316
- return this.withOptions({
317
- minHeight: r
318
- });
319
- }, i.size = function(r, o) {
320
- return this.withOptions({
321
- width: r,
322
- height: o
323
- });
324
- }, i.blur = function(r) {
325
- return this.withOptions({
326
- blur: r
327
- });
328
- }, i.sharpen = function(r) {
329
- return this.withOptions({
330
- sharpen: r
331
- });
332
- }, i.rect = function(r, o, e, a) {
333
- return this.withOptions({
334
- rect: {
335
- left: r,
336
- top: o,
337
- width: e,
338
- height: a
339
- }
340
- });
341
- }, i.format = function(r) {
342
- return this.withOptions({
343
- format: r
344
- });
345
- }, i.invert = function(r) {
346
- return this.withOptions({
347
- invert: r
348
- });
349
- }, i.orientation = function(r) {
350
- return this.withOptions({
351
- orientation: r
352
- });
353
- }, i.quality = function(r) {
354
- return this.withOptions({
355
- quality: r
356
- });
357
- }, i.forceDownload = function(r) {
358
- return this.withOptions({
359
- download: r
360
- });
361
- }, i.flipHorizontal = function() {
362
- return this.withOptions({
363
- flipHorizontal: !0
364
- });
365
- }, i.flipVertical = function() {
366
- return this.withOptions({
367
- flipVertical: !0
368
- });
369
- }, i.ignoreImageParams = function() {
370
- return this.withOptions({
371
- ignoreImageParams: !0
372
- });
373
- }, i.fit = function(r) {
374
- if (B.indexOf(r) === -1)
375
- throw new Error('Invalid fit mode "' + r + '"');
376
- return this.withOptions({
377
- fit: r
378
- });
379
- }, i.crop = function(r) {
380
- if (F.indexOf(r) === -1)
381
- throw new Error('Invalid crop mode "' + r + '"');
382
- return this.withOptions({
383
- crop: r
384
- });
385
- }, i.saturation = function(r) {
386
- return this.withOptions({
387
- saturation: r
388
- });
389
- }, i.auto = function(r) {
390
- if (N.indexOf(r) === -1)
391
- throw new Error('Invalid auto mode "' + r + '"');
392
- return this.withOptions({
393
- auto: r
394
- });
395
- }, i.pad = function(r) {
396
- return this.withOptions({
397
- pad: r
398
- });
399
- }, i.url = function() {
400
- return _(this.options);
401
- }, i.toString = function() {
402
- return this.url();
403
- }, t;
404
- }();
405
- return Y;
406
- });
407
- })(k);
408
- const C = P, tt = [
409
- 6016,
410
- // 6K
411
- 5120,
412
- // 5K
413
- 4480,
414
- // 4.5K
415
- 3840,
416
- // 4K
417
- 3200,
418
- // QHD+
419
- 2560,
420
- // WQXGA
421
- 2048,
422
- // QXGA
423
- 1920,
424
- // 1080p
425
- 1668,
426
- // iPad
427
- 1280,
428
- // 720p
429
- 1080,
430
- // iPhone 6-8 Plus
431
- 960,
432
- 720,
433
- // iPhone 6-8
434
- 640,
435
- // 480p
436
- 480,
437
- 360,
438
- 240
439
- ], K = 24, Z = 1200, T = 90;
440
- function W(f, y, s) {
441
- return f ? f * (1 - (y ?? 0) - (s ?? 0)) : void 0;
442
- }
443
- function rt({
444
- image: f,
445
- client: y,
446
- widths: s,
447
- quality: v = T
448
- }) {
449
- var S, U;
450
- const I = Array.from(s).sort((O, A) => O - A), M = C(y).image(f).quality(v).auto("format"), d = typeof f == "object" && "asset" in f ? f.asset.metadata : void 0, u = typeof f == "object" && "crop" in f ? f.crop : void 0;
451
- return {
452
- src: (d == null ? void 0 : d.lqip) ?? M.width(K).url().toString(),
453
- srcset: I.map((O) => `${M.width(O).url()} ${O}w`).join(","),
454
- naturalWidth: W(
455
- (S = d == null ? void 0 : d.dimensions) == null ? void 0 : S.width,
456
- u == null ? void 0 : u.left,
457
- u == null ? void 0 : u.right
458
- ),
459
- naturalHeight: W(
460
- (U = d == null ? void 0 : d.dimensions) == null ? void 0 : U.height,
461
- u == null ? void 0 : u.top,
462
- u == null ? void 0 : u.bottom
463
- )
464
- };
465
- }
466
- function it({
467
- image: f,
468
- client: y,
469
- width: s = Z,
470
- quality: v = T
471
- }) {
472
- return C(y).image(f).quality(v).auto("format").width(s).url();
473
- }
474
- export {
475
- Z as defaultMetaImageWidth,
476
- T as defaultQuality,
477
- tt as defaultWidths,
478
- rt as imageProps,
479
- K as lowResWidth,
480
- it as metaImageUrl
481
- };
@@ -1,2 +0,0 @@
1
- (function(c,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(c=typeof globalThis<"u"?globalThis:c||self,x(c["sanity-image"]={}))})(this,function(c){"use strict";var x=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},P={},V={get exports(){return P},set exports(f){P=f}};(function(f,O){(function(s,w){f.exports=w()})(x,function(){function s(){return s=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},s.apply(this,arguments)}function w(t,r){if(t){if(typeof t=="string")return S(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return S(t,r)}}function S(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,i=new Array(r);n<r;n++)i[n]=t[n];return i}function j(t,r){var n=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=w(t))||r&&t&&typeof t.length=="number"){n&&(t=n);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var d="image-Tb9Ew8CXIwaY6R1kjMvI0uRR-2000x3000-jpg";function u(t){var r=t.split("-"),n=r[1],i=r[2],o=r[3];if(!n||!i||!o)throw new Error("Malformed asset _ref '"+t+`'. Expected an id like "`+d+'".');var e=i.split("x"),a=e[0],h=e[1],m=+a,l=+h,p=isFinite(m)&&isFinite(l);if(!p)throw new Error("Malformed asset _ref '"+t+`'. Expected an id like "`+d+'".');return{id:n,width:m,height:l,format:o}}var U=function(r){var n=r;return n?typeof n._ref=="string":!1},A=function(r){var n=r;return n?typeof n._id=="string":!1},I=function(r){var n=r;return n&&n.asset?typeof n.asset.url=="string":!1};function R(t){if(!t)return null;var r;if(typeof t=="string"&&D(t))r={asset:{_ref:_(t)}};else if(typeof t=="string")r={asset:{_ref:t}};else if(U(t))r={asset:t};else if(A(t))r={asset:{_ref:t._id||""}};else if(I(t))r={asset:{_ref:_(t.asset.url)}};else if(typeof t.asset=="object")r=s({},t);else return null;var n=t;return n.crop&&(r.crop=n.crop),n.hotspot&&(r.hotspot=n.hotspot),G(r)}function D(t){return/^https?:\/\//.test(""+t)}function _(t){var r=t.split("/").slice(-1);return("image-"+r[0]).replace(/\.([a-z]+)$/,"-$1")}function G(t){if(t.crop&&t.hotspot)return t;var r=s({},t);return r.crop||(r.crop={left:0,top:0,bottom:0,right:0}),r.hotspot||(r.hotspot={x:.5,y:.5,height:1,width:1}),r}var L=[["width","w"],["height","h"],["format","fm"],["download","dl"],["blur","blur"],["sharpen","sharp"],["invert","invert"],["orientation","or"],["minHeight","min-h"],["maxHeight","max-h"],["minWidth","min-w"],["maxWidth","max-w"],["quality","q"],["fit","fit"],["crop","crop"],["saturation","sat"],["auto","auto"],["dpr","dpr"],["pad","pad"]];function Q(t){var r=s({},t||{}),n=r.source;delete r.source;var i=R(n);if(!i)throw new Error("Unable to resolve image URL from source ("+JSON.stringify(n)+")");var o=i.asset._ref||i.asset._id||"",e=u(o),a=Math.round(i.crop.left*e.width),h=Math.round(i.crop.top*e.height),m={left:a,top:h,width:Math.round(e.width-i.crop.right*e.width-a),height:Math.round(e.height-i.crop.bottom*e.height-h)},l=i.hotspot.height*e.height/2,p=i.hotspot.width*e.width/2,v=i.hotspot.x*e.width,b=i.hotspot.y*e.height,g={left:v-p,top:b-l,right:v+p,bottom:b+l};return r.rect||r.focalPoint||r.ignoreImageParams||r.crop||(r=s({},r,Y({crop:m,hotspot:g},r))),X(s({},r,{asset:e}))}function X(t){var r=(t.baseUrl||"https://cdn.sanity.io").replace(/\/+$/,""),n=t.asset.id+"-"+t.asset.width+"x"+t.asset.height+"."+t.asset.format,i=r+"/images/"+t.projectId+"/"+t.dataset+"/"+n,o=[];if(t.rect){var e=t.rect,a=e.left,h=e.top,m=e.width,l=e.height,p=a!==0||h!==0||l!==t.asset.height||m!==t.asset.width;p&&o.push("rect="+a+","+h+","+m+","+l)}t.bg&&o.push("bg="+t.bg),t.focalPoint&&(o.push("fp-x="+t.focalPoint.x),o.push("fp-y="+t.focalPoint.y));var v=[t.flipHorizontal&&"h",t.flipVertical&&"v"].filter(Boolean).join("");return v&&o.push("flip="+v),L.forEach(function(b){var g=b[0],y=b[1];typeof t[g]<"u"?o.push(y+"="+encodeURIComponent(t[g])):typeof t[y]<"u"&&o.push(y+"="+encodeURIComponent(t[y]))}),o.length===0?i:i+"?"+o.join("&")}function Y(t,r){var n,i=r.width,o=r.height;if(!(i&&o))return{width:i,height:o,rect:t.crop};var e=t.crop,a=t.hotspot,h=i/o,m=e.width/e.height;if(m>h){var l=Math.round(e.height),p=Math.round(l*h),v=Math.max(0,Math.round(e.top)),b=Math.round((a.right-a.left)/2+a.left),g=Math.max(0,Math.round(b-p/2));g<e.left?g=e.left:g+p>e.left+e.width&&(g=e.left+e.width-p),n={left:g,top:v,width:p,height:l}}else{var y=e.width,H=Math.round(y/h),rt=Math.max(0,Math.round(e.left)),nt=Math.round((a.bottom-a.top)/2+a.top),M=Math.max(0,Math.round(nt-H/2));M<e.top?M=e.top:M+H>e.top+e.height&&(M=e.top+e.height-H),n={left:rt,top:M,width:y,height:H}}return{width:i,height:o,rect:n}}var J=["clip","crop","fill","fillmax","max","scale","min"],$=["top","bottom","left","right","center","focalpoint","entropy"],k=["format"];function K(t){return t&&"config"in t?typeof t.config=="function":!1}function Z(t){return t&&"clientConfig"in t?typeof t.clientConfig=="object":!1}function tt(t){for(var r=L,n=j(r),i;!(i=n()).done;){var o=i.value,e=o[0],a=o[1];if(t===e||t===a)return e}return t}function it(t){if(K(t)){var r=t.config(),n=r.apiHost,i=r.projectId,o=r.dataset,e=n||"https://api.sanity.io";return new E(null,{baseUrl:e.replace(/^https:\/\/api\./,"https://cdn."),projectId:i,dataset:o})}var a=t;if(Z(a)){var h=a.clientConfig,m=h.apiHost,l=h.projectId,p=h.dataset,v=m||"https://api.sanity.io";return new E(null,{baseUrl:v.replace(/^https:\/\/api\./,"https://cdn."),projectId:l,dataset:p})}return new E(null,t)}var E=function(){function t(n,i){this.options=void 0,this.options=n?s({},n.options||{},i||{}):s({},i||{})}var r=t.prototype;return r.withOptions=function(i){var o=i.baseUrl||this.options.baseUrl,e={baseUrl:o};for(var a in i)if(i.hasOwnProperty(a)){var h=tt(a);e[h]=i[a]}return new t(this,s({baseUrl:o},e))},r.image=function(i){return this.withOptions({source:i})},r.dataset=function(i){return this.withOptions({dataset:i})},r.projectId=function(i){return this.withOptions({projectId:i})},r.bg=function(i){return this.withOptions({bg:i})},r.dpr=function(i){return this.withOptions(i&&i!==1?{dpr:i}:{})},r.width=function(i){return this.withOptions({width:i})},r.height=function(i){return this.withOptions({height:i})},r.focalPoint=function(i,o){return this.withOptions({focalPoint:{x:i,y:o}})},r.maxWidth=function(i){return this.withOptions({maxWidth:i})},r.minWidth=function(i){return this.withOptions({minWidth:i})},r.maxHeight=function(i){return this.withOptions({maxHeight:i})},r.minHeight=function(i){return this.withOptions({minHeight:i})},r.size=function(i,o){return this.withOptions({width:i,height:o})},r.blur=function(i){return this.withOptions({blur:i})},r.sharpen=function(i){return this.withOptions({sharpen:i})},r.rect=function(i,o,e,a){return this.withOptions({rect:{left:i,top:o,width:e,height:a}})},r.format=function(i){return this.withOptions({format:i})},r.invert=function(i){return this.withOptions({invert:i})},r.orientation=function(i){return this.withOptions({orientation:i})},r.quality=function(i){return this.withOptions({quality:i})},r.forceDownload=function(i){return this.withOptions({download:i})},r.flipHorizontal=function(){return this.withOptions({flipHorizontal:!0})},r.flipVertical=function(){return this.withOptions({flipVertical:!0})},r.ignoreImageParams=function(){return this.withOptions({ignoreImageParams:!0})},r.fit=function(i){if(J.indexOf(i)===-1)throw new Error('Invalid fit mode "'+i+'"');return this.withOptions({fit:i})},r.crop=function(i){if($.indexOf(i)===-1)throw new Error('Invalid crop mode "'+i+'"');return this.withOptions({crop:i})},r.saturation=function(i){return this.withOptions({saturation:i})},r.auto=function(i){if(k.indexOf(i)===-1)throw new Error('Invalid auto mode "'+i+'"');return this.withOptions({auto:i})},r.pad=function(i){return this.withOptions({pad:i})},r.url=function(){return Q(this.options)},r.toString=function(){return this.url()},t}();return it})})(V);const T=P,B=[6016,5120,4480,3840,3200,2560,2048,1920,1668,1280,1080,960,720,640,480,360,240],C=24,q=1200,W=90;function z(f,O,s){return f?f*(1-(O??0)-(s??0)):void 0}function F({image:f,client:O,widths:s,quality:w=W}){var U,A;const S=Array.from(s).sort((I,R)=>I-R),j=T(O).image(f).quality(w).auto("format"),d=typeof f=="object"&&"asset"in f?f.asset.metadata:void 0,u=typeof f=="object"&&"crop"in f?f.crop:void 0;return{src:(d==null?void 0:d.lqip)??j.width(C).url().toString(),srcset:S.map(I=>`${j.width(I).url()} ${I}w`).join(","),naturalWidth:z((U=d==null?void 0:d.dimensions)==null?void 0:U.width,u==null?void 0:u.left,u==null?void 0:u.right),naturalHeight:z((A=d==null?void 0:d.dimensions)==null?void 0:A.height,u==null?void 0:u.top,u==null?void 0:u.bottom)}}function N({image:f,client:O,width:s=q,quality:w=W}){return T(O).image(f).quality(w).auto("format").width(s).url()}c.defaultMetaImageWidth=q,c.defaultQuality=W,c.defaultWidths=B,c.imageProps=F,c.lowResWidth=C,c.metaImageUrl=N,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/dist/vite.svg DELETED
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>