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.
- package/admin/components/ImageWell.d.ts +2 -2
- package/admin/components/ImageWell.js +51 -39
- package/admin/defineField.d.ts +2 -2
- package/admin/defineWidget.d.ts +1 -1
- package/admin/defineWidget.js +2 -2
- package/admin/index.js +1 -5
- package/admin/installFieldTypes.js +26 -26
- package/admin/runWidgets.js +28 -17
- package/admin/selectMedia.d.ts +2 -2
- package/admin/selectMedia.js +1 -1
- package/blocks/ContentBlocks.d.ts +6 -6
- package/blocks/ContentBlocks.js +66 -58
- package/blocks/ErrorBoundaryEditor.d.ts +1 -1
- package/blocks/ErrorBoundaryEditor.js +45 -16
- package/blocks/ErrorBoundaryFrontend.d.ts +1 -1
- package/blocks/ErrorBoundaryFrontend.js +45 -16
- package/blocks/InspectorControls.d.ts +1 -1
- package/blocks/InspectorControls.js +3 -3
- package/blocks/blockAttributes.d.ts +2 -2
- package/blocks/blockAttributes.js +44 -24
- package/blocks/index.js +1 -5
- package/blocks/inlineEditing.d.ts +6 -6
- package/blocks/inlineEditing.js +55 -36
- package/blocks/installGutenbergHooks.js +68 -48
- package/build/babel/plugin-name-defined-components.js +16 -15
- package/build/build-favicon.js +62 -11
- package/build/clean.js +52 -5
- package/build/create-codegen-worker.js +33 -78
- package/build/create-serverless-dev-worker.js +39 -61
- package/build/create-webpack-worker.js +33 -65
- package/build/file-tree.d.ts +2 -2
- package/build/file-tree.js +12 -12
- package/build/get-webpack-config.js +395 -341
- package/build/graphql-codegen/graphql-codegen-files.js +25 -31
- package/build/graphql-codegen/graphql-codegen-no-duplicates.js +4 -4
- package/build/graphql-codegen/graphql-codegen-queries.js +99 -102
- package/build/manifests/manifest-blocks.d.ts +1 -1
- package/build/manifests/manifest-blocks.js +29 -37
- package/build/manifests/manifest-fields.d.ts +1 -1
- package/build/manifests/manifest-fields.js +21 -23
- package/build/manifests/manifest-views.d.ts +1 -1
- package/build/manifests/manifest-views.js +25 -32
- package/build/manifests/manifest-widgets.d.ts +1 -1
- package/build/manifests/manifest-widgets.js +20 -22
- package/build/manifests/manifest.d.ts +2 -2
- package/build/manifests/manifest.js +94 -30
- package/build/reporter.d.ts +1 -1
- package/build/reporter.js +32 -29
- package/build/serverless/create-next-app.d.ts +1 -1
- package/build/serverless/create-next-app.js +467 -245
- package/build/state/codegen-state.d.ts +4 -4
- package/build/state/compiler-state.d.ts +5 -5
- package/build/state/serverless-state.d.ts +3 -3
- package/build/workers/codegen-worker-script.js +519 -393
- package/build/workers/serverless-worker-dev-script.js +4 -4
- package/build/workers/webpack-worker-script.js +156 -90
- package/cli/build.dev.d.ts +1 -1
- package/cli/build.dev.js +126 -79
- package/cli/build.prod.d.ts +1 -1
- package/cli/build.prod.js +98 -42
- package/cli/cli.js +28 -19
- package/cli/display/components/BundleDisplay.d.ts +1 -1
- package/cli/display/components/BundleDisplay.js +24 -13
- package/cli/display/components/CodegenDisplay.d.ts +1 -1
- package/cli/display/components/CodegenDisplay.js +25 -14
- package/cli/display/components/DevCLIDisplay.d.ts +2 -2
- package/cli/display/components/DevCLIDisplay.js +25 -14
- package/cli/display/components/Fullscreen.js +20 -9
- package/cli/display/components/ServerlessDisplay.d.ts +2 -2
- package/cli/display/components/ServerlessDisplay.js +26 -15
- package/cli/display/components/StatusIcon.d.ts +2 -2
- package/cli/display/components/StatusIcon.js +3 -3
- package/cli/preinstall.js +5 -4
- package/cli/setup.js +73 -25
- package/components/AdminBar.d.ts +1 -1
- package/components/AdminBar.js +3 -37
- package/components/BrowserRouter.d.ts +2 -2
- package/components/BrowserRouter.js +54 -41
- package/components/InlinePage.d.ts +2 -2
- package/components/InlinePage.js +29 -17
- package/components/NextRouter.d.ts +2 -2
- package/components/NextRouter.js +29 -20
- package/components/index.js +1 -5
- package/config/config-schema.d.ts +1 -1
- package/config/config-schema.js +1 -1
- package/config/create-schema-file.js +6 -6
- package/config/get-config.js +13 -10
- package/config/index.js +1 -5
- package/config/parse-config.js +1 -1
- package/config/print-zod-errors.js +3 -3
- package/dev-ui/components/BreakpointColumnHeader.d.ts +2 -2
- package/dev-ui/components/BreakpointColumnHeader.js +18 -7
- package/dev-ui/components/BreakpointIndicator.d.ts +1 -1
- package/dev-ui/components/BreakpointIndicator.js +32 -25
- package/dev-ui/components/DevUI.d.ts +1 -1
- package/dev-ui/components/DevUI.js +13 -13
- package/dev-ui/components/Launcher.d.ts +2 -2
- package/dev-ui/components/Launcher.js +25 -13
- package/dev-ui/components/PanelWrapper.d.ts +2 -2
- package/dev-ui/components/PanelWrapper.js +8 -8
- package/dev-ui/components/ResponsiveLerpControl.d.ts +2 -2
- package/dev-ui/components/ResponsiveLerpControl.js +38 -27
- package/dev-ui/components/ResponsiveScaleEditor.d.ts +4 -4
- package/dev-ui/components/ResponsiveScaleEditor.js +78 -64
- package/dev-ui/components/atoms/Button.js +1 -1
- package/dev-ui/components/atoms/Dropdown.d.ts +3 -3
- package/dev-ui/components/atoms/Dropdown.js +9 -8
- package/dev-ui/components/atoms/NumberField.d.ts +2 -2
- package/dev-ui/components/atoms/NumberField.js +42 -29
- package/dev-ui/components/atoms/Spacer.js +1 -1
- package/dev-ui/components/atoms/Text.js +1 -1
- package/dev-ui/components/atoms/ToggleButton.d.ts +2 -2
- package/dev-ui/components/atoms/ToggleButton.js +16 -5
- package/dev-ui/components/atoms/Tooltip.d.ts +2 -2
- package/dev-ui/components/atoms/Tooltip.js +20 -8
- package/dev-ui/components/panels/AppDataDebugger.d.ts +1 -1
- package/dev-ui/components/panels/AppDataDebugger.js +19 -8
- package/dev-ui/components/panels/ColorEditor.d.ts +1 -1
- package/dev-ui/components/panels/ColorEditor.js +42 -35
- package/dev-ui/components/panels/PageDataDebugger.d.ts +1 -1
- package/dev-ui/components/panels/PageDataDebugger.js +20 -8
- package/dev-ui/components/panels/QueryDebugger.d.ts +1 -1
- package/dev-ui/components/panels/QueryDebugger.js +24 -12
- package/dev-ui/components/panels/SpacingEditor.d.ts +1 -1
- package/dev-ui/components/panels/SpacingEditor.js +48 -34
- package/dev-ui/components/panels/TypographyEditor.d.ts +1 -1
- package/dev-ui/components/panels/TypographyEditor.js +46 -38
- package/dev-ui/hooks/useBreakpoint.d.ts +1 -1
- package/dev-ui/hooks/useBreakpoint.js +13 -13
- package/dev-ui/hooks/usePersistState.js +7 -6
- package/dev-ui/hooks/useStylesheet.js +6 -6
- package/dev-ui/icons.d.ts +15 -15
- package/dev-ui/icons.js +27 -16
- package/dev-ui/index.js +1 -5
- package/dev-ui/loader.d.ts +1 -1
- package/dev-ui/loader.js +9 -13
- package/dev-ui/panels.d.ts +2 -2
- package/dev-ui/panels.js +7 -7
- package/dev-ui/theme.js +3 -3
- package/dynamic/dynamic-component.js +1 -1
- package/dynamic/index.js +1 -5
- package/entry/Root.d.ts +2 -2
- package/entry/Root.js +26 -16
- package/entry/entry.admin.dev.js +4 -4
- package/entry/entry.admin.prod.js +4 -4
- package/entry/entry.monolith.dev.js +5 -5
- package/entry/entry.monolith.prod.js +5 -5
- package/gravityforms/gravity-forms.d.ts +2 -2
- package/gravityforms/index.js +1 -5
- package/gravityforms/useGravityForm.d.ts +2 -2
- package/gravityforms/useGravityForm.js +130 -126
- package/hooks/index.js +1 -5
- package/hooks/queryUtils.d.ts +14 -14
- package/hooks/queryUtils.js +192 -101
- package/hooks/useAppData.d.ts +2 -2
- package/hooks/useAppData.js +9 -9
- package/hooks/usePageLoad.js +4 -4
- package/hooks/useQueryDebug.d.ts +1 -1
- package/hooks/useQueryDebug.js +7 -7
- package/hooks/useRPC.d.ts +4 -4
- package/hooks/useRPC.js +3 -3
- package/package.json +12 -12
- package/routing/index.js +1 -5
- package/routing/remoteProps.d.ts +1 -1
- package/routing/remoteProps.js +72 -31
- package/routing/routing.d.ts +25 -15
- package/routing/routing.js +200 -112
- package/routing/updateEditLink.js +1 -1
- package/serverless/define-api.d.ts +1 -1
- package/serverless/define-rpc-router.js +4 -8
- package/serverless/index.js +2 -6
- package/style/createStitches.js +142 -164
- package/style/index.js +1 -5
- package/tsconfig.json +1 -1
- package/utils/Observable.d.ts +2 -2
- package/utils/Observable.js +15 -12
- package/utils/getRepoName.js +3 -3
- package/utils/promptIfRepoNameIncorrect.js +64 -18
- package/utils/refreshOverlayInterop.js +1 -1
- package/utils/reportErrorStack.d.ts +1 -1
- package/utils/reportErrorStack.js +1 -1
- package/utils/serverlessAppContext.js +1 -1
- package/utils/updateEnvFile.js +69 -19
- package/utils/useObservable.js +3 -3
- 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
|
-
|
|
7
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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
|
-
|
|
44
|
-
|
|
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
|
-
|
|
47
|
-
items.push(
|
|
47
|
+
var key = relative.replace(/\.graphql/, "");
|
|
48
|
+
items.push("".concat(JSON.stringify(key), ": ").concat(typeForFile(key, typeName)));
|
|
48
49
|
}
|
|
49
50
|
});
|
|
50
|
-
for (
|
|
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
|
-
|
|
53
|
-
items.push(
|
|
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
|
|
60
|
+
return "export { };";
|
|
59
61
|
}
|
|
60
|
-
return
|
|
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(
|
|
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
|
-
|
|
4
|
-
|
|
12
|
+
var graphql_1 = require("graphql");
|
|
13
|
+
var path_1 = require("path");
|
|
5
14
|
module.exports = {
|
|
6
|
-
plugin: (schema, documents, config, info)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
documents.forEach((doc)
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
38
|
+
var fullMessage = message;
|
|
29
39
|
if (printedSource) {
|
|
30
40
|
fullMessage += ":\n\n" + printedSource;
|
|
31
41
|
}
|
|
32
42
|
else {
|
|
33
|
-
fullMessage +=
|
|
43
|
+
fullMessage += " (in ".concat(fileName, ")");
|
|
34
44
|
}
|
|
35
|
-
|
|
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 (
|
|
50
|
+
if (foundQueryOperation_1) {
|
|
41
51
|
throwErrorAtLocation(item.loc, "Only one operation is allowed in each queries/*.graphql file");
|
|
42
52
|
}
|
|
43
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
74
|
+
var baseName = (0, path_1.basename)(fileName);
|
|
65
75
|
if (baseName.replace(".graphql", "") !== name) {
|
|
66
|
-
throwErrorAtLocation(item.name.loc,
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
item.variableDefinitions
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
103
|
-
|
|
105
|
+
limitVariableIsValid_1 = true;
|
|
106
|
+
defaultLimit_1 = Number(defaultValue.value);
|
|
104
107
|
}
|
|
105
108
|
else {
|
|
106
|
-
throwErrorAtLocation(loc,
|
|
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
|
-
|
|
112
|
-
throwErrorAtLocation(loc,
|
|
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
|
-
|
|
122
|
+
cursorVariableIsValid_1 = true;
|
|
120
123
|
}
|
|
121
124
|
else {
|
|
122
|
-
throwErrorAtLocation(loc,
|
|
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 (!
|
|
129
|
-
throwErrorAtLocation(item.loc,
|
|
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
|
-
|
|
136
|
+
var pageInfo_1 = {
|
|
134
137
|
nodesPath: null,
|
|
135
138
|
pageInfoPath: null,
|
|
136
139
|
endCursorPath: null,
|
|
137
140
|
hasNextPagePath: null,
|
|
138
141
|
};
|
|
139
|
-
|
|
142
|
+
var nodesPaths_1 = [];
|
|
140
143
|
// To do this, we use the visitor pattern to find the pageInfo field selection
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
150
|
+
lookupPath_1 = __spreadArray(__spreadArray([], lookupPath_1, true), [node.name.value], false);
|
|
148
151
|
if (node.name.value === "pageInfo") {
|
|
149
|
-
|
|
152
|
+
parentNode_1 = ancestors[ancestors.length - 2];
|
|
150
153
|
// parentNode = ancestors
|
|
151
|
-
if (
|
|
154
|
+
if (pageInfo_1.pageInfoPath) {
|
|
152
155
|
// Detected multiple pageInfo fields in the query — confusing!
|
|
153
|
-
throwErrorAtLocation(node.loc,
|
|
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
|
-
|
|
156
|
-
|
|
158
|
+
lookingAtPageInfo_1 = true;
|
|
159
|
+
pageInfo_1.pageInfoPath = lookupPath_1;
|
|
157
160
|
}
|
|
158
161
|
else if (node.name.value === "nodes") {
|
|
159
|
-
|
|
162
|
+
nodesPaths_1.push(lookupPath_1);
|
|
160
163
|
}
|
|
161
|
-
else if (
|
|
164
|
+
else if (lookingAtPageInfo_1) {
|
|
162
165
|
if (node.name.value === "endCursor") {
|
|
163
|
-
|
|
166
|
+
pageInfo_1.endCursorPath = lookupPath_1;
|
|
164
167
|
}
|
|
165
168
|
else if (node.name.value === "hasNextPage") {
|
|
166
|
-
|
|
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
|
-
|
|
176
|
+
lookupPath_1 = lookupPath_1.slice(0, -1);
|
|
174
177
|
if (node.name.value === "pageInfo") {
|
|
175
|
-
|
|
178
|
+
lookingAtPageInfo_1 = false;
|
|
176
179
|
}
|
|
177
180
|
}
|
|
178
181
|
},
|
|
179
182
|
});
|
|
180
183
|
// Make sure we found pageInfo { endCursor, hasNextPage }
|
|
181
|
-
if (!
|
|
182
|
-
throwErrorAtLocation(undefined,
|
|
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
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
return testPath ===
|
|
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 (!
|
|
191
|
-
throwErrorAtLocation(undefined,
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
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
|
-
|
|
210
|
+
afterArgumentIsValid_1 = true;
|
|
208
211
|
}
|
|
209
212
|
}
|
|
210
213
|
}
|
|
211
214
|
}
|
|
212
215
|
});
|
|
213
|
-
if (
|
|
214
|
-
throwErrorAtLocation(
|
|
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
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
230
|
+
var utilsToImport = Object.keys(importUtils);
|
|
234
231
|
if (!utilsToImport)
|
|
235
|
-
return
|
|
236
|
-
|
|
232
|
+
return "export {}";
|
|
233
|
+
var codeBlocks = [];
|
|
237
234
|
// Import required utility functions
|
|
238
235
|
if (utilsToImport.length) {
|
|
239
|
-
codeBlocks.push(
|
|
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(
|
|
240
|
+
codeBlocks.push("import { ".concat(importTypes, " } from '../types.graphql'"));
|
|
244
241
|
}
|
|
245
|
-
for (
|
|
246
|
-
|
|
247
|
-
codeBlocks.push(
|
|
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
|
},
|
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
19
|
-
.filter((file)
|
|
20
|
-
.map((file)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
|
41
|
+
return "import ".concat(componentName, " from ").concat(module);
|
|
45
42
|
}
|
|
46
43
|
})
|
|
47
44
|
.filter(Boolean)
|
|
48
|
-
.join("\n")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
51
|
+
return "\"".concat(blockName, "\": dynamic(() => import(").concat(module, "))");
|
|
58
52
|
}
|
|
59
53
|
else {
|
|
60
|
-
return
|
|
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
|
}
|