@plasmicpkgs/plasmic-giphy 0.0.41 → 0.0.43
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.
|
@@ -350,7 +350,7 @@ var useFetch = function useFetch(_ref) {
|
|
|
350
350
|
if (keyword) fetchGiphy();
|
|
351
351
|
}, [keyword]);
|
|
352
352
|
var fetchGiphy = /*#__PURE__*/function () {
|
|
353
|
-
var _ref2 = _asyncToGenerator(
|
|
353
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
354
354
|
var _data$, response, _yield$response$json, data;
|
|
355
355
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
356
356
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -423,7 +423,7 @@ function Giphy(_ref) {
|
|
|
423
423
|
var gf = new jsFetchApi.GiphyFetch("X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK");
|
|
424
424
|
React.useEffect(function () {
|
|
425
425
|
var fetchGif = /*#__PURE__*/function () {
|
|
426
|
-
var _ref2 = _asyncToGenerator(
|
|
426
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
427
427
|
var _yield$gf$gif, data;
|
|
428
428
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
429
429
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKO,IAAMA,QAAQ,GAAG,SAAXA,QAAQA,CAAAC,IAAA;MAAMC,OAAO,GAAAD,IAAA,CAAPC,OAAO;EAC9B,IAAAC,SAAA,GAA8BC,cAAQ,CAAC,EAAE,CAAC;IAAnCC,OAAO,GAAAF,SAAA;IAAEG,UAAU,GAAAH,SAAA;EAE1BI,eAAS,CAAC;IACN,IAAIL,OAAO,EAAEM,UAAU,EAAE;GAC5B,EAAE,CAACN,OAAO,CAAC,CAAC;EAEb,IAAMM,UAAU;IAAA,IAAAC,KAAA,GAAAC,iBAAA,
|
|
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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AY,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;;;;;;;"}
|
|
@@ -343,7 +343,7 @@ var useFetch = function useFetch(_ref) {
|
|
|
343
343
|
if (keyword) fetchGiphy();
|
|
344
344
|
}, [keyword]);
|
|
345
345
|
var fetchGiphy = /*#__PURE__*/function () {
|
|
346
|
-
var _ref2 = _asyncToGenerator(
|
|
346
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
347
347
|
var _data$, response, _yield$response$json, data;
|
|
348
348
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
349
349
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -416,7 +416,7 @@ function Giphy(_ref) {
|
|
|
416
416
|
var gf = new GiphyFetch("X1q3afkDR9WHSZJhLS6H9yYTQMPIWOTK");
|
|
417
417
|
useEffect(function () {
|
|
418
418
|
var fetchGif = /*#__PURE__*/function () {
|
|
419
|
-
var _ref2 = _asyncToGenerator(
|
|
419
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
420
420
|
var _yield$gf$gif, data;
|
|
421
421
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
422
422
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,
|
|
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":";;;;;;;;;;;;;;;;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,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.43",
|
|
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.211",
|
|
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": "93119895a0d403158e497a0abdccdcb24d670fb7"
|
|
55
55
|
}
|