eddev 0.2.67-beta1 → 0.3.0-beta2

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 (185) hide show
  1. package/admin/components/ImageWell.d.ts +2 -2
  2. package/admin/components/ImageWell.js +51 -39
  3. package/admin/defineField.d.ts +2 -2
  4. package/admin/defineWidget.d.ts +1 -1
  5. package/admin/defineWidget.js +2 -2
  6. package/admin/index.js +1 -5
  7. package/admin/installFieldTypes.js +26 -26
  8. package/admin/runWidgets.js +28 -17
  9. package/admin/selectMedia.d.ts +2 -2
  10. package/admin/selectMedia.js +1 -1
  11. package/blocks/ContentBlocks.d.ts +6 -6
  12. package/blocks/ContentBlocks.js +66 -58
  13. package/blocks/ErrorBoundaryEditor.d.ts +1 -1
  14. package/blocks/ErrorBoundaryEditor.js +45 -16
  15. package/blocks/ErrorBoundaryFrontend.d.ts +1 -1
  16. package/blocks/ErrorBoundaryFrontend.js +45 -16
  17. package/blocks/InspectorControls.d.ts +1 -1
  18. package/blocks/InspectorControls.js +3 -3
  19. package/blocks/blockAttributes.d.ts +2 -2
  20. package/blocks/blockAttributes.js +44 -24
  21. package/blocks/index.js +1 -5
  22. package/blocks/inlineEditing.d.ts +6 -6
  23. package/blocks/inlineEditing.js +55 -36
  24. package/blocks/installGutenbergHooks.js +68 -48
  25. package/build/babel/plugin-name-defined-components.js +16 -15
  26. package/build/build-favicon.js +62 -11
  27. package/build/clean.js +52 -5
  28. package/build/create-codegen-worker.js +33 -78
  29. package/build/create-serverless-dev-worker.js +39 -61
  30. package/build/create-webpack-worker.js +33 -65
  31. package/build/file-tree.d.ts +2 -2
  32. package/build/file-tree.js +12 -12
  33. package/build/get-webpack-config.js +395 -341
  34. package/build/graphql-codegen/graphql-codegen-files.js +25 -31
  35. package/build/graphql-codegen/graphql-codegen-no-duplicates.js +4 -4
  36. package/build/graphql-codegen/graphql-codegen-queries.js +99 -102
  37. package/build/manifests/manifest-blocks.d.ts +1 -1
  38. package/build/manifests/manifest-blocks.js +29 -37
  39. package/build/manifests/manifest-fields.d.ts +1 -1
  40. package/build/manifests/manifest-fields.js +21 -23
  41. package/build/manifests/manifest-views.d.ts +1 -1
  42. package/build/manifests/manifest-views.js +25 -32
  43. package/build/manifests/manifest-widgets.d.ts +1 -1
  44. package/build/manifests/manifest-widgets.js +20 -22
  45. package/build/manifests/manifest.d.ts +2 -2
  46. package/build/manifests/manifest.js +94 -30
  47. package/build/reporter.d.ts +1 -1
  48. package/build/reporter.js +32 -29
  49. package/build/serverless/create-next-app.d.ts +1 -1
  50. package/build/serverless/create-next-app.js +467 -245
  51. package/build/state/codegen-state.d.ts +4 -4
  52. package/build/state/compiler-state.d.ts +5 -5
  53. package/build/state/serverless-state.d.ts +3 -3
  54. package/build/workers/codegen-worker-script.js +519 -393
  55. package/build/workers/serverless-worker-dev-script.js +4 -4
  56. package/build/workers/webpack-worker-script.js +156 -90
  57. package/cli/build.dev.d.ts +1 -1
  58. package/cli/build.dev.js +126 -79
  59. package/cli/build.prod.d.ts +1 -1
  60. package/cli/build.prod.js +98 -42
  61. package/cli/cli.js +28 -19
  62. package/cli/display/components/BundleDisplay.d.ts +1 -1
  63. package/cli/display/components/BundleDisplay.js +24 -13
  64. package/cli/display/components/CodegenDisplay.d.ts +1 -1
  65. package/cli/display/components/CodegenDisplay.js +25 -14
  66. package/cli/display/components/DevCLIDisplay.d.ts +2 -2
  67. package/cli/display/components/DevCLIDisplay.js +25 -14
  68. package/cli/display/components/Fullscreen.js +20 -9
  69. package/cli/display/components/ServerlessDisplay.d.ts +2 -2
  70. package/cli/display/components/ServerlessDisplay.js +26 -15
  71. package/cli/display/components/StatusIcon.d.ts +2 -2
  72. package/cli/display/components/StatusIcon.js +3 -3
  73. package/cli/preinstall.js +5 -4
  74. package/cli/setup.js +73 -25
  75. package/components/AdminBar.d.ts +1 -1
  76. package/components/AdminBar.js +3 -37
  77. package/components/BrowserRouter.d.ts +2 -2
  78. package/components/BrowserRouter.js +54 -41
  79. package/components/InlinePage.d.ts +2 -2
  80. package/components/InlinePage.js +29 -17
  81. package/components/NextRouter.d.ts +2 -2
  82. package/components/NextRouter.js +29 -20
  83. package/components/index.js +1 -5
  84. package/config/config-schema.d.ts +1 -1
  85. package/config/config-schema.js +1 -1
  86. package/config/create-schema-file.js +6 -6
  87. package/config/get-config.js +13 -10
  88. package/config/index.js +1 -5
  89. package/config/parse-config.js +1 -1
  90. package/config/print-zod-errors.js +3 -3
  91. package/dev-ui/components/BreakpointColumnHeader.d.ts +2 -2
  92. package/dev-ui/components/BreakpointColumnHeader.js +18 -7
  93. package/dev-ui/components/BreakpointIndicator.d.ts +1 -1
  94. package/dev-ui/components/BreakpointIndicator.js +32 -25
  95. package/dev-ui/components/DevUI.d.ts +1 -1
  96. package/dev-ui/components/DevUI.js +13 -13
  97. package/dev-ui/components/Launcher.d.ts +2 -2
  98. package/dev-ui/components/Launcher.js +25 -13
  99. package/dev-ui/components/PanelWrapper.d.ts +2 -2
  100. package/dev-ui/components/PanelWrapper.js +8 -8
  101. package/dev-ui/components/ResponsiveLerpControl.d.ts +2 -2
  102. package/dev-ui/components/ResponsiveLerpControl.js +38 -27
  103. package/dev-ui/components/ResponsiveScaleEditor.d.ts +4 -4
  104. package/dev-ui/components/ResponsiveScaleEditor.js +78 -64
  105. package/dev-ui/components/atoms/Button.js +1 -1
  106. package/dev-ui/components/atoms/Dropdown.d.ts +3 -3
  107. package/dev-ui/components/atoms/Dropdown.js +9 -8
  108. package/dev-ui/components/atoms/NumberField.d.ts +2 -2
  109. package/dev-ui/components/atoms/NumberField.js +42 -29
  110. package/dev-ui/components/atoms/Spacer.js +1 -1
  111. package/dev-ui/components/atoms/Text.js +1 -1
  112. package/dev-ui/components/atoms/ToggleButton.d.ts +2 -2
  113. package/dev-ui/components/atoms/ToggleButton.js +16 -5
  114. package/dev-ui/components/atoms/Tooltip.d.ts +2 -2
  115. package/dev-ui/components/atoms/Tooltip.js +20 -8
  116. package/dev-ui/components/panels/AppDataDebugger.d.ts +1 -1
  117. package/dev-ui/components/panels/AppDataDebugger.js +19 -8
  118. package/dev-ui/components/panels/ColorEditor.d.ts +1 -1
  119. package/dev-ui/components/panels/ColorEditor.js +42 -35
  120. package/dev-ui/components/panels/PageDataDebugger.d.ts +1 -1
  121. package/dev-ui/components/panels/PageDataDebugger.js +20 -8
  122. package/dev-ui/components/panels/QueryDebugger.d.ts +1 -1
  123. package/dev-ui/components/panels/QueryDebugger.js +24 -12
  124. package/dev-ui/components/panels/SpacingEditor.d.ts +1 -1
  125. package/dev-ui/components/panels/SpacingEditor.js +48 -34
  126. package/dev-ui/components/panels/TypographyEditor.d.ts +1 -1
  127. package/dev-ui/components/panels/TypographyEditor.js +46 -38
  128. package/dev-ui/hooks/useBreakpoint.d.ts +1 -1
  129. package/dev-ui/hooks/useBreakpoint.js +13 -13
  130. package/dev-ui/hooks/usePersistState.js +7 -6
  131. package/dev-ui/hooks/useStylesheet.js +6 -6
  132. package/dev-ui/icons.d.ts +15 -15
  133. package/dev-ui/icons.js +27 -16
  134. package/dev-ui/index.js +1 -5
  135. package/dev-ui/loader.d.ts +1 -1
  136. package/dev-ui/loader.js +9 -13
  137. package/dev-ui/panels.d.ts +2 -2
  138. package/dev-ui/panels.js +7 -7
  139. package/dev-ui/theme.js +3 -3
  140. package/dynamic/dynamic-component.js +1 -1
  141. package/dynamic/index.js +1 -5
  142. package/entry/Root.d.ts +2 -2
  143. package/entry/Root.js +26 -16
  144. package/entry/entry.admin.dev.js +4 -4
  145. package/entry/entry.admin.prod.js +4 -4
  146. package/entry/entry.monolith.dev.js +5 -5
  147. package/entry/entry.monolith.prod.js +5 -5
  148. package/gravityforms/gravity-forms.d.ts +2 -2
  149. package/gravityforms/index.js +1 -5
  150. package/gravityforms/useGravityForm.d.ts +2 -2
  151. package/gravityforms/useGravityForm.js +130 -126
  152. package/hooks/index.js +1 -5
  153. package/hooks/queryUtils.d.ts +14 -14
  154. package/hooks/queryUtils.js +192 -101
  155. package/hooks/useAppData.d.ts +2 -2
  156. package/hooks/useAppData.js +9 -9
  157. package/hooks/usePageLoad.js +4 -4
  158. package/hooks/useQueryDebug.d.ts +1 -1
  159. package/hooks/useQueryDebug.js +7 -7
  160. package/hooks/useRPC.d.ts +4 -4
  161. package/hooks/useRPC.js +3 -3
  162. package/package.json +12 -12
  163. package/routing/index.js +1 -5
  164. package/routing/remoteProps.d.ts +1 -1
  165. package/routing/remoteProps.js +72 -31
  166. package/routing/routing.d.ts +25 -15
  167. package/routing/routing.js +200 -112
  168. package/routing/updateEditLink.js +1 -1
  169. package/serverless/define-api.d.ts +1 -1
  170. package/serverless/define-rpc-router.js +4 -8
  171. package/serverless/index.js +2 -6
  172. package/style/createStitches.js +142 -164
  173. package/style/index.js +1 -5
  174. package/tsconfig.json +1 -1
  175. package/utils/Observable.d.ts +2 -2
  176. package/utils/Observable.js +15 -12
  177. package/utils/getRepoName.js +3 -3
  178. package/utils/promptIfRepoNameIncorrect.js +64 -18
  179. package/utils/refreshOverlayInterop.js +1 -1
  180. package/utils/reportErrorStack.d.ts +1 -1
  181. package/utils/reportErrorStack.js +1 -1
  182. package/utils/serverlessAppContext.js +1 -1
  183. package/utils/updateEnvFile.js +69 -19
  184. package/utils/useObservable.js +3 -3
  185. package/views/index.js +1 -5
