@pixelfiddler/next 1.0.2 → 1.0.3
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/index.cjs +70 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,21 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
9
30
|
|
|
10
|
-
|
|
31
|
+
// src/index.ts
|
|
32
|
+
var index_exports = {};
|
|
33
|
+
__export(index_exports, {
|
|
34
|
+
PixelFiddlerImage: () => PixelFiddlerImage,
|
|
35
|
+
PixelFiddlerProvider: () => PixelFiddlerProvider
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
11
38
|
|
|
12
39
|
// src/components/pixel-fiddler-image.tsx
|
|
13
|
-
var
|
|
40
|
+
var import_react2 = require("react");
|
|
41
|
+
var import_image = __toESM(require("next/image"), 1);
|
|
42
|
+
var import_core2 = require("@pixelfiddler/core");
|
|
43
|
+
|
|
44
|
+
// src/provider/pixel-fiddler-context.tsx
|
|
45
|
+
var import_react = require("react");
|
|
46
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
|
+
var PixelFiddlerContext = (0, import_react.createContext)(null);
|
|
14
48
|
function PixelFiddlerProvider({ children, config }) {
|
|
15
|
-
return /* @__PURE__ */
|
|
49
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PixelFiddlerContext.Provider, { value: { config }, children });
|
|
16
50
|
}
|
|
51
|
+
|
|
52
|
+
// src/utils/loader.ts
|
|
53
|
+
var import_core = require("@pixelfiddler/core");
|
|
17
54
|
var loader = ({ src, baseUrl, width: loaderWidth, transformations }) => {
|
|
18
|
-
return
|
|
55
|
+
return (0, import_core.buildTransformationUrl)({
|
|
19
56
|
src,
|
|
20
57
|
baseUrl,
|
|
21
58
|
transformations: {
|
|
@@ -24,6 +61,9 @@ var loader = ({ src, baseUrl, width: loaderWidth, transformations }) => {
|
|
|
24
61
|
}
|
|
25
62
|
});
|
|
26
63
|
};
|
|
64
|
+
|
|
65
|
+
// src/components/pixel-fiddler-image.tsx
|
|
66
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
27
67
|
function PixelFiddlerImage({
|
|
28
68
|
src,
|
|
29
69
|
transformations,
|
|
@@ -33,36 +73,36 @@ function PixelFiddlerImage({
|
|
|
33
73
|
quality,
|
|
34
74
|
...imageProps
|
|
35
75
|
}) {
|
|
36
|
-
const context =
|
|
76
|
+
const context = (0, import_react2.useContext)(PixelFiddlerContext);
|
|
37
77
|
const finalBaseUrl = baseUrl || context?.config?.baseUrl;
|
|
38
|
-
const srcWithoutTransformations =
|
|
39
|
-
return
|
|
78
|
+
const srcWithoutTransformations = (0, import_react2.useMemo)(() => {
|
|
79
|
+
return (0, import_core2.buildTransformationUrl)({
|
|
40
80
|
baseUrl: finalBaseUrl,
|
|
41
81
|
src
|
|
42
82
|
});
|
|
43
83
|
}, [src]);
|
|
44
84
|
if (unoptimized) {
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
|
|
85
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
86
|
+
import_image.default,
|
|
47
87
|
{
|
|
48
88
|
unoptimized: true,
|
|
49
|
-
src:
|
|
89
|
+
src: (0, import_core2.buildTransformationUrl)({ src, baseUrl: finalBaseUrl }),
|
|
50
90
|
...imageProps
|
|
51
91
|
}
|
|
52
92
|
);
|
|
53
93
|
}
|
|
54
94
|
if (!responsive) {
|
|
55
|
-
return /* @__PURE__ */
|
|
56
|
-
|
|
95
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
96
|
+
import_image.default,
|
|
57
97
|
{
|
|
58
98
|
unoptimized: true,
|
|
59
|
-
src:
|
|
99
|
+
src: (0, import_core2.buildTransformationUrl)(
|
|
60
100
|
{
|
|
61
101
|
src,
|
|
62
102
|
baseUrl: finalBaseUrl,
|
|
63
103
|
transformations: {
|
|
64
104
|
...transformations,
|
|
65
|
-
quality: quality &&
|
|
105
|
+
quality: quality && (0, import_core2.parseNumberLikeParam)(quality)
|
|
66
106
|
}
|
|
67
107
|
}
|
|
68
108
|
),
|
|
@@ -70,8 +110,8 @@ function PixelFiddlerImage({
|
|
|
70
110
|
}
|
|
71
111
|
);
|
|
72
112
|
}
|
|
73
|
-
return /* @__PURE__ */
|
|
74
|
-
|
|
113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
114
|
+
import_image.default,
|
|
75
115
|
{
|
|
76
116
|
loader: ({ src: src2, width }) => loader(
|
|
77
117
|
{
|
|
@@ -79,7 +119,7 @@ function PixelFiddlerImage({
|
|
|
79
119
|
src: src2,
|
|
80
120
|
transformations: {
|
|
81
121
|
...transformations,
|
|
82
|
-
quality: quality &&
|
|
122
|
+
quality: quality && (0, import_core2.parseNumberLikeParam)(quality)
|
|
83
123
|
},
|
|
84
124
|
baseUrl: finalBaseUrl
|
|
85
125
|
}
|
|
@@ -89,8 +129,9 @@ function PixelFiddlerImage({
|
|
|
89
129
|
}
|
|
90
130
|
);
|
|
91
131
|
}
|
|
92
|
-
|
|
93
|
-
exports
|
|
94
|
-
|
|
95
|
-
|
|
132
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
133
|
+
0 && (module.exports = {
|
|
134
|
+
PixelFiddlerImage,
|
|
135
|
+
PixelFiddlerProvider
|
|
136
|
+
});
|
|
96
137
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/components/pixel-fiddler-image.tsx","../src/provider/pixel-fiddler-context.tsx","../src/utils/loader.ts"],"sourcesContent":["export { PixelFiddlerImage } from './components/pixel-fiddler-image';\r\nexport type { PixelFiddlerImageProps } from './components/pixel-fiddler-image';\r\n\r\nexport { PixelFiddlerProvider } from './provider/pixel-fiddler-context';\r\nexport type { PixelFiddlerContextValue } from './provider/pixel-fiddler-context';\r\n\r\nexport type {\r\n TransformationOptions,\r\n ResizeOptions,\r\n FormatOptions,\r\n EffectOptions,\r\n CropOptions,\r\n BorderOptions,\r\n TextOptions,\r\n WatermarkOptions,\r\n PixelFiddlerConfig,\r\n} from '@pixelfiddler/core';\r\n","import { useContext, useMemo } from 'react'\r\nimport Image, { ImageProps } from 'next/image'\r\nimport { buildTransformationUrl, parseNumberLikeParam, TransformationOptions, } from '@pixelfiddler/core'\r\nimport { PixelFiddlerContext } from '../provider/pixel-fiddler-context'\r\nimport { loader } from '../utils/loader';\r\n\r\nexport interface PixelFiddlerImageProps\r\n extends Omit<ImageProps, 'src' | 'loader' | 'sizes'> {\r\n /** Src to your image - can be both relative or absolute.\r\n * If it's relative, it will be attached to baseUrl from config\r\n * If it's absolute, it will be left as is\r\n */\r\n src: string\r\n /** Base URL from PixelFiddler Dashboard.\r\n * Can be omitted if provided via PixelFiddlerProvider\r\n */\r\n baseUrl?: string\r\n /**\r\n * Sizes attribute for responsive images\r\n * e.g. \"(max-width: 768px) 100vw, 50vw\"\r\n */\r\n sizes?: string\r\n /**\r\n * Whether automatic generation of srcset should be enabled.\r\n * @default true\r\n */\r\n responsive?: boolean\r\n /**\r\n * Transformation options to apply\r\n */\r\n transformations?: TransformationOptions\r\n}\r\n\r\nexport function PixelFiddlerImage({\r\n src,\r\n transformations,\r\n baseUrl,\r\n responsive = true,\r\n unoptimized = false,\r\n quality,\r\n ...imageProps\r\n }: PixelFiddlerImageProps) {\r\n const context = useContext(PixelFiddlerContext)\r\n const finalBaseUrl = baseUrl || context?.config?.baseUrl\r\n\r\n\r\n const srcWithoutTransformations = useMemo(() => {\r\n return buildTransformationUrl({\r\n baseUrl: finalBaseUrl,\r\n src\r\n })\r\n }, [src])\r\n\r\n if (unoptimized) {\r\n return <Image unoptimized={true}\r\n src={buildTransformationUrl({src, baseUrl: finalBaseUrl})}\r\n {...imageProps}\r\n />\r\n }\r\n\r\n if (!responsive) {\r\n return <Image\r\n unoptimized={true}\r\n src={buildTransformationUrl(\r\n {\r\n src,\r\n baseUrl: finalBaseUrl,\r\n transformations: {\r\n ...transformations,\r\n quality: quality && parseNumberLikeParam(quality),\r\n }\r\n }\r\n )\r\n }\r\n {...imageProps}\r\n />\r\n }\r\n\r\n return (\r\n <Image\r\n loader={({src, width}) => loader(\r\n {\r\n width,\r\n src,\r\n transformations: {\r\n ...transformations,\r\n quality: quality && parseNumberLikeParam(quality),\r\n },\r\n baseUrl: finalBaseUrl\r\n })}\r\n src={srcWithoutTransformations}\r\n {...imageProps}\r\n />\r\n )\r\n}\r\n","import { createContext, type ReactNode } from 'react';\r\nimport type { PixelFiddlerConfig } from '@pixelfiddler/core';\r\n\r\nexport interface PixelFiddlerContextValue {\r\n config: PixelFiddlerConfig;\r\n}\r\n\r\nexport const PixelFiddlerContext = createContext<PixelFiddlerContextValue | null>(null);\r\n\r\nexport interface PixelFiddlerProviderProps {\r\n children: ReactNode;\r\n config: PixelFiddlerConfig;\r\n}\r\n\r\nexport function PixelFiddlerProvider({ children, config }: PixelFiddlerProviderProps) {\r\n return (\r\n <PixelFiddlerContext.Provider value={{config}}>\r\n {children}\r\n </PixelFiddlerContext.Provider>\r\n );\r\n}\r\n","import { ImageLoaderProps } from 'next/image';\r\nimport { buildTransformationUrl, TransformationOptions } from '@pixelfiddler/core';\r\n\r\ntype PixelFiddlerLoaderProps = ImageLoaderProps & {\r\n baseUrl?: string,\r\n transformations?: TransformationOptions\r\n}\r\n\r\ntype PixelFiddlerLoader = (props: PixelFiddlerLoaderProps) => string\r\n\r\nexport const loader: PixelFiddlerLoader = ({src, baseUrl, width: loaderWidth, transformations}) => {\r\n return buildTransformationUrl({\r\n src,\r\n baseUrl,\r\n transformations: {\r\n ...transformations,\r\n width: transformations?.width || loaderWidth,\r\n },\r\n })\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAoC;AACpC,mBAAkC;AAClC,IAA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AAG;AAAA;AAAA,IACR;AAAA,EACJ;AAEA,SACI;AAAA,IAAC,aAAAA;AAAA,IAAA;AAAA,MACG,QAAQ,CAAC,EAAC,KAAAC,MAAK,MAAK,MAAM;AAAA,QACtB;AAAA,UACI;AAAA,UACA,KAAAA;AAAA,UACA,iBAAiB;AAAA,YACb,GAAG;AAAA,YACH,SAAS,eAAW,mCAAqB,OAAO;AAAA,UACpD;AAAA,UACA,SAAS;AAAA,QACjB;AAAA,MAAC;AAAA,MACD,KAAK;AAAA,MACJ,GAAG;AAAA;AAAA,EACR;AAER;","names":["import_react","import_core","import_jsx_runtime","Image","src"]}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
import Image from 'next/image';
|
|
3
|
-
import { buildTransformationUrl, parseNumberLikeParam } from '@pixelfiddler/core';
|
|
4
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
"use client";
|
|
5
2
|
|
|
6
3
|
// src/components/pixel-fiddler-image.tsx
|
|
4
|
+
import { useContext, useMemo } from "react";
|
|
5
|
+
import Image from "next/image";
|
|
6
|
+
import { buildTransformationUrl as buildTransformationUrl2, parseNumberLikeParam } from "@pixelfiddler/core";
|
|
7
|
+
|
|
8
|
+
// src/provider/pixel-fiddler-context.tsx
|
|
9
|
+
import { createContext } from "react";
|
|
10
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
11
|
var PixelFiddlerContext = createContext(null);
|
|
8
12
|
function PixelFiddlerProvider({ children, config }) {
|
|
9
13
|
return /* @__PURE__ */ jsx(PixelFiddlerContext.Provider, { value: { config }, children });
|
|
10
14
|
}
|
|
15
|
+
|
|
16
|
+
// src/utils/loader.ts
|
|
17
|
+
import { buildTransformationUrl } from "@pixelfiddler/core";
|
|
11
18
|
var loader = ({ src, baseUrl, width: loaderWidth, transformations }) => {
|
|
12
19
|
return buildTransformationUrl({
|
|
13
20
|
src,
|
|
@@ -18,6 +25,9 @@ var loader = ({ src, baseUrl, width: loaderWidth, transformations }) => {
|
|
|
18
25
|
}
|
|
19
26
|
});
|
|
20
27
|
};
|
|
28
|
+
|
|
29
|
+
// src/components/pixel-fiddler-image.tsx
|
|
30
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
21
31
|
function PixelFiddlerImage({
|
|
22
32
|
src,
|
|
23
33
|
transformations,
|
|
@@ -30,27 +40,27 @@ function PixelFiddlerImage({
|
|
|
30
40
|
const context = useContext(PixelFiddlerContext);
|
|
31
41
|
const finalBaseUrl = baseUrl || context?.config?.baseUrl;
|
|
32
42
|
const srcWithoutTransformations = useMemo(() => {
|
|
33
|
-
return
|
|
43
|
+
return buildTransformationUrl2({
|
|
34
44
|
baseUrl: finalBaseUrl,
|
|
35
45
|
src
|
|
36
46
|
});
|
|
37
47
|
}, [src]);
|
|
38
48
|
if (unoptimized) {
|
|
39
|
-
return /* @__PURE__ */
|
|
49
|
+
return /* @__PURE__ */ jsx2(
|
|
40
50
|
Image,
|
|
41
51
|
{
|
|
42
52
|
unoptimized: true,
|
|
43
|
-
src:
|
|
53
|
+
src: buildTransformationUrl2({ src, baseUrl: finalBaseUrl }),
|
|
44
54
|
...imageProps
|
|
45
55
|
}
|
|
46
56
|
);
|
|
47
57
|
}
|
|
48
58
|
if (!responsive) {
|
|
49
|
-
return /* @__PURE__ */
|
|
59
|
+
return /* @__PURE__ */ jsx2(
|
|
50
60
|
Image,
|
|
51
61
|
{
|
|
52
62
|
unoptimized: true,
|
|
53
|
-
src:
|
|
63
|
+
src: buildTransformationUrl2(
|
|
54
64
|
{
|
|
55
65
|
src,
|
|
56
66
|
baseUrl: finalBaseUrl,
|
|
@@ -64,7 +74,7 @@ function PixelFiddlerImage({
|
|
|
64
74
|
}
|
|
65
75
|
);
|
|
66
76
|
}
|
|
67
|
-
return /* @__PURE__ */
|
|
77
|
+
return /* @__PURE__ */ jsx2(
|
|
68
78
|
Image,
|
|
69
79
|
{
|
|
70
80
|
loader: ({ src: src2, width }) => loader(
|
|
@@ -83,7 +93,8 @@ function PixelFiddlerImage({
|
|
|
83
93
|
}
|
|
84
94
|
);
|
|
85
95
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
96
|
+
export {
|
|
97
|
+
PixelFiddlerImage,
|
|
98
|
+
PixelFiddlerProvider
|
|
99
|
+
};
|
|
89
100
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/components/pixel-fiddler-image.tsx","../src/provider/pixel-fiddler-context.tsx","../src/utils/loader.ts"],"sourcesContent":["import { useContext, useMemo } from 'react'\r\nimport Image, { ImageProps } from 'next/image'\r\nimport { buildTransformationUrl, parseNumberLikeParam, TransformationOptions, } from '@pixelfiddler/core'\r\nimport { PixelFiddlerContext } from '../provider/pixel-fiddler-context'\r\nimport { loader } from '../utils/loader';\r\n\r\nexport interface PixelFiddlerImageProps\r\n extends Omit<ImageProps, 'src' | 'loader' | 'sizes'> {\r\n /** Src to your image - can be both relative or absolute.\r\n * If it's relative, it will be attached to baseUrl from config\r\n * If it's absolute, it will be left as is\r\n */\r\n src: string\r\n /** Base URL from PixelFiddler Dashboard.\r\n * Can be omitted if provided via PixelFiddlerProvider\r\n */\r\n baseUrl?: string\r\n /**\r\n * Sizes attribute for responsive images\r\n * e.g. \"(max-width: 768px) 100vw, 50vw\"\r\n */\r\n sizes?: string\r\n /**\r\n * Whether automatic generation of srcset should be enabled.\r\n * @default true\r\n */\r\n responsive?: boolean\r\n /**\r\n * Transformation options to apply\r\n */\r\n transformations?: TransformationOptions\r\n}\r\n\r\nexport function PixelFiddlerImage({\r\n src,\r\n transformations,\r\n baseUrl,\r\n responsive = true,\r\n unoptimized = false,\r\n quality,\r\n ...imageProps\r\n }: PixelFiddlerImageProps) {\r\n const context = useContext(PixelFiddlerContext)\r\n const finalBaseUrl = baseUrl || context?.config?.baseUrl\r\n\r\n\r\n const srcWithoutTransformations = useMemo(() => {\r\n return buildTransformationUrl({\r\n baseUrl: finalBaseUrl,\r\n src\r\n })\r\n }, [src])\r\n\r\n if (unoptimized) {\r\n return <Image unoptimized={true}\r\n src={buildTransformationUrl({src, baseUrl: finalBaseUrl})}\r\n {...imageProps}\r\n />\r\n }\r\n\r\n if (!responsive) {\r\n return <Image\r\n unoptimized={true}\r\n src={buildTransformationUrl(\r\n {\r\n src,\r\n baseUrl: finalBaseUrl,\r\n transformations: {\r\n ...transformations,\r\n quality: quality && parseNumberLikeParam(quality),\r\n }\r\n }\r\n )\r\n }\r\n {...imageProps}\r\n />\r\n }\r\n\r\n return (\r\n <Image\r\n loader={({src, width}) => loader(\r\n {\r\n width,\r\n src,\r\n transformations: {\r\n ...transformations,\r\n quality: quality && parseNumberLikeParam(quality),\r\n },\r\n baseUrl: finalBaseUrl\r\n })}\r\n src={srcWithoutTransformations}\r\n {...imageProps}\r\n />\r\n )\r\n}\r\n","import { createContext, type ReactNode } from 'react';\r\nimport type { PixelFiddlerConfig } from '@pixelfiddler/core';\r\n\r\nexport interface PixelFiddlerContextValue {\r\n config: PixelFiddlerConfig;\r\n}\r\n\r\nexport const PixelFiddlerContext = createContext<PixelFiddlerContextValue | null>(null);\r\n\r\nexport interface PixelFiddlerProviderProps {\r\n children: ReactNode;\r\n config: PixelFiddlerConfig;\r\n}\r\n\r\nexport function PixelFiddlerProvider({ children, config }: PixelFiddlerProviderProps) {\r\n return (\r\n <PixelFiddlerContext.Provider value={{config}}>\r\n {children}\r\n </PixelFiddlerContext.Provider>\r\n );\r\n}\r\n","import { ImageLoaderProps } from 'next/image';\r\nimport { buildTransformationUrl, TransformationOptions } from '@pixelfiddler/core';\r\n\r\ntype PixelFiddlerLoaderProps = ImageLoaderProps & {\r\n baseUrl?: string,\r\n transformations?: TransformationOptions\r\n}\r\n\r\ntype PixelFiddlerLoader = (props: PixelFiddlerLoaderProps) => string\r\n\r\nexport const loader: PixelFiddlerLoader = ({src, baseUrl, width: loaderWidth, transformations}) => {\r\n return buildTransformationUrl({\r\n src,\r\n baseUrl,\r\n transformations: {\r\n ...transformations,\r\n width: transformations?.width || loaderWidth,\r\n },\r\n })\r\n}\r\n"],"mappings":";;;AAAA,SAAS,YAAY,eAAe;AACpC,OAAO,WAA2B;AAClC,SAAS,0BAAAA,yBAAwB,4BAAoD;;;ACFrF,SAAS,qBAAqC;AAgBtC;AATD,IAAM,sBAAsB,cAA+C,IAAI;AAO/E,SAAS,qBAAqB,EAAE,UAAU,OAAO,GAA8B;AAClF,SACI,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,EAAC,OAAM,GACvC,UACL;AAER;;;ACnBA,SAAS,8BAAqD;AASvD,IAAM,SAA6B,CAAC,EAAC,KAAK,SAAS,OAAO,aAAa,gBAAe,MAAM;AAC/F,SAAO,uBAAuB;AAAA,IAC1B;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,MACb,GAAG;AAAA,MACH,OAAO,iBAAiB,SAAS;AAAA,IACrC;AAAA,EACJ,CAAC;AACL;;;AFmCe,gBAAAC,YAAA;AArBR,SAAS,kBAAkB;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,cAAc;AAAA,EACd;AAAA,EACA,GAAG;AACP,GAA2B;AACzD,QAAM,UAAU,WAAW,mBAAmB;AAC9C,QAAM,eAAe,WAAW,SAAS,QAAQ;AAGjD,QAAM,4BAA4B,QAAQ,MAAM;AAC5C,WAAOC,wBAAuB;AAAA,MAC1B,SAAS;AAAA,MACT;AAAA,IACJ,CAAC;AAAA,EACL,GAAG,CAAC,GAAG,CAAC;AAER,MAAI,aAAa;AACb,WAAO,gBAAAD;AAAA,MAAC;AAAA;AAAA,QAAM,aAAa;AAAA,QACb,KAAKC,wBAAuB,EAAC,KAAK,SAAS,aAAY,CAAC;AAAA,QACvD,GAAG;AAAA;AAAA,IAClB;AAAA,EACJ;AAEA,MAAI,CAAC,YAAY;AACb,WAAO,gBAAAD;AAAA,MAAC;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