@plasmicpkgs/plasmic-giphy 0.0.43 → 0.0.44
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/plasmic-giphy.cjs.development.js +28 -33
- package/dist/plasmic-giphy.cjs.development.js.map +1 -1
- package/dist/plasmic-giphy.cjs.production.min.js +1 -1
- package/dist/plasmic-giphy.cjs.production.min.js.map +1 -1
- package/dist/plasmic-giphy.esm.js +28 -33
- package/dist/plasmic-giphy.esm.js.map +1 -1
- package/package.json +3 -3
|
@@ -9,6 +9,31 @@ var jsFetchApi = require('@giphy/js-fetch-api');
|
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var React__default = _interopDefault(React);
|
|
11
11
|
|
|
12
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
13
|
+
try {
|
|
14
|
+
var i = n[a](c),
|
|
15
|
+
u = i.value;
|
|
16
|
+
} catch (n) {
|
|
17
|
+
return void e(n);
|
|
18
|
+
}
|
|
19
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
20
|
+
}
|
|
21
|
+
function _asyncToGenerator(n) {
|
|
22
|
+
return function () {
|
|
23
|
+
var t = this,
|
|
24
|
+
e = arguments;
|
|
25
|
+
return new Promise(function (r, o) {
|
|
26
|
+
var a = n.apply(t, e);
|
|
27
|
+
function _next(n) {
|
|
28
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
29
|
+
}
|
|
30
|
+
function _throw(n) {
|
|
31
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
32
|
+
}
|
|
33
|
+
_next(void 0);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
}
|
|
12
37
|
function _regeneratorRuntime() {
|
|
13
38
|
_regeneratorRuntime = function () {
|
|
14
39
|
return e;
|
|
@@ -117,7 +142,7 @@ function _regeneratorRuntime() {
|
|
|
117
142
|
function makeInvokeMethod(e, r, n) {
|
|
118
143
|
var o = h;
|
|
119
144
|
return function (i, a) {
|
|
120
|
-
if (o === f) throw
|
|
145
|
+
if (o === f) throw Error("Generator is already running");
|
|
121
146
|
if (o === s) {
|
|
122
147
|
if ("throw" === i) throw a;
|
|
123
148
|
return {
|
|
@@ -259,7 +284,7 @@ function _regeneratorRuntime() {
|
|
|
259
284
|
} else if (c) {
|
|
260
285
|
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
261
286
|
} else {
|
|
262
|
-
if (!u) throw
|
|
287
|
+
if (!u) throw Error("try statement without catch or finally");
|
|
263
288
|
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
264
289
|
}
|
|
265
290
|
}
|
|
@@ -299,7 +324,7 @@ function _regeneratorRuntime() {
|
|
|
299
324
|
return o;
|
|
300
325
|
}
|
|
301
326
|
}
|
|
302
|
-
throw
|
|
327
|
+
throw Error("illegal catch attempt");
|
|
303
328
|
},
|
|
304
329
|
delegateYield: function (e, r, n) {
|
|
305
330
|
return this.delegate = {
|
|
@@ -310,36 +335,6 @@ function _regeneratorRuntime() {
|
|
|
310
335
|
}
|
|
311
336
|
}, e;
|
|
312
337
|
}
|
|
313
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
314
|
-
try {
|
|
315
|
-
var info = gen[key](arg);
|
|
316
|
-
var value = info.value;
|
|
317
|
-
} catch (error) {
|
|
318
|
-
reject(error);
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
if (info.done) {
|
|
322
|
-
resolve(value);
|
|
323
|
-
} else {
|
|
324
|
-
Promise.resolve(value).then(_next, _throw);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
function _asyncToGenerator(fn) {
|
|
328
|
-
return function () {
|
|
329
|
-
var self = this,
|
|
330
|
-
args = arguments;
|
|
331
|
-
return new Promise(function (resolve, reject) {
|
|
332
|
-
var gen = fn.apply(self, args);
|
|
333
|
-
function _next(value) {
|
|
334
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
335
|
-
}
|
|
336
|
-
function _throw(err) {
|
|
337
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
338
|
-
}
|
|
339
|
-
_next(undefined);
|
|
340
|
-
});
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
338
|
|
|
344
339
|
var useFetch = function useFetch(_ref) {
|
|
345
340
|
var keyword = _ref.keyword;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plasmic-giphy.cjs.development.js","sources":["../src/hooks/useFetch.ts","../src/giphy.tsx","../src/index.tsx"],"sourcesContent":["import { useState, useEffect } from \"react\";\n\ninterface HookProps {\n keyword: string\n}\nexport const useFetch = ({ keyword }: HookProps) => {\n const [giphyId, setGiphyId] = useState(\"\");\n\n useEffect(() => {\n if (keyword) fetchGiphy();\n }, [keyword]);\n\n const fetchGiphy = async () => {\n try {\n const response = await fetch(\n `https://api.giphy.com/v1/gifs/search?api_key=X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK&q=${keyword\n .split(\" \")\n .join(\"\")}&limit=1`\n );\n\n const { data } = await response.json();\n\n setGiphyId(data[0]?.id);\n } catch (error) {\n console.log(\"Error in gif api retrieval: \", error);\n setGiphyId(\"\");\n }\n };\n return giphyId;\n};\n","import { GiphyFetch } from \"@giphy/js-fetch-api\";\nimport { IGif } from \"@giphy/js-types\";\nimport { ComponentMeta } from \"@plasmicapp/host\";\nimport React, { useEffect, useState } from \"react\";\nimport { useFetch } from \"./hooks/useFetch\";\n\nexport function ensure<T>(x: T | null | undefined): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(`Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n\nconst modulePath = \"@plasmicpkgs/plasmic-giphy\";\n\ninterface GiphyProps {\n searchTerm: string;\n className: string;\n noLayout?: boolean;\n}\n\nexport const GiphyMeta: ComponentMeta<GiphyProps> = {\n name: \"hostless-giphy\",\n displayName: \"Giphy\",\n importName: \"Giphy\",\n importPath: modulePath,\n providesData: true,\n description: \"Fetches Giphy data and render it\",\n props: {\n searchTerm: {\n type: \"string\",\n displayName: \"Search Term\",\n description: \"Search term for fetching gif \",\n defaultValue: \"Cat\",\n },\n },\n};\n\nexport function Giphy({ searchTerm, className }: GiphyProps) {\n const id = useFetch({ keyword: searchTerm });\n const [gif, setGif] = useState<IGif | null>(null);\n\n const gf = new GiphyFetch(\"X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK\");\n useEffect(() => {\n const fetchGif = async () => {\n if (!id) {\n return null;\n }\n const { data } = await gf.gif(id);\n setGif(data);\n return data;\n };\n fetchGif();\n }, [id]);\n\n return (\n <img\n src={gif?.images.downsized_medium.url}\n alt=\"Gif\"\n className={className}\n />\n );\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\n\nimport { Giphy, GiphyMeta } from \"./giphy\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n\n _registerComponent(Giphy, GiphyMeta);\n}\n\nexport * from \"./giphy\";\n"],"names":["useFetch","_ref","keyword","_useState","useState","giphyId","setGiphyId","useEffect","fetchGiphy","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_data$","response","_yield$response$json","data","wrap","_callee$","_context","prev","next","fetch","split","join","sent","json","id","t0","console","log","stop","apply","arguments","ensure","x","undefined","Error","modulePath","GiphyMeta","name","displayName","importName","importPath","providesData","description","props","searchTerm","type","defaultValue","Giphy","className","gif","setGif","gf","GiphyFetch","fetchGif","_yield$gf$gif","abrupt","React","src","images","downsized_medium","url","alt","registerAll","loader","_registerComponent","Component","defaultMeta","registerComponent"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plasmic-giphy.cjs.development.js","sources":["../src/hooks/useFetch.ts","../src/giphy.tsx","../src/index.tsx"],"sourcesContent":["import { useState, useEffect } from \"react\";\n\ninterface HookProps {\n keyword: string\n}\nexport const useFetch = ({ keyword }: HookProps) => {\n const [giphyId, setGiphyId] = useState(\"\");\n\n useEffect(() => {\n if (keyword) fetchGiphy();\n }, [keyword]);\n\n const fetchGiphy = async () => {\n try {\n const response = await fetch(\n `https://api.giphy.com/v1/gifs/search?api_key=X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK&q=${keyword\n .split(\" \")\n .join(\"\")}&limit=1`\n );\n\n const { data } = await response.json();\n\n setGiphyId(data[0]?.id);\n } catch (error) {\n console.log(\"Error in gif api retrieval: \", error);\n setGiphyId(\"\");\n }\n };\n return giphyId;\n};\n","import { GiphyFetch } from \"@giphy/js-fetch-api\";\nimport { IGif } from \"@giphy/js-types\";\nimport { ComponentMeta } from \"@plasmicapp/host\";\nimport React, { useEffect, useState } from \"react\";\nimport { useFetch } from \"./hooks/useFetch\";\n\nexport function ensure<T>(x: T | null | undefined): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(`Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n\nconst modulePath = \"@plasmicpkgs/plasmic-giphy\";\n\ninterface GiphyProps {\n searchTerm: string;\n className: string;\n noLayout?: boolean;\n}\n\nexport const GiphyMeta: ComponentMeta<GiphyProps> = {\n name: \"hostless-giphy\",\n displayName: \"Giphy\",\n importName: \"Giphy\",\n importPath: modulePath,\n providesData: true,\n description: \"Fetches Giphy data and render it\",\n props: {\n searchTerm: {\n type: \"string\",\n displayName: \"Search Term\",\n description: \"Search term for fetching gif \",\n defaultValue: \"Cat\",\n },\n },\n};\n\nexport function Giphy({ searchTerm, className }: GiphyProps) {\n const id = useFetch({ keyword: searchTerm });\n const [gif, setGif] = useState<IGif | null>(null);\n\n const gf = new GiphyFetch(\"X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK\");\n useEffect(() => {\n const fetchGif = async () => {\n if (!id) {\n return null;\n }\n const { data } = await gf.gif(id);\n setGif(data);\n return data;\n };\n fetchGif();\n }, [id]);\n\n return (\n <img\n src={gif?.images.downsized_medium.url}\n alt=\"Gif\"\n className={className}\n />\n );\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\n\nimport { Giphy, GiphyMeta } from \"./giphy\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n\n _registerComponent(Giphy, GiphyMeta);\n}\n\nexport * from \"./giphy\";\n"],"names":["useFetch","_ref","keyword","_useState","useState","giphyId","setGiphyId","useEffect","fetchGiphy","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_data$","response","_yield$response$json","data","wrap","_callee$","_context","prev","next","fetch","split","join","sent","json","id","t0","console","log","stop","apply","arguments","ensure","x","undefined","Error","modulePath","GiphyMeta","name","displayName","importName","importPath","providesData","description","props","searchTerm","type","defaultValue","Giphy","className","gif","setGif","gf","GiphyFetch","fetchGif","_yield$gf$gif","abrupt","React","src","images","downsized_medium","url","alt","registerAll","loader","_registerComponent","Component","defaultMeta","registerComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AEC,WAAW,CAAC;;GAE5C;EAEDF,kBAAkB,CAACjB,KAAK,EAAEX,SAAS,CAAC;AACtC;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var r=t(require("@plasmicapp/host/registerComponent")),e=require("@giphy/js-fetch-api"),n=require("react"),o=t(n);function i(){i=function(){return r};var t,r={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,r,e){t[r]=e.value},
|
|
1
|
+
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var r=t(require("@plasmicapp/host/registerComponent")),e=require("@giphy/js-fetch-api"),n=require("react"),o=t(n);function i(t,r,e,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?r(u):Promise.resolve(u).then(n,o)}function a(t){return function(){var r=this,e=arguments;return new Promise((function(n,o){var a=t.apply(r,e);function c(t){i(a,n,o,c,u,"next",t)}function u(t){i(a,n,o,c,u,"throw",t)}c(void 0)}))}}function c(){c=function(){return r};var t,r={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,r,e){t[r]=e.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function f(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{f({},"")}catch(t){f=function(t,r,e){return t[r]=e}}function l(t,r,e,n){var i=Object.create((r&&r.prototype instanceof g?r:g).prototype),a=new N(n||[]);return o(i,"_invoke",{value:k(t,e,a)}),i}function h(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}r.wrap=l;var p="suspendedStart",y="executing",v="completed",d={};function g(){}function m(){}function w(){}var x={};f(x,a,(function(){return this}));var b=Object.getPrototypeOf,L=b&&b(b(P([])));L&&L!==e&&n.call(L,a)&&(x=L);var E=w.prototype=g.prototype=Object.create(x);function _(t){["next","throw","return"].forEach((function(r){f(t,r,(function(t){return this._invoke(r,t)}))}))}function j(t,r){function e(o,i,a,c){var u=h(t[o],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?r.resolve(f.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new r((function(r,o){e(t,n,r,o)}))}return i=i?i.then(o,o):o()}})}function k(r,e,n){var o=p;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=O(c,n);if(u){if(u===d)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===p)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=h(r,e,n);if("normal"===s.type){if(o=n.done?v:"suspendedYield",s.arg===d)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=v,n.method="throw",n.arg=s.arg)}}}function O(r,e){var n=e.method,o=r.iterator[n];if(o===t)return e.delegate=null,"throw"===n&&r.iterator.return&&(e.method="return",e.arg=t,O(r,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),d;var i=h(o,r.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,d;var a=i.arg;return a?a.done?(e[r.resultName]=a.value,e.next=r.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,d):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function G(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function S(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(G,this),this.reset(!0)}function P(r){if(r||""===r){var e=r[a];if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,i=function e(){for(;++o<r.length;)if(n.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(typeof r+" is not iterable")}return m.prototype=w,o(E,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:m,configurable:!0}),m.displayName=f(w,s,"GeneratorFunction"),r.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===m||"GeneratorFunction"===(r.displayName||r.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,s,"GeneratorFunction")),t.prototype=Object.create(E),t},r.awrap=function(t){return{__await:t}},_(j.prototype),f(j.prototype,u,(function(){return this})),r.AsyncIterator=j,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new j(l(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},_(E),f(E,s,"Generator"),f(E,a,(function(){return this})),f(E,"toString",(function(){return"[object Generator]"})),r.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=P,N.prototype={constructor:N,reset:function(r){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(S),!r)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(r){if(this.done)throw r;var e=this;function o(n,o){return c.type="throw",c.arg=r,e.next=n,o&&(e.method="next",e.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),d},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),S(e),d}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;S(e)}return o}}throw Error("illegal catch attempt")},delegateYield:function(r,e,n){return this.delegate={iterator:P(r),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=t),d}},r}var u={name:"hostless-giphy",displayName:"Giphy",importName:"Giphy",importPath:"@plasmicpkgs/plasmic-giphy",providesData:!0,description:"Fetches Giphy data and render it",props:{searchTerm:{type:"string",displayName:"Search Term",description:"Search term for fetching gif ",defaultValue:"Cat"}}};function s(t){var r=t.className,i=function(t){var r=t.keyword,e=n.useState(""),o=e[0],i=e[1];n.useEffect((function(){r&&u()}),[r]);var u=function(){var t=a(c().mark((function t(){var e,n;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch("https://api.giphy.com/v1/gifs/search?api_key=X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK&q="+r.split(" ").join("")+"&limit=1");case 3:return n=t.sent,t.next=6,n.json();case 6:i(null==(e=t.sent.data[0])?void 0:e.id),t.next=15;break;case 11:t.prev=11,t.t0=t.catch(0),console.log("Error in gif api retrieval: ",t.t0),i("");case 15:case"end":return t.stop()}}),t,null,[[0,11]])})));return function(){return t.apply(this,arguments)}}();return o}({keyword:t.searchTerm}),u=n.useState(null),s=u[0],f=u[1],l=new e.GiphyFetch("X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK");return n.useEffect((function(){!function(){var t=a(c().mark((function t(){var r;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i){t.next=2;break}return t.abrupt("return",null);case 2:return t.next=4,l.gif(i);case 4:return f(r=t.sent.data),t.abrupt("return",r);case 8:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()()}),[i]),o.createElement("img",{src:null==s?void 0:s.images.downsized_medium.url,alt:"Gif",className:r})}exports.Giphy=s,exports.GiphyMeta=u,exports.ensure=function(t){if(null==t)throw new Error("Value must not be undefined or null");return t},exports.registerAll=function(t){var e,n;e=s,n=u,t?t.registerComponent(e,n):r(e,n)};
|
|
2
2
|
//# sourceMappingURL=plasmic-giphy.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plasmic-giphy.cjs.production.min.js","sources":["../src/giphy.tsx","../src/hooks/useFetch.ts","../src/index.tsx"],"sourcesContent":["import { GiphyFetch } from \"@giphy/js-fetch-api\";\nimport { IGif } from \"@giphy/js-types\";\nimport { ComponentMeta } from \"@plasmicapp/host\";\nimport React, { useEffect, useState } from \"react\";\nimport { useFetch } from \"./hooks/useFetch\";\n\nexport function ensure<T>(x: T | null | undefined): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(`Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n\nconst modulePath = \"@plasmicpkgs/plasmic-giphy\";\n\ninterface GiphyProps {\n searchTerm: string;\n className: string;\n noLayout?: boolean;\n}\n\nexport const GiphyMeta: ComponentMeta<GiphyProps> = {\n name: \"hostless-giphy\",\n displayName: \"Giphy\",\n importName: \"Giphy\",\n importPath: modulePath,\n providesData: true,\n description: \"Fetches Giphy data and render it\",\n props: {\n searchTerm: {\n type: \"string\",\n displayName: \"Search Term\",\n description: \"Search term for fetching gif \",\n defaultValue: \"Cat\",\n },\n },\n};\n\nexport function Giphy({ searchTerm, className }: GiphyProps) {\n const id = useFetch({ keyword: searchTerm });\n const [gif, setGif] = useState<IGif | null>(null);\n\n const gf = new GiphyFetch(\"X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK\");\n useEffect(() => {\n const fetchGif = async () => {\n if (!id) {\n return null;\n }\n const { data } = await gf.gif(id);\n setGif(data);\n return data;\n };\n fetchGif();\n }, [id]);\n\n return (\n <img\n src={gif?.images.downsized_medium.url}\n alt=\"Gif\"\n className={className}\n />\n );\n}\n","import { useState, useEffect } from \"react\";\n\ninterface HookProps {\n keyword: string\n}\nexport const useFetch = ({ keyword }: HookProps) => {\n const [giphyId, setGiphyId] = useState(\"\");\n\n useEffect(() => {\n if (keyword) fetchGiphy();\n }, [keyword]);\n\n const fetchGiphy = async () => {\n try {\n const response = await fetch(\n `https://api.giphy.com/v1/gifs/search?api_key=X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK&q=${keyword\n .split(\" \")\n .join(\"\")}&limit=1`\n );\n\n const { data } = await response.json();\n\n setGiphyId(data[0]?.id);\n } catch (error) {\n console.log(\"Error in gif api retrieval: \", error);\n setGiphyId(\"\");\n }\n };\n return giphyId;\n};\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\n\nimport { Giphy, GiphyMeta } from \"./giphy\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n\n _registerComponent(Giphy, GiphyMeta);\n}\n\nexport * from \"./giphy\";\n"],"names":["GiphyMeta","name","displayName","importName","importPath","providesData","description","props","searchTerm","type","defaultValue","Giphy","_ref","className","id","keyword","_useState","useState","giphyId","setGiphyId","useEffect","fetchGiphy","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_data$","response","wrap","_context","prev","next","fetch","split","join","sent","json","data","t0","console","log","stop","apply","arguments","useFetch","gif","setGif","gf","GiphyFetch","abrupt","fetchGif","React","src","images","downsized_medium","url","alt","x","Error","loader","Component","defaultMeta","registerComponent"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plasmic-giphy.cjs.production.min.js","sources":["../src/giphy.tsx","../src/hooks/useFetch.ts","../src/index.tsx"],"sourcesContent":["import { GiphyFetch } from \"@giphy/js-fetch-api\";\nimport { IGif } from \"@giphy/js-types\";\nimport { ComponentMeta } from \"@plasmicapp/host\";\nimport React, { useEffect, useState } from \"react\";\nimport { useFetch } from \"./hooks/useFetch\";\n\nexport function ensure<T>(x: T | null | undefined): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(`Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n\nconst modulePath = \"@plasmicpkgs/plasmic-giphy\";\n\ninterface GiphyProps {\n searchTerm: string;\n className: string;\n noLayout?: boolean;\n}\n\nexport const GiphyMeta: ComponentMeta<GiphyProps> = {\n name: \"hostless-giphy\",\n displayName: \"Giphy\",\n importName: \"Giphy\",\n importPath: modulePath,\n providesData: true,\n description: \"Fetches Giphy data and render it\",\n props: {\n searchTerm: {\n type: \"string\",\n displayName: \"Search Term\",\n description: \"Search term for fetching gif \",\n defaultValue: \"Cat\",\n },\n },\n};\n\nexport function Giphy({ searchTerm, className }: GiphyProps) {\n const id = useFetch({ keyword: searchTerm });\n const [gif, setGif] = useState<IGif | null>(null);\n\n const gf = new GiphyFetch(\"X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK\");\n useEffect(() => {\n const fetchGif = async () => {\n if (!id) {\n return null;\n }\n const { data } = await gf.gif(id);\n setGif(data);\n return data;\n };\n fetchGif();\n }, [id]);\n\n return (\n <img\n src={gif?.images.downsized_medium.url}\n alt=\"Gif\"\n className={className}\n />\n );\n}\n","import { useState, useEffect } from \"react\";\n\ninterface HookProps {\n keyword: string\n}\nexport const useFetch = ({ keyword }: HookProps) => {\n const [giphyId, setGiphyId] = useState(\"\");\n\n useEffect(() => {\n if (keyword) fetchGiphy();\n }, [keyword]);\n\n const fetchGiphy = async () => {\n try {\n const response = await fetch(\n `https://api.giphy.com/v1/gifs/search?api_key=X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK&q=${keyword\n .split(\" \")\n .join(\"\")}&limit=1`\n );\n\n const { data } = await response.json();\n\n setGiphyId(data[0]?.id);\n } catch (error) {\n console.log(\"Error in gif api retrieval: \", error);\n setGiphyId(\"\");\n }\n };\n return giphyId;\n};\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\n\nimport { Giphy, GiphyMeta } from \"./giphy\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n\n _registerComponent(Giphy, GiphyMeta);\n}\n\nexport * from \"./giphy\";\n"],"names":["GiphyMeta","name","displayName","importName","importPath","providesData","description","props","searchTerm","type","defaultValue","Giphy","_ref","className","id","keyword","_useState","useState","giphyId","setGiphyId","useEffect","fetchGiphy","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_data$","response","wrap","_context","prev","next","fetch","split","join","sent","json","data","t0","console","log","stop","apply","arguments","useFetch","gif","setGif","gf","GiphyFetch","abrupt","fetchGif","React","src","images","downsized_medium","url","alt","x","Error","loader","Component","defaultMeta","registerComponent"],"mappings":"w5NAeA,IAQaA,EAAuC,CAClDC,KAAM,iBACNC,YAAa,QACbC,WAAY,QACZC,WAZiB,6BAajBC,cAAc,EACdC,YAAa,mCACbC,MAAO,CACLC,WAAY,CACVC,KAAM,SACNP,YAAa,cACbI,YAAa,gCACbI,aAAc,kBAKJC,EAAKC,OAAeC,EAASD,EAATC,UAC5BC,ECpCgB,SAAHF,OAAMG,EAAOH,EAAPG,QACvBC,EAA8BC,WAAS,IAAhCC,EAAOF,KAAEG,EAAUH,KAE1BI,aAAU,WACFL,GAASM,MACd,CAACN,IAEJ,IAAMM,aAAU,IAAAC,EAAAC,EAAAC,IAAAC,MAAG,SAAAC,IAAA,IAAAC,EAAAC,EAAA,OAAAJ,IAAAK,eAAAC,GAAA,cAAAA,EAAAC,KAAAD,EAAAE,MAAA,OAAA,OAAAF,EAAAC,OAAAD,EAAAE,OAEYC,yFACgElB,EAC9EmB,MAAM,KACNC,KAAK,gBACb,OAJa,OAARP,EAAQE,EAAAM,KAAAN,EAAAE,OAMSJ,EAASS,OAAM,OAEtClB,SAAUQ,EAF4BG,EAAAM,KAA9BE,KAEQ,WAALX,EAASb,IAAIgB,EAAAE,QAAA,MAAA,QAAAF,EAAAC,QAAAD,EAAAS,GAAAT,WAExBU,QAAQC,IAAI,+BAA8BX,EAAAS,IAC1CpB,EAAW,IAAI,QAAA,UAAA,OAAAW,EAAAY,UAAAhB,qBAEtB,kBAfe,OAAAJ,EAAAqB,WAAAC,eAgBhB,OAAO1B,EDaE2B,CAAS,CAAE9B,QADUH,EAAVJ,aAEtBQ,EAAsBC,WAAsB,MAArC6B,EAAG9B,KAAE+B,EAAM/B,KAEZgC,EAAK,IAAIC,aAAW,oCAa1B,OAZA7B,aAAU,uBACM,IAAAE,EAAAC,EAAAC,IAAAC,MAAG,SAAAC,IAAA,IAAAY,EAAA,OAAAd,IAAAK,eAAAC,GAAA,cAAAA,EAAAC,KAAAD,EAAAE,MAAA,OAAA,GACVlB,GAAEgB,EAAAE,OAAA,MAAA,OAAAF,EAAAoB,gBACE,MAAI,OAAA,OAAApB,EAAAE,OAEUgB,EAAGF,IAAIhC,GAAG,OACpB,OAAbiC,EADQT,EAAyBR,EAAAM,KAAzBE,MACKR,EAAAoB,gBACNZ,GAAI,OAAA,UAAA,OAAAR,EAAAY,UAAAhB,OACZ,kBAPa,OAAAJ,EAAAqB,WAAAC,cAQdO,KACC,CAACrC,IAGFsC,uBACEC,UAAKP,SAAAA,EAAKQ,OAAOC,iBAAiBC,IAClCC,IAAI,MACJ5C,UAAWA,gEAvDS6C,GACxB,GAAIA,MAAAA,EAEF,MAAM,IAAIC,6CAEV,OAAOD,gCEJiBE,GAI1B,IACEC,EACAC,EADAD,EAUiBlD,EATjBmD,EASwB9D,EAPpB4D,EACFA,EAAOG,kBAAkBF,EAAWC,GAEpCC,EAAkBF,EAAWC"}
|
|
@@ -2,6 +2,31 @@ import registerComponent from '@plasmicapp/host/registerComponent';
|
|
|
2
2
|
import { GiphyFetch } from '@giphy/js-fetch-api';
|
|
3
3
|
import React, { useState, useEffect } from 'react';
|
|
4
4
|
|
|
5
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
6
|
+
try {
|
|
7
|
+
var i = n[a](c),
|
|
8
|
+
u = i.value;
|
|
9
|
+
} catch (n) {
|
|
10
|
+
return void e(n);
|
|
11
|
+
}
|
|
12
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
13
|
+
}
|
|
14
|
+
function _asyncToGenerator(n) {
|
|
15
|
+
return function () {
|
|
16
|
+
var t = this,
|
|
17
|
+
e = arguments;
|
|
18
|
+
return new Promise(function (r, o) {
|
|
19
|
+
var a = n.apply(t, e);
|
|
20
|
+
function _next(n) {
|
|
21
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
22
|
+
}
|
|
23
|
+
function _throw(n) {
|
|
24
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
25
|
+
}
|
|
26
|
+
_next(void 0);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
5
30
|
function _regeneratorRuntime() {
|
|
6
31
|
_regeneratorRuntime = function () {
|
|
7
32
|
return e;
|
|
@@ -110,7 +135,7 @@ function _regeneratorRuntime() {
|
|
|
110
135
|
function makeInvokeMethod(e, r, n) {
|
|
111
136
|
var o = h;
|
|
112
137
|
return function (i, a) {
|
|
113
|
-
if (o === f) throw
|
|
138
|
+
if (o === f) throw Error("Generator is already running");
|
|
114
139
|
if (o === s) {
|
|
115
140
|
if ("throw" === i) throw a;
|
|
116
141
|
return {
|
|
@@ -252,7 +277,7 @@ function _regeneratorRuntime() {
|
|
|
252
277
|
} else if (c) {
|
|
253
278
|
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
254
279
|
} else {
|
|
255
|
-
if (!u) throw
|
|
280
|
+
if (!u) throw Error("try statement without catch or finally");
|
|
256
281
|
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
257
282
|
}
|
|
258
283
|
}
|
|
@@ -292,7 +317,7 @@ function _regeneratorRuntime() {
|
|
|
292
317
|
return o;
|
|
293
318
|
}
|
|
294
319
|
}
|
|
295
|
-
throw
|
|
320
|
+
throw Error("illegal catch attempt");
|
|
296
321
|
},
|
|
297
322
|
delegateYield: function (e, r, n) {
|
|
298
323
|
return this.delegate = {
|
|
@@ -303,36 +328,6 @@ function _regeneratorRuntime() {
|
|
|
303
328
|
}
|
|
304
329
|
}, e;
|
|
305
330
|
}
|
|
306
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
307
|
-
try {
|
|
308
|
-
var info = gen[key](arg);
|
|
309
|
-
var value = info.value;
|
|
310
|
-
} catch (error) {
|
|
311
|
-
reject(error);
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
if (info.done) {
|
|
315
|
-
resolve(value);
|
|
316
|
-
} else {
|
|
317
|
-
Promise.resolve(value).then(_next, _throw);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
function _asyncToGenerator(fn) {
|
|
321
|
-
return function () {
|
|
322
|
-
var self = this,
|
|
323
|
-
args = arguments;
|
|
324
|
-
return new Promise(function (resolve, reject) {
|
|
325
|
-
var gen = fn.apply(self, args);
|
|
326
|
-
function _next(value) {
|
|
327
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
328
|
-
}
|
|
329
|
-
function _throw(err) {
|
|
330
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
331
|
-
}
|
|
332
|
-
_next(undefined);
|
|
333
|
-
});
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
331
|
|
|
337
332
|
var useFetch = function useFetch(_ref) {
|
|
338
333
|
var keyword = _ref.keyword;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plasmic-giphy.esm.js","sources":["../src/hooks/useFetch.ts","../src/giphy.tsx","../src/index.tsx"],"sourcesContent":["import { useState, useEffect } from \"react\";\n\ninterface HookProps {\n keyword: string\n}\nexport const useFetch = ({ keyword }: HookProps) => {\n const [giphyId, setGiphyId] = useState(\"\");\n\n useEffect(() => {\n if (keyword) fetchGiphy();\n }, [keyword]);\n\n const fetchGiphy = async () => {\n try {\n const response = await fetch(\n `https://api.giphy.com/v1/gifs/search?api_key=X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK&q=${keyword\n .split(\" \")\n .join(\"\")}&limit=1`\n );\n\n const { data } = await response.json();\n\n setGiphyId(data[0]?.id);\n } catch (error) {\n console.log(\"Error in gif api retrieval: \", error);\n setGiphyId(\"\");\n }\n };\n return giphyId;\n};\n","import { GiphyFetch } from \"@giphy/js-fetch-api\";\nimport { IGif } from \"@giphy/js-types\";\nimport { ComponentMeta } from \"@plasmicapp/host\";\nimport React, { useEffect, useState } from \"react\";\nimport { useFetch } from \"./hooks/useFetch\";\n\nexport function ensure<T>(x: T | null | undefined): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(`Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n\nconst modulePath = \"@plasmicpkgs/plasmic-giphy\";\n\ninterface GiphyProps {\n searchTerm: string;\n className: string;\n noLayout?: boolean;\n}\n\nexport const GiphyMeta: ComponentMeta<GiphyProps> = {\n name: \"hostless-giphy\",\n displayName: \"Giphy\",\n importName: \"Giphy\",\n importPath: modulePath,\n providesData: true,\n description: \"Fetches Giphy data and render it\",\n props: {\n searchTerm: {\n type: \"string\",\n displayName: \"Search Term\",\n description: \"Search term for fetching gif \",\n defaultValue: \"Cat\",\n },\n },\n};\n\nexport function Giphy({ searchTerm, className }: GiphyProps) {\n const id = useFetch({ keyword: searchTerm });\n const [gif, setGif] = useState<IGif | null>(null);\n\n const gf = new GiphyFetch(\"X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK\");\n useEffect(() => {\n const fetchGif = async () => {\n if (!id) {\n return null;\n }\n const { data } = await gf.gif(id);\n setGif(data);\n return data;\n };\n fetchGif();\n }, [id]);\n\n return (\n <img\n src={gif?.images.downsized_medium.url}\n alt=\"Gif\"\n className={className}\n />\n );\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\n\nimport { Giphy, GiphyMeta } from \"./giphy\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n\n _registerComponent(Giphy, GiphyMeta);\n}\n\nexport * from \"./giphy\";\n"],"names":["useFetch","_ref","keyword","_useState","useState","giphyId","setGiphyId","useEffect","fetchGiphy","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_data$","response","_yield$response$json","data","wrap","_callee$","_context","prev","next","fetch","split","join","sent","json","id","t0","console","log","stop","apply","arguments","ensure","x","undefined","Error","modulePath","GiphyMeta","name","displayName","importName","importPath","providesData","description","props","searchTerm","type","defaultValue","Giphy","className","gif","setGif","gf","GiphyFetch","fetchGif","_yield$gf$gif","abrupt","React","src","images","downsized_medium","url","alt","registerAll","loader","_registerComponent","Component","defaultMeta","registerComponent"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plasmic-giphy.esm.js","sources":["../src/hooks/useFetch.ts","../src/giphy.tsx","../src/index.tsx"],"sourcesContent":["import { useState, useEffect } from \"react\";\n\ninterface HookProps {\n keyword: string\n}\nexport const useFetch = ({ keyword }: HookProps) => {\n const [giphyId, setGiphyId] = useState(\"\");\n\n useEffect(() => {\n if (keyword) fetchGiphy();\n }, [keyword]);\n\n const fetchGiphy = async () => {\n try {\n const response = await fetch(\n `https://api.giphy.com/v1/gifs/search?api_key=X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK&q=${keyword\n .split(\" \")\n .join(\"\")}&limit=1`\n );\n\n const { data } = await response.json();\n\n setGiphyId(data[0]?.id);\n } catch (error) {\n console.log(\"Error in gif api retrieval: \", error);\n setGiphyId(\"\");\n }\n };\n return giphyId;\n};\n","import { GiphyFetch } from \"@giphy/js-fetch-api\";\nimport { IGif } from \"@giphy/js-types\";\nimport { ComponentMeta } from \"@plasmicapp/host\";\nimport React, { useEffect, useState } from \"react\";\nimport { useFetch } from \"./hooks/useFetch\";\n\nexport function ensure<T>(x: T | null | undefined): T {\n if (x === null || x === undefined) {\n debugger;\n throw new Error(`Value must not be undefined or null`);\n } else {\n return x;\n }\n}\n\nconst modulePath = \"@plasmicpkgs/plasmic-giphy\";\n\ninterface GiphyProps {\n searchTerm: string;\n className: string;\n noLayout?: boolean;\n}\n\nexport const GiphyMeta: ComponentMeta<GiphyProps> = {\n name: \"hostless-giphy\",\n displayName: \"Giphy\",\n importName: \"Giphy\",\n importPath: modulePath,\n providesData: true,\n description: \"Fetches Giphy data and render it\",\n props: {\n searchTerm: {\n type: \"string\",\n displayName: \"Search Term\",\n description: \"Search term for fetching gif \",\n defaultValue: \"Cat\",\n },\n },\n};\n\nexport function Giphy({ searchTerm, className }: GiphyProps) {\n const id = useFetch({ keyword: searchTerm });\n const [gif, setGif] = useState<IGif | null>(null);\n\n const gf = new GiphyFetch(\"X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK\");\n useEffect(() => {\n const fetchGif = async () => {\n if (!id) {\n return null;\n }\n const { data } = await gf.gif(id);\n setGif(data);\n return data;\n };\n fetchGif();\n }, [id]);\n\n return (\n <img\n src={gif?.images.downsized_medium.url}\n alt=\"Gif\"\n className={className}\n />\n );\n}\n","import registerComponent, {\n ComponentMeta,\n} from \"@plasmicapp/host/registerComponent\";\nimport registerGlobalContext from \"@plasmicapp/host/registerGlobalContext\";\n\nimport { Giphy, GiphyMeta } from \"./giphy\";\n\nexport function registerAll(loader?: {\n registerComponent: typeof registerComponent;\n registerGlobalContext: typeof registerGlobalContext;\n}) {\n const _registerComponent = <T extends React.ComponentType<any>>(\n Component: T,\n defaultMeta: ComponentMeta<React.ComponentProps<T>>\n ) => {\n if (loader) {\n loader.registerComponent(Component, defaultMeta);\n } else {\n registerComponent(Component, defaultMeta);\n }\n };\n\n _registerComponent(Giphy, GiphyMeta);\n}\n\nexport * from \"./giphy\";\n"],"names":["useFetch","_ref","keyword","_useState","useState","giphyId","setGiphyId","useEffect","fetchGiphy","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_data$","response","_yield$response$json","data","wrap","_callee$","_context","prev","next","fetch","split","join","sent","json","id","t0","console","log","stop","apply","arguments","ensure","x","undefined","Error","modulePath","GiphyMeta","name","displayName","importName","importPath","providesData","description","props","searchTerm","type","defaultValue","Giphy","className","gif","setGif","gf","GiphyFetch","fetchGif","_yield$gf$gif","abrupt","React","src","images","downsized_medium","url","alt","registerAll","loader","_registerComponent","Component","defaultMeta","registerComponent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,IAAMA,QAAQ,GAAG,SAAXA,QAAQA,CAAAC,IAAA;MAAMC,OAAO,GAAAD,IAAA,CAAPC,OAAO;EAC9B,IAAAC,SAAA,GAA8BC,QAAQ,CAAC,EAAE,CAAC;IAAnCC,OAAO,GAAAF,SAAA;IAAEG,UAAU,GAAAH,SAAA;EAE1BI,SAAS,CAAC;IACN,IAAIL,OAAO,EAAEM,UAAU,EAAE;GAC5B,EAAE,CAACN,OAAO,CAAC,CAAC;EAEb,IAAMM,UAAU;IAAA,IAAAC,KAAA,GAAAC,iBAAA,cAAAC,mBAAA,GAAAC,IAAA,CAAG,SAAAC;MAAA,IAAAC,MAAA,EAAAC,QAAA,EAAAC,oBAAA,EAAAC,IAAA;MAAA,OAAAN,mBAAA,GA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AA,WACN1C,IAAI;YAAA;YAAA;cAAA,OAAAG,QAAA,CAAAY,IAAA;;WAAAnB,OAAA;OACZ;MAAA,gBAPK4C,QAAQA;QAAA,OAAAhD,KAAA,CAAAwB,KAAA,OAAAC,SAAA;;OAOb;IACDuB,QAAQ,EAAE;GACX,EAAE,CAAC7B,EAAE,CAAC,CAAC;EAER,OACEgC;IACEC,GAAG,EAAER,GAAG,oBAAHA,GAAG,CAAES,MAAM,CAACC,gBAAgB,CAACC,GAAG;IACrCC,GAAG,EAAC,KAAK;IACTb,SAAS,EAAEA;IACX;AAEN;;SCzDgBc,WAAWA,CAACC,MAG3B;EACC,IAAMC,kBAAkB,GAAG,SAArBA,kBAAkBA,CACtBC,SAAY,EACZC,WAAmD;IAEnD,IAAIH,MAAM,EAAE;MACVA,MAAM,CAACI,iBAAiB,CAACF,SAAS,EAAEC,WAAW,CAAC;KACjD,MAAM;MACLC,iBAAiB,CAACF,SAAS,EAAEC,WAAW,CAAC;;GAE5C;EAEDF,kBAAkB,CAACjB,KAAK,EAAEX,SAAS,CAAC;AACtC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicpkgs/plasmic-giphy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
4
4
|
"description": "Plasmic Giphy components.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
}
|
|
35
35
|
],
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@plasmicapp/host": "1.0.
|
|
37
|
+
"@plasmicapp/host": "1.0.212",
|
|
38
38
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
39
39
|
"@types/react": "^18.0.27",
|
|
40
40
|
"@types/react-dom": "^18.0.10",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"@giphy/react-components": "^9.0.1",
|
|
52
52
|
"change-case": "^4.1.2"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "e14716fd42ea79a35e4844d660f6d12aa97a9768"
|
|
55
55
|
}
|