@webiny/app 0.0.0-unstable.d7f521b032 → 0.0.0-unstable.df6d94b531

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.
Files changed (40) hide show
  1. package/package.json +11 -11
  2. package/plugins/AddQuerySelectionPlugin.d.ts +8 -1
  3. package/plugins/AddQuerySelectionPlugin.js +26 -5
  4. package/plugins/AddQuerySelectionPlugin.js.map +1 -1
  5. package/plugins/LocaleHeaderLinkPlugin.d.ts +0 -5
  6. package/plugins/LocaleHeaderLinkPlugin.js +2 -5
  7. package/plugins/LocaleHeaderLinkPlugin.js.map +1 -1
  8. package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +9 -3
  9. package/plugins/TenantHeaderLinkPlugin.d.ts +0 -5
  10. package/plugins/TenantHeaderLinkPlugin.js +2 -5
  11. package/plugins/TenantHeaderLinkPlugin.js.map +1 -1
  12. package/types.d.ts +4 -2
  13. package/types.js.map +1 -1
  14. package/utils/getApiUrl.d.ts +1 -0
  15. package/utils/getApiUrl.js +11 -0
  16. package/utils/getApiUrl.js.map +1 -0
  17. package/utils/getGqlApiUrl.d.ts +1 -0
  18. package/utils/getGqlApiUrl.js +11 -0
  19. package/utils/getGqlApiUrl.js.map +1 -0
  20. package/utils/getHeadlessCmsGqlApiUrl.d.ts +5 -0
  21. package/utils/getHeadlessCmsGqlApiUrl.js +17 -0
  22. package/utils/getHeadlessCmsGqlApiUrl.js.map +1 -0
  23. package/utils/getLocaleCode.d.ts +6 -0
  24. package/utils/getLocaleCode.js +42 -0
  25. package/utils/getLocaleCode.js.map +1 -0
  26. package/utils/getPrerenderId.d.ts +6 -0
  27. package/utils/getPrerenderId.js +10 -0
  28. package/utils/getPrerenderId.js.map +1 -0
  29. package/utils/getTenantId.d.ts +6 -0
  30. package/utils/getTenantId.js +34 -0
  31. package/utils/getTenantId.js.map +1 -0
  32. package/utils/index.d.ts +8 -0
  33. package/utils/index.js +93 -0
  34. package/utils/index.js.map +1 -0
  35. package/utils/isLocalhost.d.ts +1 -0
  36. package/utils/isLocalhost.js +14 -0
  37. package/utils/isLocalhost.js.map +1 -0
  38. package/utils/isPrerendering.d.ts +1 -0
  39. package/utils/isPrerendering.js +10 -0
  40. package/utils/isPrerendering.js.map +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app",
3
- "version": "0.0.0-unstable.d7f521b032",
3
+ "version": "0.0.0-unstable.df6d94b531",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,15 +16,15 @@
16
16
  "dependencies": {
17
17
  "@apollo/react-hooks": "3.1.5",
18
18
  "@babel/runtime": "7.20.13",
19
- "@emotion/styled": "10.3.0",
19
+ "@emotion/styled": "11.10.6",
20
20
  "@types/react": "17.0.39",
21
21
  "@types/web": "0.0.61",
22
- "@webiny/i18n": "0.0.0-unstable.d7f521b032",
23
- "@webiny/i18n-react": "0.0.0-unstable.d7f521b032",
24
- "@webiny/plugins": "0.0.0-unstable.d7f521b032",
25
- "@webiny/react-composition": "0.0.0-unstable.d7f521b032",
26
- "@webiny/react-router": "0.0.0-unstable.d7f521b032",
27
- "@webiny/ui": "0.0.0-unstable.d7f521b032",
22
+ "@webiny/i18n": "0.0.0-unstable.df6d94b531",
23
+ "@webiny/i18n-react": "0.0.0-unstable.df6d94b531",
24
+ "@webiny/plugins": "0.0.0-unstable.df6d94b531",
25
+ "@webiny/react-composition": "0.0.0-unstable.df6d94b531",
26
+ "@webiny/react-router": "0.0.0-unstable.df6d94b531",
27
+ "@webiny/ui": "0.0.0-unstable.df6d94b531",
28
28
  "apollo-cache": "1.3.5",
29
29
  "apollo-cache-inmemory": "1.6.6",
30
30
  "apollo-client": "2.6.10",
@@ -52,8 +52,8 @@
52
52
  "@babel/preset-typescript": "^7.18.6",
53
53
  "@types/lodash.debounce": "^4.0.7",
54
54
  "@types/warning": "^3.0.0",
55
- "@webiny/cli": "^0.0.0-unstable.d7f521b032",
56
- "@webiny/project-utils": "^0.0.0-unstable.d7f521b032",
55
+ "@webiny/cli": "^0.0.0-unstable.df6d94b531",
56
+ "@webiny/project-utils": "^0.0.0-unstable.df6d94b531",
57
57
  "babel-plugin-lodash": "^3.3.4",
58
58
  "rimraf": "^3.0.2",
59
59
  "typescript": "4.7.4"
@@ -74,5 +74,5 @@
74
74
  ]
75
75
  }
76
76
  },
77
- "gitHead": "d7f521b0325964664dbeb6d2d07e2b6518e53841"
77
+ "gitHead": "df6d94b531ed0453caef22c785d42be580c9df96"
78
78
  }
@@ -1,6 +1,11 @@
1
1
  import { ApolloLink } from "apollo-link";
2
2
  import { DocumentNode } from "graphql";
3
3
  import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
4
+ declare module "graphql" {
5
+ interface DocumentNode {
6
+ __webiny__: Set<string>;
7
+ }
8
+ }
4
9
  interface Config {
5
10
  operationName: string;
6
11
  selectionPath: string;
@@ -10,6 +15,8 @@ export declare class AddQuerySelectionPlugin extends ApolloLinkPlugin {
10
15
  private readonly config;
11
16
  constructor(config: Config);
12
17
  createLink(): ApolloLink;
13
- addSelectionToQuery(operationName: string, query: DocumentNode): void;
18
+ addSelectionToQuery(operationName: string, document: DocumentNode): void;
19
+ private isProcessed;
20
+ private markProcessed;
14
21
  }
15
22
  export {};
@@ -14,6 +14,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
14
14
  var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
15
15
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
16
  var _apolloLink = require("apollo-link");
17
+ var _graphql = require("graphql");
17
18
  var _ApolloLinkPlugin2 = require("./ApolloLinkPlugin");
18
19
  var AddQuerySelectionPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
19
20
  (0, _inherits2.default)(AddQuerySelectionPlugin, _ApolloLinkPlugin);
@@ -40,18 +41,22 @@ var AddQuerySelectionPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
40
41
  }
41
42
  }, {
42
43
  key: "addSelectionToQuery",
43
- value: function addSelectionToQuery(operationName, query) {
44
+ value: function addSelectionToQuery(operationName, document) {
44
45
  var _tree;
45
46
  if (operationName !== this.config.operationName) {
46
47
  return;
47
48
  }
49
+
50
+ // If this plugin already processed the given document (documents are always passed by reference),
51
+ // then we don't want to apply the selection again, to avoid adding duplicate selections.
52
+ if (this.isProcessed(document)) {
53
+ return;
54
+ }
55
+ this.markProcessed(document);
48
56
  var _this$config = this.config,
49
57
  addSelection = _this$config.addSelection,
50
58
  selectionPath = _this$config.selectionPath;
51
-
52
- // TODO: check if the selection is already in the query and don't add it again if not necessary.
53
-
54
- var firstQueryDefinition = query.definitions[0];
59
+ var firstQueryDefinition = document.definitions[0];
55
60
  if (!firstQueryDefinition) {
56
61
  return;
57
62
  } else if (!firstQueryDefinition.selectionSet) {
@@ -95,6 +100,22 @@ var AddQuerySelectionPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
95
100
  */
96
101
  (_tree = tree).push.apply(_tree, (0, _toConsumableArray2.default)(addSelection.definitions[0].selectionSet.selections));
97
102
  }
103
+ }, {
104
+ key: "isProcessed",
105
+ value: function isProcessed(document) {
106
+ if (!document.hasOwnProperty("__webiny__")) {
107
+ document.__webiny__ = new Set();
108
+ }
109
+ return document.__webiny__.has(this.cacheKey);
110
+ }
111
+ }, {
112
+ key: "markProcessed",
113
+ value: function markProcessed(document) {
114
+ if (!document.hasOwnProperty("__webiny__")) {
115
+ document.__webiny__ = new Set();
116
+ }
117
+ document.__webiny__.add(this.cacheKey);
118
+ }
98
119
  }]);
