eddev 0.2.65 → 0.2.67-beta1

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