@usereactify/search 5.37.0 → 5.38.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [5.38.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.37.0...release-v5.38.0) (2023-10-27)
6
+
7
+
8
+ ### Features
9
+
10
+ * add retry when loading config from network ([ef84d6a](https://bitbucket.org/usereactify/reactify-search-ui/commit/ef84d6a258b94bdd460b49c2599c3bb51d0e9683))
11
+
5
12
  ## [5.37.0](https://bitbucket.org/usereactify/reactify-search-ui/compare/release-v5.36.1...release-v5.37.0) (2023-10-26)
6
13
 
7
14
 
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@usereactify/search",
3
3
  "description": "React UI library for Reactify Search",
4
- "version": "5.37.0",
4
+ "version": "5.38.0",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -46,7 +46,14 @@ const useConfig = (shopifyPermanentDomain, configId) => {
46
46
  if (configId) {
47
47
  searchParams.set("id", configId);
48
48
  }
49
- const json = yield fetch(`https://config.search.reactify.app/?${searchParams.toString()}`).then((response) => response.json());
49
+ let json;
50
+ try {
51
+ json = yield fetch(`https://config.search.reactify.app/?${searchParams.toString()}`).then((response) => response.json());
52
+ }
53
+ catch (error) {
54
+ utility_1.debug.log("useConfig", "error loading config, retrying...");
55
+ json = yield fetch(`https://config.search.reactify.app/?${searchParams.toString()}`).then((response) => response.json());
56
+ }
50
57
  setConfig(json.body);
51
58
  utility_1.debug.log("useConfig", "loaded fresh config");
52
59
  window.sessionStorage.setItem("reactify-search:config", JSON.stringify({
@@ -1 +1 @@
1
- {"version":3,"file":"useConfig.js","sourceRoot":"","sources":["../../../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AI,QAAQ,EAAE;gBACZ,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;aAClC;YAED,MAAM,IAAI,GAAG,MAAM,KAAK,CACtB,uCAAuC,YAAY,CAAC,QAAQ,EAAE,EAAE,CACjE,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YAEtC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAErB,eAAK,CAAC,GAAG,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC;YAE9C,MAAM,CAAC,cAAc,CAAC,OAAO,CAC3B,wBAAwB,EACxB,IAAI,CAAC,SAAS,CAAC;gBACb,MAAM,EAAE,IAAI,CAAC,IAAI;aAClB,CAAC,CACH,CAAC;QACJ,CAAC,CAAA,CAAC,EAAE,CAAC;IACP,CAAC,EAAE,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEvC,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO;QACL,MAAM;KACP,CAAC;AACJ,CAAC,CAAC;AAvEW,QAAA,SAAS,aAuEpB","sourcesContent":["import React from \"react\";\n\nimport { Config } from \"../types/config\";\nimport { debug } from \"../utility\";\n\nexport const useConfig = (\n shopifyPermanentDomain: string,\n configId?: string\n): {\n config: Config | undefined;\n} => {\n // synchronously returns cached and non-expired config from session storage\n const cachedConfig = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n debug.log(\"useConfig\", \"checking config cache\");\n\n const sessionConfig: {\n config: Config;\n } | null = JSON.parse(\n window.sessionStorage.getItem(\"reactify-search:config\") ?? \"null\"\n );\n\n if (sessionConfig) {\n if (sessionConfig.config.cache?.enabled === false) {\n debug.log(\"useConfig\", `cache disabled, ignoring cached config`);\n return;\n }\n\n debug.log(\"useConfig\", `cache enabled, using cached config`);\n\n return sessionConfig.config;\n } else {\n debug.log(\"useConfig\", `cached config missing`);\n }\n\n return;\n }, []);\n\n const [config, setConfig] = React.useState<Config | undefined>(cachedConfig);\n\n React.useEffect(() => {\n (async () => {\n debug.log(\"useConfig\", \"loading fresh config\");\n const searchParams = new URLSearchParams();\n searchParams.set(\"shop\", shopifyPermanentDomain);\n\n if (configId) {\n searchParams.set(\"id\", configId);\n }\n\n const json = await fetch(\n `https://config.search.reactify.app/?${searchParams.toString()}`\n ).then((response) => response.json());\n\n setConfig(json.body);\n\n debug.log(\"useConfig\", \"loaded fresh config\");\n\n window.sessionStorage.setItem(\n \"reactify-search:config\",\n JSON.stringify({\n config: json.body,\n })\n );\n })();\n }, [shopifyPermanentDomain, configId]);\n\n React.useEffect(() => {\n debug.log(\"useConfig\", \"config\", config);\n }, [config]);\n\n return {\n config,\n };\n};\n"]}
1
+ {"version":3,"file":"useConfig.js","sourceRoot":"","sources":["../../../src/hooks/useConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAG1B,wCAAmC;AAE5B,MAAM,SAAS,GAAG,CACvB,sBAA8B,EAC9B,QAAiB,EAGjB,EAAE;IACF,2EAA2E;IAC3E,MAAM,YAAY,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QACtC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,OAAO;SACR;QACD,eAAK,CAAC,GAAG,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;QAEhD,MAAM,aAAa,GAER,IAAI,CAAC,KAAK,CACnB,MAAA,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,wBAAwB,CAAC,mCAAI,MAAM,CAClE,CAAC;QAEF,IAAI,aAAa,EAAE;YACjB,IAAI,CAAA,MAAA,aAAa,CAAC,MAAM,CAAC,KAAK,0CAAE,OAAO,MAAK,KAAK,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,IAAI,CAAC,IAAI,CAAC,CAAC;YAErB,eAAK,CAAC,GAAG,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC;YAE9C,MAAM,CAAC,cAAc,CAAC,OAAO,CAC3B,wBAAwB,EACxB,IAAI,CAAC,SAAS,CAAC;gBACb,MAAM,EAAE,IAAI,CAAC,IAAI;aAClB,CAAC,CACH,CAAC;QACJ,CAAC,CAAA,CAAC,EAAE,CAAC;IACP,CAAC,EAAE,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEvC,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,eAAK,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO;QACL,MAAM;KACP,CAAC;AACJ,CAAC,CAAC;AAlFW,QAAA,SAAS,aAkFpB","sourcesContent":["import React from \"react\";\n\nimport { Config } from \"../types/config\";\nimport { debug } from \"../utility\";\n\nexport const useConfig = (\n shopifyPermanentDomain: string,\n configId?: string\n): {\n config: Config | undefined;\n} => {\n // synchronously returns cached and non-expired config from session storage\n const cachedConfig = React.useMemo(() => {\n if (typeof window === \"undefined\") {\n return;\n }\n debug.log(\"useConfig\", \"checking config cache\");\n\n const sessionConfig: {\n config: Config;\n } | null = JSON.parse(\n window.sessionStorage.getItem(\"reactify-search:config\") ?? \"null\"\n );\n\n if (sessionConfig) {\n if (sessionConfig.config.cache?.enabled === false) {\n debug.log(\"useConfig\", `cache disabled, ignoring cached config`);\n return;\n }\n\n debug.log(\"useConfig\", `cache enabled, using cached config`);\n\n return sessionConfig.config;\n } else {\n debug.log(\"useConfig\", `cached config missing`);\n }\n\n return;\n }, []);\n\n const [config, setConfig] = React.useState<Config | undefined>(cachedConfig);\n\n React.useEffect(() => {\n (async () => {\n debug.log(\"useConfig\", \"loading fresh config\");\n const searchParams = new URLSearchParams();\n searchParams.set(\"shop\", shopifyPermanentDomain);\n\n if (configId) {\n searchParams.set(\"id\", configId);\n }\n\n let json: any;\n\n try {\n json = await fetch(\n `https://config.search.reactify.app/?${searchParams.toString()}`\n ).then((response) => response.json());\n \n } catch (error) {\n debug.log(\"useConfig\", \"error loading config, retrying...\");\n\n json = await fetch(\n `https://config.search.reactify.app/?${searchParams.toString()}`\n ).then((response) => response.json());\n }\n\n setConfig(json.body);\n\n debug.log(\"useConfig\", \"loaded fresh config\");\n\n window.sessionStorage.setItem(\n \"reactify-search:config\",\n JSON.stringify({\n config: json.body,\n })\n );\n })();\n }, [shopifyPermanentDomain, configId]);\n\n React.useEffect(() => {\n debug.log(\"useConfig\", \"config\", config);\n }, [config]);\n\n return {\n config,\n };\n};\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@usereactify/search",
3
3
  "description": "React UI library for Reactify Search",
4
- "version": "5.37.0",
4
+ "version": "5.38.0",
5
5
  "license": "MIT",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",