eddev 0.1.26 → 0.1.30
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/blocks/installGutenbergHooks.js +1 -0
- package/build/codegen-worker-script.js +4 -4
- package/build/create-codegen-worker.d.ts +1 -1
- package/build/create-codegen-worker.js +1 -1
- package/build/create-webpack-worker.js +2 -2
- package/build/get-webpack-config.js +26 -27
- package/build/graphql-codegen/graphql-codegen-files.js +3 -3
- package/build/graphql-codegen/graphql-codegen-no-duplicates.js +1 -1
- package/build/graphql-codegen/graphql-codegen-queries.js +17 -17
- package/build/reporter.js +1 -1
- package/build/workers/codegen-worker-script.d.ts +5 -0
- package/build/workers/codegen-worker-script.js +543 -0
- package/build/workers/webpack-worker-script.d.ts +2 -0
- package/build/workers/webpack-worker-script.js +160 -0
- package/cli/cli.js +3 -28
- package/cli/display/components/BundleDisplay.js +1 -1
- package/cli/display/components/CodegenDisplay.js +2 -2
- package/cli/generate.js +1 -15
- package/components/BrowserRouter.js +1 -1
- package/components/InlinePage.js +1 -1
- package/components/index.d.ts +0 -1
- package/components/index.js +0 -1
- package/components/routing.d.ts +3 -1
- package/components/routing.js +4 -5
- package/entry/Root.js +4 -4
- package/hooks/queryUtils.js +2 -2
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +5 -7
- package/routing/index.d.ts +1 -0
- package/routing/index.js +13 -0
- package/routing/routing.d.ts +45 -0
- package/routing/routing.js +373 -0
- package/style/createStitches.d.ts +5 -4
- package/style/createStitches.js +9 -9
- package/style/index.d.ts +0 -1
- package/style/index.js +0 -1
- package/utils/promptIfRepoNameIncorrect.js +1 -1
- package/utils/remoteProps.d.ts +2 -2
- package/build/dev/codegen-state.d.ts +0 -6
- package/build/dev/codegen-state.js +0 -2
- package/build/dev/compiler-state.d.ts +0 -11
- package/build/dev/compiler-state.js +0 -2
- package/build/getWebpackConfig.d.ts +0 -11
- package/build/getWebpackConfig.js +0 -428
- package/cli/build.dev2.d.ts +0 -5
- package/cli/build.dev2.js +0 -88
- package/cli/dev/codegen-state.d.ts +0 -6
- package/cli/dev/codegen-state.js +0 -2
- package/cli/dev/compiler-state.d.ts +0 -11
- package/cli/dev/compiler-state.js +0 -2
- package/cli/dev/dev-command.d.ts +0 -5
- package/cli/dev/dev-command.js +0 -56
- package/cli/dev/webpack-worker.d.ts +0 -1
- package/cli/dev/webpack-worker.js +0 -5
- package/cli/dev/worker.d.ts +0 -0
- package/cli/dev/worker.js +0 -2
- package/cli/display/components/SyntaxErrorBox.d.ts +0 -0
- package/cli/display/components/SyntaxErrorBox.js +0 -1
- package/cli/lib/create-webpack-worker.d.ts +0 -0
- package/cli/lib/create-webpack-worker.js +0 -1
- package/cli/lib/webpack-worker-script.d.ts +0 -1
- package/cli/lib/webpack-worker-script.js +0 -5
- package/cli/lib/webpack-worker.d.ts +0 -1
- package/cli/lib/webpack-worker.js +0 -5
- package/hooks/createUseQuery.d.ts +0 -9
- package/hooks/createUseQuery.js +0 -12
- package/style/themeDefinition.d.ts +0 -22
- package/style/themeDefinition.js +0 -2
- package/utils/cxBabelPlugin.d.ts +0 -0
- package/utils/cxBabelPlugin.js +0 -21
- package/utils/generateSchemaTypes.d.ts +0 -6
- package/utils/generateSchemaTypes.js +0 -169
- package/utils/graphql-codegen/graphql-codegen-blocks.d.ts +0 -1
- package/utils/graphql-codegen/graphql-codegen-blocks.js +0 -8
- package/utils/graphql-codegen/graphql-codegen-files.d.ts +0 -1
- package/utils/graphql-codegen/graphql-codegen-files.js +0 -64
- package/utils/graphql-codegen/graphql-codegen-no-duplicates.d.ts +0 -1
- package/utils/graphql-codegen/graphql-codegen-no-duplicates.js +0 -13
- package/utils/jsx/jsx-runtime.d.ts +0 -2
- package/utils/jsx/jsx-runtime.js +0 -27
|
@@ -25,6 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.installEDGutenbergHooks = void 0;
|
|
27
27
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
// @ts-ignore
|
|
28
29
|
var hooks_1 = require("@wordpress/hooks");
|
|
29
30
|
var react_1 = require("react");
|
|
30
31
|
// @ts-ignore
|
|
@@ -230,7 +230,7 @@ function beginWork(opts) {
|
|
|
230
230
|
return [3 /*break*/, 3];
|
|
231
231
|
case 2:
|
|
232
232
|
err_3 = _a.sent();
|
|
233
|
-
parseErrors.push("Error parsing \""
|
|
233
|
+
parseErrors.push("Error parsing \"".concat(file.replace(opts.baseDirectory, ""), ":\n").concat(err_3));
|
|
234
234
|
return [3 /*break*/, 3];
|
|
235
235
|
case 3: return [2 /*return*/];
|
|
236
236
|
}
|
|
@@ -332,15 +332,15 @@ function beginWork(opts) {
|
|
|
332
332
|
var item = _d[_i];
|
|
333
333
|
if (item.name.value === "block") {
|
|
334
334
|
var blockField = (_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.selectionSet) === null || _a === void 0 ? void 0 : _a.selections[0]) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.value;
|
|
335
|
-
blockSelection = "Exclude<"
|
|
335
|
+
blockSelection = "Exclude<".concat(importedName, "[\"block\"][").concat(JSON.stringify(blockField), "], null>");
|
|
336
336
|
}
|
|
337
337
|
else {
|
|
338
|
-
queryKeyVals.push([JSON.stringify(item.name.value), importedName
|
|
338
|
+
queryKeyVals.push([JSON.stringify(item.name.value), "".concat(importedName, "[").concat(JSON.stringify(item.name.value), "]")].join(": "));
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
var type = [];
|
|
342
342
|
if (queryKeyVals.length)
|
|
343
|
-
type.push("{"
|
|
343
|
+
type.push("{".concat(queryKeyVals.join(",\n"), "}"));
|
|
344
344
|
if (blockSelection)
|
|
345
345
|
type.push(blockSelection);
|
|
346
346
|
if (type.length === 0)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Observable } from "../cli/display/lib/Observable";
|
|
2
|
-
import { CodegenOptions } from "./codegen-worker-script";
|
|
2
|
+
import { CodegenOptions } from "./workers/codegen-worker-script";
|
|
3
3
|
import { CodegenState } from "./state/codegen-state";
|
|
4
4
|
export declare function createCodegenWorker(opts: CodegenOptions): Observable<CodegenState>;
|
|
@@ -16,7 +16,7 @@ var worker_threads_1 = require("worker_threads");
|
|
|
16
16
|
var path_1 = require("path");
|
|
17
17
|
var Observable_1 = require("../cli/display/lib/Observable");
|
|
18
18
|
function createCodegenWorker(opts) {
|
|
19
|
-
var worker = new worker_threads_1.Worker((0, path_1.join)(__dirname, "codegen-worker-script.js"), {
|
|
19
|
+
var worker = new worker_threads_1.Worker((0, path_1.join)(__dirname, "workers/codegen-worker-script.js"), {
|
|
20
20
|
workerData: opts,
|
|
21
21
|
stderr: true,
|
|
22
22
|
stdin: false,
|
|
@@ -16,7 +16,7 @@ var worker_threads_1 = require("worker_threads");
|
|
|
16
16
|
var path_1 = require("path");
|
|
17
17
|
var Observable_1 = require("../cli/display/lib/Observable");
|
|
18
18
|
function createWebpackWorker(opts) {
|
|
19
|
-
var worker = new worker_threads_1.Worker((0, path_1.join)(__dirname, "webpack-worker-script.js"), {
|
|
19
|
+
var worker = new worker_threads_1.Worker((0, path_1.join)(__dirname, "workers/webpack-worker-script.js"), {
|
|
20
20
|
workerData: opts,
|
|
21
21
|
stderr: true,
|
|
22
22
|
stdin: false,
|
|
@@ -48,7 +48,7 @@ function createWebpackWorker(opts) {
|
|
|
48
48
|
}
|
|
49
49
|
else if (data.code === "invalidated") {
|
|
50
50
|
subject.update(function (state) { return (__assign(__assign({}, state), { status: "compiling", statusLabel: data.changedFile
|
|
51
|
-
? "Rebuilding ("
|
|
51
|
+
? "Rebuilding (".concat(data.changedFile.replace(opts.baseDirectory, ""), ")")
|
|
52
52
|
: "Rebuilding (changes detected)", log: "", duration: 0, errors: [] })); });
|
|
53
53
|
}
|
|
54
54
|
});
|
|
@@ -95,24 +95,24 @@ function getWebpackConfig(opts) {
|
|
|
95
95
|
entryDir = path_1.default.resolve(path_1.default.dirname(__dirname), "./entry");
|
|
96
96
|
if (isDev) {
|
|
97
97
|
if (opts.isAdmin) {
|
|
98
|
-
ENTRY["main"] = [entryDir
|
|
98
|
+
ENTRY["main"] = ["".concat(entryDir, "/entry.publicPath.js"), "".concat(entryDir, "/entry.admin.dev.js")];
|
|
99
99
|
}
|
|
100
100
|
else if (isServerless) {
|
|
101
|
-
ENTRY["main"] = [entryDir
|
|
101
|
+
ENTRY["main"] = ["".concat(entryDir, "/entry.serverless.dev.js")];
|
|
102
102
|
}
|
|
103
103
|
else {
|
|
104
|
-
ENTRY["main"] = [entryDir
|
|
104
|
+
ENTRY["main"] = ["".concat(entryDir, "/entry.publicPath.js"), "".concat(entryDir, "/entry.monolith.dev.js")];
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
else {
|
|
108
108
|
if (opts.isAdmin) {
|
|
109
|
-
ENTRY["main"] = [entryDir
|
|
109
|
+
ENTRY["main"] = ["".concat(entryDir, "/entry.publicPath.js"), "".concat(entryDir, "/entry.admin.prod.js")];
|
|
110
110
|
}
|
|
111
111
|
else if (isServerless) {
|
|
112
|
-
ENTRY["main"] = [entryDir
|
|
112
|
+
ENTRY["main"] = ["".concat(entryDir, "/entry.serverless.prod.js")];
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
|
-
ENTRY["main"] = [entryDir
|
|
115
|
+
ENTRY["main"] = ["".concat(entryDir, "/entry.publicPath.js"), "".concat(entryDir, "/entry.monolith.prod.js")];
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
distSuffix = opts.isAdmin ? "admin" : "frontend";
|
|
@@ -145,13 +145,11 @@ function getWebpackConfig(opts) {
|
|
|
145
145
|
require.resolve("@babel/preset-react"),
|
|
146
146
|
{
|
|
147
147
|
runtime: "automatic",
|
|
148
|
-
// importSource: Path.resolve(__dirname, "../utils/jsx"),
|
|
149
148
|
},
|
|
150
149
|
],
|
|
151
150
|
require.resolve("@babel/preset-typescript"),
|
|
152
151
|
],
|
|
153
152
|
plugins: [
|
|
154
|
-
// Path.resolve(__dirname, "../utils/cxBabelPlugin.js"),
|
|
155
153
|
isBrowser && isDev && [require.resolve("react-refresh/babel"), { skipEnvCheck: true }],
|
|
156
154
|
require.resolve("@loadable/babel-plugin"),
|
|
157
155
|
].filter(Boolean),
|
|
@@ -169,7 +167,7 @@ function getWebpackConfig(opts) {
|
|
|
169
167
|
{
|
|
170
168
|
loader: mini_css_extract_plugin_1.default.loader,
|
|
171
169
|
options: {
|
|
172
|
-
publicPath: "/wp-content/themes/"
|
|
170
|
+
publicPath: "/wp-content/themes/".concat(opts.themeName, "/dist/").concat(distSuffix),
|
|
173
171
|
},
|
|
174
172
|
},
|
|
175
173
|
{
|
|
@@ -199,9 +197,10 @@ function getWebpackConfig(opts) {
|
|
|
199
197
|
DEFINES["process.LOADABLE_STATS_FILE"] = JSON.stringify(loadableManifestFile);
|
|
200
198
|
DEFINES["process.dev"] = isDev ? "true" : "false";
|
|
201
199
|
DEFINES["process.admin"] = opts.isAdmin ? "true" : "false";
|
|
202
|
-
DEFINES["process.env.themePath"] = JSON.stringify("/wp-content/themes/"
|
|
200
|
+
DEFINES["process.env.themePath"] = JSON.stringify("/wp-content/themes/".concat(opts.themeName));
|
|
201
|
+
DEFINES["process.themePath"] = JSON.stringify("/wp-content/themes/".concat(opts.themeName));
|
|
203
202
|
if (isBrowser) {
|
|
204
|
-
DEFINES["process.env.themePath"] = "window.THEME_PATH || "
|
|
203
|
+
DEFINES["process.env.themePath"] = "window.THEME_PATH || ".concat(DEFINES["process.env.themePath"]);
|
|
205
204
|
}
|
|
206
205
|
// Bundle analyser
|
|
207
206
|
if (!opts.isAdmin && !isDev) {
|
|
@@ -261,25 +260,25 @@ function getWebpackConfig(opts) {
|
|
|
261
260
|
var componentName = (0, change_case_1.pascalCase)(name);
|
|
262
261
|
return { relative: relative, name: name, module: module, componentName: componentName };
|
|
263
262
|
});
|
|
264
|
-
writeVirtualModule(ALIAS["@manifest/views"], "\n "
|
|
263
|
+
writeVirtualModule(ALIAS["@manifest/views"], "\n ".concat(!isServerless && "import loadable from '".concat(require.resolve("@loadable/component"), "';"), "\n import App from ").concat(JSON.stringify("./views/_app.tsx"), "\n\n ").concat(isServerless
|
|
265
264
|
? files.map(function (_a) {
|
|
266
265
|
var componentName = _a.componentName, module = _a.module;
|
|
267
|
-
return "import "
|
|
266
|
+
return "import ".concat(componentName, " from ").concat(module);
|
|
268
267
|
}).join("\n")
|
|
269
|
-
: ""
|
|
268
|
+
: "", "\n\n export { App }\n\n export default {\n ").concat(files
|
|
270
269
|
.map(function (_a) {
|
|
271
270
|
var relative = _a.relative, componentName = _a.componentName, module = _a.module;
|
|
272
271
|
if (!isServerless) {
|
|
273
272
|
// In serverless mode, export @loadable components. Script tags will be
|
|
274
273
|
// auto-included in output HTML
|
|
275
|
-
return "\""
|
|
274
|
+
return "\"".concat(relative, "\": loadable(() => import(").concat(module, "))");
|
|
276
275
|
}
|
|
277
276
|
else {
|
|
278
277
|
// On non-serverless, the templates are bundled straight into the main app.
|
|
279
|
-
return "\""
|
|
278
|
+
return "\"".concat(relative, "\": ").concat(componentName);
|
|
280
279
|
}
|
|
281
280
|
})
|
|
282
|
-
.join(",\n")
|
|
281
|
+
.join(",\n"), "\n }\n "));
|
|
283
282
|
};
|
|
284
283
|
templateLookupPattern = path_1.default.resolve(opts.baseDirectory, "views/**/*.tsx");
|
|
285
284
|
if (!opts.isAdmin) return [3 /*break*/, 1];
|
|
@@ -310,31 +309,31 @@ function getWebpackConfig(opts) {
|
|
|
310
309
|
return { relative: relative, name: name, module: module, componentName: componentName };
|
|
311
310
|
});
|
|
312
311
|
if (opts.isAdmin) {
|
|
313
|
-
writeVirtualModule(ALIAS["@manifest/blocks"], "\n import coreBlocks from './blocks/_core.tsx'\n "
|
|
312
|
+
writeVirtualModule(ALIAS["@manifest/blocks"], "\n import coreBlocks from './blocks/_core.tsx'\n ".concat(!isServerless && "import loadable from '".concat(require.resolve("@loadable/component"), "';"), "\n\n export default {\n ...coreBlocks,\n ").concat(files
|
|
314
313
|
.map(function (_a) {
|
|
315
314
|
var relative = _a.relative, componentName = _a.componentName, module = _a.module;
|
|
316
315
|
var parts = relative.replace(/\.tsx$/, "").split("/");
|
|
317
316
|
var blockName = "acf/" + parts.slice(1).join("-");
|
|
318
|
-
return "\""
|
|
317
|
+
return "\"".concat(blockName, "\": loadable(() => import(").concat(module, "))");
|
|
319
318
|
})
|
|
320
|
-
.join(",\n")
|
|
319
|
+
.join(",\n"), "\n }\n "));
|
|
321
320
|
}
|
|
322
321
|
else {
|
|
323
|
-
writeVirtualModule(ALIAS["@manifest/blocks"], "\n import coreBlocks from './blocks/_core.tsx'\n\n "
|
|
322
|
+
writeVirtualModule(ALIAS["@manifest/blocks"], "\n import coreBlocks from './blocks/_core.tsx'\n\n ".concat(files
|
|
324
323
|
.map(function (_a) {
|
|
325
324
|
var relative = _a.relative, componentName = _a.componentName, module = _a.module;
|
|
326
325
|
var parts = relative.replace(/\.tsx$/, "").split("/");
|
|
327
326
|
var blockName = "acf/" + parts.slice(1).join("-");
|
|
328
|
-
return "import "
|
|
327
|
+
return "import ".concat(componentName, " from ").concat(module);
|
|
329
328
|
})
|
|
330
|
-
.join("\n")
|
|
329
|
+
.join("\n"), "\n\n export default {\n ...coreBlocks,\n ").concat(files
|
|
331
330
|
.map(function (_a) {
|
|
332
331
|
var relative = _a.relative, componentName = _a.componentName, module = _a.module;
|
|
333
332
|
var parts = relative.replace(/\.tsx$/, "").split("/");
|
|
334
333
|
var blockName = "acf/" + parts.slice(1).join("-");
|
|
335
|
-
return "\""
|
|
334
|
+
return "\"".concat(blockName, "\": ").concat(componentName);
|
|
336
335
|
})
|
|
337
|
-
.join(",\n")
|
|
336
|
+
.join(",\n"), "\n }\n "));
|
|
338
337
|
}
|
|
339
338
|
};
|
|
340
339
|
blockLookupManifest = path_1.default.resolve(opts.baseDirectory, "blocks/**/*.tsx");
|
|
@@ -373,8 +372,8 @@ function getWebpackConfig(opts) {
|
|
|
373
372
|
// chunkIds: "named",
|
|
374
373
|
},
|
|
375
374
|
output: {
|
|
376
|
-
filename: "[name]."
|
|
377
|
-
publicPath: isDev ? "//127.0.0.1:"
|
|
375
|
+
filename: "[name].".concat(opts.isAdmin ? "admin" : "frontend", ".js"),
|
|
376
|
+
publicPath: isDev ? "//127.0.0.1:".concat(opts.hotPort, "/") : "/wp-content/themes/".concat(opts.themeName, "/dist/").concat(distSuffix, "/"),
|
|
378
377
|
path: outputFolder,
|
|
379
378
|
globalObject: isSSR ? "this" : "self",
|
|
380
379
|
clean: true,
|
|
@@ -45,20 +45,20 @@ module.exports = {
|
|
|
45
45
|
var typeName = ((_a = config.getType) === null || _a === void 0 ? void 0 : _a.call(config, importedName, doc.document.definitions[0])) || importedName;
|
|
46
46
|
imports.push(importedName);
|
|
47
47
|
var key = relative.replace(/\.graphql/, "");
|
|
48
|
-
items.push(JSON.stringify(key)
|
|
48
|
+
items.push("".concat(JSON.stringify(key), ": ").concat(typeForFile(key, typeName)));
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
|
|
52
52
|
var file = files_1[_i];
|
|
53
53
|
if (!filesFound[file.replace(/\.tsx/, "")]) {
|
|
54
54
|
var key = getRelative(file).replace(/\.tsx$/, "");
|
|
55
|
-
items.push(JSON.stringify(key)
|
|
55
|
+
items.push("".concat(JSON.stringify(key), ": ").concat(typeForFile(key, "")));
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
if (imports.length === 0) {
|
|
59
59
|
process.exit();
|
|
60
60
|
return "export { };";
|
|
61
61
|
}
|
|
62
|
-
return "import { "
|
|
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 ");
|
|
63
63
|
},
|
|
64
64
|
};
|
|
@@ -5,7 +5,7 @@ module.exports = {
|
|
|
5
5
|
validate: function (schema, documents, config, info) {
|
|
6
6
|
documents.forEach(function (doc) {
|
|
7
7
|
if (doc.document.definitions.length === 0) {
|
|
8
|
-
throw new Error("GraphQL file '"
|
|
8
|
+
throw new Error("GraphQL file '".concat(doc.location, "' does not contain any uniquely named operations."));
|
|
9
9
|
process.exit();
|
|
10
10
|
}
|
|
11
11
|
});
|
|
@@ -40,7 +40,7 @@ module.exports = {
|
|
|
40
40
|
fullMessage += ":\n\n" + printedSource;
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
|
-
fullMessage += " (in "
|
|
43
|
+
fullMessage += " (in ".concat(fileName, ")");
|
|
44
44
|
}
|
|
45
45
|
var err = new Error(fullMessage);
|
|
46
46
|
err.name = "QueryError";
|
|
@@ -68,12 +68,12 @@ module.exports = {
|
|
|
68
68
|
var resultTypeName = name + (type === "mutation" ? "Mutation" : "Query");
|
|
69
69
|
// For conventions sake, the name of the operation should start with 'Use'
|
|
70
70
|
if (!name.match(/^Use/)) {
|
|
71
|
-
throwErrorAtLocation(item.name.loc, "Expected your query name to start with 'Use', but found '"
|
|
71
|
+
throwErrorAtLocation(item.name.loc, "Expected your query name to start with 'Use', but found '".concat(name, "'. Did you mean 'Use").concat(name, "'"));
|
|
72
72
|
}
|
|
73
73
|
// Another convention, the query name and file name should be the same
|
|
74
74
|
var baseName = (0, path_1.basename)(fileName);
|
|
75
75
|
if (baseName.replace(".graphql", "") !== name) {
|
|
76
|
-
throwErrorAtLocation(item.name.loc, "Expected your query name and file name to match, for conventions sake (eg. '"
|
|
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')"));
|
|
77
77
|
}
|
|
78
78
|
// Only import variables if the operation has variables
|
|
79
79
|
if (variablesTypeName) {
|
|
@@ -83,12 +83,12 @@ module.exports = {
|
|
|
83
83
|
if (type === "normal") {
|
|
84
84
|
// Just a normal query!
|
|
85
85
|
importUtils["createUseQuery"] = true;
|
|
86
|
-
hooks[hookName] = "\n createUseQuery<"
|
|
86
|
+
hooks[hookName] = "\n createUseQuery<".concat(resultTypeName, ", ").concat(variablesTypeName || "undefined", ">({\n name: ").concat(JSON.stringify(name), "\n })\n ");
|
|
87
87
|
}
|
|
88
88
|
else if (type === "mutation") {
|
|
89
89
|
// A triggerable mutation
|
|
90
90
|
importUtils["createUseMutation"] = true;
|
|
91
|
-
hooks[hookName] = "\n createUseMutation<"
|
|
91
|
+
hooks[hookName] = "\n createUseMutation<".concat(resultTypeName, ", ").concat(variablesTypeName || "undefined", ">({\n name: ").concat(JSON.stringify(name), "\n })\n ");
|
|
92
92
|
}
|
|
93
93
|
else if (type === "infinite") {
|
|
94
94
|
// Ensure the query has 'limit' and 'cursor' variables
|
|
@@ -106,13 +106,13 @@ module.exports = {
|
|
|
106
106
|
defaultLimit_1 = Number(defaultValue.value);
|
|
107
107
|
}
|
|
108
108
|
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)");
|
|
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");
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
113
113
|
// @ts-ignore
|
|
114
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 '"
|
|
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"));
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
else if (variable.name.value === "cursor") {
|
|
@@ -122,14 +122,14 @@ module.exports = {
|
|
|
122
122
|
cursorVariableIsValid_1 = true;
|
|
123
123
|
}
|
|
124
124
|
else {
|
|
125
|
-
throwErrorAtLocation(loc, "For infinite queries, the required '$cursor' variable must be an optional String.\nFor example: posts($limit: Int = 10, $cursor: String)");
|
|
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");
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
130
|
// Check that both the 'limit' and 'cursor' variables are present!
|
|
131
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) "
|
|
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"));
|
|
133
133
|
}
|
|
134
134
|
// Finally, ensure that pageInfo is queried somewhere
|
|
135
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
|
|
@@ -182,7 +182,7 @@ module.exports = {
|
|
|
182
182
|
});
|
|
183
183
|
// Make sure we found pageInfo { endCursor, hasNextPage }
|
|
184
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");
|
|
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");
|
|
186
186
|
}
|
|
187
187
|
// Look for a nodes path which shares the same parent as the pageInfo path
|
|
188
188
|
var expectedNodesPath_1 = pageInfo_1.pageInfoPath.slice(0, -1).join(",");
|
|
@@ -191,7 +191,7 @@ module.exports = {
|
|
|
191
191
|
return testPath === expectedNodesPath_1;
|
|
192
192
|
});
|
|
193
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.");
|
|
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");
|
|
195
195
|
}
|
|
196
196
|
var firstArgumentIsValid_1 = false;
|
|
197
197
|
var afterArgumentIsValid_1 = false;
|
|
@@ -214,15 +214,15 @@ module.exports = {
|
|
|
214
214
|
}
|
|
215
215
|
});
|
|
216
216
|
if (parentNode_1 && (!firstArgumentIsValid_1 || !afterArgumentIsValid_1)) {
|
|
217
|
-
throwErrorAtLocation(parentNode_1.loc, "You must use the arguments
|
|
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");
|
|
218
218
|
}
|
|
219
219
|
// Drill down to the path type
|
|
220
220
|
var finalResultTypeName_1 = resultTypeName;
|
|
221
221
|
pageInfo_1.nodesPath.forEach(function (key) {
|
|
222
|
-
finalResultTypeName_1 = "Exclude<"
|
|
222
|
+
finalResultTypeName_1 = "Exclude<".concat(finalResultTypeName_1, "[").concat(JSON.stringify(key), "], null>");
|
|
223
223
|
});
|
|
224
224
|
importUtils["createUseInfiniteQuery"] = true;
|
|
225
|
-
hooks[hookName] = "\n createUseInfiniteQuery<Exclude<"
|
|
225
|
+
hooks[hookName] = "\n createUseInfiniteQuery<Exclude<".concat(finalResultTypeName_1, "[0], 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 ");
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
228
|
}
|
|
@@ -233,15 +233,15 @@ module.exports = {
|
|
|
233
233
|
var codeBlocks = [];
|
|
234
234
|
// Import required utility functions
|
|
235
235
|
if (utilsToImport.length) {
|
|
236
|
-
codeBlocks.push("import { "
|
|
236
|
+
codeBlocks.push("import { ".concat(utilsToImport.join(", "), " } from 'eddev/hooks/queryUtils'"));
|
|
237
237
|
}
|
|
238
238
|
// Import types from types.graphql
|
|
239
239
|
if (importTypes.length) {
|
|
240
|
-
codeBlocks.push("import { "
|
|
240
|
+
codeBlocks.push("import { ".concat(importTypes, " } from '../types.graphql'"));
|
|
241
241
|
}
|
|
242
242
|
for (var hookName in hooks) {
|
|
243
243
|
var hookCode = hooks[hookName];
|
|
244
|
-
codeBlocks.push("export const "
|
|
244
|
+
codeBlocks.push("export const ".concat(hookName, " = ").concat(hookCode));
|
|
245
245
|
}
|
|
246
246
|
return codeBlocks.join("\n\n");
|
|
247
247
|
},
|
package/build/reporter.js
CHANGED
|
@@ -61,7 +61,7 @@ var ReporterPlugin = /** @class */ (function () {
|
|
|
61
61
|
// // ],
|
|
62
62
|
// })
|
|
63
63
|
var log = function (type, message, errors) {
|
|
64
|
-
var label = " "
|
|
64
|
+
var label = " ".concat(type.toUpperCase(), " (").concat(_this.title, ") ");
|
|
65
65
|
if (type === "done") {
|
|
66
66
|
label = chalk_1.default.bgGreenBright.black(label);
|
|
67
67
|
}
|