@hanzogui/image 2.0.0
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 +21 -0
- package/dist/cjs/Image.cjs +62 -0
- package/dist/cjs/Image.native.js +33 -0
- package/dist/cjs/Image.native.js.map +1 -0
- package/dist/cjs/createImage.cjs +128 -0
- package/dist/cjs/createImage.native.js +134 -0
- package/dist/cjs/createImage.native.js.map +1 -0
- package/dist/cjs/index.cjs +19 -0
- package/dist/cjs/index.native.js +22 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/cjs/types.cjs +16 -0
- package/dist/cjs/types.native.js +19 -0
- package/dist/cjs/types.native.js.map +1 -0
- package/dist/cjs/v1/Image.cjs +86 -0
- package/dist/cjs/v1/Image.native.js +105 -0
- package/dist/cjs/v1/Image.native.js.map +1 -0
- package/dist/cjs/v1/index.cjs +18 -0
- package/dist/cjs/v1/index.native.js +21 -0
- package/dist/cjs/v1/index.native.js.map +1 -0
- package/dist/esm/Image.mjs +39 -0
- package/dist/esm/Image.mjs.map +1 -0
- package/dist/esm/Image.native.js +7 -0
- package/dist/esm/Image.native.js.map +1 -0
- package/dist/esm/createImage.mjs +105 -0
- package/dist/esm/createImage.mjs.map +1 -0
- package/dist/esm/createImage.native.js +108 -0
- package/dist/esm/createImage.native.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +3 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -0
- package/dist/esm/types.native.js.map +1 -0
- package/dist/esm/v1/Image.mjs +52 -0
- package/dist/esm/v1/Image.mjs.map +1 -0
- package/dist/esm/v1/Image.native.js +68 -0
- package/dist/esm/v1/Image.native.js.map +1 -0
- package/dist/esm/v1/index.mjs +2 -0
- package/dist/esm/v1/index.mjs.map +1 -0
- package/dist/esm/v1/index.native.js +2 -0
- package/dist/esm/v1/index.native.js.map +1 -0
- package/dist/jsx/Image.mjs +39 -0
- package/dist/jsx/Image.mjs.map +1 -0
- package/dist/jsx/Image.native.js +33 -0
- package/dist/jsx/Image.native.js.map +1 -0
- package/dist/jsx/createImage.mjs +105 -0
- package/dist/jsx/createImage.mjs.map +1 -0
- package/dist/jsx/createImage.native.js +134 -0
- package/dist/jsx/createImage.native.js.map +1 -0
- package/dist/jsx/index.js +3 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/index.mjs +3 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/index.native.js +22 -0
- package/dist/jsx/index.native.js.map +1 -0
- package/dist/jsx/types.mjs +2 -0
- package/dist/jsx/types.mjs.map +1 -0
- package/dist/jsx/types.native.js +19 -0
- package/dist/jsx/types.native.js.map +1 -0
- package/dist/jsx/v1/Image.mjs +52 -0
- package/dist/jsx/v1/Image.mjs.map +1 -0
- package/dist/jsx/v1/Image.native.js +105 -0
- package/dist/jsx/v1/Image.native.js.map +1 -0
- package/dist/jsx/v1/index.mjs +2 -0
- package/dist/jsx/v1/index.mjs.map +1 -0
- package/dist/jsx/v1/index.native.js +21 -0
- package/dist/jsx/v1/index.native.js.map +1 -0
- package/package.json +53 -0
- package/src/Image.native.tsx +6 -0
- package/src/Image.tsx +41 -0
- package/src/createImage.tsx +236 -0
- package/src/index.ts +3 -0
- package/src/types.ts +54 -0
- package/src/v1/Image.tsx +144 -0
- package/src/v1/index.ts +1 -0
- package/types/Image.d.ts +3 -0
- package/types/Image.native.d.ts +16 -0
- package/types/createImage.d.ts +77 -0
- package/types/index.d.ts +4 -0
- package/types/types.d.ts +42 -0
- package/types/v1/Image.d.ts +36 -0
- package/types/v1/index.d.ts +2 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Nate Wienert
|
|
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.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var Image_exports = {};
|
|
22
|
+
__export(Image_exports, {
|
|
23
|
+
Image: () => Image
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(Image_exports);
|
|
26
|
+
var import_gui_web = require("@hanzo/gui-web"),
|
|
27
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
const StyledImage = (0, import_gui_web.styled)(import_gui_web.View, {
|
|
29
|
+
name: "Image",
|
|
30
|
+
render: "img"
|
|
31
|
+
}),
|
|
32
|
+
Image = StyledImage.styleable((inProps, ref) => {
|
|
33
|
+
const {
|
|
34
|
+
// exclude native only props
|
|
35
|
+
blurRadius,
|
|
36
|
+
capInsets,
|
|
37
|
+
defaultSource,
|
|
38
|
+
fadeDuration,
|
|
39
|
+
loadingIndicatorSource,
|
|
40
|
+
onLoadEnd,
|
|
41
|
+
onPartialLoad,
|
|
42
|
+
progressiveRenderingEnabled,
|
|
43
|
+
resizeMethod,
|
|
44
|
+
tintColor,
|
|
45
|
+
...rest
|
|
46
|
+
} = inProps;
|
|
47
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(StyledImage, {
|
|
48
|
+
ref,
|
|
49
|
+
...rest
|
|
50
|
+
});
|
|
51
|
+
}, {
|
|
52
|
+
staticConfig: {
|
|
53
|
+
memo: !0
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
func = () => {};
|
|
57
|
+
Image.getSize = func;
|
|
58
|
+
Image.getSizeWithHeaders = func;
|
|
59
|
+
Image.prefetch = func;
|
|
60
|
+
Image.prefetchWithMetadata = func;
|
|
61
|
+
Image.abortPrefetch = func;
|
|
62
|
+
Image.queryCache = func;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: !0
|
|
22
|
+
}), mod);
|
|
23
|
+
var Image_native_exports = {};
|
|
24
|
+
__export(Image_native_exports, {
|
|
25
|
+
Image: () => Image
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(Image_native_exports);
|
|
28
|
+
var import_react_native = require("react-native"),
|
|
29
|
+
import_createImage = require("./createImage.native.js"),
|
|
30
|
+
Image = (0, import_createImage.createImage)({
|
|
31
|
+
Component: import_react_native.Image
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=Image.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Image_native_exports","__export","Image","module","exports","__toCommonJS","import_react_native","require","import_createImage","createImage","Component"],"sources":["../../src/Image.native.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,oBAAA;AAAAC,QAAA,CAAAD,oBAAA;EAAAE,KAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAL,oBAAA;AAAA,IAAAM,mBAAA,GAAiCC,OAAA;EACjCC,kBAAA,GAA4BD,OAAA;EACjBL,KAAA,OAAQM,kBAAA,CAAAC,WAAA,EAAY;IAC3BC,SAAA,EAAWJ,mBAAA,CAAAJ;EACf,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var createImage_exports = {};
|
|
22
|
+
__export(createImage_exports, {
|
|
23
|
+
createImage: () => createImage
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(createImage_exports);
|
|
26
|
+
var import_gui_web = require("@hanzo/gui-web"),
|
|
27
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
const defaultObjectFitMap = objectFit => {
|
|
29
|
+
switch (objectFit) {
|
|
30
|
+
case "fill":
|
|
31
|
+
return "stretch";
|
|
32
|
+
case "none":
|
|
33
|
+
return "center";
|
|
34
|
+
case "scale-down":
|
|
35
|
+
return "contain";
|
|
36
|
+
case "contain":
|
|
37
|
+
return "contain";
|
|
38
|
+
default:
|
|
39
|
+
return "cover";
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
defaultTransformSource = props => {
|
|
43
|
+
const {
|
|
44
|
+
src,
|
|
45
|
+
source,
|
|
46
|
+
width,
|
|
47
|
+
height
|
|
48
|
+
} = props;
|
|
49
|
+
return source || (src && typeof src != "string" ? src : {
|
|
50
|
+
uri: src,
|
|
51
|
+
width,
|
|
52
|
+
height
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
function createImage(options) {
|
|
56
|
+
const {
|
|
57
|
+
Component,
|
|
58
|
+
mapObjectFitToResizeMode = defaultObjectFitMap,
|
|
59
|
+
resizeModePropName = "resizeMode",
|
|
60
|
+
objectPositionPropName,
|
|
61
|
+
transformSource = defaultTransformSource
|
|
62
|
+
} = options,
|
|
63
|
+
ImageComponent = (0, import_gui_web.styled)(Component, {
|
|
64
|
+
name: "Image"
|
|
65
|
+
}, {
|
|
66
|
+
inlineProps: /* @__PURE__ */new Set(["source", "placeholder", "transition", "contentFit", "contentPosition", "cachePolicy", "recyclingKey", "allowDownscaling", "autoplay", "blurRadius", "priority", "placeholderContentFit", "responsivePolicy", "onLoadStart", "onProgress", "onLoadEnd"])
|
|
67
|
+
}).styleable((incomingProps, ref) => {
|
|
68
|
+
const props = incomingProps,
|
|
69
|
+
{
|
|
70
|
+
src,
|
|
71
|
+
width,
|
|
72
|
+
height,
|
|
73
|
+
objectFit,
|
|
74
|
+
objectPosition,
|
|
75
|
+
// web only props - filter out on native
|
|
76
|
+
decoding,
|
|
77
|
+
elementTiming,
|
|
78
|
+
fetchpriority,
|
|
79
|
+
isMap,
|
|
80
|
+
loading,
|
|
81
|
+
sizes,
|
|
82
|
+
useMap,
|
|
83
|
+
onLoad,
|
|
84
|
+
onError,
|
|
85
|
+
...rest
|
|
86
|
+
} = props,
|
|
87
|
+
resolvedWidth = typeof width == "string" && width[0] === "$" ? (0, import_gui_web.getTokenValue)(width) : width,
|
|
88
|
+
resolvedHeight = typeof height == "string" && height[0] === "$" ? (0, import_gui_web.getTokenValue)(height) : height,
|
|
89
|
+
finalSource = transformSource({
|
|
90
|
+
src,
|
|
91
|
+
width: resolvedWidth,
|
|
92
|
+
height: resolvedHeight
|
|
93
|
+
}),
|
|
94
|
+
incomingStyle = Array.isArray(rest.style) ? Object.assign({}, ...rest.style.flat()) : rest.style,
|
|
95
|
+
finalProps = {
|
|
96
|
+
...rest,
|
|
97
|
+
source: finalSource,
|
|
98
|
+
style: {
|
|
99
|
+
...incomingStyle,
|
|
100
|
+
...(resolvedWidth !== void 0 && {
|
|
101
|
+
width: resolvedWidth
|
|
102
|
+
}),
|
|
103
|
+
...(resolvedHeight !== void 0 && {
|
|
104
|
+
height: resolvedHeight
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
return objectFit && (finalProps[resizeModePropName] = mapObjectFitToResizeMode(objectFit)), objectPositionPropName && objectPosition && (finalProps[objectPositionPropName] = objectPosition), onLoad && (finalProps.onLoad = e => {
|
|
109
|
+
const source = e?.nativeEvent?.source || e?.source || {};
|
|
110
|
+
onLoad({
|
|
111
|
+
target: {
|
|
112
|
+
naturalHeight: source?.height,
|
|
113
|
+
naturalWidth: source?.width
|
|
114
|
+
},
|
|
115
|
+
type: "load"
|
|
116
|
+
});
|
|
117
|
+
}), onError && (finalProps.onError = () => {
|
|
118
|
+
onError({
|
|
119
|
+
type: "error"
|
|
120
|
+
});
|
|
121
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(Component, {
|
|
122
|
+
ref,
|
|
123
|
+
...finalProps
|
|
124
|
+
});
|
|
125
|
+
}),
|
|
126
|
+
comp = Component;
|
|
127
|
+
return ImageComponent.getSize = comp.getSize || (() => {}), ImageComponent.getSizeWithHeaders = comp.getSizeWithHeaders || (() => {}), ImageComponent.prefetch = comp.prefetch || (() => {}), ImageComponent.prefetchWithMetadata = comp.prefetchWithMetadata || (() => {}), ImageComponent.abortPrefetch = comp.abortPrefetch || (() => {}), ImageComponent.queryCache = comp.queryCache || (() => {}), ImageComponent;
|
|
128
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: !0
|
|
22
|
+
}), mod);
|
|
23
|
+
var createImage_exports = {};
|
|
24
|
+
__export(createImage_exports, {
|
|
25
|
+
createImage: () => createImage
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(createImage_exports);
|
|
28
|
+
var import_jsx_runtime = require("react/jsx-runtime"),
|
|
29
|
+
import_gui_web = require("@hanzo/gui-web"),
|
|
30
|
+
defaultObjectFitMap = function (objectFit) {
|
|
31
|
+
switch (objectFit) {
|
|
32
|
+
case "fill":
|
|
33
|
+
return "stretch";
|
|
34
|
+
case "none":
|
|
35
|
+
return "center";
|
|
36
|
+
case "scale-down":
|
|
37
|
+
return "contain";
|
|
38
|
+
case "contain":
|
|
39
|
+
return "contain";
|
|
40
|
+
default:
|
|
41
|
+
return "cover";
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
defaultTransformSource = function (props) {
|
|
45
|
+
var {
|
|
46
|
+
src,
|
|
47
|
+
source,
|
|
48
|
+
width,
|
|
49
|
+
height
|
|
50
|
+
} = props;
|
|
51
|
+
return source || (src && typeof src != "string" ? src : {
|
|
52
|
+
uri: src,
|
|
53
|
+
width,
|
|
54
|
+
height
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
function createImage(options) {
|
|
58
|
+
var {
|
|
59
|
+
Component,
|
|
60
|
+
mapObjectFitToResizeMode = defaultObjectFitMap,
|
|
61
|
+
resizeModePropName = "resizeMode",
|
|
62
|
+
objectPositionPropName,
|
|
63
|
+
transformSource = defaultTransformSource
|
|
64
|
+
} = options,
|
|
65
|
+
inlinePropsSet = /* @__PURE__ */new Set(["source", "placeholder", "transition", "contentFit", "contentPosition", "cachePolicy", "recyclingKey", "allowDownscaling", "autoplay", "blurRadius", "priority", "placeholderContentFit", "responsivePolicy", "onLoadStart", "onProgress", "onLoadEnd"]),
|
|
66
|
+
StyledImage = (0, import_gui_web.styled)(Component, {
|
|
67
|
+
name: "Image"
|
|
68
|
+
}, {
|
|
69
|
+
inlineProps: inlinePropsSet
|
|
70
|
+
}),
|
|
71
|
+
ImageComponent = StyledImage.styleable(function (incomingProps, ref) {
|
|
72
|
+
var props = incomingProps,
|
|
73
|
+
{
|
|
74
|
+
src,
|
|
75
|
+
width,
|
|
76
|
+
height,
|
|
77
|
+
objectFit,
|
|
78
|
+
objectPosition,
|
|
79
|
+
// web only props - filter out on native
|
|
80
|
+
decoding,
|
|
81
|
+
elementTiming,
|
|
82
|
+
fetchpriority,
|
|
83
|
+
isMap,
|
|
84
|
+
loading,
|
|
85
|
+
sizes,
|
|
86
|
+
useMap,
|
|
87
|
+
onLoad,
|
|
88
|
+
onError,
|
|
89
|
+
...rest
|
|
90
|
+
} = props,
|
|
91
|
+
resolvedWidth = typeof width == "string" && width[0] === "$" ? (0, import_gui_web.getTokenValue)(width) : width,
|
|
92
|
+
resolvedHeight = typeof height == "string" && height[0] === "$" ? (0, import_gui_web.getTokenValue)(height) : height,
|
|
93
|
+
finalSource = transformSource({
|
|
94
|
+
src,
|
|
95
|
+
width: resolvedWidth,
|
|
96
|
+
height: resolvedHeight
|
|
97
|
+
}),
|
|
98
|
+
incomingStyle = Array.isArray(rest.style) ? Object.assign({}, ...rest.style.flat()) : rest.style,
|
|
99
|
+
finalProps = {
|
|
100
|
+
...rest,
|
|
101
|
+
source: finalSource,
|
|
102
|
+
style: {
|
|
103
|
+
...incomingStyle,
|
|
104
|
+
...(resolvedWidth !== void 0 && {
|
|
105
|
+
width: resolvedWidth
|
|
106
|
+
}),
|
|
107
|
+
...(resolvedHeight !== void 0 && {
|
|
108
|
+
height: resolvedHeight
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return objectFit && (finalProps[resizeModePropName] = mapObjectFitToResizeMode(objectFit)), objectPositionPropName && objectPosition && (finalProps[objectPositionPropName] = objectPosition), onLoad && (finalProps.onLoad = function (e) {
|
|
113
|
+
var _e_nativeEvent,
|
|
114
|
+
source = (e == null || (_e_nativeEvent = e.nativeEvent) === null || _e_nativeEvent === void 0 ? void 0 : _e_nativeEvent.source) || e?.source || {};
|
|
115
|
+
onLoad({
|
|
116
|
+
target: {
|
|
117
|
+
naturalHeight: source?.height,
|
|
118
|
+
naturalWidth: source?.width
|
|
119
|
+
},
|
|
120
|
+
type: "load"
|
|
121
|
+
});
|
|
122
|
+
}), onError && (finalProps.onError = function () {
|
|
123
|
+
onError({
|
|
124
|
+
type: "error"
|
|
125
|
+
});
|
|
126
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(Component, {
|
|
127
|
+
ref,
|
|
128
|
+
...finalProps
|
|
129
|
+
});
|
|
130
|
+
}),
|
|
131
|
+
comp = Component;
|
|
132
|
+
return ImageComponent.getSize = comp.getSize || function () {}, ImageComponent.getSizeWithHeaders = comp.getSizeWithHeaders || function () {}, ImageComponent.prefetch = comp.prefetch || function () {}, ImageComponent.prefetchWithMetadata = comp.prefetchWithMetadata || function () {}, ImageComponent.abortPrefetch = comp.abortPrefetch || function () {}, ImageComponent.queryCache = comp.queryCache || function () {}, ImageComponent;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=createImage.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","createImage_exports","__export","createImage","module","exports","import_jsx_runtime","require","import_gui_web","defaultObjectFitMap","objectFit","defaultTransformSource","props","src","source","width","height","uri","options","Component","mapObjectFitToResizeMode","resizeModePropName","objectPositionPropName","transformSource","inlinePropsSet","Set","StyledImage","styled","name","inlineProps","ImageComponent","styleable","incomingProps","ref","objectPosition","decoding","elementTiming","fetchpriority","isMap","loading","sizes","useMap","onLoad","onError","rest","resolvedWidth","getTokenValue","resolvedHeight","finalSource","incomingStyle","Array","isArray","style","Object","assign","flat","finalProps","e","_e_nativeEvent","nativeEvent","target","naturalHeight","naturalWidth","type","jsx","comp","getSize","getSizeWithHeaders","prefetch","prefetchWithMetadata","abortPrefetch","queryCache"],"sources":["../../src/createImage.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,mBAAA;AAAAC,QAAA,CAAAD,mBAAA;EAAAE,WAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAsC,CAAAK,mBA8N3B;AApLX,IAAAK,kBAAM,GAAAC,OAAuB,oBAAuC;EA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EA;IAAQ;IAAAS,IACN,GAAA9C,SAAM;EAAA,OACAW,cAAA,CAAAoC,OAAA,GAAAD,IAAA,CAAAC,OAAA,oBACVpC,cAIK,CAAAqC,kBAAA,GAAAF,IAAA,CAAAE,kBAAC,IAAU,YAAc,CAClC,CAAC,EAAArC,cAGY,CAAAsC,QAAA,GAAAH,IAAA,CAAAG,QAAA,iBACb,GAAAtC,cAAA,CAAAuC,oBAA8B,GAAAJ,IAAA,CAAAI,oBAAkB,iBAAC,GAAAvC,cACjD,CAAAwC,aAAe,GAAAL,IAAA,CAAAK,aAA0B,iBAA8B,GAAAxC,cACvE,CAAAyC,UAAe,GAAWN,IAAK,CAAAM,UAAA,IAAa,YAAM,CAAC,GAAAzC,cACnD;AAA0E","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
+
get: () => from[key],
|
|
8
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
+
});
|
|
10
|
+
return to;
|
|
11
|
+
},
|
|
12
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
+
value: !0
|
|
15
|
+
}), mod);
|
|
16
|
+
var index_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(index_exports);
|
|
18
|
+
__reExport(index_exports, require("./Image.cjs"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./createImage.cjs"), module.exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
9
|
+
get: () => from[key],
|
|
10
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
+
});
|
|
12
|
+
return to;
|
|
13
|
+
},
|
|
14
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
+
value: !0
|
|
17
|
+
}), mod);
|
|
18
|
+
var index_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(index_exports);
|
|
20
|
+
__reExport(index_exports, require("./Image.native.js"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./createImage.native.js"), module.exports);
|
|
22
|
+
//# sourceMappingURL=index.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","module","exports","__reExport","require"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAP,YAAc,CAAAK,aAAA;AACdG,UAAA,CAAAH,aAAA,EAAcI,OAAA,uBAAAH,MADd,CAAAC,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
+
get: () => from[key],
|
|
8
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
+
});
|
|
10
|
+
return to;
|
|
11
|
+
};
|
|
12
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
13
|
+
value: !0
|
|
14
|
+
}), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
9
|
+
get: () => from[key],
|
|
10
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
+
});
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
15
|
+
value: !0
|
|
16
|
+
}), mod);
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=types.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","types_exports"],"sources":["../../src/types.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA","ignoreList":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var Image_exports = {};
|
|
33
|
+
__export(Image_exports, {
|
|
34
|
+
Image: () => Image
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(Image_exports);
|
|
37
|
+
var import_react = __toESM(require("react"), 1),
|
|
38
|
+
import_gui_constants = require("@hanzo/gui-constants"),
|
|
39
|
+
import_gui_web = require("@hanzo/gui-web"),
|
|
40
|
+
import_react_native = require("react-native-web"),
|
|
41
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
+
const StyledImage = (0, import_gui_web.styled)(import_react_native.Image, {
|
|
43
|
+
name: "Image"
|
|
44
|
+
});
|
|
45
|
+
let hasWarned = !1;
|
|
46
|
+
const Image = StyledImage.styleable((inProps, ref) => {
|
|
47
|
+
const [props, style] = (0, import_gui_web.usePropsAndStyle)(inProps),
|
|
48
|
+
{
|
|
49
|
+
src,
|
|
50
|
+
source,
|
|
51
|
+
objectFit,
|
|
52
|
+
...rest
|
|
53
|
+
} = props;
|
|
54
|
+
process.env.NODE_ENV === "development" && typeof src == "string" && (typeof props.width == "string" && props.width[0] !== "$" || typeof props.height == "string" && props.height[0] !== "$") && (hasWarned || (hasWarned = !0, console.warn('React Native expects a numerical width/height. If you want to use a percent you must define the "source" prop with width, height, and uri.')));
|
|
55
|
+
let finalSource = typeof src == "string" ? {
|
|
56
|
+
uri: src,
|
|
57
|
+
...(import_gui_constants.isWeb && {
|
|
58
|
+
width: props.width || style?.width,
|
|
59
|
+
height: props.height || style?.height
|
|
60
|
+
})
|
|
61
|
+
} : source ?? src;
|
|
62
|
+
return finalSource && typeof finalSource == "object" && (process.env.NODE_ENV === "development" && process.env.HANZO_GUI_IMAGE_CHECK_ERROR && import_react.default.useEffect(() => {
|
|
63
|
+
async function run() {
|
|
64
|
+
if (typeof src == "string") try {
|
|
65
|
+
await fetch(src).then(res => res.text());
|
|
66
|
+
} catch {
|
|
67
|
+
console.error(`Error loading image: ${src}`, {
|
|
68
|
+
props
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
run();
|
|
73
|
+
}, [src]), finalSource.default && (finalSource = finalSource.default)), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.Image, {
|
|
74
|
+
resizeMode: objectFit,
|
|
75
|
+
ref,
|
|
76
|
+
source: finalSource,
|
|
77
|
+
style,
|
|
78
|
+
...rest
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
Image.getSize = import_react_native.Image.getSize;
|
|
82
|
+
Image.getSizeWithHeaders = import_react_native.Image.getSizeWithHeaders;
|
|
83
|
+
Image.prefetch = import_react_native.Image.prefetch;
|
|
84
|
+
Image.prefetchWithMetadata = import_react_native.Image.prefetchWithMetadata;
|
|
85
|
+
Image.abortPrefetch = import_react_native.Image.abortPrefetch;
|
|
86
|
+
Image.queryCache = import_react_native.Image.queryCache;
|