@@ -3,22 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const glob_promise_1 = require("glob-promise");
7
- const path_1 = __importDefault(require("path"));
6
+ var glob_promise_1 = require("glob-promise");
7
+ var path_1 = __importDefault(require("path"));
8
8
  module.exports = {
9
- plugin: (schema, documents, config, info) => {
10
- const folder = path_1.default.resolve(config.rootDir, config.folderName);
11
- const imports = [];
12
- const items = [];
13
- const files = glob_promise_1.glob.sync(folder + "/**/*.tsx");
14
- const filesFound = {};
15
- const additionalTypes = config.additionalTypes || {};
9
+ plugin: function (schema, documents, config, info) {
10
+ var folder = path_1.default.resolve(config.rootDir, config.folderName);
11
+ var imports = [];
12
+ var items = [];
13
+ var files = glob_promise_1.glob.sync(folder + "/**/*.tsx");
14
+ var filesFound = {};
15
+ var additionalTypes = config.additionalTypes || {};
16
16
  // const additionalTypes: Record<string, string> = {
17
17
  // "_html.tsx": `{ "template": string, "htmlContent": string }`,
18
18
  // }
19
- const getRelative = (path) => path_1.default.relative(folder, path);
20
- const typeForFile = (file, baseType) => {
21
- const types = [];
19
+ var getRelative = function (path) { return path_1.default.relative(folder, path); };
20
+ var typeForFile = function (file, baseType) {
21
+ var types = [];
22
22
  if (baseType)
23
23
  types.push(baseType);
24
24
  if (additionalTypes[file]) {
@@ -31,40 +31,34 @@ module.exports = {
31
31
  return types.join(" & ");
32
32
  }
33
33
  };
34
- documents.forEach((doc) => {
34
+ documents.forEach(function (doc) {
35
+ var _a;
35
36
  if (!doc.location.startsWith(folder))
36
37
  return;
37
38
  filesFound[doc.location.replace(/\.graphql/, "")] = true;
38
- const relative = getRelative(doc.location);
39
+ var relative = getRelative(doc.location);
39
40
  // const docsNames = doc.document.definitions.map(
40
41
  // (def: any) => def.name.value
41
42
  // )
42
43
  if (relative && doc.document.definitions.length) {
43
- let importedName = doc.document.definitions[0].name.value + "Query";
44
- let typeName = config.getType?.(importedName, doc.document.definitions[0]) || importedName;
44
+ var importedName = doc.document.definitions[0].name.value + "Query";
45
+ var typeName = ((_a = config.getType) === null || _a === void 0 ? void 0 : _a.call(config, importedName, doc.document.definitions[0])) || importedName;
45
46
  imports.push(importedName);
46
- const key = relative.replace(/\.graphql/, "");
47
- items.push(`${JSON.stringify(key)}: ${typeForFile(key, typeName)}`);
47
+ var key = relative.replace(/\.graphql/, "");
48
+ items.push("".concat(JSON.stringify(key), ": ").concat(typeForFile(key, typeName)));
48
49
  }
49
50
  });
50
- for (const file of files) {
51
+ for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
52
+ var file = files_1[_i];
51
53
  if (!filesFound[file.replace(/\.tsx/, "")]) {
52
- const key = getRelative(file).replace(/\.tsx$/, "");
53
- items.push(`${JSON.stringify(key)}: ${typeForFile(key, "")}`);
54
+ var key = getRelative(file).replace(/\.tsx$/, "");
55
+ items.push("".concat(JSON.stringify(key), ": ").concat(typeForFile(key, "")));
54
56
  }
55
57
  }
56
58
  if (imports.length === 0) {
57
59
  process.exit();
58
- return `export { };`;
60
+ return "export { };";
59
61
  }
60
- return `import { ${imports.sort().join(", ")} } from "./types.graphql"
61
- export { };
62
-
63
- declare global {
64
- type ${config.globalName} = {
65
- ${items.sort().join(",\n")}
66
- }
67
- }
68
- `;
62
+ return "import { ".concat(imports.sort().join(", "), " } from \"./types.graphql\"\nexport { };\n\ndeclare global {\n type ").concat(config.globalName, " = {\n").concat(items.sort().join(",\n"), "\n }\n}\n ");
69
63
  },
70
64
  };
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  module.exports = {
4
- plugin: () => { },
5
- validate: (schema, documents, config, info) => {
6
- documents.forEach((doc) => {
4
+ plugin: function () { },
5
+ validate: function (schema, documents, config, info) {
6
+ documents.forEach(function (doc) {
7
7
  if (doc.document.definitions.length === 0) {
8
- throw new Error(`GraphQL file '${doc.location}' does not contain any uniquely named operations.`);
8
+ throw new Error("GraphQL file '".concat(doc.location, "' does not contain any uniquely named operations."));
9
9
  process.exit();
10
10
  }
11
11
  });
@@ -1,23 +1,33 @@
1
1
  "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const graphql_1 = require("graphql");
4
- const path_1 = require("path");
12
+ var graphql_1 = require("graphql");
13
+ var path_1 = require("path");
5
14
  module.exports = {
6
- plugin: (schema, documents, config, info) => {
7
- const hooks = {};
8
- const importTypes = [];
9
- const importUtils = {};
10
- documents.forEach((doc) => {
11
- const fullFileName = doc.location;
12
- const fileName = doc.location.replace(config.rootDir, "");
15
+ plugin: function (schema, documents, config, info) {
16
+ var hooks = {};
17
+ var importTypes = [];
18
+ var importUtils = {};
19
+ documents.forEach(function (doc) {
20
+ var fullFileName = doc.location;
21
+ var fileName = doc.location.replace(config.rootDir, "");
13
22
  if (doc.document.definitions.length) {
14
- let foundQueryOperation = false;
15
- doc.document.definitions.forEach((item) => {
23
+ var foundQueryOperation_1 = false;
24
+ doc.document.definitions.forEach(function (item) {
25
+ var _a, _b, _c;
16
26
  // We only care about 'operations'
17
27
  if (item.kind !== "OperationDefinition" || !item.name)
18
28
  return;
19
29
  function throwErrorAtLocation(loc, message) {
20
- let printedSource = "";
30
+ var printedSource = "";
21
31
  if (loc && loc.source) {
22
32
  loc.source.name = fileName;
23
33
  printedSource = (0, graphql_1.printSourceLocation)(loc.source, {
@@ -25,45 +35,45 @@ module.exports = {
25
35
  column: loc.startToken.column,
26
36
  });
27
37
  }
28
- let fullMessage = message;
38
+ var fullMessage = message;
29
39
  if (printedSource) {
30
40
  fullMessage += ":\n\n" + printedSource;
31
41
  }
32
42
  else {
33
- fullMessage += ` (in ${fileName})`;
43
+ fullMessage += " (in ".concat(fileName, ")");
34
44
  }
35
- const err = new Error(fullMessage);
45
+ var err = new Error(fullMessage);
36
46
  err.name = "QueryError";
37
47
  throw err;
38
48
  }
39
49
  // Ensure only ONE operation per query file
40
- if (foundQueryOperation) {
50
+ if (foundQueryOperation_1) {
41
51
  throwErrorAtLocation(item.loc, "Only one operation is allowed in each queries/*.graphql file");
42
52
  }
43
- foundQueryOperation = true;
53
+ foundQueryOperation_1 = true;
44
54
  /**
45
55
  * Determine the 'hook type'
46
56
  * - 'mutation' if the operation starts with 'mutation' instead of 'query'
47
57
  * - 'infinite' if the operation contains the word 'infinite'
48
58
  * - 'normal' otherwise
49
59
  */
50
- const type = item.operation === "mutation" ? "mutation" : item.name.value.match(/infinite/i) ? "infinite" : "normal";
51
- const name = item.name.value;
52
- const hookName = "use" + name.replace(/^use/i, "").replace(/^[a-z]/, (c) => c.toUpperCase());
53
- const variablesTypeName = item.variableDefinitions?.length
60
+ var type = item.operation === "mutation" ? "mutation" : item.name.value.match(/infinite/i) ? "infinite" : "normal";
61
+ var name = item.name.value;
62
+ var hookName = "use" + name.replace(/^use/i, "").replace(/^[a-z]/, function (c) { return c.toUpperCase(); });
63
+ var variablesTypeName = ((_a = item.variableDefinitions) === null || _a === void 0 ? void 0 : _a.length)
54
64
  ? type === "mutation"
55
65
  ? name + "MutationVariables"
56
66
  : name + "QueryVariables"
57
67
  : null;
58
- const resultTypeName = name + (type === "mutation" ? "Mutation" : "Query");
68
+ var resultTypeName = name + (type === "mutation" ? "Mutation" : "Query");
59
69
  // For conventions sake, the name of the operation should start with 'Use'
60
70
  if (!name.match(/^Use/)) {
61
- throwErrorAtLocation(item.name.loc, `Expected your query name to start with 'Use', but found '${name}'. Did you mean 'Use${name}'`);
71
+ throwErrorAtLocation(item.name.loc, "Expected your query name to start with 'Use', but found '".concat(name, "'. Did you mean 'Use").concat(name, "'"));
62
72
  }
63
73
  // Another convention, the query name and file name should be the same
64
- const baseName = (0, path_1.basename)(fileName);
74
+ var baseName = (0, path_1.basename)(fileName);
65
75
  if (baseName.replace(".graphql", "") !== name) {
66
- throwErrorAtLocation(item.name.loc, `Expected your query name and file name to match, for conventions sake (eg. '${baseName}' should be '${name}.graphql')`);
76
+ throwErrorAtLocation(item.name.loc, "Expected your query name and file name to match, for conventions sake (eg. '".concat(baseName, "' should be '").concat(name, ".graphql')"));
67
77
  }
68
78
  // Only import variables if the operation has variables
69
79
  if (variablesTypeName) {
@@ -73,178 +83,165 @@ module.exports = {
73
83
  if (type === "normal") {
74
84
  // Just a normal query!
75
85
  importUtils["createUseQuery"] = true;
76
- hooks[hookName] = `
77
- createUseQuery<${resultTypeName}, ${variablesTypeName || "undefined"}>({
78
- name: ${JSON.stringify(name)}
79
- })
80
- `;
86
+ hooks[hookName] = "\n createUseQuery<".concat(resultTypeName, ", ").concat(variablesTypeName || "undefined", ">({\n name: ").concat(JSON.stringify(name), "\n })\n ");
81
87
  }
82
88
  else if (type === "mutation") {
83
89
  // A triggerable mutation
84
90
  importUtils["createUseMutation"] = true;
85
- hooks[hookName] = `
86
- createUseMutation<${resultTypeName}, ${variablesTypeName || "undefined"}>({
87
- name: ${JSON.stringify(name)}
88
- })
89
- `;
91
+ hooks[hookName] = "\n createUseMutation<".concat(resultTypeName, ", ").concat(variablesTypeName || "undefined", ">({\n name: ").concat(JSON.stringify(name), "\n })\n ");
90
92
  }
91
93
  else if (type === "infinite") {
92
94
  // Ensure the query has 'limit' and 'cursor' variables
93
- let limitVariableIsValid = false;
94
- let cursorVariableIsValid = false;
95
- let defaultLimit = 0;
96
- item.variableDefinitions?.forEach((item) => {
97
- const { variable, type, loc, defaultValue } = item;
98
- if (variable?.name?.value === "limit") {
95
+ var limitVariableIsValid_1 = false;
96
+ var cursorVariableIsValid_1 = false;
97
+ var defaultLimit_1 = 0;
98
+ (_b = item.variableDefinitions) === null || _b === void 0 ? void 0 : _b.forEach(function (item) {
99
+ var _a, _b;
100
+ var variable = item.variable, type = item.type, loc = item.loc, defaultValue = item.defaultValue;
101
+ if (((_a = variable === null || variable === void 0 ? void 0 : variable.name) === null || _a === void 0 ? void 0 : _a.value) === "limit") {
99
102
  // Found 'limit', but make sure it's an Int, and has a default value
100
103
  if (type.kind === "NamedType" && type.name.value === "Int") {
101
104
  if (defaultValue && defaultValue.kind === "IntValue") {
102
- limitVariableIsValid = true;
103
- defaultLimit = Number(defaultValue.value);
105
+ limitVariableIsValid_1 = true;
106
+ defaultLimit_1 = Number(defaultValue.value);
104
107
  }
105
108
  else {
106
- throwErrorAtLocation(loc, `For infinite queries, be sure to give the '$limit' variable a default value!\nFor example: posts($limit: Int = 10, $cursor: String)\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks`);
109
+ throwErrorAtLocation(loc, "For infinite queries, be sure to give the '$limit' variable a default value!\nFor example: posts($limit: Int = 10, $cursor: String)\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks");
107
110
  }
108
111
  }
109
112
  else {
110
113
  // @ts-ignore
111
- const wrongType = type?.name?.value;
112
- throwErrorAtLocation(loc, `For infinite queries, the '$limit' variable is expected to be an 'Int' type, but you've used '${wrongType}' instead!\nFor example: posts($limit: Int = 10, $cursor: String)\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks`);
114
+ var wrongType = (_b = type === null || type === void 0 ? void 0 : type.name) === null || _b === void 0 ? void 0 : _b.value;
115
+ throwErrorAtLocation(loc, "For infinite queries, the '$limit' variable is expected to be an 'Int' type, but you've used '".concat(wrongType, "' instead!\nFor example: posts($limit: Int = 10, $cursor: String)\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks"));
113
116
  }
114
117
  }
115
118
  else if (variable.name.value === "cursor") {
116
119
  // Found 'cursor', but make sure it's a string
117
120
  if (type.kind === "NamedType") {
118
121
  if (type.name.value === "String") {
119
- cursorVariableIsValid = true;
122
+ cursorVariableIsValid_1 = true;
120
123
  }
121
124
  else {
122
- throwErrorAtLocation(loc, `For infinite queries, the required '$cursor' variable must be an optional String.\nFor example: posts($limit: Int = 10, $cursor: String)\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks`);
125
+ throwErrorAtLocation(loc, "For infinite queries, the required '$cursor' variable must be an optional String.\nFor example: posts($limit: Int = 10, $cursor: String)\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks");
123
126
  }
124
127
  }
125
128
  }
126
129
  });
127
130
  // Check that both the 'limit' and 'cursor' variables are present!
128
- if (!cursorVariableIsValid || !limitVariableIsValid) {
129
- throwErrorAtLocation(item.loc, `For infinite queries, you must supply and use the '$limit' and '$cursor' variables\nFor example: posts($limit: Int = 10, $cursor: String) ${cursorVariableIsValid} ${limitVariableIsValid}\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks`);
131
+ if (!cursorVariableIsValid_1 || !limitVariableIsValid_1) {
132
+ throwErrorAtLocation(item.loc, "For infinite queries, you must supply and use the '$limit' and '$cursor' variables\nFor example: posts($limit: Int = 10, $cursor: String) ".concat(cursorVariableIsValid_1, " ").concat(limitVariableIsValid_1, "\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks"));
130
133
  }
131
134
  // Finally, ensure that pageInfo is queried somewhere
132
135
  // We actually want the selection path for a whole bunch of fields, so that we can extract pagination info, and the list of data
133
- const pageInfo = {
136
+ var pageInfo_1 = {
134
137
  nodesPath: null,
135
138
  pageInfoPath: null,
136
139
  endCursorPath: null,
137
140
  hasNextPagePath: null,
138
141
  };
139
- let nodesPaths = [];
142
+ var nodesPaths_1 = [];
140
143
  // To do this, we use the visitor pattern to find the pageInfo field selection
141
- let lookingAtPageInfo = true;
142
- let lookupPath = [];
143
- let parentNode;
144
+ var lookingAtPageInfo_1 = true;
145
+ var lookupPath_1 = [];
146
+ var parentNode_1;
144
147
  (0, graphql_1.visit)(item.selectionSet, {
145
- enter(node, key, parent, path, ancestors) {
148
+ enter: function (node, key, parent, path, ancestors) {
146
149
  if (node.kind === "Field") {
147
- lookupPath = [...lookupPath, node.name.value];
150
+ lookupPath_1 = __spreadArray(__spreadArray([], lookupPath_1, true), [node.name.value], false);
148
151
  if (node.name.value === "pageInfo") {
149
- parentNode = ancestors[ancestors.length - 2];
152
+ parentNode_1 = ancestors[ancestors.length - 2];
150
153
  // parentNode = ancestors
151
- if (pageInfo.pageInfoPath) {
154
+ if (pageInfo_1.pageInfoPath) {
152
155
  // Detected multiple pageInfo fields in the query — confusing!
153
- throwErrorAtLocation(node.loc, `For infinite queries, be sure to only use 'pageInfo' once. Multiple 'pageInfo' fields were selected in your query!`);
156
+ throwErrorAtLocation(node.loc, "For infinite queries, be sure to only use 'pageInfo' once. Multiple 'pageInfo' fields were selected in your query!");
154
157
  }
155
- lookingAtPageInfo = true;
156
- pageInfo.pageInfoPath = lookupPath;
158
+ lookingAtPageInfo_1 = true;
159
+ pageInfo_1.pageInfoPath = lookupPath_1;
157
160
  }
158
161
  else if (node.name.value === "nodes") {
159
- nodesPaths.push(lookupPath);
162
+ nodesPaths_1.push(lookupPath_1);
160
163
  }
161
- else if (lookingAtPageInfo) {
164
+ else if (lookingAtPageInfo_1) {
162
165
  if (node.name.value === "endCursor") {
163
- pageInfo.endCursorPath = lookupPath;
166
+ pageInfo_1.endCursorPath = lookupPath_1;
164
167
  }
165
168
  else if (node.name.value === "hasNextPage") {
166
- pageInfo.hasNextPagePath = lookupPath;
169
+ pageInfo_1.hasNextPagePath = lookupPath_1;
167
170
  }
168
171
  }
169
172
  }
170
173
  },
171
- leave(node, key, parent, path, ancestors) {
174
+ leave: function (node, key, parent, path, ancestors) {
172
175
  if (node.kind === "Field") {
173
- lookupPath = lookupPath.slice(0, -1);
176
+ lookupPath_1 = lookupPath_1.slice(0, -1);
174
177
  if (node.name.value === "pageInfo") {
175
- lookingAtPageInfo = false;
178
+ lookingAtPageInfo_1 = false;
176
179
  }
177
180
  }
178
181
  },
179
182
  });
180
183
  // Make sure we found pageInfo { endCursor, hasNextPage }
181
- if (!pageInfo.pageInfoPath || !pageInfo.endCursorPath || !pageInfo.hasNextPagePath) {
182
- throwErrorAtLocation(undefined, `For infinite queries, you need to ensure you select the 'pageInfo' field and it's child 'hasNextPage' and 'endCursor' fields\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks`);
184
+ if (!pageInfo_1.pageInfoPath || !pageInfo_1.endCursorPath || !pageInfo_1.hasNextPagePath) {
185
+ throwErrorAtLocation(undefined, "For infinite queries, you need to ensure you select the 'pageInfo' field and it's child 'hasNextPage' and 'endCursor' fields\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks");
183
186
  }
184
187
  // Look for a nodes path which shares the same parent as the pageInfo path
185
- const expectedNodesPath = pageInfo.pageInfoPath.slice(0, -1).join(",");
186
- pageInfo.nodesPath = nodesPaths.find((path) => {
187
- const testPath = path.slice(0, -1).join(",");
188
- return testPath === expectedNodesPath;
188
+ var expectedNodesPath_1 = pageInfo_1.pageInfoPath.slice(0, -1).join(",");
189
+ pageInfo_1.nodesPath = nodesPaths_1.find(function (path) {
190
+ var testPath = path.slice(0, -1).join(",");
191
+ return testPath === expectedNodesPath_1;
189
192
  });
190
- if (!pageInfo.nodesPath || !parentNode) {
191
- throwErrorAtLocation(undefined, `For infinite queries, be sure to select some nodes using the 'nodes' field, adjacent to the 'pageInfo' field which has been selected.\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks`);
193
+ if (!pageInfo_1.nodesPath || !parentNode_1) {
194
+ throwErrorAtLocation(undefined, "For infinite queries, be sure to select some nodes using the 'nodes' field, adjacent to the 'pageInfo' field which has been selected.\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks");
192
195
  }
193
- let firstArgumentIsValid = false;
194
- let afterArgumentIsValid = false;
195
- parentNode?.arguments?.forEach((arg) => {
196
+ var firstArgumentIsValid_1 = false;
197
+ var afterArgumentIsValid_1 = false;
198
+ (_c = parentNode_1 === null || parentNode_1 === void 0 ? void 0 : parentNode_1.arguments) === null || _c === void 0 ? void 0 : _c.forEach(function (arg) {
196
199
  if (arg.kind === "Argument") {
197
200
  if (arg.name.value === "first") {
198
201
  if (arg.value.kind === "Variable") {
199
202
  if (arg.value.name.value === "limit") {
200
- firstArgumentIsValid = true;
203
+ firstArgumentIsValid_1 = true;
201
204
  }
202
205
  }
203
206
  }
204
207
  if (arg.name.value === "after") {
205
208
  if (arg.value.kind === "Variable") {
206
209
  if (arg.value.name.value === "cursor") {
207
- afterArgumentIsValid = true;
210
+ afterArgumentIsValid_1 = true;
208
211
  }
209
212
  }
210
213
  }
211
214
  }
212
215
  });
213
- if (parentNode && (!firstArgumentIsValid || !afterArgumentIsValid)) {
214
- throwErrorAtLocation(parentNode.loc, `You must use the arguments (first: $limit, after: $cursor) when using infinite queries.\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks`);
216
+ if (parentNode_1 && (!firstArgumentIsValid_1 || !afterArgumentIsValid_1)) {
217
+ throwErrorAtLocation(parentNode_1.loc, "You must use the arguments (first: $limit, after: $cursor) when using infinite queries.\nRead more -> https://eddev.ed.studio/docs/graphql/query-hooks");
215
218
  }
216
219
  // Drill down to the path type
217
- let finalResultTypeName = resultTypeName;
218
- pageInfo.nodesPath.forEach((key) => {
219
- finalResultTypeName = `Exclude<${finalResultTypeName}[${JSON.stringify(key)}], undefined | null>`;
220
+ var finalResultTypeName_1 = resultTypeName;
221
+ pageInfo_1.nodesPath.forEach(function (key) {
222
+ finalResultTypeName_1 = "Exclude<".concat(finalResultTypeName_1, "[").concat(JSON.stringify(key), "], undefined | null>");
220
223
  });
221
224
  importUtils["createUseInfiniteQuery"] = true;
222
- hooks[hookName] = `
223
- createUseInfiniteQuery<Exclude<${finalResultTypeName}[0], undefined | null>, Omit<${variablesTypeName || "undefined"}, 'limit' | 'cursor'>>({
224
- name: ${JSON.stringify(name)},
225
- defaultLimit: ${defaultLimit},
226
- paths: ${JSON.stringify(pageInfo)}
227
- })
228
- `;
225
+ hooks[hookName] = "\n createUseInfiniteQuery<Exclude<".concat(finalResultTypeName_1, "[0], undefined | null>, Omit<").concat(variablesTypeName || "undefined", ", 'limit' | 'cursor'>>({\n name: ").concat(JSON.stringify(name), ",\n defaultLimit: ").concat(defaultLimit_1, ",\n paths: ").concat(JSON.stringify(pageInfo_1), "\n })\n ");
229
226
  }
230
227
  });
231
228
  }
232
229
  });
233
- const utilsToImport = Object.keys(importUtils);
230
+ var utilsToImport = Object.keys(importUtils);
234
231
  if (!utilsToImport)
235
- return `export {}`;
236
- const codeBlocks = [];
232
+ return "export {}";
233
+ var codeBlocks = [];
237
234
  // Import required utility functions
238
235
  if (utilsToImport.length) {
239
- codeBlocks.push(`import { ${utilsToImport.join(", ")} } from 'eddev/hooks/queryUtils'`);
236
+ codeBlocks.push("import { ".concat(utilsToImport.join(", "), " } from 'eddev/hooks/queryUtils'"));
240
237
  }
241
238
  // Import types from types.graphql
242
239
  if (importTypes.length) {
243
- codeBlocks.push(`import { ${importTypes} } from '../types.graphql'`);
240
+ codeBlocks.push("import { ".concat(importTypes, " } from '../types.graphql'"));
244
241
  }
245
- for (const hookName in hooks) {
246
- const hookCode = hooks[hookName];
247
- codeBlocks.push(`export const ${hookName} = ${hookCode}`);
242
+ for (var hookName in hooks) {
243
+ var hookCode = hooks[hookName];
244
+ codeBlocks.push("export const ".concat(hookName, " = ").concat(hookCode));
248
245
  }
249
246
  return codeBlocks.join("\n\n");
250
247
  },
@@ -1,4 +1,4 @@
1
- type Options = {
1
+ declare type Options = {
2
2
  baseDirectory: string;
3
3
  isAdmin: boolean;
4
4
  isDev: boolean;
@@ -4,65 +4,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createBlockManifestGenerator = void 0;
7
- const manifest_1 = require("./manifest");
8
- const path_1 = __importDefault(require("path"));
9
- const change_case_1 = require("change-case");
10
- const fs_1 = require("fs");
11
- const JSX = /\.(jsx|tsx|ts|js)$/i;
7
+ var manifest_1 = require("./manifest");
8
+ var path_1 = __importDefault(require("path"));
9
+ var change_case_1 = require("change-case");
10
+ var fs_1 = require("fs");
11
+ var JSX = /\.(jsx|tsx|ts|js)$/i;
12
12
  function createBlockManifestGenerator(opts) {
13
13
  return (0, manifest_1.createManifestGenerator)({
14
14
  glob: path_1.default.join(opts.baseDirectory, "/blocks/**/*.tsx"),
15
15
  onGenerate: opts.onGenerate,
16
16
  watch: opts.watch,
17
- generate(fileNames) {
18
- const files = fileNames
19
- .filter((file) => !file.includes("/_core"))
20
- .map((file) => {
21
- const relative = path_1.default.relative(opts.baseDirectory, file).replace(JSX, "");
22
- const name = path_1.default.basename(file).replace(JSX, "");
23
- const module = JSON.stringify("./" + relative).replace(JSX, "");
24
- const componentName = (0, change_case_1.pascalCase)(name);
17
+ generate: function (fileNames) {
18
+ var files = fileNames
19
+ .filter(function (file) { return !file.includes("/_core"); })
20
+ .map(function (file) {
21
+ var relative = path_1.default.relative(opts.baseDirectory, file).replace(JSX, "");
22
+ var name = path_1.default.basename(file).replace(JSX, "");
23
+ var module = JSON.stringify("./" + relative).replace(JSX, "");
24
+ var componentName = (0, change_case_1.pascalCase)(name);
25
25
  // Test if the block has Dynamic: true in the header
26
- const dynamic = !opts.isAdmin &&
26
+ var dynamic = !opts.isAdmin &&
27
27
  !!(0, fs_1.readFileSync)(file)
28
28
  .toString()
29
29
  .match(/\*[\s]*dynamic: true/i);
30
- return { relative, name, module, componentName, dynamic };
30
+ return { relative: relative, name: name, module: module, componentName: componentName, dynamic: dynamic };
31
31
  });
32
- return `
33
- import coreBlocks from './blocks/_core'
34
- import { dynamic } from 'eddev/dynamic';
35
-
36
- ${files
37
- .map(({ relative, componentName, module, dynamic }) => {
38
- const parts = relative.replace(/\.tsx$/, "").split("/");
39
- const blockName = "acf/" + parts.slice(1).join("-");
32
+ return "\n import coreBlocks from './blocks/_core'\n import { dynamic } from 'eddev/dynamic';\n \n ".concat(files
33
+ .map(function (_a) {
34
+ var relative = _a.relative, componentName = _a.componentName, module = _a.module, dynamic = _a.dynamic;
35
+ var parts = relative.replace(/\.tsx$/, "").split("/");
36
+ var blockName = "acf/" + parts.slice(1).join("-");
40
37
  if (dynamic) {
41
38
  return null;
42
39
  }
43
40
  else {
44
- return `import ${componentName} from ${module}`;
41
+ return "import ".concat(componentName, " from ").concat(module);
45
42
  }
46
43
  })
47
44
  .filter(Boolean)
48
- .join("\n")}
49
-
50
- export default {
51
- ...coreBlocks,
52
- ${files
53
- .map(({ relative, componentName, module, dynamic }) => {
54
- const parts = relative.replace(/\.tsx$/, "").split("/");
55
- const blockName = "acf/" + parts.slice(1).join("-");
45
+ .join("\n"), "\n \n export default {\n ...coreBlocks,\n ").concat(files
46
+ .map(function (_a) {
47
+ var relative = _a.relative, componentName = _a.componentName, module = _a.module, dynamic = _a.dynamic;
48
+ var parts = relative.replace(/\.tsx$/, "").split("/");
49
+ var blockName = "acf/" + parts.slice(1).join("-");
56
50
  if (dynamic) {
57
- return `"${blockName}": dynamic(() => import(${module}))`;
51
+ return "\"".concat(blockName, "\": dynamic(() => import(").concat(module, "))");
58
52
  }
59
53
  else {
60
- return `"${blockName}": ${componentName}`;
54
+ return "\"".concat(blockName, "\": ").concat(componentName);
61
55
  }
62
56
  })
63
- .join(",\n")}
64
- }
65
- `;
57
+ .join(",\n"), "\n }\n ");
66
58
  },
67
59
  });
68
60
  }
@@ -1,4 +1,4 @@
1
- type Options = {
1
+ declare type Options = {
2
2
  baseDirectory: string;
3
3
  isAdmin: boolean;
4
4
  isDev: boolean;