@getcronit/pylon 3.0.0-canary-20250303121751.7a1e28546f22cace7b91da6877508f76107e42aa → 3.0.0-canary-20250303143548.bb9615641321063a172cd6af0a5cd52e2a2bc0a1
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/pages/index.d.ts
CHANGED
package/dist/pages/index.js
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
// src/pages/index.ts
|
|
2
2
|
import * as __PYLON_ROUTER_INTERNALS_DO_NOT_USE from "react-router";
|
|
3
|
+
|
|
4
|
+
// src/pages/image.tsx
|
|
5
|
+
import { useState, useEffect, useMemo, useRef } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var usePylonImageValues = (props) => {
|
|
8
|
+
return useMemo(() => {
|
|
9
|
+
const url = new URL(props.src, "http://localhost");
|
|
10
|
+
const searchParams = new URLSearchParams(url.search);
|
|
11
|
+
const getValue = (propValue, paramKey) => propValue ?? searchParams.get(paramKey);
|
|
12
|
+
const width = getValue(props.width, "w");
|
|
13
|
+
const height = getValue(props.height, "h");
|
|
14
|
+
const blurDataURL = getValue(props.blurDataURL, "blurDataURL");
|
|
15
|
+
const pylonMediaSearchParams = new URLSearchParams({
|
|
16
|
+
src: url.pathname,
|
|
17
|
+
...width && { w: width.toString() },
|
|
18
|
+
...height && { h: height.toString() }
|
|
19
|
+
});
|
|
20
|
+
const finalSrc = `/__pylon/image?${pylonMediaSearchParams.toString()}`;
|
|
21
|
+
return {
|
|
22
|
+
width: width ? parseInt(width) : void 0,
|
|
23
|
+
height: height ? parseInt(height) : void 0,
|
|
24
|
+
blurDataURL,
|
|
25
|
+
src: finalSrc
|
|
26
|
+
};
|
|
27
|
+
}, [props]);
|
|
28
|
+
};
|
|
29
|
+
var PylonImage = (props) => {
|
|
30
|
+
console.log("PylonImage", props);
|
|
31
|
+
const values = usePylonImageValues(props);
|
|
32
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
33
|
+
const imgRef = useRef(null);
|
|
34
|
+
console.log("mgRef.current?.complete", imgRef.current?.complete);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (imgRef.current?.complete) {
|
|
37
|
+
setIsLoaded(true);
|
|
38
|
+
}
|
|
39
|
+
}, [imgRef.current]);
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
"img",
|
|
42
|
+
{
|
|
43
|
+
ref: imgRef,
|
|
44
|
+
src: values.src,
|
|
45
|
+
alt: props.alt,
|
|
46
|
+
className: props.className,
|
|
47
|
+
width: values.width,
|
|
48
|
+
height: values.height,
|
|
49
|
+
onLoad: () => setIsLoaded(true),
|
|
50
|
+
style: {
|
|
51
|
+
backgroundImage: `url(${values.blurDataURL})`,
|
|
52
|
+
backgroundSize: "cover",
|
|
53
|
+
filter: !isLoaded ? "blur(5px)" : "none",
|
|
54
|
+
transition: "filter 0.3s ease-out, opacity 0.3s ease-out"
|
|
55
|
+
},
|
|
56
|
+
loading: "lazy"
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
};
|
|
3
60
|
export {
|
|
61
|
+
PylonImage as Image,
|
|
4
62
|
__PYLON_ROUTER_INTERNALS_DO_NOT_USE
|
|
5
63
|
};
|
|
6
64
|
//# sourceMappingURL=index.js.map
|
package/dist/pages/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/pages/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * as __PYLON_ROUTER_INTERNALS_DO_NOT_USE from 'react-router'\nexport {type PageProps, type PageData} from '../plugins/use-pages/index'\n"],
|
|
5
|
-
"mappings": ";AAAA,YAAY,yCAAyC;",
|
|
3
|
+
"sources": ["../../src/pages/index.ts", "../../src/pages/image.tsx"],
|
|
4
|
+
"sourcesContent": ["export * as __PYLON_ROUTER_INTERNALS_DO_NOT_USE from 'react-router'\nexport {type PageProps, type PageData} from '../plugins/use-pages/index'\nexport {PylonImage as Image} from './image'\n", "import React, {useState, useEffect, useMemo, useRef} from 'react'\n\nexport interface ImageProps {\n src: string\n alt?: string\n className?: string\n width?: number\n height?: number\n blurDataURL?: string\n}\n\n/**\n * Custom hook to process and extract image properties,\n * ensuring correct values for width, height, and blur data.\n * Generates a final image URL compatible with Pylon's media proxy.\n *\n * @param {ImageProps} props - The image properties including src, width, height, and blurDataURL.\n * @returns {Object} The processed image values: width, height, blurDataURL, and final image source.\n */\nconst usePylonImageValues = (\n props: ImageProps\n): {\n src: string\n width?: number\n height?: number\n blurDataURL?: string\n} => {\n return useMemo(() => {\n // Parse the image source URL to extract query parameters\n const url = new URL(props.src, 'http://localhost')\n const searchParams = new URLSearchParams(url.search)\n\n // Extract values, prioritizing props over query params\n const getValue = (propValue, paramKey) =>\n propValue ?? searchParams.get(paramKey)\n const width = getValue(props.width, 'w')\n const height = getValue(props.height, 'h')\n const blurDataURL = getValue(props.blurDataURL, 'blurDataURL')\n\n // Prepare Pylon-specific query params\n const pylonMediaSearchParams = new URLSearchParams({\n src: url.pathname,\n ...(width && {w: width.toString()}),\n ...(height && {h: height.toString()})\n })\n\n // Construct the final image source URL\n const finalSrc = `/__pylon/image?${pylonMediaSearchParams.toString()}`\n\n return {\n width: width ? parseInt(width) : undefined,\n height: height ? parseInt(height) : undefined,\n blurDataURL,\n src: finalSrc\n }\n }, [props])\n}\n\nexport const PylonImage: React.FC<ImageProps> = props => {\n console.log('PylonImage', props)\n\n const values = usePylonImageValues(props)\n const [isLoaded, setIsLoaded] = useState(false)\n const imgRef = useRef<HTMLImageElement | null>(null)\n\n console.log('mgRef.current?.complete', imgRef.current?.complete)\n\n useEffect(() => {\n if (imgRef.current?.complete) {\n setIsLoaded(true)\n }\n }, [imgRef.current])\n\n return (\n <img\n ref={imgRef}\n src={values.src}\n alt={props.alt}\n className={props.className}\n width={values.width}\n height={values.height}\n onLoad={() => setIsLoaded(true)}\n style={{\n backgroundImage: `url(${values.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OAAO,SAAS,UAAU;AAC5B,kBAAY,IAAI;AAAA,IAClB;AAAA,EACF,GAAG,CAAC,OAAO,OAAO,CAAC;AAEnB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,KAAK;AAAA,MACL,KAAK,OAAO;AAAA,MACZ,KAAK,MAAM;AAAA,MACX,WAAW,MAAM;AAAA,MACjB,OAAO,OAAO;AAAA,MACd,QAAQ,OAAO;AAAA,MACf,QAAQ,MAAM,YAAY,IAAI;AAAA,MAC9B,OAAO;AAAA,QACL,iBAAiB,OAAO,OAAO,WAAW;AAAA,QAC1C,gBAAgB;AAAA,QAChB,QAAQ,CAAC,WAAW,cAAc;AAAA,QAClC,YAAY;AAAA,MACd;AAAA,MACA,SAAQ;AAAA;AAAA,EACV;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getcronit/pylon",
|
|
3
|
-
"version": "3.0.0-canary-
|
|
3
|
+
"version": "3.0.0-canary-20250303143548.bb9615641321063a172cd6af0a5cd52e2a2bc0a1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@sentry/types": "^8.54.0",
|
|
58
|
+
"@types/react": "^19.0.8",
|
|
58
59
|
"@types/react-dom": "^19.0.4"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|