99
120
  return AddQuerySelectionPlugin;
100
121
  }(_ApolloLinkPlugin2.ApolloLinkPlugin);
@@ -1 +1 @@
1
- {"version":3,"names":["AddQuerySelectionPlugin","config","ApolloLink","operation","forward","operationName","addSelectionToQuery","query","addSelection","selectionPath","firstQueryDefinition","definitions","selectionSet","tree","selections","fields","split","fieldLoop","field","selection","name","value","push","ApolloLinkPlugin"],"sources":["AddQuerySelectionPlugin.ts"],"sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport { DocumentNode } from \"graphql\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { ExecutableDefinitionNode, FieldNode } from \"graphql/language/ast\";\n\ninterface Config {\n operationName: string;\n selectionPath: string;\n addSelection: DocumentNode;\n}\n\nexport class AddQuerySelectionPlugin extends ApolloLinkPlugin {\n private readonly config: Config;\n\n constructor(config: Config) {\n super();\n this.config = config;\n }\n\n public override createLink(): ApolloLink {\n return new ApolloLink((operation, forward) => {\n if (operation.operationName !== this.config.operationName) {\n return forward(operation);\n }\n\n this.addSelectionToQuery(operation.operationName, operation.query);\n\n return forward(operation);\n });\n }\n\n public addSelectionToQuery(operationName: string, query: DocumentNode): void {\n if (operationName !== this.config.operationName) {\n return;\n }\n\n const { addSelection, selectionPath } = this.config;\n\n // TODO: check if the selection is already in the query and don't add it again if not necessary.\n\n const firstQueryDefinition = query.definitions[0] as ExecutableDefinitionNode;\n if (!firstQueryDefinition) {\n return;\n } else if (!firstQueryDefinition.selectionSet) {\n return;\n }\n\n let tree = firstQueryDefinition.selectionSet.selections as FieldNode[];\n const fields = selectionPath.split(\".\");\n\n fieldLoop: for (const field of fields) {\n for (const selection of tree) {\n if (!selection.selectionSet) {\n continue;\n }\n if (selection.name.value === field) {\n tree = selection.selectionSet.selections as FieldNode[];\n continue fieldLoop;\n }\n }\n // If we get here, it means we didn't find the necessary selection\n return;\n }\n /**\n * We must cast because there are a lot of types that are not intertwined and TS is complaining\n */\n tree.push(\n ...((addSelection.definitions[0] as ExecutableDefinitionNode).selectionSet\n .selections as FieldNode[])\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAEA;AAAsD,IASzCA,uBAAuB;EAAA;EAAA;EAGhC,iCAAYC,MAAc,EAAE;IAAA;IAAA;IACxB;IAAQ;IACR,MAAKA,MAAM,GAAGA,MAAM;IAAC;EACzB;EAAC;IAAA;IAAA,OAED,sBAAyC;MAAA;MACrC,OAAO,IAAIC,sBAAU,CAAC,UAACC,SAAS,EAAEC,OAAO,EAAK;QAC1C,IAAID,SAAS,CAACE,aAAa,KAAK,MAAI,CAACJ,MAAM,CAACI,aAAa,EAAE;UACvD,OAAOD,OAAO,CAACD,SAAS,CAAC;QAC7B;QAEA,MAAI,CAACG,mBAAmB,CAACH,SAAS,CAACE,aAAa,EAAEF,SAAS,CAACI,KAAK,CAAC;QAElE,OAAOH,OAAO,CAACD,SAAS,CAAC;MAC7B,CAAC,CAAC;IACN;EAAC;IAAA;IAAA,OAED,6BAA2BE,aAAqB,EAAEE,KAAmB,EAAQ;MAAA;MACzE,IAAIF,aAAa,KAAK,IAAI,CAACJ,MAAM,CAACI,aAAa,EAAE;QAC7C;MACJ;MAEA,mBAAwC,IAAI,CAACJ,MAAM;QAA3CO,YAAY,gBAAZA,YAAY;QAAEC,aAAa,gBAAbA,aAAa;;MAEnC;;MAEA,IAAMC,oBAAoB,GAAGH,KAAK,CAACI,WAAW,CAAC,CAAC,CAA6B;MAC7E,IAAI,CAACD,oBAAoB,EAAE;QACvB;MACJ,CAAC,MAAM,IAAI,CAACA,oBAAoB,CAACE,YAAY,EAAE;QAC3C;MACJ;MAEA,IAAIC,IAAI,GAAGH,oBAAoB,CAACE,YAAY,CAACE,UAAyB;MACtE,IAAMC,MAAM,GAAGN,aAAa,CAACO,KAAK,CAAC,GAAG,CAAC;MAAC,yDAETD,MAAM;QAAA;MAAA;QAArCE,SAAS,EAAE,oDAA4B;UAAA,IAAjBC,KAAK;UAAA,0DACCL,IAAI;YAAA;UAAA;YAA5B,uDAA8B;cAAA,IAAnBM,SAAS;cAChB,IAAI,CAACA,SAAS,CAACP,YAAY,EAAE;gBACzB;cACJ;cACA,IAAIO,SAAS,CAACC,IAAI,CAACC,KAAK,KAAKH,KAAK,EAAE;gBAChCL,IAAI,GAAGM,SAAS,CAACP,YAAY,CAACE,UAAyB;gBACvD,SAASG,SAAS;cACtB;YACJ;YACA;UAAA;YAAA;UAAA;YAAA;UAAA;UACA;QACJ;MAAC;QAAA;MAAA;QAAA;MAAA;MACD;AACR;AACA;MACQ,SAAAJ,IAAI,EAACS,IAAI,+CACAd,YAAY,CAACG,WAAW,CAAC,CAAC,CAAC,CAA8BC,YAAY,CACrEE,UAAU,EAClB;IACL;EAAC;EAAA;AAAA,EA3DwCS,mCAAgB;AAAA"}
1
+ {"version":3,"names":["AddQuerySelectionPlugin","config","ApolloLink","operation","forward","operationName","addSelectionToQuery","query","document","isProcessed","markProcessed","addSelection","selectionPath","firstQueryDefinition","definitions","selectionSet","tree","selections","fields","split","fieldLoop","field","selection","name","value","push","hasOwnProperty","__webiny__","Set","has","cacheKey","add","ApolloLinkPlugin"],"sources":["AddQuerySelectionPlugin.ts"],"sourcesContent":["import { ApolloLink } from \"apollo-link\";\nimport { DocumentNode } from \"graphql\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { ExecutableDefinitionNode, FieldNode } from \"graphql/language/ast\";\n\ndeclare module \"graphql\" {\n interface DocumentNode {\n __webiny__: Set<string>;\n }\n}\n\ninterface Config {\n operationName: string;\n selectionPath: string;\n addSelection: DocumentNode;\n}\n\nexport class AddQuerySelectionPlugin extends ApolloLinkPlugin {\n private readonly config: Config;\n\n constructor(config: Config) {\n super();\n this.config = config;\n }\n\n public override createLink(): ApolloLink {\n return new ApolloLink((operation, forward) => {\n if (operation.operationName !== this.config.operationName) {\n return forward(operation);\n }\n\n this.addSelectionToQuery(operation.operationName, operation.query);\n\n return forward(operation);\n });\n }\n\n public addSelectionToQuery(operationName: string, document: DocumentNode): void {\n if (operationName !== this.config.operationName) {\n return;\n }\n\n // If this plugin already processed the given document (documents are always passed by reference),\n // then we don't want to apply the selection again, to avoid adding duplicate selections.\n if (this.isProcessed(document)) {\n return;\n }\n\n this.markProcessed(document);\n\n const { addSelection, selectionPath } = this.config;\n\n const firstQueryDefinition = document.definitions[0] as ExecutableDefinitionNode;\n if (!firstQueryDefinition) {\n return;\n } else if (!firstQueryDefinition.selectionSet) {\n return;\n }\n\n let tree = firstQueryDefinition.selectionSet.selections as FieldNode[];\n const fields = selectionPath.split(\".\");\n\n fieldLoop: for (const field of fields) {\n for (const selection of tree) {\n if (!selection.selectionSet) {\n continue;\n }\n if (selection.name.value === field) {\n tree = selection.selectionSet.selections as FieldNode[];\n continue fieldLoop;\n }\n }\n // If we get here, it means we didn't find the necessary selection\n return;\n }\n /**\n * We must cast because there are a lot of types that are not intertwined and TS is complaining\n */\n tree.push(\n ...((addSelection.definitions[0] as ExecutableDefinitionNode).selectionSet\n .selections as FieldNode[])\n );\n }\n\n private isProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n return document.__webiny__.has(this.cacheKey);\n }\n\n private markProcessed(document: DocumentNode) {\n if (!document.hasOwnProperty(\"__webiny__\")) {\n document.__webiny__ = new Set();\n }\n\n document.__webiny__.add(this.cacheKey);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AAAsD,IAezCA,uBAAuB;EAAA;EAAA;EAGhC,iCAAYC,MAAc,EAAE;IAAA;IAAA;IACxB;IAAQ;IACR,MAAKA,MAAM,GAAGA,MAAM;IAAC;EACzB;EAAC;IAAA;IAAA,OAED,sBAAyC;MAAA;MACrC,OAAO,IAAIC,sBAAU,CAAC,UAACC,SAAS,EAAEC,OAAO,EAAK;QAC1C,IAAID,SAAS,CAACE,aAAa,KAAK,MAAI,CAACJ,MAAM,CAACI,aAAa,EAAE;UACvD,OAAOD,OAAO,CAACD,SAAS,CAAC;QAC7B;QAEA,MAAI,CAACG,mBAAmB,CAACH,SAAS,CAACE,aAAa,EAAEF,SAAS,CAACI,KAAK,CAAC;QAElE,OAAOH,OAAO,CAACD,SAAS,CAAC;MAC7B,CAAC,CAAC;IACN;EAAC;IAAA;IAAA,OAED,6BAA2BE,aAAqB,EAAEG,QAAsB,EAAQ;MAAA;MAC5E,IAAIH,aAAa,KAAK,IAAI,CAACJ,MAAM,CAACI,aAAa,EAAE;QAC7C;MACJ;;MAEA;MACA;MACA,IAAI,IAAI,CAACI,WAAW,CAACD,QAAQ,CAAC,EAAE;QAC5B;MACJ;MAEA,IAAI,CAACE,aAAa,CAACF,QAAQ,CAAC;MAE5B,mBAAwC,IAAI,CAACP,MAAM;QAA3CU,YAAY,gBAAZA,YAAY;QAAEC,aAAa,gBAAbA,aAAa;MAEnC,IAAMC,oBAAoB,GAAGL,QAAQ,CAACM,WAAW,CAAC,CAAC,CAA6B;MAChF,IAAI,CAACD,oBAAoB,EAAE;QACvB;MACJ,CAAC,MAAM,IAAI,CAACA,oBAAoB,CAACE,YAAY,EAAE;QAC3C;MACJ;MAEA,IAAIC,IAAI,GAAGH,oBAAoB,CAACE,YAAY,CAACE,UAAyB;MACtE,IAAMC,MAAM,GAAGN,aAAa,CAACO,KAAK,CAAC,GAAG,CAAC;MAAC,yDAETD,MAAM;QAAA;MAAA;QAArCE,SAAS,EAAE,oDAA4B;UAAA,IAAjBC,KAAK;UAAA,0DACCL,IAAI;YAAA;UAAA;YAA5B,uDAA8B;cAAA,IAAnBM,SAAS;cAChB,IAAI,CAACA,SAAS,CAACP,YAAY,EAAE;gBACzB;cACJ;cACA,IAAIO,SAAS,CAACC,IAAI,CAACC,KAAK,KAAKH,KAAK,EAAE;gBAChCL,IAAI,GAAGM,SAAS,CAACP,YAAY,CAACE,UAAyB;gBACvD,SAASG,SAAS;cACtB;YACJ;YACA;UAAA;YAAA;UAAA;YAAA;UAAA;UACA;QACJ;MAAC;QAAA;MAAA;QAAA;MAAA;MACD;AACR;AACA;MACQ,SAAAJ,IAAI,EAACS,IAAI,+CACAd,YAAY,CAACG,WAAW,CAAC,CAAC,CAAC,CAA8BC,YAAY,CACrEE,UAAU,EAClB;IACL;EAAC;IAAA;IAAA,OAED,qBAAoBT,QAAsB,EAAE;MACxC,IAAI,CAACA,QAAQ,CAACkB,cAAc,CAAC,YAAY,CAAC,EAAE;QACxClB,QAAQ,CAACmB,UAAU,GAAG,IAAIC,GAAG,EAAE;MACnC;MAEA,OAAOpB,QAAQ,CAACmB,UAAU,CAACE,GAAG,CAAC,IAAI,CAACC,QAAQ,CAAC;IACjD;EAAC;IAAA;IAAA,OAED,uBAAsBtB,QAAsB,EAAE;MAC1C,IAAI,CAACA,QAAQ,CAACkB,cAAc,CAAC,YAAY,CAAC,EAAE;QACxClB,QAAQ,CAACmB,UAAU,GAAG,IAAIC,GAAG,EAAE;MACnC;MAEApB,QAAQ,CAACmB,UAAU,CAACI,GAAG,CAAC,IAAI,CAACD,QAAQ,CAAC;IAC1C;EAAC;EAAA;AAAA,EAjFwCE,mCAAgB;AAAA"}
@@ -1,10 +1,5 @@
1
1
  import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
2
2
  import { ApolloLink } from "apollo-link";
3
- declare global {
4
- interface Window {
5
- __PS_RENDER_LOCALE__: string;
6
- }
7
- }
8
3
  /**
9
4
  * Append `x-i18n-locale` header from URL query (necessary for prerendering service).
10
5
  */
@@ -14,6 +14,7 @@ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
14
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
15
  var _apolloLinkContext = require("apollo-link-context");
16
16
  var _ApolloLinkPlugin2 = require("./ApolloLinkPlugin");
17
+ var _utils = require("../utils");
17
18
  /**
18
19
  * Append `x-i18n-locale` header from URL query (necessary for prerendering service).
19
20
  */
@@ -25,11 +26,7 @@ var LocaleHeaderLinkPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
25
26
  (0, _classCallCheck2.default)(this, LocaleHeaderLinkPlugin);
26
27
  _this = _super.call(this);
27
28
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "locale", void 0);
28
- if (!locale) {
29
- var query = new URLSearchParams(location.search);
30
- locale = query.get("__locale") || window.__PS_RENDER_LOCALE__;
31
- }
32
- _this.locale = locale;
29
+ _this.locale = locale || (0, _utils.getLocaleCode)();
33
30
  return _this;
