eddev 0.1.25-beta-01 → 0.1.27
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/inlineEditing.js +1 -0
- package/build/codegen-worker-script.js +34 -34
- package/build/get-webpack-config.js +5 -26
- package/build/graphql-codegen/graphql-codegen-queries.d.ts +1 -0
- package/build/graphql-codegen/graphql-codegen-queries.js +248 -0
- package/components/BrowserRouter.js +4 -2
- package/hooks/createUseQuery.d.ts +9 -0
- package/hooks/createUseQuery.js +12 -0
- package/hooks/queryUtils.d.ts +54 -0
- package/hooks/queryUtils.js +226 -0
- package/hooks/useAppData.js +0 -1
- package/hooks/useQuery.d.ts +1 -0
- package/hooks/useQuery.js +10 -0
- package/package.json +2 -3
- package/style/createStitches.d.ts +6 -5
- package/style/createStitches.js +1 -3
package/blocks/inlineEditing.js
CHANGED
|
@@ -43,6 +43,7 @@ function EditableText(_a) {
|
|
|
43
43
|
delete otherProps.disableLineBreaks;
|
|
44
44
|
delete otherProps.id;
|
|
45
45
|
delete otherProps.as;
|
|
46
|
+
delete otherProps.placeholder;
|
|
46
47
|
if (value === "" || typeof value !== "string") {
|
|
47
48
|
if (props.defaultValue) {
|
|
48
49
|
value = props.defaultValue;
|
|
@@ -95,6 +95,7 @@ var typescriptPlugin = __importStar(require("@graphql-codegen/typescript"));
|
|
|
95
95
|
var typescriptOperationsPlugin = __importStar(require("@graphql-codegen/typescript-operations"));
|
|
96
96
|
var CodegenNoDuplicates = __importStar(require("./graphql-codegen/graphql-codegen-no-duplicates"));
|
|
97
97
|
var CodegenFiles = __importStar(require("./graphql-codegen/graphql-codegen-files"));
|
|
98
|
+
var CodegenQueries = __importStar(require("./graphql-codegen/graphql-codegen-queries"));
|
|
98
99
|
var sendSignal = function (sig) {
|
|
99
100
|
if (worker_threads_1.parentPort) {
|
|
100
101
|
worker_threads_1.parentPort.postMessage(sig);
|
|
@@ -201,58 +202,43 @@ function beginWork(opts) {
|
|
|
201
202
|
documentSets = {};
|
|
202
203
|
parseErrors = [];
|
|
203
204
|
_loop_1 = function (key) {
|
|
204
|
-
var pattern, files
|
|
205
|
+
var pattern, files;
|
|
205
206
|
return __generator(this, function (_g) {
|
|
206
207
|
switch (_g.label) {
|
|
207
208
|
case 0:
|
|
208
209
|
pattern = graphqlPatterns[key];
|
|
209
|
-
|
|
210
|
-
case 1:
|
|
211
|
-
_g.trys.push([1, 4, , 5]);
|
|
210
|
+
// Find all the documents by globbing
|
|
212
211
|
documentSets[key] = [];
|
|
213
212
|
return [4 /*yield*/, (0, glob_promise_1.default)(Path.resolve(opts.baseDirectory, pattern))];
|
|
214
|
-
case
|
|
213
|
+
case 1:
|
|
215
214
|
files = _g.sent();
|
|
216
215
|
return [4 /*yield*/, Promise.all(files.map(function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
217
|
-
var contents,
|
|
216
|
+
var contents, document_1, err_3;
|
|
218
217
|
return __generator(this, function (_a) {
|
|
219
218
|
switch (_a.label) {
|
|
220
|
-
case 0:
|
|
219
|
+
case 0:
|
|
220
|
+
_a.trys.push([0, 2, , 3]);
|
|
221
|
+
return [4 /*yield*/, (0, promises_1.readFile)(file)];
|
|
221
222
|
case 1:
|
|
222
223
|
contents = (_a.sent()).toString();
|
|
223
|
-
|
|
224
|
+
document_1 = (0, graphql_1.parse)(contents);
|
|
224
225
|
documentSets[key].push({
|
|
225
|
-
document:
|
|
226
|
+
document: document_1,
|
|
226
227
|
rawSDL: contents,
|
|
227
|
-
location: file,
|
|
228
|
+
location: file,
|
|
228
229
|
});
|
|
229
|
-
return [
|
|
230
|
+
return [3 /*break*/, 3];
|
|
231
|
+
case 2:
|
|
232
|
+
err_3 = _a.sent();
|
|
233
|
+
parseErrors.push("Error parsing \"" + file.replace(opts.baseDirectory, "") + ":\n" + err_3);
|
|
234
|
+
return [3 /*break*/, 3];
|
|
235
|
+
case 3: return [2 /*return*/];
|
|
230
236
|
}
|
|
231
237
|
});
|
|
232
|
-
}); }))
|
|
233
|
-
|
|
234
|
-
// return
|
|
235
|
-
// documentSets[key] = await loadDocuments(pattern, {
|
|
236
|
-
// loaders: [new GraphQLFileLoader()],
|
|
237
|
-
// })
|
|
238
|
-
];
|
|
239
|
-
case 3:
|
|
238
|
+
}); }))];
|
|
239
|
+
case 2:
|
|
240
240
|
_g.sent();
|
|
241
|
-
|
|
242
|
-
// return
|
|
243
|
-
// documentSets[key] = await loadDocuments(pattern, {
|
|
244
|
-
// loaders: [new GraphQLFileLoader()],
|
|
245
|
-
// })
|
|
246
|
-
if (key === "views") {
|
|
247
|
-
// console.log(documentSets[key])
|
|
248
|
-
// return
|
|
249
|
-
}
|
|
250
|
-
return [3 /*break*/, 5];
|
|
251
|
-
case 4:
|
|
252
|
-
err_3 = _g.sent();
|
|
253
|
-
parseErrors.push(String(err_3));
|
|
254
|
-
return [3 /*break*/, 5];
|
|
255
|
-
case 5: return [2 /*return*/];
|
|
241
|
+
return [2 /*return*/];
|
|
256
242
|
}
|
|
257
243
|
});
|
|
258
244
|
};
|
|
@@ -363,6 +349,20 @@ function beginWork(opts) {
|
|
|
363
349
|
},
|
|
364
350
|
},
|
|
365
351
|
},
|
|
352
|
+
"hooks/queries.ts": {
|
|
353
|
+
documents: __spreadArray([], documentSets.queries, true),
|
|
354
|
+
plugins: [
|
|
355
|
+
{
|
|
356
|
+
queries: {},
|
|
357
|
+
},
|
|
358
|
+
],
|
|
359
|
+
pluginMap: {
|
|
360
|
+
queries: CodegenQueries,
|
|
361
|
+
},
|
|
362
|
+
config: {
|
|
363
|
+
rootDir: opts.baseDirectory,
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
366
|
};
|
|
367
367
|
// Notify of generation start
|
|
368
368
|
sendSignal({
|
|
@@ -95,21 +95,13 @@ 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"] = [
|
|
99
|
-
// "webpack-plugin-serve/client",
|
|
100
|
-
entryDir + "/entry.publicPath.js",
|
|
101
|
-
entryDir + "/entry.admin.dev.js",
|
|
102
|
-
];
|
|
98
|
+
ENTRY["main"] = [entryDir + "/entry.publicPath.js", entryDir + "/entry.admin.dev.js"];
|
|
103
99
|
}
|
|
104
100
|
else if (isServerless) {
|
|
105
101
|
ENTRY["main"] = [entryDir + "/entry.serverless.dev.js"];
|
|
106
102
|
}
|
|
107
103
|
else {
|
|
108
|
-
ENTRY["main"] = [
|
|
109
|
-
// "webpack-plugin-serve/client",
|
|
110
|
-
entryDir + "/entry.publicPath.js",
|
|
111
|
-
entryDir + "/entry.monolith.dev.js",
|
|
112
|
-
];
|
|
104
|
+
ENTRY["main"] = [entryDir + "/entry.publicPath.js", entryDir + "/entry.monolith.dev.js"];
|
|
113
105
|
}
|
|
114
106
|
}
|
|
115
107
|
else {
|
|
@@ -131,6 +123,7 @@ function getWebpackConfig(opts) {
|
|
|
131
123
|
ALIAS["@components"] = path_1.default.join(opts.baseDirectory, "components");
|
|
132
124
|
ALIAS["@views"] = path_1.default.join(opts.baseDirectory, "views");
|
|
133
125
|
ALIAS["@hooks"] = path_1.default.join(opts.baseDirectory, "hooks");
|
|
126
|
+
ALIAS["@queries"] = path_1.default.join(opts.baseDirectory, "hooks/queries");
|
|
134
127
|
RULES.push({
|
|
135
128
|
test: /\.[jt]sx?$/,
|
|
136
129
|
exclude: /node_modules/,
|
|
@@ -198,21 +191,6 @@ function getWebpackConfig(opts) {
|
|
|
198
191
|
},
|
|
199
192
|
},
|
|
200
193
|
},
|
|
201
|
-
// {
|
|
202
|
-
// loader: require.resolve("sass-loader"),
|
|
203
|
-
// options: {
|
|
204
|
-
// sourceMap: true,
|
|
205
|
-
// implementation: require("sass"),
|
|
206
|
-
// // prependData: (loaderContext: any) => {
|
|
207
|
-
// // const entryName = path
|
|
208
|
-
// // .basename(loaderContext.resourcePath)
|
|
209
|
-
// // .replace(/\.scss$/i, "")
|
|
210
|
-
// // return `
|
|
211
|
-
// // $bundle: ${JSON.stringify(entryName || "")};
|
|
212
|
-
// // $env: "${process.env.NODE_ENV}";
|
|
213
|
-
// // `
|
|
214
|
-
// },
|
|
215
|
-
// },
|
|
216
194
|
],
|
|
217
195
|
});
|
|
218
196
|
// Define some values
|
|
@@ -396,9 +374,10 @@ function getWebpackConfig(opts) {
|
|
|
396
374
|
},
|
|
397
375
|
output: {
|
|
398
376
|
filename: "[name]." + (opts.isAdmin ? "admin" : "frontend") + ".js",
|
|
399
|
-
publicPath: isDev ? "//127.0.0.1:" + opts.hotPort + "/" : "/wp-content/themes/" + opts.themeName + "/dist/" + distSuffix,
|
|
377
|
+
publicPath: isDev ? "//127.0.0.1:" + opts.hotPort + "/" : "/wp-content/themes/" + opts.themeName + "/dist/" + distSuffix + "/",
|
|
400
378
|
path: outputFolder,
|
|
401
379
|
globalObject: isSSR ? "this" : "self",
|
|
380
|
+
clean: true,
|
|
402
381
|
},
|
|
403
382
|
externals: __assign({ worker_threads: true }, EXTERNALS),
|
|
404
383
|
resolve: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,248 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
var graphql_1 = require("graphql");
|
|
13
|
+
var path_1 = require("path");
|
|
14
|
+
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, "");
|
|
22
|
+
if (doc.document.definitions.length) {
|
|
23
|
+
var foundQueryOperation_1 = false;
|
|
24
|
+
doc.document.definitions.forEach(function (item) {
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
// We only care about 'operations'
|
|
27
|
+
if (item.kind !== "OperationDefinition" || !item.name)
|
|
28
|
+
return;
|
|
29
|
+
function throwErrorAtLocation(loc, message) {
|
|
30
|
+
var printedSource = "";
|
|
31
|
+
if (loc && loc.source) {
|
|
32
|
+
loc.source.name = fileName;
|
|
33
|
+
printedSource = (0, graphql_1.printSourceLocation)(loc.source, {
|
|
34
|
+
line: loc.startToken.line,
|
|
35
|
+
column: loc.startToken.column,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
var fullMessage = message;
|
|
39
|
+
if (printedSource) {
|
|
40
|
+
fullMessage += ":\n\n" + printedSource;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
fullMessage += " (in " + fileName + ")";
|
|
44
|
+
}
|
|
45
|
+
var err = new Error(fullMessage);
|
|
46
|
+
err.name = "QueryError";
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
// Ensure only ONE operation per query file
|
|
50
|
+
if (foundQueryOperation_1) {
|
|
51
|
+
throwErrorAtLocation(item.loc, "Only one operation is allowed in each queries/*.graphql file");
|
|
52
|
+
}
|
|
53
|
+
foundQueryOperation_1 = true;
|
|
54
|
+
/**
|
|
55
|
+
* Determine the 'hook type'
|
|
56
|
+
* - 'mutation' if the operation starts with 'mutation' instead of 'query'
|
|
57
|
+
* - 'infinite' if the operation contains the word 'infinite'
|
|
58
|
+
* - 'normal' otherwise
|
|
59
|
+
*/
|
|
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)
|
|
64
|
+
? type === "mutation"
|
|
65
|
+
? name + "MutationVariables"
|
|
66
|
+
: name + "QueryVariables"
|
|
67
|
+
: null;
|
|
68
|
+
var resultTypeName = name + (type === "mutation" ? "Mutation" : "Query");
|
|
69
|
+
// For conventions sake, the name of the operation should start with 'Use'
|
|
70
|
+
if (!name.match(/^Use/)) {
|
|
71
|
+
throwErrorAtLocation(item.name.loc, "Expected your query name to start with 'Use', but found '" + name + "'. Did you mean 'Use" + name + "'");
|
|
72
|
+
}
|
|
73
|
+
// Another convention, the query name and file name should be the same
|
|
74
|
+
var baseName = (0, path_1.basename)(fileName);
|
|
75
|
+
if (baseName.replace(".graphql", "") !== name) {
|
|
76
|
+
throwErrorAtLocation(item.name.loc, "Expected your query name and file name to match, for conventions sake (eg. '" + baseName + "' should be '" + name + ".graphql')");
|
|
77
|
+
}
|
|
78
|
+
// Only import variables if the operation has variables
|
|
79
|
+
if (variablesTypeName) {
|
|
80
|
+
importTypes.push(variablesTypeName);
|
|
81
|
+
}
|
|
82
|
+
importTypes.push(resultTypeName);
|
|
83
|
+
if (type === "normal") {
|
|
84
|
+
// Just a normal query!
|
|
85
|
+
importUtils["createUseQuery"] = true;
|
|
86
|
+
hooks[hookName] = "\n createUseQuery<" + resultTypeName + ", " + (variablesTypeName || "undefined") + ">({\n name: " + JSON.stringify(name) + "\n })\n ";
|
|
87
|
+
}
|
|
88
|
+
else if (type === "mutation") {
|
|
89
|
+
// A triggerable mutation
|
|
90
|
+
importUtils["createUseMutation"] = true;
|
|
91
|
+
hooks[hookName] = "\n createUseMutation<" + resultTypeName + ", " + (variablesTypeName || "undefined") + ">({\n name: " + JSON.stringify(name) + "\n })\n ";
|
|
92
|
+
}
|
|
93
|
+
else if (type === "infinite") {
|
|
94
|
+
// 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") {
|
|
102
|
+
// Found 'limit', but make sure it's an Int, and has a default value
|
|
103
|
+
if (type.kind === "NamedType" && type.name.value === "Int") {
|
|
104
|
+
if (defaultValue && defaultValue.kind === "IntValue") {
|
|
105
|
+
limitVariableIsValid_1 = true;
|
|
106
|
+
defaultLimit_1 = Number(defaultValue.value);
|
|
107
|
+
}
|
|
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)");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// @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 '" + wrongType + "' instead!\nFor example: posts($limit: Int = 10, $cursor: String)");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (variable.name.value === "cursor") {
|
|
119
|
+
// Found 'cursor', but make sure it's a string
|
|
120
|
+
if (type.kind === "NamedType") {
|
|
121
|
+
if (type.name.value === "String") {
|
|
122
|
+
cursorVariableIsValid_1 = true;
|
|
123
|
+
}
|
|
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)");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
// 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) " + cursorVariableIsValid_1 + " " + limitVariableIsValid_1);
|
|
133
|
+
}
|
|
134
|
+
// Finally, ensure that pageInfo is queried somewhere
|
|
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
|
|
136
|
+
var pageInfo_1 = {
|
|
137
|
+
nodesPath: null,
|
|
138
|
+
pageInfoPath: null,
|
|
139
|
+
endCursorPath: null,
|
|
140
|
+
hasNextPagePath: null,
|
|
141
|
+
};
|
|
142
|
+
var nodesPaths_1 = [];
|
|
143
|
+
// 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;
|
|
147
|
+
(0, graphql_1.visit)(item.selectionSet, {
|
|
148
|
+
enter: function (node, key, parent, path, ancestors) {
|
|
149
|
+
if (node.kind === "Field") {
|
|
150
|
+
lookupPath_1 = __spreadArray(__spreadArray([], lookupPath_1, true), [node.name.value], false);
|
|
151
|
+
if (node.name.value === "pageInfo") {
|
|
152
|
+
parentNode_1 = ancestors[ancestors.length - 2];
|
|
153
|
+
// parentNode = ancestors
|
|
154
|
+
if (pageInfo_1.pageInfoPath) {
|
|
155
|
+
// 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!");
|
|
157
|
+
}
|
|
158
|
+
lookingAtPageInfo_1 = true;
|
|
159
|
+
pageInfo_1.pageInfoPath = lookupPath_1;
|
|
160
|
+
}
|
|
161
|
+
else if (node.name.value === "nodes") {
|
|
162
|
+
nodesPaths_1.push(lookupPath_1);
|
|
163
|
+
}
|
|
164
|
+
else if (lookingAtPageInfo_1) {
|
|
165
|
+
if (node.name.value === "endCursor") {
|
|
166
|
+
pageInfo_1.endCursorPath = lookupPath_1;
|
|
167
|
+
}
|
|
168
|
+
else if (node.name.value === "hasNextPage") {
|
|
169
|
+
pageInfo_1.hasNextPagePath = lookupPath_1;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
leave: function (node, key, parent, path, ancestors) {
|
|
175
|
+
if (node.kind === "Field") {
|
|
176
|
+
lookupPath_1 = lookupPath_1.slice(0, -1);
|
|
177
|
+
if (node.name.value === "pageInfo") {
|
|
178
|
+
lookingAtPageInfo_1 = false;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
// 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");
|
|
186
|
+
}
|
|
187
|
+
// 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;
|
|
192
|
+
});
|
|
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.");
|
|
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) {
|
|
199
|
+
if (arg.kind === "Argument") {
|
|
200
|
+
if (arg.name.value === "first") {
|
|
201
|
+
if (arg.value.kind === "Variable") {
|
|
202
|
+
if (arg.value.name.value === "limit") {
|
|
203
|
+
firstArgumentIsValid_1 = true;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (arg.name.value === "after") {
|
|
208
|
+
if (arg.value.kind === "Variable") {
|
|
209
|
+
if (arg.value.name.value === "cursor") {
|
|
210
|
+
afterArgumentIsValid_1 = true;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
});
|
|
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.");
|
|
218
|
+
}
|
|
219
|
+
// Drill down to the path type
|
|
220
|
+
var finalResultTypeName_1 = resultTypeName;
|
|
221
|
+
pageInfo_1.nodesPath.forEach(function (key) {
|
|
222
|
+
finalResultTypeName_1 = "Exclude<" + finalResultTypeName_1 + "[" + JSON.stringify(key) + "], null>";
|
|
223
|
+
});
|
|
224
|
+
importUtils["createUseInfiniteQuery"] = true;
|
|
225
|
+
hooks[hookName] = "\n createUseInfiniteQuery<Exclude<" + finalResultTypeName_1 + "[0], null>, Omit<" + (variablesTypeName || "undefined") + ", 'limit' | 'cursor'>>({\n name: " + JSON.stringify(name) + ",\n defaultLimit: " + defaultLimit_1 + ",\n paths: " + JSON.stringify(pageInfo_1) + "\n })\n ";
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
var utilsToImport = Object.keys(importUtils);
|
|
231
|
+
if (!utilsToImport)
|
|
232
|
+
return "export {}";
|
|
233
|
+
var codeBlocks = [];
|
|
234
|
+
// Import required utility functions
|
|
235
|
+
if (utilsToImport.length) {
|
|
236
|
+
codeBlocks.push("import { " + utilsToImport.join(", ") + " } from 'eddev/hooks/queryUtils'");
|
|
237
|
+
}
|
|
238
|
+
// Import types from types.graphql
|
|
239
|
+
if (importTypes.length) {
|
|
240
|
+
codeBlocks.push("import { " + importTypes + " } from '../types.graphql'");
|
|
241
|
+
}
|
|
242
|
+
for (var hookName in hooks) {
|
|
243
|
+
var hookCode = hooks[hookName];
|
|
244
|
+
codeBlocks.push("export const " + hookName + " = " + hookCode);
|
|
245
|
+
}
|
|
246
|
+
return codeBlocks.join("\n\n");
|
|
247
|
+
},
|
|
248
|
+
};
|
|
@@ -24,6 +24,7 @@ var views_1 = __importDefault(require("@manifest/views"));
|
|
|
24
24
|
var usePageLoad_1 = require("../hooks/usePageLoad");
|
|
25
25
|
var hooks_1 = require("../hooks");
|
|
26
26
|
var reportErrorStack_1 = require("../utils/reportErrorStack");
|
|
27
|
+
var hasPopulatedCache = false;
|
|
27
28
|
function BrowserRouter(props) {
|
|
28
29
|
var setAppData = (0, hooks_1.useAppDataStore)(function (s) { return s.setAppData; });
|
|
29
30
|
var _a = (0, react_1.useState)(function () { return document.location.href; }), url = _a[0], setUrl = _a[1];
|
|
@@ -38,9 +39,10 @@ function BrowserRouter(props) {
|
|
|
38
39
|
(0, reportErrorStack_1.reportErrorStack)(data.errorStack);
|
|
39
40
|
}
|
|
40
41
|
}, [data]);
|
|
41
|
-
|
|
42
|
+
if (!hasPopulatedCache) {
|
|
43
|
+
hasPopulatedCache = true;
|
|
42
44
|
(0, remoteProps_1.setInitialProps)(url, data);
|
|
43
|
-
}
|
|
45
|
+
}
|
|
44
46
|
(0, react_1.useEffect)(function () {
|
|
45
47
|
var handle = function (e) {
|
|
46
48
|
setPendingUrl({ popped: true, url: document.location.href });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare type CreateUseQueryOptions = {
|
|
2
|
+
name: string;
|
|
3
|
+
};
|
|
4
|
+
export declare function createUseQuery<TReturn extends any, TVars extends {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
} | undefined>(opts: CreateUseQueryOptions): void;
|
|
7
|
+
export declare function createUseInfiniteQuery(): void;
|
|
8
|
+
export declare function createUseMutation(): void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createUseMutation = exports.createUseInfiniteQuery = exports.createUseQuery = void 0;
|
|
4
|
+
function createUseQuery(opts) {
|
|
5
|
+
// return (opts: QueryOptions) => {
|
|
6
|
+
// }
|
|
7
|
+
}
|
|
8
|
+
exports.createUseQuery = createUseQuery;
|
|
9
|
+
function createUseInfiniteQuery() { }
|
|
10
|
+
exports.createUseInfiniteQuery = createUseInfiniteQuery;
|
|
11
|
+
function createUseMutation() { }
|
|
12
|
+
exports.createUseMutation = createUseMutation;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Generic Error */
|
|
2
|
+
declare type GraphQLError = {
|
|
3
|
+
message: string;
|
|
4
|
+
};
|
|
5
|
+
/** Regular queries */
|
|
6
|
+
declare type CreateUseQueryOptions = {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
declare type QueryOptions = {};
|
|
10
|
+
declare type MaybeVars = {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
} | undefined;
|
|
13
|
+
declare type QueryHookReturn<TReturn, TVars> = {
|
|
14
|
+
loading: boolean;
|
|
15
|
+
errors?: GraphQLError[];
|
|
16
|
+
data?: TReturn;
|
|
17
|
+
refresh: (vars?: TVars) => void;
|
|
18
|
+
};
|
|
19
|
+
declare type QueryHook<TReturn, TVars> = TVars extends undefined ? (vars?: TVars, opts?: QueryOptions) => QueryHookReturn<TReturn, TVars> : (vars: TVars, opts?: QueryOptions) => QueryHookReturn<TReturn, TVars>;
|
|
20
|
+
export declare function createUseQuery<TReturn extends any, TVars extends MaybeVars>(init: CreateUseQueryOptions): QueryHook<TReturn, TVars>;
|
|
21
|
+
/** Infinite queries */
|
|
22
|
+
declare type CreateUseInfiniteQueryOptions = {
|
|
23
|
+
name: string;
|
|
24
|
+
defaultLimit: number;
|
|
25
|
+
paths: {
|
|
26
|
+
nodesPath: string[];
|
|
27
|
+
pageInfoPath: string[];
|
|
28
|
+
endCursorPath: string[];
|
|
29
|
+
hasNextPagePath: string[];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
declare type InfiniteQueryHookReturn<TItem, TVars> = {
|
|
33
|
+
loading: boolean;
|
|
34
|
+
loadingMore: boolean;
|
|
35
|
+
errors?: GraphQLError[];
|
|
36
|
+
items?: TItem[];
|
|
37
|
+
hasMore?: boolean;
|
|
38
|
+
canLoadMore?: boolean;
|
|
39
|
+
refresh: (vars?: TVars) => void;
|
|
40
|
+
loadMore: () => void;
|
|
41
|
+
};
|
|
42
|
+
declare type InfiniteQueryHasAdditionalVars<TVars> = Exclude<keyof TVars, "limit" | "cursor"> extends never ? false : true;
|
|
43
|
+
declare type InfiniteQueryHook<TItem, TVars> = InfiniteQueryHasAdditionalVars<TVars> extends false ? (vars?: TVars, opts?: QueryOptions) => InfiniteQueryHookReturn<TItem, TVars> : (vars: TVars, opts?: QueryOptions) => InfiniteQueryHookReturn<TItem, TVars>;
|
|
44
|
+
export declare function createUseInfiniteQuery<TItem, TVars extends MaybeVars>(init: CreateUseInfiniteQueryOptions): InfiniteQueryHook<TItem, TVars>;
|
|
45
|
+
declare type MutationHookReturn<TReturn, TVars> = {
|
|
46
|
+
submitting: boolean;
|
|
47
|
+
submitted: boolean;
|
|
48
|
+
errors?: GraphQLError[];
|
|
49
|
+
data?: TReturn;
|
|
50
|
+
submit: (vars: TVars) => void;
|
|
51
|
+
};
|
|
52
|
+
declare type MutationHook<TReturn, TVars> = (opts?: QueryOptions) => MutationHookReturn<TReturn, TVars>;
|
|
53
|
+
export declare function createUseMutation<TReturn extends any, TVars extends MaybeVars>(init: CreateUseQueryOptions): MutationHook<TReturn, TVars>;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
58
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.createUseMutation = exports.createUseInfiniteQuery = exports.createUseQuery = void 0;
|
|
63
|
+
var react_1 = require("react");
|
|
64
|
+
var swr_1 = __importDefault(require("swr"));
|
|
65
|
+
/** Generic fetcher functions */
|
|
66
|
+
var fetcherGET = function (name, params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
67
|
+
var url, result, payload;
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
switch (_a.label) {
|
|
70
|
+
case 0:
|
|
71
|
+
url = "/wp-json/ed/v1/query/" + name;
|
|
72
|
+
if (params)
|
|
73
|
+
url += "?params=" + encodeURIComponent(params);
|
|
74
|
+
return [4 /*yield*/, fetch(url, {})];
|
|
75
|
+
case 1:
|
|
76
|
+
result = _a.sent();
|
|
77
|
+
return [4 /*yield*/, result.json()];
|
|
78
|
+
case 2:
|
|
79
|
+
payload = _a.sent();
|
|
80
|
+
return [2 /*return*/, payload];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}); };
|
|
84
|
+
function createUseQuery(init) {
|
|
85
|
+
var hook = function (vars, opts) {
|
|
86
|
+
var _a = (0, swr_1.default)([init.name, JSON.stringify(vars)], fetcherGET, {
|
|
87
|
+
revalidateIfStale: false,
|
|
88
|
+
}), payload = _a.data, isValidating = _a.isValidating, error = _a.error, mutate = _a.mutate;
|
|
89
|
+
return {
|
|
90
|
+
loading: isValidating && !payload,
|
|
91
|
+
data: payload === null || payload === void 0 ? void 0 : payload.data,
|
|
92
|
+
errors: error ? [error] : payload === null || payload === void 0 ? void 0 : payload.errors,
|
|
93
|
+
refresh: mutate,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
return hook;
|
|
97
|
+
}
|
|
98
|
+
exports.createUseQuery = createUseQuery;
|
|
99
|
+
function createUseInfiniteQuery(init) {
|
|
100
|
+
var extract = function (path, payload) {
|
|
101
|
+
var value = payload;
|
|
102
|
+
for (var _i = 0, path_1 = path; _i < path_1.length; _i++) {
|
|
103
|
+
var segment = path_1[_i];
|
|
104
|
+
value = value[segment];
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
};
|
|
108
|
+
var hook = function (vars, opts) {
|
|
109
|
+
var _a = (0, react_1.useState)(), activeCursor = _a[0], setActiveCursor = _a[1];
|
|
110
|
+
var _b = (0, react_1.useState)(), errors = _b[0], setErrors = _b[1];
|
|
111
|
+
var _c = (0, react_1.useState)(undefined), nextCursor = _c[0], setNextCursor = _c[1];
|
|
112
|
+
var _d = (0, react_1.useState)(false), hasMore = _d[0], setHasMore = _d[1];
|
|
113
|
+
var _e = (0, react_1.useState)(true), isLoadingMore = _e[0], setIsLoadingMore = _e[1];
|
|
114
|
+
var _f = (0, react_1.useState)([]), items = _f[0], setItems = _f[1];
|
|
115
|
+
var _g = (0, swr_1.default)([
|
|
116
|
+
init.name,
|
|
117
|
+
JSON.stringify(__assign(__assign({}, (vars || {})), { cursor: activeCursor })),
|
|
118
|
+
], fetcherGET, {
|
|
119
|
+
revalidateIfStale: false,
|
|
120
|
+
revalidateOnFocus: false,
|
|
121
|
+
revalidateOnReconnect: false,
|
|
122
|
+
}), payload = _g.data, isValidating = _g.isValidating, error = _g.error, mutate = _g.mutate;
|
|
123
|
+
(0, react_1.useEffect)(function () {
|
|
124
|
+
if (payload) {
|
|
125
|
+
console.log("Got payload", payload);
|
|
126
|
+
setIsLoadingMore(false);
|
|
127
|
+
if (payload.errors) {
|
|
128
|
+
setErrors(payload.errors);
|
|
129
|
+
}
|
|
130
|
+
else if (payload.data) {
|
|
131
|
+
// Extract data
|
|
132
|
+
var nodes_1 = extract(init.paths.nodesPath, payload.data);
|
|
133
|
+
var nextCursor_1 = extract(init.paths.endCursorPath, payload.data);
|
|
134
|
+
var hasMore_1 = extract(init.paths.hasNextPagePath, payload.data);
|
|
135
|
+
setErrors(undefined);
|
|
136
|
+
setNextCursor(nextCursor_1);
|
|
137
|
+
setHasMore(hasMore_1);
|
|
138
|
+
setItems(function () { return __spreadArray(__spreadArray([], items, true), nodes_1, true); });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}, [payload]);
|
|
142
|
+
return {
|
|
143
|
+
loading: isValidating && !items.length,
|
|
144
|
+
loadingMore: isLoadingMore,
|
|
145
|
+
items: items,
|
|
146
|
+
errors: error ? [error] : errors,
|
|
147
|
+
refresh: function () {
|
|
148
|
+
setErrors(undefined);
|
|
149
|
+
setNextCursor(undefined);
|
|
150
|
+
setActiveCursor(undefined);
|
|
151
|
+
setIsLoadingMore(false);
|
|
152
|
+
mutate();
|
|
153
|
+
},
|
|
154
|
+
loadMore: function () {
|
|
155
|
+
if (isLoadingMore || !hasMore)
|
|
156
|
+
return;
|
|
157
|
+
setIsLoadingMore(true);
|
|
158
|
+
setActiveCursor(nextCursor);
|
|
159
|
+
},
|
|
160
|
+
hasMore: hasMore,
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
return hook;
|
|
164
|
+
}
|
|
165
|
+
exports.createUseInfiniteQuery = createUseInfiniteQuery;
|
|
166
|
+
function createUseMutation(init) {
|
|
167
|
+
var _this = this;
|
|
168
|
+
var hook = function (opts) {
|
|
169
|
+
var _a = (0, react_1.useState)(false), submitting = _a[0], setSubmitting = _a[1];
|
|
170
|
+
var _b = (0, react_1.useState)(false), submitted = _b[0], setSubmitted = _b[1];
|
|
171
|
+
var _c = (0, react_1.useState)(undefined), data = _c[0], setData = _c[1];
|
|
172
|
+
var _d = (0, react_1.useState)(), errors = _d[0], setErrors = _d[1];
|
|
173
|
+
var submit = function (params) { return __awaiter(_this, void 0, void 0, function () {
|
|
174
|
+
var url, result, payload, error_1;
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
switch (_a.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
setSubmitting(true);
|
|
179
|
+
setSubmitted(false);
|
|
180
|
+
url = "/wp-json/ed/v1/mutation/" + init.name;
|
|
181
|
+
_a.label = 1;
|
|
182
|
+
case 1:
|
|
183
|
+
_a.trys.push([1, 4, , 5]);
|
|
184
|
+
return [4 /*yield*/, fetch(url, {
|
|
185
|
+
method: "POST",
|
|
186
|
+
headers: {
|
|
187
|
+
"Content-type": "application/json",
|
|
188
|
+
},
|
|
189
|
+
credentials: "include",
|
|
190
|
+
body: JSON.stringify(params),
|
|
191
|
+
})];
|
|
192
|
+
case 2:
|
|
193
|
+
result = _a.sent();
|
|
194
|
+
return [4 /*yield*/, result.json()];
|
|
195
|
+
case 3:
|
|
196
|
+
payload = _a.sent();
|
|
197
|
+
if (payload.errors) {
|
|
198
|
+
setErrors(payload.errors);
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
setData(payload.data);
|
|
202
|
+
setSubmitted(true);
|
|
203
|
+
setErrors(undefined);
|
|
204
|
+
}
|
|
205
|
+
return [3 /*break*/, 5];
|
|
206
|
+
case 4:
|
|
207
|
+
error_1 = _a.sent();
|
|
208
|
+
setErrors([error_1]);
|
|
209
|
+
return [2 /*return*/];
|
|
210
|
+
case 5:
|
|
211
|
+
setSubmitting(false);
|
|
212
|
+
return [2 /*return*/];
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}); };
|
|
216
|
+
return {
|
|
217
|
+
submitting: submitting,
|
|
218
|
+
submitted: submitted,
|
|
219
|
+
data: data,
|
|
220
|
+
errors: errors,
|
|
221
|
+
submit: submit,
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
return hook;
|
|
225
|
+
}
|
|
226
|
+
exports.createUseMutation = createUseMutation;
|
package/hooks/useAppData.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eddev",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"@types/rimraf": "^3.0.2",
|
|
24
24
|
"@types/url-parse": "^1.4.4",
|
|
25
25
|
"@types/webpack-dev-server": "^3.11.2",
|
|
26
|
-
"@types/webpack-plugin-serve": "^1.4.1",
|
|
27
26
|
"csstype": "^3.0.9",
|
|
28
27
|
"react-html-props": "^1.0.32"
|
|
29
28
|
},
|
|
@@ -79,13 +78,13 @@
|
|
|
79
78
|
"react-merge-refs": "^1.1.0",
|
|
80
79
|
"react-refresh": "^0.10.0",
|
|
81
80
|
"rimraf": "^3.0.2",
|
|
81
|
+
"swr": "^1.0.1",
|
|
82
82
|
"typescript": "^4.4.2",
|
|
83
83
|
"url-parse": "^1.5.3",
|
|
84
84
|
"webpack": "^5.52.0",
|
|
85
85
|
"webpack-bundle-analyzer": "^4.5.0",
|
|
86
86
|
"webpack-dev-server": "^3.11.2",
|
|
87
87
|
"webpack-hot-middleware": "^2.25.0",
|
|
88
|
-
"webpack-plugin-serve": "^1.5.0",
|
|
89
88
|
"webpack-virtual-modules": "^0.4.3",
|
|
90
89
|
"zustand": "^3.5.10"
|
|
91
90
|
},
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { DefaultThemeMap } from "@stitches/react";
|
|
3
2
|
import { ConfigType } from "@stitches/core/types/config";
|
|
4
3
|
import { Properties as CSS } from "csstype";
|
|
@@ -13,6 +12,8 @@ declare type TypographyConfig<Theme extends ConfigType.Theme<{}>, Media extends
|
|
|
13
12
|
fontSize?: ResponsiveValue<Media, Theme["fontSizes"] extends {} ? `$${Extract<keyof Theme["fontSizes"], string>}` | CSS["fontSize"] : CSS["fontSize"]>;
|
|
14
13
|
textTransform?: CSS["textTransform"];
|
|
15
14
|
fontWeight?: CSS["fontWeight"];
|
|
15
|
+
wordSpacing?: CSS["wordSpacing"];
|
|
16
|
+
letterSpacing?: CSS["letterSpacing"];
|
|
16
17
|
lineHeight?: ResponsiveValue<Media, Theme["lineHeights"] extends {} ? `$${Extract<keyof Theme["lineHeights"], string>}` | CSS["lineHeight"] : CSS["lineHeight"]>;
|
|
17
18
|
};
|
|
18
19
|
};
|
|
@@ -585,7 +586,7 @@ export declare function createStitches<Prefix extends string = "", Media extends
|
|
|
585
586
|
} & { [Scale_4 in keyof (Theme & { [Scale_1 in keyof Responsive]: { [T_1 in keyof Responsive[Scale_1]]: string; }; })]: { [Token_2 in keyof (Theme & { [Scale_1 in keyof Responsive]: { [T_1 in keyof Responsive[Scale_1]]: string; }; })[Scale_4]]: import("@stitches/react/types/theme").Token<Extract<Token_2, string | number>, string, Extract<Scale_4, string | void>, "">; }; };
|
|
586
587
|
reset: () => void;
|
|
587
588
|
getCssText: () => string;
|
|
588
|
-
css: <Composers extends (string | import("react").
|
|
589
|
+
css: <Composers extends (string | import("@stitches/react/types/util").Function | import("react").ExoticComponent<any> | import("react").JSXElementConstructor<any> | {
|
|
589
590
|
[name: string]: unknown;
|
|
590
591
|
})[], CSS_1 = import("@stitches/react/types/css-util").CSS<{
|
|
591
592
|
initial: "";
|
|
@@ -708,7 +709,7 @@ export declare function createStitches<Prefix extends string = "", Media extends
|
|
|
708
709
|
gridColumn: string;
|
|
709
710
|
"--grid-columns": number;
|
|
710
711
|
};
|
|
711
|
-
}>>(...composers: { [K_1 in keyof Composers]: Composers[K_1] extends string | import("react").
|
|
712
|
+
}>>(...composers: { [K_1 in keyof Composers]: Composers[K_1] extends string | import("@stitches/react/types/util").Function | import("react").ExoticComponent<any> | import("react").JSXElementConstructor<any> ? Composers[K_1] : import("@stitches/react/types/stitches").RemoveIndex<CSS_1> & {
|
|
712
713
|
variants?: {
|
|
713
714
|
[x: string]: {
|
|
714
715
|
[x: string]: CSS_1;
|
|
@@ -722,7 +723,7 @@ export declare function createStitches<Prefix extends string = "", Media extends
|
|
|
722
723
|
} & CSS_1 & { [K2 in keyof Composers[K_1]]: K2 extends "compoundVariants" | "defaultVariants" | "variants" ? unknown : K2 extends keyof CSS_1 ? CSS_1[K2] : unknown; }; }) => import("@stitches/react/types/styled-component").CssComponent<import("@stitches/react/types/styled-component").StyledComponentType<Composers>, import("@stitches/react/types/styled-component").StyledComponentProps<Composers>, {
|
|
723
724
|
initial: "";
|
|
724
725
|
} & Media, CSS_1>;
|
|
725
|
-
styled: <Type extends import("react").
|
|
726
|
+
styled: <Type extends import("@stitches/react/types/util").Function | keyof JSX.IntrinsicElements | import("react").ComponentType<any>, Composers_1 extends (string | import("@stitches/react/types/util").Function | import("react").ComponentType<any> | {
|
|
726
727
|
[name: string]: unknown;
|
|
727
728
|
})[], CSS_2 = import("@stitches/react/types/css-util").CSS<{
|
|
728
729
|
initial: "";
|
|
@@ -845,7 +846,7 @@ export declare function createStitches<Prefix extends string = "", Media extends
|
|
|
845
846
|
gridColumn: string;
|
|
846
847
|
"--grid-columns": number;
|
|
847
848
|
};
|
|
848
|
-
}>>(type: Type, ...composers: { [K_2 in keyof Composers_1]: Composers_1[K_2] extends string | import("react").
|
|
849
|
+
}>>(type: Type, ...composers: { [K_2 in keyof Composers_1]: Composers_1[K_2] extends string | import("@stitches/react/types/util").Function | import("react").ComponentType<any> ? Composers_1[K_2] : import("@stitches/react/types/stitches").RemoveIndex<CSS_2> & {
|
|
849
850
|
variants?: {
|
|
850
851
|
[x: string]: {
|
|
851
852
|
[x: string]: CSS_2;
|
package/style/createStitches.js
CHANGED
|
@@ -155,9 +155,7 @@ function parseResponsiveObject(theme, breakpoints, object, varName, scale) {
|
|
|
155
155
|
var _a;
|
|
156
156
|
// Util for grabbing the raw value of a token, for lerping
|
|
157
157
|
var resolveValue = function (value) {
|
|
158
|
-
if (typeof value === "string" &&
|
|
159
|
-
value.match(/^\$[a-z0-9\-\_]+$/) &&
|
|
160
|
-
scale) {
|
|
158
|
+
if (typeof value === "string" && value.match(/^\$[a-z0-9\-\_]+$/) && scale) {
|
|
161
159
|
// Single scale
|
|
162
160
|
return theme[scale][value.replace("$", "")];
|
|
163
161
|
}
|