@data-client/img 0.14.15 → 0.14.19
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.js +8 -42
- package/dist/index.umd.min.js +1 -1
- package/lib/getImage.js +3 -2
- package/package.json +15 -5
- package/src/__tests__/Img.web.tsx +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1,41 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
4
|
var react = require('@data-client/react');
|
|
6
5
|
var React = require('react');
|
|
7
6
|
var endpoint = require('@data-client/endpoint');
|
|
8
7
|
|
|
9
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
-
|
|
11
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
-
|
|
13
|
-
function unwrapExports (x) {
|
|
14
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function createCommonjsModule(fn, module) {
|
|
18
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
var objectWithoutPropertiesLoose = createCommonjsModule(function (module) {
|
|
22
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
23
|
-
if (source == null) return {};
|
|
24
|
-
var target = {};
|
|
25
|
-
var sourceKeys = Object.keys(source);
|
|
26
|
-
var key, i;
|
|
27
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
28
|
-
key = sourceKeys[i];
|
|
29
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
30
|
-
target[key] = source[key];
|
|
31
|
-
}
|
|
32
|
-
return target;
|
|
33
|
-
}
|
|
34
|
-
module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
var _objectWithoutPropertiesLoose = unwrapExports(objectWithoutPropertiesLoose);
|
|
38
|
-
|
|
39
8
|
const getImage = new endpoint.Endpoint(async function ({
|
|
40
9
|
src
|
|
41
10
|
}) {
|
|
@@ -60,19 +29,16 @@ const getImage = new endpoint.Endpoint(async function ({
|
|
|
60
29
|
return `GET ${src}`;
|
|
61
30
|
}
|
|
62
31
|
});
|
|
63
|
-
var getImage$1 = getImage;
|
|
64
32
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
71
|
-
react.useSuspense(getImage$1, rest.src ? {
|
|
33
|
+
function Img({
|
|
34
|
+
component = 'img',
|
|
35
|
+
...rest
|
|
36
|
+
}) {
|
|
37
|
+
react.useSuspense(getImage, rest.src ? {
|
|
72
38
|
src: rest.src
|
|
73
39
|
} : null);
|
|
74
|
-
return /*#__PURE__*/
|
|
40
|
+
return /*#__PURE__*/React.createElement(component, rest);
|
|
75
41
|
}
|
|
76
42
|
|
|
77
43
|
exports.Img = Img;
|
|
78
|
-
exports.getImage = getImage
|
|
44
|
+
exports.getImage = getImage;
|
package/dist/index.umd.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@data-client/react"),require("react")):"function"==typeof define&&define.amd?define(["exports","@data-client/react","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Img={},e.RDC,e.React)}(this,(function(e,t,n){"use strict";
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@data-client/react"),require("react")):"function"==typeof define&&define.amd?define(["exports","@data-client/react","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Img={},e.RDC,e.React)}(this,(function(e,t,n){"use strict";var r;const o="undefined"!=typeof document;let c=o&&!(null!=(r=document.querySelector("meta[http-equiv='Content-Security-Policy']"))&&r.getAttribute("content"));try{c||Function()}catch(e){c=!0,o&&console.error("Content Security Policy: The previous CSP log can be safely ignored - @data-client/endpoint will use setPrototypeOf instead")}var i;class s extends Function{constructor(e,t){let n,r;return c?(n=(...e)=>n.fetch(...e),Object.setPrototypeOf(n,new.target.prototype)):(super("return arguments.callee.fetch.apply(arguments.callee, arguments)"),n=this),e&&(n.fetch=e),t&&"name"in t||!e||!e.name||"anonymous"===e.name||(r=e.name),Object.defineProperty(n,"name",{get(){return r||this.__name},set(e){this.__name=e}}),Object.assign(n,t),n}key(...e){return`${this.name} ${JSON.stringify(e)}`}testKey(e){return e.startsWith(this.name)}bind(e,...t){const n=this.fetch,r=this.key;return this.extend({fetch(){return n.apply(null!=e?e:this,t)},key(){return r.apply(this,t)}})}extend(e){class t extends this.constructor{}return Object.assign(t.prototype,this),new t(e.fetch,e)}}i=s,(()=>{if("undefined"!=typeof document&&document.FUNC_MANGLE){const e=i.prototype.key;i.prototype.key=function(...t){return null==document.FUNC_MANGLE||document.FUNC_MANGLE(this),this.prototype.key=e,e.call(this,...t)}}})();const u=new s((async function({src:e}){return new Promise((t=>{"undefined"!=typeof window&&"function"==typeof Image||t(e);const n=new Image;n.onload=()=>{t(e)},n.onerror=n=>{t(e)},n.src=e}))}),{key:({src:e})=>`GET ${e}`}),a=["component"];e.Img=function(e){let{component:r="img"}=e,o=function(e,t){if(null==e)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}(e,a);return t.useSuspense(u,o.src?{src:o.src}:null),n.createElement(r,o)},e.getImage=u}));
|
package/lib/getImage.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import _Promise from "core-js-pure/stable/promise/index.js";
|
|
1
2
|
import { Endpoint } from '@data-client/endpoint';
|
|
2
3
|
const getImage = new Endpoint(async function ({
|
|
3
4
|
src
|
|
4
5
|
}) {
|
|
5
|
-
return new
|
|
6
|
+
return new _Promise(resolve => {
|
|
6
7
|
// even if we polyfill, on server we don't want to actually wait to resolve the Image
|
|
7
8
|
if (typeof window === 'undefined' || typeof Image !== 'function') resolve(src);
|
|
8
9
|
const img = new Image();
|
|
@@ -24,4 +25,4 @@ const getImage = new Endpoint(async function ({
|
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
27
|
export default getImage;
|
|
27
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
28
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJFbmRwb2ludCIsImdldEltYWdlIiwic3JjIiwiX1Byb21pc2UiLCJyZXNvbHZlIiwid2luZG93IiwiSW1hZ2UiLCJpbWciLCJvbmxvYWQiLCJvbmVycm9yIiwiZXJyb3IiLCJrZXkiXSwic291cmNlcyI6WyIuLi9zcmMvZ2V0SW1hZ2UudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgRW5kcG9pbnQsIEVuZHBvaW50SW5zdGFuY2UgfSBmcm9tICdAZGF0YS1jbGllbnQvZW5kcG9pbnQnO1xuXG5jb25zdCBnZXRJbWFnZTogRW5kcG9pbnRJbnN0YW5jZTxcbiAgKHRoaXM6IEVuZHBvaW50SW5zdGFuY2UsIHsgc3JjIH06IHsgc3JjOiBzdHJpbmcgfSkgPT4gUHJvbWlzZTxzdHJpbmc+LFxuICBzdHJpbmcsXG4gIHVuZGVmaW5lZFxuPiA9IG5ldyBFbmRwb2ludChcbiAgYXN5bmMgZnVuY3Rpb24gKFxuICAgIHRoaXM6IEVuZHBvaW50SW5zdGFuY2UsXG4gICAgeyBzcmMgfTogeyBzcmM6IHN0cmluZyB9LFxuICApOiBQcm9taXNlPHN0cmluZz4ge1xuICAgIHJldHVybiBuZXcgUHJvbWlzZShyZXNvbHZlID0+IHtcbiAgICAgIC8vIGV2ZW4gaWYgd2UgcG9seWZpbGwsIG9u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QUFXLElBQUksT0FBT0MsS0FBSyxLQUFLLFVBQVUsRUFDOURGLE9BQU8sQ0FBQ0YsR0FBRyxDQUFDO0lBQ2QsTUFBTUssR0FBRyxHQUFHLElBQUlELEtBQUssQ0FBQyxDQUFDO0lBQ3ZCQyxHQUFHLENBQUNDLE1BQU0sR0FBRyxNQUFNO01BQ2pCSixPQUFPLENBQUNGLEdBQUcsQ0FBQztJQUNkLENBQUM7SUFDREssR0FBRyxDQUFDRSxPQUFPLEdBQUdDLEtBQUssSUFBSTtNQUNyQjtNQUNBO01BQ0FOLE9BQU8sQ0FBQ0YsR0FBRyxDQUFDO0lBQ2QsQ0FBQztJQUNESyxHQUFHLENBQUNMLEdBQUcsR0FBR0EsR0FBRztFQUNmLENBQUMsQ0FBQztBQUNKLENBQUMsRUFDRDtFQUNFUyxHQUFHQSxDQUF5QjtJQUFFVDtFQUFxQixDQUFDLEVBQUU7SUFDcEQsT0FBTyxPQUFPQSxHQUFHLEVBQUU7RUFDckI7QUFDRixDQUNGLENBQUM7QUFDRCxlQUFlRCxRQUFRIiwiaWdub3JlTGlzdCI6W119
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-client/img",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.19",
|
|
4
4
|
"description": "Suspenseful images",
|
|
5
5
|
"homepage": "https://dataclient.io/docs/guides/img-media#just-images",
|
|
6
6
|
"repository": {
|
|
@@ -47,6 +47,9 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"type": "module",
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=16"
|
|
52
|
+
},
|
|
50
53
|
"files": [
|
|
51
54
|
"src",
|
|
52
55
|
"dist",
|
|
@@ -57,7 +60,9 @@
|
|
|
57
60
|
],
|
|
58
61
|
"scripts": {
|
|
59
62
|
"build:lib": "NODE_ENV=production BROWSERSLIST_ENV=2019 yarn g:babel --out-dir lib",
|
|
60
|
-
"build:
|
|
63
|
+
"build:js:node": "BROWSERSLIST_ENV=node16 yarn g:rollup",
|
|
64
|
+
"build:js:browser": "BROWSERSLIST_ENV=legacy yarn g:rollup",
|
|
65
|
+
"build:bundle": "yarn g:runs build:js:\\* && echo '{\"type\":\"commonjs\"}' > dist/package.json",
|
|
61
66
|
"build:clean": "yarn g:clean",
|
|
62
67
|
"build:legacy-types": "yarn g:downtypes lib ts3.4",
|
|
63
68
|
"build": "run build:lib && run build:bundle",
|
|
@@ -69,8 +74,9 @@
|
|
|
69
74
|
"funding": "https://github.com/sponsors/ntucker",
|
|
70
75
|
"license": "Apache-2.0",
|
|
71
76
|
"dependencies": {
|
|
72
|
-
"@babel/runtime": "^7.
|
|
73
|
-
"@data-client/endpoint": "^0.14.
|
|
77
|
+
"@babel/runtime-corejs3": "^7.26.0",
|
|
78
|
+
"@data-client/endpoint": "^0.14.19",
|
|
79
|
+
"core-js-pure": "^3.40.0"
|
|
74
80
|
},
|
|
75
81
|
"peerDependencies": {
|
|
76
82
|
"@data-client/react": "^0.1.0 || ^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^0.14.0",
|
|
@@ -85,7 +91,11 @@
|
|
|
85
91
|
"devDependencies": {
|
|
86
92
|
"@anansi/browserslist-config": "^1.4.2",
|
|
87
93
|
"@data-client/react": "workspace:*",
|
|
94
|
+
"@testing-library/react": "^16.1.0",
|
|
95
|
+
"@types/jest": "^29.5.14",
|
|
88
96
|
"@types/node": "^22.0.0",
|
|
89
|
-
"@types/react": "
|
|
97
|
+
"@types/react": "19.0.10",
|
|
98
|
+
"react": "^19.0.0",
|
|
99
|
+
"rollup-plugins": "workspace:*"
|
|
90
100
|
}
|
|
91
101
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataProvider } from '@data-client/react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { render, waitFor } from '@testing-library/react';
|
|
3
|
+
import { Suspense } from 'react';
|
|
4
4
|
|
|
5
5
|
import { Img } from '..';
|
|
6
6
|
|