34
31
  }
35
32
  (0, _createClass2.default)(LocaleHeaderLinkPlugin, [{
@@ -1 +1 @@
1
- {"version":3,"names":["LocaleHeaderLinkPlugin","locale","query","URLSearchParams","location","search","get","window","__PS_RENDER_LOCALE__","setContext","_","headers","ApolloLinkPlugin"],"sources":["LocaleHeaderLinkPlugin.ts"],"sourcesContent":["import { setContext } from \"apollo-link-context\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { ApolloLink } from \"apollo-link\";\n\ndeclare global {\n interface Window {\n __PS_RENDER_LOCALE__: string;\n }\n}\n\n/**\n * Append `x-i18n-locale` header from URL query (necessary for prerendering service).\n */\nexport class LocaleHeaderLinkPlugin extends ApolloLinkPlugin {\n private readonly locale: string;\n\n constructor(locale?: string) {\n super();\n\n if (!locale) {\n const query = new URLSearchParams(location.search);\n locale = query.get(\"__locale\") || window.__PS_RENDER_LOCALE__;\n }\n\n this.locale = locale;\n }\n\n public override createLink(): ApolloLink {\n return setContext((_, { headers }) => {\n if (this.locale) {\n return {\n headers: {\n ...headers,\n \"x-i18n-locale\": `content:${this.locale};`\n }\n };\n }\n\n return { headers };\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AASA;AACA;AACA;AAFA,IAGaA,sBAAsB;EAAA;EAAA;EAG/B,gCAAYC,MAAe,EAAE;IAAA;IAAA;IACzB;IAAQ;IAER,IAAI,CAACA,MAAM,EAAE;MACT,IAAMC,KAAK,GAAG,IAAIC,eAAe,CAACC,QAAQ,CAACC,MAAM,CAAC;MAClDJ,MAAM,GAAGC,KAAK,CAACI,GAAG,CAAC,UAAU,CAAC,IAAIC,MAAM,CAACC,oBAAoB;IACjE;IAEA,MAAKP,MAAM,GAAGA,MAAM;IAAC;EACzB;EAAC;IAAA;IAAA,OAED,sBAAyC;MAAA;MACrC,OAAO,IAAAQ,6BAAU,EAAC,UAACC,CAAC,QAAkB;QAAA,IAAdC,OAAO,QAAPA,OAAO;QAC3B,IAAI,MAAI,CAACV,MAAM,EAAE;UACb,OAAO;YACHU,OAAO,8DACAA,OAAO;cACV,eAAe,oBAAa,MAAI,CAACV,MAAM;YAAG;UAElD,CAAC;QACL;QAEA,OAAO;UAAEU,OAAO,EAAPA;QAAQ,CAAC;MACtB,CAAC,CAAC;IACN;EAAC;EAAA;AAAA,EA3BuCC,mCAAgB;AAAA"}
1
+ {"version":3,"names":["LocaleHeaderLinkPlugin","locale","getLocaleCode","setContext","_","headers","ApolloLinkPlugin"],"sources":["LocaleHeaderLinkPlugin.ts"],"sourcesContent":["import { setContext } from \"apollo-link-context\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { ApolloLink } from \"apollo-link\";\nimport { getLocaleCode } from \"~/utils\";\n\n/**\n * Append `x-i18n-locale` header from URL query (necessary for prerendering service).\n */\nexport class LocaleHeaderLinkPlugin extends ApolloLinkPlugin {\n private readonly locale: string;\n\n constructor(locale?: string) {\n super();\n\n this.locale = locale || (getLocaleCode() as string);\n }\n\n public override createLink(): ApolloLink {\n return setContext((_, { headers }) => {\n if (this.locale) {\n return {\n headers: {\n ...headers,\n \"x-i18n-locale\": `content:${this.locale};`\n }\n };\n }\n\n return { headers };\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAEA;AAEA;AACA;AACA;AAFA,IAGaA,sBAAsB;EAAA;EAAA;EAG/B,gCAAYC,MAAe,EAAE;IAAA;IAAA;IACzB;IAAQ;IAER,MAAKA,MAAM,GAAGA,MAAM,IAAK,IAAAC,oBAAa,GAAa;IAAC;EACxD;EAAC;IAAA;IAAA,OAED,sBAAyC;MAAA;MACrC,OAAO,IAAAC,6BAAU,EAAC,UAACC,CAAC,QAAkB;QAAA,IAAdC,OAAO,QAAPA,OAAO;QAC3B,IAAI,MAAI,CAACJ,MAAM,EAAE;UACb,OAAO;YACHI,OAAO,8DACAA,OAAO;cACV,eAAe,oBAAa,MAAI,CAACJ,MAAM;YAAG;UAElD,CAAC;QACL;QAEA,OAAO;UAAEI,OAAO,EAAPA;QAAQ,CAAC;MACtB,CAAC,CAAC;IACN;EAAC;EAAA;AAAA,EAtBuCC,mCAAgB;AAAA"}
@@ -1,5 +1,11 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="web" />
3
2
  /// <reference types="react" />
4
- export declare const OverlayWrapper: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Pick<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement>, keyof import("react").HTMLAttributes<HTMLDivElement>>, object>;
5
- export declare const Pre: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLPreElement>, HTMLPreElement>, Pick<import("react").ClassAttributes<HTMLPreElement> & import("react").HTMLAttributes<HTMLPreElement>, keyof import("react").HTMLAttributes<HTMLPreElement>>, object>;
3
+ /// <reference types="web" />
4
+ export declare const OverlayWrapper: import("@emotion/styled").StyledComponent<{
5
+ theme?: import("@emotion/react").Theme | undefined;
6
+ as?: import("react").ElementType<any> | undefined;
7
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
8
+ export declare const Pre: import("@emotion/styled").StyledComponent<{
9
+ theme?: import("@emotion/react").Theme | undefined;
10
+ as?: import("react").ElementType<any> | undefined;
11
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLPreElement>, HTMLPreElement>, {}>;
@@ -1,10 +1,5 @@
1
1
  import { ApolloLinkPlugin } from "./ApolloLinkPlugin";
2
2
  import { ApolloLink } from "apollo-link";
3
- declare global {
4
- interface Window {
5
- __PS_RENDER_TENANT__: string;
6
- }
7
- }
8
3
  /**
9
4
  * Append `x-tenant` header from URL query (necessary for prerendering service).
10
5
  */
@@ -14,6 +14,7 @@ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
14
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
15
  var _apolloLinkContext = require("apollo-link-context");
16
16
  var _ApolloLinkPlugin2 = require("./ApolloLinkPlugin");
17
+ var _utils = require("../utils");
17
18
  /**
18
19
  * Append `x-tenant` header from URL query (necessary for prerendering service).
19
20
  */
@@ -26,11 +27,7 @@ var TenantHeaderLinkPlugin = /*#__PURE__*/function (_ApolloLinkPlugin) {
26
27
  _this = _super.call(this);
27
28
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tenant", void 0);
28
29
  _this.name = "tenant-header-link";
29
- if (!tenant) {
30
- var query = new URLSearchParams(location.search);
31
- tenant = query.get("__tenant") || window.__PS_RENDER_TENANT__;
32
- }
33
- _this.tenant = tenant;
30
+ _this.tenant = tenant || (0, _utils.getTenantId)();
34
31
  return _this;
35
32
  }
36
33
  (0, _createClass2.default)(TenantHeaderLinkPlugin, [{
@@ -1 +1 @@
1
- {"version":3,"names":["TenantHeaderLinkPlugin","tenant","name","query","URLSearchParams","location","search","get","window","__PS_RENDER_TENANT__","setContext","_","headers","ApolloLinkPlugin"],"sources":["TenantHeaderLinkPlugin.ts"],"sourcesContent":["import { setContext } from \"apollo-link-context\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { ApolloLink } from \"apollo-link\";\n\ndeclare global {\n interface Window {\n __PS_RENDER_TENANT__: string;\n }\n}\n\n/**\n * Append `x-tenant` header from URL query (necessary for prerendering service).\n */\nexport class TenantHeaderLinkPlugin extends ApolloLinkPlugin {\n private readonly tenant: string;\n\n public constructor(tenant?: string) {\n super();\n this.name = \"tenant-header-link\";\n\n if (!tenant) {\n const query = new URLSearchParams(location.search);\n tenant = query.get(\"__tenant\") || window.__PS_RENDER_TENANT__;\n }\n\n this.tenant = tenant;\n }\n\n public override createLink(): ApolloLink {\n return setContext((_, { headers }) => {\n // If tenant header is already set, do not overwrite it.\n if (headers && \"x-tenant\" in headers) {\n return { headers };\n }\n\n if (this.tenant) {\n return {\n headers: {\n ...headers,\n \"x-tenant\": this.tenant\n }\n };\n }\n\n return { headers };\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AASA;AACA;AACA;AAFA,IAGaA,sBAAsB;EAAA;EAAA;EAG/B,gCAAmBC,MAAe,EAAE;IAAA;IAAA;IAChC;IAAQ;IACR,MAAKC,IAAI,GAAG,oBAAoB;IAEhC,IAAI,CAACD,MAAM,EAAE;MACT,IAAME,KAAK,GAAG,IAAIC,eAAe,CAACC,QAAQ,CAACC,MAAM,CAAC;MAClDL,MAAM,GAAGE,KAAK,CAACI,GAAG,CAAC,UAAU,CAAC,IAAIC,MAAM,CAACC,oBAAoB;IACjE;IAEA,MAAKR,MAAM,GAAGA,MAAM;IAAC;EACzB;EAAC;IAAA;IAAA,OAED,sBAAyC;MAAA;MACrC,OAAO,IAAAS,6BAAU,EAAC,UAACC,CAAC,QAAkB;QAAA,IAAdC,OAAO,QAAPA,OAAO;QAC3B;QACA,IAAIA,OAAO,IAAI,UAAU,IAAIA,OAAO,EAAE;UAClC,OAAO;YAAEA,OAAO,EAAPA;UAAQ,CAAC;QACtB;QAEA,IAAI,MAAI,CAACX,MAAM,EAAE;UACb,OAAO;YACHW,OAAO,8DACAA,OAAO;cACV,UAAU,EAAE,MAAI,CAACX;YAAM;UAE/B,CAAC;QACL;QAEA,OAAO;UAAEW,OAAO,EAAPA;QAAQ,CAAC;MACtB,CAAC,CAAC;IACN;EAAC;EAAA;AAAA,EAjCuCC,mCAAgB;AAAA"}
1
+ {"version":3,"names":["TenantHeaderLinkPlugin","tenant","name","getTenantId","setContext","_","headers","ApolloLinkPlugin"],"sources":["TenantHeaderLinkPlugin.ts"],"sourcesContent":["import { setContext } from \"apollo-link-context\";\nimport { ApolloLinkPlugin } from \"./ApolloLinkPlugin\";\nimport { ApolloLink } from \"apollo-link\";\nimport { getTenantId } from \"~/utils\";\n\n/**\n * Append `x-tenant` header from URL query (necessary for prerendering service).\n */\nexport class TenantHeaderLinkPlugin extends ApolloLinkPlugin {\n private readonly tenant: string;\n\n public constructor(tenant?: string) {\n super();\n this.name = \"tenant-header-link\";\n\n this.tenant = tenant || (getTenantId() as string);\n }\n\n public override createLink(): ApolloLink {\n return setContext((_, { headers }) => {\n // If tenant header is already set, do not overwrite it.\n if (headers && \"x-tenant\" in headers) {\n return { headers };\n }\n\n if (this.tenant) {\n return {\n headers: {\n ...headers,\n \"x-tenant\": this.tenant\n }\n };\n }\n\n return { headers };\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AAEA;AAEA;AACA;AACA;AAFA,IAGaA,sBAAsB;EAAA;EAAA;EAG/B,gCAAmBC,MAAe,EAAE;IAAA;IAAA;IAChC;IAAQ;IACR,MAAKC,IAAI,GAAG,oBAAoB;IAEhC,MAAKD,MAAM,GAAGA,MAAM,IAAK,IAAAE,kBAAW,GAAa;IAAC;EACtD;EAAC;IAAA;IAAA,OAED,sBAAyC;MAAA;MACrC,OAAO,IAAAC,6BAAU,EAAC,UAACC,CAAC,QAAkB;QAAA,IAAdC,OAAO,QAAPA,OAAO;QAC3B;QACA,IAAIA,OAAO,IAAI,UAAU,IAAIA,OAAO,EAAE;UAClC,OAAO;YAAEA,OAAO,EAAPA;UAAQ,CAAC;QACtB;QAEA,IAAI,MAAI,CAACL,MAAM,EAAE;UACb,OAAO;YACHK,OAAO,8DACAA,OAAO;cACV,UAAU,EAAE,MAAI,CAACL;YAAM;UAE/B,CAAC;QACL;QAEA,OAAO;UAAEK,OAAO,EAAPA;QAAQ,CAAC;MACtB,CAAC,CAAC;IACN;EAAC;EAAA;AAAA,EA5BuCC,mCAAgB;AAAA"}
package/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /// <reference types="web" />
1
2
  import * as React from "react";
2
3
  import { Plugin } from "@webiny/plugins/types";
3
4
  import { ApolloClient } from "apollo-client";
@@ -18,6 +19,7 @@ export interface FileItem {
18
19
  }
19
20
  export declare type UploadOptions = {
20
21
  apolloClient: ApolloClient<object>;
22
+ onProgress?: (progress: number) => void;
21
23
  };
22
24
  export declare type UiStatePlugin = Plugin & {
23
25
  type: "ui-state";
@@ -25,11 +27,11 @@ export declare type UiStatePlugin = Plugin & {
25
27
  };
26
28
  export declare type FileUploaderPlugin = Plugin & {
27
29
  type: "file-uploader";
28
- upload(file: FileItem, options: UploadOptions): Promise<any>;
30
+ upload(file: File, options: UploadOptions): Promise<any>;
29
31
  };
30
32
  export declare type AppFileManagerStoragePlugin = Plugin & {
31
33
  type: "app-file-manager-storage";
32
- upload(file: FileItem, options: UploadOptions): Promise<any>;
34
+ upload(file: File, options: UploadOptions): Promise<any>;
33
35
  };
34
36
  export { Plugin };
35
37
  export interface ImageProps {
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import * as React from \"react\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { ApolloClient } from \"apollo-client\";\nimport { CSSProperties } from \"react\";\n\nexport interface FileItem {\n id: string;\n name: string;\n key: string;\n src: string;\n size: number;\n type: string;\n tags: string[];\n createdOn: string;\n createdBy: {\n id: string;\n };\n [key: string]: any;\n}\n\nexport type UploadOptions = {\n apolloClient: ApolloClient<object>;\n};\n\nexport type UiStatePlugin = Plugin & {\n type: \"ui-state\";\n render(): React.ReactElement;\n};\n\nexport type FileUploaderPlugin = Plugin & {\n type: \"file-uploader\";\n // TODO: @adrian define type for the returned object\n upload(file: FileItem, options: UploadOptions): Promise<any>;\n};\n\nexport type AppFileManagerStoragePlugin = Plugin & {\n type: \"app-file-manager-storage\";\n // TODO: @adrian define type for the returned object\n upload(file: FileItem, options: UploadOptions): Promise<any>;\n};\n\nexport { Plugin };\n\nexport interface ImageProps {\n src: string;\n preset?: string;\n transform?: {\n [key: string]: any;\n };\n // \"auto\" is a special keyword - if present, plugins insert their own srcSet.\n srcSet?: { [key: string]: any } | \"auto\";\n className?: string;\n title?: string;\n alt?: string;\n style?: CSSProperties;\n width?: string | number;\n height?: string | number;\n}\n\n/**\n * \"getImageSrc\" has to be defined as a separate property, so its functionality can be reused outside of\n * the Image component. This is ideal in cases where manual creation of image src is needed.\n */\nexport type ImageComponentPlugin = Plugin & {\n type: \"image-component\";\n render: (props: ImageProps) => React.ReactElement;\n getImageSrc: (props?: Record<string, any>) => string;\n presets: { [key: string]: any };\n};\n\n/**\n * Enables registering new routes.\n * @see https://docs.webiny.com/docs/webiny-apps/admin/development/plugins-reference/app#route\n */\nexport type RoutePlugin = Plugin & {\n type: \"route\";\n route: React.ReactElement;\n};\n"],"mappings":";;;;;;;;;;;AACA"}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import * as React from \"react\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { ApolloClient } from \"apollo-client\";\nimport { CSSProperties } from \"react\";\n\nexport interface FileItem {\n id: string;\n name: string;\n key: string;\n src: string;\n size: number;\n type: string;\n tags: string[];\n createdOn: string;\n createdBy: {\n id: string;\n };\n [key: string]: any;\n}\n\nexport type UploadOptions = {\n apolloClient: ApolloClient<object>;\n onProgress?: (progress: number) => void;\n};\n\nexport type UiStatePlugin = Plugin & {\n type: \"ui-state\";\n render(): React.ReactElement;\n};\n\nexport type FileUploaderPlugin = Plugin & {\n type: \"file-uploader\";\n // TODO: @adrian define type for the returned object\n upload(file: File, options: UploadOptions): Promise<any>;\n};\n\nexport type AppFileManagerStoragePlugin = Plugin & {\n type: \"app-file-manager-storage\";\n // TODO: @adrian define type for the returned object\n upload(file: File, options: UploadOptions): Promise<any>;\n};\n\nexport { Plugin };\n\nexport interface ImageProps {\n src: string;\n preset?: string;\n transform?: {\n [key: string]: any;\n };\n // \"auto\" is a special keyword - if present, plugins insert their own srcSet.\n srcSet?: { [key: string]: any } | \"auto\";\n className?: string;\n title?: string;\n alt?: string;\n style?: CSSProperties;\n width?: string | number;\n height?: string | number;\n}\n\n/**\n * \"getImageSrc\" has to be defined as a separate property, so its functionality can be reused outside of\n * the Image component. This is ideal in cases where manual creation of image src is needed.\n */\nexport type ImageComponentPlugin = Plugin & {\n type: \"image-component\";\n render: (props: ImageProps) => React.ReactElement;\n getImageSrc: (props?: Record<string, any>) => string;\n presets: { [key: string]: any };\n};\n\n/**\n * Enables registering new routes.\n * @see https://docs.webiny.com/docs/webiny-apps/admin/development/plugins-reference/app#route\n */\nexport type RoutePlugin = Plugin & {\n type: \"route\";\n route: React.ReactElement;\n};\n"],"mappings":";;;;;;;;;;;AACA"}
@@ -0,0 +1 @@
1
+ export declare const getApiUrl: (path?: string) => string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getApiUrl = void 0;
7
+ var getApiUrl = function getApiUrl() {
8
+ var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
9
+ return process.env.REACT_APP_API_URL + path;
10
+ };
11
+ exports.getApiUrl = getApiUrl;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getApiUrl","path","process","env","REACT_APP_API_URL"],"sources":["getApiUrl.ts"],"sourcesContent":["export const getApiUrl = (path = \"\"): string => {\n return process.env.REACT_APP_API_URL + path;\n};\n"],"mappings":";;;;;;AAAO,IAAMA,SAAS,GAAG,SAAZA,SAAS,GAA0B;EAAA,IAAtBC,IAAI,uEAAG,EAAE;EAC/B,OAAOC,OAAO,CAACC,GAAG,CAACC,iBAAiB,GAAGH,IAAI;AAC/C,CAAC;AAAC"}
@@ -0,0 +1 @@
1
+ export declare const getGqlApiUrl: () => string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getGqlApiUrl = void 0;
7
+ var _getApiUrl = require("./getApiUrl");
8
+ var getGqlApiUrl = function getGqlApiUrl() {
9
+ return (0, _getApiUrl.getApiUrl)("/graphql");
10
+ };
11
+ exports.getGqlApiUrl = getGqlApiUrl;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getGqlApiUrl","getApiUrl"],"sources":["getGqlApiUrl.ts"],"sourcesContent":["import { getApiUrl } from \"./getApiUrl\";\n\nexport const getGqlApiUrl = (): string => {\n return getApiUrl(\"/graphql\");\n};\n"],"mappings":";;;;;;AAAA;AAEO,IAAMA,YAAY,GAAG,SAAfA,YAAY,GAAiB;EACtC,OAAO,IAAAC,oBAAS,EAAC,UAAU,CAAC;AAChC,CAAC;AAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const getHeadlessCmsGqlApiUrl: () => {
2
+ preview: string;
3
+ read: string;
4
+ manage: string;
5
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getHeadlessCmsGqlApiUrl = void 0;
7
+ var _getApiUrl = require("./getApiUrl");
8
+ var _getLocaleCode = require("./getLocaleCode");
9
+ var getHeadlessCmsGqlApiUrl = function getHeadlessCmsGqlApiUrl() {
10
+ var locale = (0, _getLocaleCode.getLocaleCode)();
11
+ return {
12
+ preview: (0, _getApiUrl.getApiUrl)("/cms/preview/".concat(locale)),
13
+ read: (0, _getApiUrl.getApiUrl)("/cms/read/".concat(locale)),
14
+ manage: (0, _getApiUrl.getApiUrl)("/cms/manage/".concat(locale))
15
+ };
16
+ };
17
+ exports.getHeadlessCmsGqlApiUrl = getHeadlessCmsGqlApiUrl;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getHeadlessCmsGqlApiUrl","locale","getLocaleCode","preview","getApiUrl","read","manage"],"sources":["getHeadlessCmsGqlApiUrl.ts"],"sourcesContent":["import { getApiUrl } from \"./getApiUrl\";\nimport { getLocaleCode } from \"./getLocaleCode\";\n\nexport const getHeadlessCmsGqlApiUrl = (): { preview: string; read: string; manage: string } => {\n const locale = getLocaleCode();\n return {\n preview: getApiUrl(`/cms/preview/${locale}`),\n read: getApiUrl(`/cms/read/${locale}`),\n manage: getApiUrl(`/cms/manage/${locale}`)\n };\n};\n"],"mappings":";;;;;;AAAA;AACA;AAEO,IAAMA,uBAAuB,GAAG,SAA1BA,uBAAuB,GAA4D;EAC5F,IAAMC,MAAM,GAAG,IAAAC,4BAAa,GAAE;EAC9B,OAAO;IACHC,OAAO,EAAE,IAAAC,oBAAS,yBAAiBH,MAAM,EAAG;IAC5CI,IAAI,EAAE,IAAAD,oBAAS,sBAAcH,MAAM,EAAG;IACtCK,MAAM,EAAE,IAAAF,oBAAS,wBAAgBH,MAAM;EAC3C,CAAC;AACL,CAAC;AAAC"}
@@ -0,0 +1,6 @@
1
+ declare global {
2
+ interface Window {
3
+ __PS_RENDER_LOCALE__: string;
4
+ }
5
+ }
6
+ export declare const getLocaleCode: () => string | null;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getLocaleCode = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _isLocalhost = require("./isLocalhost");
10
+ var getLocaleCode = function getLocaleCode() {
11
+ // 1. Get locale via the `__locale` query param. Useful when doing page previews.
12
+ var locale = new URLSearchParams(location.search).get("__locale");
13
+ if (locale) {
14
+ return locale;
15
+ }
16
+
17
+ // 2. Get locale via `window.__PS_RENDER_LOCALE__`. Used with prerendered pages.
18
+ locale = window.__PS_RENDER_LOCALE__;
19
+ if (locale) {
20
+ return locale;
21
+ }
22
+
23
+ // 3. Get locale via `window.localStorage.webiny_i18n_locale`. Used within the Admin app.
24
+ var localesByContext = window.localStorage.webiny_i18n_locale;
25
+ if (localesByContext) {
26
+ // The `localesByContext` is a string that contains locales for all available
27
+ // "locale contexts", for example: `default:en-US;content:en-US;`. Here, we
28
+ // want to extract the locale for the "content" locale context.
29
+ var _localesByContext$mat = localesByContext.match(/content:(.*?);/),
30
+ _localesByContext$mat2 = (0, _slicedToArray2.default)(_localesByContext$mat, 2),
31
+ matchedLocale = _localesByContext$mat2[1];
32
+ return matchedLocale;
33
+ }
34
+
35
+ // 4. Finally, for development purposes, we take the `WEBINY_WEBSITE_LOCALE_CODE`
36
+ // and `WEBINY_ADMIN_LOCALE_CODE` environment variables into consideration.
37
+ if ((0, _isLocalhost.isLocalhost)()) {
38
+ return process.env.WEBINY_WEBSITE_LOCALE_CODE || process.env.WEBINY_ADMIN_LOCALE_CODE || null;
39
+ }
40
+ return null;
41
+ };
42
+ exports.getLocaleCode = getLocaleCode;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getLocaleCode","locale","URLSearchParams","location","search","get","window","__PS_RENDER_LOCALE__","localesByContext","localStorage","webiny_i18n_locale","match","matchedLocale","isLocalhost","process","env","WEBINY_WEBSITE_LOCALE_CODE","WEBINY_ADMIN_LOCALE_CODE"],"sources":["getLocaleCode.ts"],"sourcesContent":["import { isLocalhost } from \"./isLocalhost\";\n\ndeclare global {\n interface Window {\n __PS_RENDER_LOCALE__: string;\n }\n}\n\nexport const getLocaleCode = (): string | null => {\n // 1. Get locale via the `__locale` query param. Useful when doing page previews.\n let locale = new URLSearchParams(location.search).get(\"__locale\");\n if (locale) {\n return locale;\n }\n\n // 2. Get locale via `window.__PS_RENDER_LOCALE__`. Used with prerendered pages.\n locale = window.__PS_RENDER_LOCALE__;\n if (locale) {\n return locale;\n }\n\n // 3. Get locale via `window.localStorage.webiny_i18n_locale`. Used within the Admin app.\n const localesByContext = window.localStorage.webiny_i18n_locale;\n if (localesByContext) {\n // The `localesByContext` is a string that contains locales for all available\n // \"locale contexts\", for example: `default:en-US;content:en-US;`. Here, we\n // want to extract the locale for the \"content\" locale context.\n const [, matchedLocale] = localesByContext.match(/content:(.*?);/);\n return matchedLocale;\n }\n\n // 4. Finally, for development purposes, we take the `WEBINY_WEBSITE_LOCALE_CODE`\n // and `WEBINY_ADMIN_LOCALE_CODE` environment variables into consideration.\n if (isLocalhost()) {\n return (\n process.env.WEBINY_WEBSITE_LOCALE_CODE || process.env.WEBINY_ADMIN_LOCALE_CODE || null\n );\n }\n\n return null;\n};\n"],"mappings":";;;;;;;;AAAA;AAQO,IAAMA,aAAa,GAAG,SAAhBA,aAAa,GAAwB;EAC9C;EACA,IAAIC,MAAM,GAAG,IAAIC,eAAe,CAACC,QAAQ,CAACC,MAAM,CAAC,CAACC,GAAG,CAAC,UAAU,CAAC;EACjE,IAAIJ,MAAM,EAAE;IACR,OAAOA,MAAM;EACjB;;EAEA;EACAA,MAAM,GAAGK,MAAM,CAACC,oBAAoB;EACpC,IAAIN,MAAM,EAAE;IACR,OAAOA,MAAM;EACjB;;EAEA;EACA,IAAMO,gBAAgB,GAAGF,MAAM,CAACG,YAAY,CAACC,kBAAkB;EAC/D,IAAIF,gBAAgB,EAAE;IAClB;IACA;IACA;IACA,4BAA0BA,gBAAgB,CAACG,KAAK,CAAC,gBAAgB,CAAC;MAAA;MAAzDC,aAAa;IACtB,OAAOA,aAAa;EACxB;;EAEA;EACA;EACA,IAAI,IAAAC,wBAAW,GAAE,EAAE;IACf,OACIC,OAAO,CAACC,GAAG,CAACC,0BAA0B,IAAIF,OAAO,CAACC,GAAG,CAACE,wBAAwB,IAAI,IAAI;EAE9F;EAEA,OAAO,IAAI;AACf,CAAC;AAAC"}
@@ -0,0 +1,6 @@
1
+ declare global {
2
+ interface Window {
3
+ __PS_RENDER_ID__: string;
4
+ }
5
+ }
6
+ export declare const getPrerenderId: () => string | null;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPrerenderId = void 0;
7
+ var getPrerenderId = function getPrerenderId() {
8
+ return window["__PS_RENDER_ID__"] || null;
9
+ };
10
+ exports.getPrerenderId = getPrerenderId;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getPrerenderId","window"],"sources":["getPrerenderId.ts"],"sourcesContent":["declare global {\n interface Window {\n __PS_RENDER_ID__: string;\n }\n}\n\nexport const getPrerenderId = (): string | null => {\n return window[\"__PS_RENDER_ID__\"] || null;\n};\n"],"mappings":";;;;;;AAMO,IAAMA,cAAc,GAAG,SAAjBA,cAAc,GAAwB;EAC/C,OAAOC,MAAM,CAAC,kBAAkB,CAAC,IAAI,IAAI;AAC7C,CAAC;AAAC"}
@@ -0,0 +1,6 @@
1
+ declare global {
2
+ interface Window {
3
+ __PS_RENDER_TENANT__: string;
4
+ }
5
+ }
6
+ export declare const getTenantId: () => string | null;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTenantId = void 0;
7
+ var _isLocalhost = require("./isLocalhost");
8
+ var getTenantId = function getTenantId() {
9
+ // 1. Get tenant via the `__tenant` query param. Useful when doing page previews.
10
+ var tenant = new URLSearchParams(location.search).get("__tenant");
11
+ if (tenant) {
12
+ return tenant;
13
+ }
14
+
15
+ // 2. Get tenant via `window.__PS_RENDER_TENANT__`. Used with prerendered pages.
16
+ tenant = window.__PS_RENDER_TENANT__;
17
+ if (tenant) {
18
+ return tenant;
19
+ }
20
+
21
+ // 3. Get tenant via `window.localStorage.webiny_tenant`. Used within the Admin app.
22
+ tenant = window.localStorage.webiny_tenant;
23
+ if (tenant) {
24
+ return tenant;
25
+ }
26
+
27
+ // 4. Finally, for development purposes, we take the `WEBINY_WEBSITE_TENANT_ID`
28
+ // and `WEBINY_ADMIN_TENANT_ID` environment variables into consideration.
29
+ if ((0, _isLocalhost.isLocalhost)()) {
30
+ return process.env.WEBINY_WEBSITE_TENANT_ID || process.env.WEBINY_ADMIN_TENANT_ID || null;
31
+ }
32
+ return null;
33
+ };
34
+ exports.getTenantId = getTenantId;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getTenantId","tenant","URLSearchParams","location","search","get","window","__PS_RENDER_TENANT__","localStorage","webiny_tenant","isLocalhost","process","env","WEBINY_WEBSITE_TENANT_ID","WEBINY_ADMIN_TENANT_ID"],"sources":["getTenantId.ts"],"sourcesContent":["import { isLocalhost } from \"~/utils/isLocalhost\";\n\ndeclare global {\n interface Window {\n __PS_RENDER_TENANT__: string;\n }\n}\n\nexport const getTenantId = (): string | null => {\n // 1. Get tenant via the `__tenant` query param. Useful when doing page previews.\n let tenant = new URLSearchParams(location.search).get(\"__tenant\");\n if (tenant) {\n return tenant;\n }\n\n // 2. Get tenant via `window.__PS_RENDER_TENANT__`. Used with prerendered pages.\n tenant = window.__PS_RENDER_TENANT__;\n if (tenant) {\n return tenant;\n }\n\n // 3. Get tenant via `window.localStorage.webiny_tenant`. Used within the Admin app.\n tenant = window.localStorage.webiny_tenant;\n if (tenant) {\n return tenant;\n }\n\n // 4. Finally, for development purposes, we take the `WEBINY_WEBSITE_TENANT_ID`\n // and `WEBINY_ADMIN_TENANT_ID` environment variables into consideration.\n if (isLocalhost()) {\n return process.env.WEBINY_WEBSITE_TENANT_ID || process.env.WEBINY_ADMIN_TENANT_ID || null;\n }\n\n return null;\n};\n"],"mappings":";;;;;;AAAA;AAQO,IAAMA,WAAW,GAAG,SAAdA,WAAW,GAAwB;EAC5C;EACA,IAAIC,MAAM,GAAG,IAAIC,eAAe,CAACC,QAAQ,CAACC,MAAM,CAAC,CAACC,GAAG,CAAC,UAAU,CAAC;EACjE,IAAIJ,MAAM,EAAE;IACR,OAAOA,MAAM;EACjB;;EAEA;EACAA,MAAM,GAAGK,MAAM,CAACC,oBAAoB;EACpC,IAAIN,MAAM,EAAE;IACR,OAAOA,MAAM;EACjB;;EAEA;EACAA,MAAM,GAAGK,MAAM,CAACE,YAAY,CAACC,aAAa;EAC1C,IAAIR,MAAM,EAAE;IACR,OAAOA,MAAM;EACjB;;EAEA;EACA;EACA,IAAI,IAAAS,wBAAW,GAAE,EAAE;IACf,OAAOC,OAAO,CAACC,GAAG,CAACC,wBAAwB,IAAIF,OAAO,CAACC,GAAG,CAACE,sBAAsB,IAAI,IAAI;EAC7F;EAEA,OAAO,IAAI;AACf,CAAC;AAAC"}
@@ -0,0 +1,8 @@
1
+ export * from "./getApiUrl";
2
+ export * from "./getGqlApiUrl";
3
+ export * from "./getHeadlessCmsGqlApiUrl";
4
+ export * from "./getLocaleCode";
5
+ export * from "./getPrerenderId";
6
+ export * from "./getTenantId";
7
+ export * from "./isLocalhost";
8
+ export * from "./isPrerendering";
package/utils/index.js ADDED
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _getApiUrl = require("./getApiUrl");
7
+ Object.keys(_getApiUrl).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _getApiUrl[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _getApiUrl[key];
14
+ }
15
+ });
16
+ });
17
+ var _getGqlApiUrl = require("./getGqlApiUrl");
18
+ Object.keys(_getGqlApiUrl).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _getGqlApiUrl[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function get() {
24
+ return _getGqlApiUrl[key];
25
+ }
26
+ });
27
+ });
28
+ var _getHeadlessCmsGqlApiUrl = require("./getHeadlessCmsGqlApiUrl");
29
+ Object.keys(_getHeadlessCmsGqlApiUrl).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _getHeadlessCmsGqlApiUrl[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function get() {
35
+ return _getHeadlessCmsGqlApiUrl[key];
36
+ }
37
+ });
38
+ });
39
+ var _getLocaleCode = require("./getLocaleCode");
40
+ Object.keys(_getLocaleCode).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _getLocaleCode[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _getLocaleCode[key];
47
+ }
48
+ });
49
+ });
50
+ var _getPrerenderId = require("./getPrerenderId");
51
+ Object.keys(_getPrerenderId).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _getPrerenderId[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function get() {
57
+ return _getPrerenderId[key];
58
+ }
59
+ });
60
+ });
61
+ var _getTenantId = require("./getTenantId");
62
+ Object.keys(_getTenantId).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _getTenantId[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function get() {
68
+ return _getTenantId[key];
69
+ }
70
+ });
71
+ });
72
+ var _isLocalhost = require("./isLocalhost");
73
+ Object.keys(_isLocalhost).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _isLocalhost[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function get() {
79
+ return _isLocalhost[key];
80
+ }
81
+ });
82
+ });
83
+ var _isPrerendering = require("./isPrerendering");
84
+ Object.keys(_isPrerendering).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (key in exports && exports[key] === _isPrerendering[key]) return;
87
+ Object.defineProperty(exports, key, {
88
+ enumerable: true,
89
+ get: function get() {
90
+ return _isPrerendering[key];
91
+ }
92
+ });
93
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./getApiUrl\";\nexport * from \"./getGqlApiUrl\";\nexport * from \"./getHeadlessCmsGqlApiUrl\";\nexport * from \"./getLocaleCode\";\nexport * from \"./getPrerenderId\";\nexport * from \"./getTenantId\";\nexport * from \"./isLocalhost\";\nexport * from \"./isPrerendering\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1 @@
1
+ export declare const isLocalhost: () => boolean;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isLocalhost = void 0;
7
+ var INCLUDES = ["localhost", "127.0.0.1"];
8
+ var isLocalhost = function isLocalhost() {
9
+ var href = window.location.href;
10
+ return INCLUDES.some(function (current) {
11
+ return href.includes(current);
12
+ });
13
+ };
14
+ exports.isLocalhost = isLocalhost;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["INCLUDES","isLocalhost","href","window","location","some","current","includes"],"sources":["isLocalhost.ts"],"sourcesContent":["const INCLUDES = [\"localhost\", \"127.0.0.1\"];\n\nexport const isLocalhost = () => {\n const href = window.location.href;\n return INCLUDES.some(current => href.includes(current));\n};\n"],"mappings":";;;;;;AAAA,IAAMA,QAAQ,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC;AAEpC,IAAMC,WAAW,GAAG,SAAdA,WAAW,GAAS;EAC7B,IAAMC,IAAI,GAAGC,MAAM,CAACC,QAAQ,CAACF,IAAI;EACjC,OAAOF,QAAQ,CAACK,IAAI,CAAC,UAAAC,OAAO;IAAA,OAAIJ,IAAI,CAACK,QAAQ,CAACD,OAAO,CAAC;EAAA,EAAC;AAC3D,CAAC;AAAC"}
@@ -0,0 +1 @@
1
+ export declare const isPrerendering: () => boolean;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isPrerendering = void 0;
7
+ var isPrerendering = function isPrerendering() {
8
+ return "__PS_RENDER__" in window;
9
+ };
10
+ exports.isPrerendering = isPrerendering;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isPrerendering","window"],"sources":["isPrerendering.ts"],"sourcesContent":["export const isPrerendering = (): boolean => {\n return \"__PS_RENDER__\" in window;\n};\n"],"mappings":";;;;;;AAAO,IAAMA,cAAc,GAAG,SAAjBA,cAAc,GAAkB;EACzC,OAAO,eAAe,IAAIC,MAAM;AACpC,CAAC;AAAC"}