@dusted/anqst 1.7.1 → 1.7.3
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/AnQstWebBase/AnQstWebBaseAbi.cmake +1 -0
- package/AnQstWebBase/CMakeLists.txt +116 -0
- package/AnQstWebBase/CMakeUserPresets.json +14 -0
- package/AnQstWebBase/README.md +65 -0
- package/AnQstWebBase/src/AnQstBase93.cpp +91 -0
- package/AnQstWebBase/src/AnQstBase93.h +15 -0
- package/AnQstWebBase/src/AnQstBridgeProxy.cpp +30 -0
- package/AnQstWebBase/src/AnQstBridgeProxy.h +41 -0
- package/AnQstWebBase/src/AnQstHostBridgeFacade.cpp +345 -0
- package/AnQstWebBase/src/AnQstHostBridgeFacade.h +99 -0
- package/AnQstWebBase/src/AnQstWebBaseAbi.h +4 -0
- package/AnQstWebBase/src/AnQstWebBaseAbi.h.in +4 -0
- package/AnQstWebBase/src/AnQstWebHostBase.cpp +1822 -0
- package/AnQstWebBase/src/AnQstWebHostBase.h +227 -0
- package/AnQstWebBase/src/AnQstWidgetDebugDialog.cpp +425 -0
- package/AnQstWebBase/src/AnQstWidgetDebugDialog.h +105 -0
- package/AnQstWebBase/src/AngularHttpBaseServer.cpp +965 -0
- package/AnQstWebBase/src/AngularHttpBaseServer.h +97 -0
- package/AnQstWebBase/src/UI/AnQstWidgetDebugDialog.ui +235 -0
- package/AnQstWebBase/tests/CMakeLists.txt +22 -0
- package/AnQstWebBase/tests/test_AnQstWebHostBase.cpp +1102 -0
- package/dist/src/abi-hash-stamp.js +5 -0
- package/dist/src/abi-hash.js +33 -0
- package/dist/src/app.js +67 -19
- package/dist/src/boundary-codec-render.js +17 -10
- package/dist/src/emit.js +76 -30
- package/dist/src/project.js +11 -1
- package/dist/src/webbase.js +94 -0
- package/package.json +2 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ANQST_WEBBASE_ABI_HASH_STAMP = void 0;
|
|
4
|
+
// Generated by scripts/build-with-stamp.js. Do not edit by hand.
|
|
5
|
+
exports.ANQST_WEBBASE_ABI_HASH_STAMP = "_da43ea0d526e8ac0a869ccc79976519d2566b40d8b97a12bddfa2aaaac5304f6";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAnQstWebBaseAbiHashStamp = resolveAnQstWebBaseAbiHashStamp;
|
|
4
|
+
exports.anqstWebBaseTargetName = anqstWebBaseTargetName;
|
|
5
|
+
exports.anqstWebBaseNamespaceName = anqstWebBaseNamespaceName;
|
|
6
|
+
const abi_hash_stamp_1 = require("./abi-hash-stamp");
|
|
7
|
+
let resolvedLocalStamp;
|
|
8
|
+
function isValidAbiHashStamp(value) {
|
|
9
|
+
return /^_[A-Za-z0-9_]+$/.test(value);
|
|
10
|
+
}
|
|
11
|
+
function resolveLocalAbiHashStamp() {
|
|
12
|
+
if (!resolvedLocalStamp) {
|
|
13
|
+
resolvedLocalStamp = `_local_${Math.floor(Date.now() / 1000)}`;
|
|
14
|
+
}
|
|
15
|
+
return resolvedLocalStamp;
|
|
16
|
+
}
|
|
17
|
+
function resolveAnQstWebBaseAbiHashStamp() {
|
|
18
|
+
const fromEnv = process.env.ANQST_WEBBASE_ABI_HASH_STAMP?.trim();
|
|
19
|
+
if (fromEnv && isValidAbiHashStamp(fromEnv)) {
|
|
20
|
+
return fromEnv;
|
|
21
|
+
}
|
|
22
|
+
const generated = abi_hash_stamp_1.ANQST_WEBBASE_ABI_HASH_STAMP.trim();
|
|
23
|
+
if (generated && generated !== "_local_0" && isValidAbiHashStamp(generated)) {
|
|
24
|
+
return generated;
|
|
25
|
+
}
|
|
26
|
+
return resolveLocalAbiHashStamp();
|
|
27
|
+
}
|
|
28
|
+
function anqstWebBaseTargetName(stamp = resolveAnQstWebBaseAbiHashStamp()) {
|
|
29
|
+
return `anqstwebhost${stamp}`;
|
|
30
|
+
}
|
|
31
|
+
function anqstWebBaseNamespaceName(stamp = resolveAnQstWebBaseAbiHashStamp()) {
|
|
32
|
+
return `anqstwebbase${stamp}`;
|
|
33
|
+
}
|
package/dist/src/app.js
CHANGED
|
@@ -19,6 +19,8 @@ const project_1 = require("./project");
|
|
|
19
19
|
const layout_1 = require("./layout");
|
|
20
20
|
const parser_1 = require("./parser");
|
|
21
21
|
const verify_1 = require("./verify");
|
|
22
|
+
const webbase_1 = require("./webbase");
|
|
23
|
+
const abi_hash_1 = require("./abi-hash");
|
|
22
24
|
class CliUsageError extends Error {
|
|
23
25
|
constructor(message) {
|
|
24
26
|
super(message);
|
|
@@ -45,13 +47,16 @@ function renderHelp() {
|
|
|
45
47
|
"Commands:",
|
|
46
48
|
" instill <WidgetName> Initialize AnQst in current npm project",
|
|
47
49
|
" test Verify AnQst spec from package settings",
|
|
48
|
-
" build [--designerplugin[=true|false]] Generate artifacts from package settings",
|
|
50
|
+
" build [--designerplugin[=true|false]] [--noShared|--useShared] Generate artifacts from package settings",
|
|
49
51
|
" generate <specFile> Generate artifacts from explicit spec file",
|
|
50
52
|
" verify <specFile> Verify explicit spec file only",
|
|
51
53
|
" clean <path> [-f|--force] Remove generated artifacts under path",
|
|
52
54
|
"",
|
|
53
55
|
"Options:",
|
|
56
|
+
" --writeSharedBaseWidget Write bundled AnQstWebBase to ./AnQstWebBase and exit",
|
|
54
57
|
" --designerplugin Build Qt Designer plugin (build command only, QWidget target required)",
|
|
58
|
+
" --noShared Vendor AnQstWebBase for this build, overriding settings",
|
|
59
|
+
" --useShared Require shared AnQstWebBase for this build, overriding settings",
|
|
55
60
|
" -h, --help Show this help output",
|
|
56
61
|
" -v, --version Print CLI version"
|
|
57
62
|
].join("\n");
|
|
@@ -60,7 +65,7 @@ function usageFor(command) {
|
|
|
60
65
|
if (command === "instill")
|
|
61
66
|
return "Usage: anqst instill <WidgetName>";
|
|
62
67
|
if (command === "build")
|
|
63
|
-
return "Usage: anqst build [--designerplugin[=true|false]]";
|
|
68
|
+
return "Usage: anqst build [--designerplugin[=true|false]] [--noShared|--useShared]";
|
|
64
69
|
if (command === "verify")
|
|
65
70
|
return "Usage: anqst verify <specFile>";
|
|
66
71
|
if (command === "generate")
|
|
@@ -143,10 +148,10 @@ function runGenerate(specArg) {
|
|
|
143
148
|
const verification = (0, verify_1.verifySpec)(parsed);
|
|
144
149
|
const generationTargets = resolveGenerationTargetsFromCwd(cwd);
|
|
145
150
|
resetGeneratedTargets(cwd, parsed.widgetName, generationTargets);
|
|
146
|
-
const outputs = (0, emit_1.generateOutputs)(parsed, generationTargets);
|
|
151
|
+
const outputs = (0, emit_1.generateOutputs)(parsed, { ...generationTargets, useSharedBaseWidget: true });
|
|
147
152
|
(0, emit_1.writeGeneratedOutputs)(cwd, outputs);
|
|
148
153
|
if (generationTargets.emitQWidget) {
|
|
149
|
-
(0, emit_1.installQtIntegrationCMake)(cwd, parsed.widgetName);
|
|
154
|
+
(0, emit_1.installQtIntegrationCMake)(cwd, parsed.widgetName, { useSharedBaseWidget: true });
|
|
150
155
|
}
|
|
151
156
|
return {
|
|
152
157
|
success: true,
|
|
@@ -163,14 +168,11 @@ function runTest(cwd) {
|
|
|
163
168
|
message: verification.message
|
|
164
169
|
};
|
|
165
170
|
}
|
|
166
|
-
function resolveAnQstGenRoot() {
|
|
167
|
-
return node_path_1.default.resolve(__dirname, "..", "..");
|
|
168
|
-
}
|
|
169
171
|
function readActiveBuildStamp() {
|
|
170
172
|
if (process.env.ANQST_BUILD_STAMP && process.env.ANQST_BUILD_STAMP.trim().length > 0) {
|
|
171
173
|
return process.env.ANQST_BUILD_STAMP.trim();
|
|
172
174
|
}
|
|
173
|
-
const activePath = node_path_1.default.join(resolveAnQstGenRoot(), ANQSTGEN_ACTIVE_STAMP_FILE);
|
|
175
|
+
const activePath = node_path_1.default.join((0, webbase_1.resolveAnQstGenRoot)(), ANQSTGEN_ACTIVE_STAMP_FILE);
|
|
174
176
|
if (!node_fs_1.default.existsSync(activePath)) {
|
|
175
177
|
return "unknown_build_0";
|
|
176
178
|
}
|
|
@@ -185,13 +187,34 @@ function readActiveBuildStamp() {
|
|
|
185
187
|
}
|
|
186
188
|
return "unknown_build_0";
|
|
187
189
|
}
|
|
188
|
-
function
|
|
190
|
+
function writeSharedBaseWidgetFromPackage(cwd) {
|
|
191
|
+
const targetDir = node_path_1.default.join(cwd, webbase_1.ANQST_WEBBASE_DIR_NAME);
|
|
192
|
+
if (node_fs_1.default.existsSync(targetDir)) {
|
|
193
|
+
console.error("Refusing to overwrite existing AnQstWebBase, delete it and run again.");
|
|
194
|
+
return 1;
|
|
195
|
+
}
|
|
196
|
+
try {
|
|
197
|
+
(0, webbase_1.copyAnQstWebBaseTree)((0, webbase_1.resolveAnQstWebBaseSourceDir)(), targetDir);
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
node_fs_1.default.rmSync(targetDir, { recursive: true, force: true });
|
|
201
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
202
|
+
console.error(`Failed to write AnQstWebBase to ${cwd}: ${reason}`);
|
|
203
|
+
return 1;
|
|
204
|
+
}
|
|
205
|
+
console.log(`AnQstWebBase written to ${(0, layout_1.normalizeSlashes)(targetDir)}`);
|
|
206
|
+
return 0;
|
|
207
|
+
}
|
|
208
|
+
function runDesignerPluginBuild(cwd, widgetName, useSharedBaseWidget) {
|
|
189
209
|
const layout = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, widgetName);
|
|
190
210
|
const pluginSourceDir = layout.designerPluginRoot;
|
|
191
211
|
const pluginBuildDir = layout.designerPluginBuildRoot;
|
|
192
|
-
const webBaseDir = process.env.ANQST_WEBBASE_DIR?.trim()
|
|
193
|
-
|
|
194
|
-
|
|
212
|
+
const webBaseDir = process.env.ANQST_WEBBASE_DIR?.trim()
|
|
213
|
+
|| (useSharedBaseWidget
|
|
214
|
+
? (0, webbase_1.resolveAnQstWebBaseSourceDir)()
|
|
215
|
+
: node_path_1.default.join(layout.cppQtWidgetRoot, webbase_1.ANQST_WEBBASE_DIR_NAME));
|
|
216
|
+
if (!node_fs_1.default.existsSync(node_path_1.default.join(webBaseDir, "CMakeLists.txt"))) {
|
|
217
|
+
throw new errors_1.VerifyError(`Unable to locate AnQstWebBase sources for --designerplugin build at '${(0, layout_1.normalizeSlashes)(webBaseDir)}'.`);
|
|
195
218
|
}
|
|
196
219
|
const configureArgs = [
|
|
197
220
|
"-S",
|
|
@@ -221,13 +244,14 @@ function runDesignerPluginBuild(cwd, widgetName) {
|
|
|
221
244
|
throw new errors_1.VerifyError("CMake build failed while compiling Qt Designer plugin.");
|
|
222
245
|
}
|
|
223
246
|
}
|
|
224
|
-
function runBuild(cwd, designerPlugin = false) {
|
|
247
|
+
function runBuild(cwd, designerPlugin = false, useSharedBaseWidgetOverride) {
|
|
225
248
|
const buildVersion = readActiveBuildStamp();
|
|
226
249
|
process.env.ANQST_BUILD_STAMP = buildVersion;
|
|
227
250
|
try {
|
|
228
251
|
const specPath = (0, project_1.resolveAnQstSpecPath)(cwd);
|
|
229
252
|
const configuredWidgetName = (0, project_1.resolveAnQstWidgetName)(cwd);
|
|
230
253
|
const configuredTargets = (0, project_1.resolveAnQstGenerateTargets)(cwd);
|
|
254
|
+
const useSharedBaseWidget = useSharedBaseWidgetOverride ?? (0, project_1.resolveAnQstUseSharedBaseWidget)(cwd);
|
|
231
255
|
const generationTargets = resolveGenerationTargetsFromCwd(cwd, true);
|
|
232
256
|
const preferredFrontendTarget = firstBrowserFrontendTarget(configuredTargets);
|
|
233
257
|
const parsed = (0, parser_1.parseSpecFile)(specPath);
|
|
@@ -236,10 +260,13 @@ function runBuild(cwd, designerPlugin = false) {
|
|
|
236
260
|
throw new errors_1.VerifyError(`Settings widgetName '${configuredWidgetName}' does not match spec namespace '${parsed.widgetName}'.`);
|
|
237
261
|
}
|
|
238
262
|
resetGeneratedTargets(cwd, parsed.widgetName, generationTargets);
|
|
239
|
-
const outputs = (0, emit_1.generateOutputs)(parsed, generationTargets);
|
|
263
|
+
const outputs = (0, emit_1.generateOutputs)(parsed, { ...generationTargets, useSharedBaseWidget });
|
|
240
264
|
(0, emit_1.writeGeneratedOutputs)(cwd, outputs);
|
|
241
265
|
if (generationTargets.emitQWidget) {
|
|
242
|
-
(
|
|
266
|
+
if (!useSharedBaseWidget) {
|
|
267
|
+
(0, emit_1.installVendoredAnQstWebBase)(cwd, parsed.widgetName);
|
|
268
|
+
}
|
|
269
|
+
(0, emit_1.installQtIntegrationCMake)(cwd, parsed.widgetName, { useSharedBaseWidget });
|
|
243
270
|
}
|
|
244
271
|
const shouldRunAngularBuild = generationTargets.emitQWidget
|
|
245
272
|
&& preferredFrontendTarget === "AngularService"
|
|
@@ -284,8 +311,8 @@ function runBuild(cwd, designerPlugin = false) {
|
|
|
284
311
|
}
|
|
285
312
|
else {
|
|
286
313
|
const widgetCategory = (0, project_1.resolveAnQstWidgetCategory)(cwd);
|
|
287
|
-
(0, emit_1.installQtDesignerPluginCMake)(cwd, parsed.widgetName, { widgetCategory });
|
|
288
|
-
runDesignerPluginBuild(cwd, parsed.widgetName);
|
|
314
|
+
(0, emit_1.installQtDesignerPluginCMake)(cwd, parsed.widgetName, { widgetCategory, useSharedBaseWidget });
|
|
315
|
+
runDesignerPluginBuild(cwd, parsed.widgetName, useSharedBaseWidget);
|
|
289
316
|
designerPluginBuilt = true;
|
|
290
317
|
}
|
|
291
318
|
}
|
|
@@ -321,7 +348,12 @@ function runBuild(cwd, designerPlugin = false) {
|
|
|
321
348
|
detailLines.push(` - Browser global: window.AnQstGenerated.${parsed.widgetName}`);
|
|
322
349
|
}
|
|
323
350
|
if (generationTargets.emitQWidget) {
|
|
351
|
+
const widgetClassName = `${parsed.widgetName}Widget`;
|
|
324
352
|
detailLines.push(" Target QWidget:");
|
|
353
|
+
detailLines.push(` - QWidget name: ${widgetClassName}`);
|
|
354
|
+
detailLines.push(` - AnQstWebBase module: ${useSharedBaseWidget
|
|
355
|
+
? `External ${(0, abi_hash_1.anqstWebBaseTargetName)()}, see anqst --help for more info`
|
|
356
|
+
: `Embedded in ${widgetClassName}`}`);
|
|
325
357
|
detailLines.push(` - Qt integration CMake: ${(0, layout_1.toProjectRelative)(cwd, node_path_1.default.join(layout.cppCmakeRoot, "CMakeLists.txt"))}`);
|
|
326
358
|
detailLines.push(` - Widget output root: ${(0, layout_1.toProjectRelative)(cwd, layout.cppQtWidgetRoot)}`);
|
|
327
359
|
detailLines.push(" - C++ handoff: downstream CMake consumes this generated tree directly");
|
|
@@ -373,6 +405,7 @@ function parseSpecCommandArg(commandName, specArg, extraArgs) {
|
|
|
373
405
|
function parseBuildCommandArgs(specArg, extraArgs) {
|
|
374
406
|
const allArgs = [specArg, ...extraArgs].filter((arg) => typeof arg === "string" && arg.length > 0);
|
|
375
407
|
let designerPlugin = false;
|
|
408
|
+
let useSharedBaseWidgetOverride;
|
|
376
409
|
const positional = [];
|
|
377
410
|
for (let i = 0; i < allArgs.length; i += 1) {
|
|
378
411
|
const arg = allArgs[i];
|
|
@@ -392,6 +425,14 @@ function parseBuildCommandArgs(specArg, extraArgs) {
|
|
|
392
425
|
designerPlugin = value.toLowerCase() === "true";
|
|
393
426
|
continue;
|
|
394
427
|
}
|
|
428
|
+
if (arg === "--noShared") {
|
|
429
|
+
useSharedBaseWidgetOverride = false;
|
|
430
|
+
continue;
|
|
431
|
+
}
|
|
432
|
+
if (arg === "--useShared") {
|
|
433
|
+
useSharedBaseWidgetOverride = true;
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
395
436
|
if (arg.startsWith("-")) {
|
|
396
437
|
throw new CliUsageError(`Unknown build flag '${arg}'. ${usageFor("build")}`);
|
|
397
438
|
}
|
|
@@ -400,7 +441,7 @@ function parseBuildCommandArgs(specArg, extraArgs) {
|
|
|
400
441
|
if (positional.length > 0) {
|
|
401
442
|
throw new CliUsageError(`Unexpected extra argument '${positional[0]}'. ${usageFor("build")}`);
|
|
402
443
|
}
|
|
403
|
-
return { designerPlugin };
|
|
444
|
+
return { designerPlugin, useSharedBaseWidgetOverride };
|
|
404
445
|
}
|
|
405
446
|
function parseCleanCommandArgs(specArg, extraArgs) {
|
|
406
447
|
const allArgs = [specArg, ...extraArgs].filter((arg) => typeof arg === "string" && arg.length > 0);
|
|
@@ -564,6 +605,13 @@ function runCommand(command, specArg, extraArgs = []) {
|
|
|
564
605
|
console.error(renderHelp());
|
|
565
606
|
return 1;
|
|
566
607
|
}
|
|
608
|
+
if (command === "--writeSharedBaseWidget") {
|
|
609
|
+
if (specArg || extraArgs.length > 0) {
|
|
610
|
+
console.error("Usage: anqst --writeSharedBaseWidget");
|
|
611
|
+
return 1;
|
|
612
|
+
}
|
|
613
|
+
return writeSharedBaseWidgetFromPackage(process.cwd());
|
|
614
|
+
}
|
|
567
615
|
if (command === "-h" || command === "--help" || command === "help") {
|
|
568
616
|
console.log(renderHelp());
|
|
569
617
|
return 0;
|
|
@@ -592,7 +640,7 @@ function runCommand(command, specArg, extraArgs = []) {
|
|
|
592
640
|
}
|
|
593
641
|
if (normalizedCommand === "build") {
|
|
594
642
|
const parsedArgs = parseBuildCommandArgs(specArg, extraArgs);
|
|
595
|
-
const res = runBuild(process.cwd(), parsedArgs.designerPlugin);
|
|
643
|
+
const res = runBuild(process.cwd(), parsedArgs.designerPlugin, parsedArgs.useSharedBaseWidgetOverride);
|
|
596
644
|
console.log(res.message);
|
|
597
645
|
return 0;
|
|
598
646
|
}
|
|
@@ -3,10 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.renderTsBoundaryCodecHelpers = renderTsBoundaryCodecHelpers;
|
|
4
4
|
exports.renderCppBoundaryCodecHelpers = renderCppBoundaryCodecHelpers;
|
|
5
5
|
const base93_1 = require("./base93");
|
|
6
|
+
const abi_hash_1 = require("./abi-hash");
|
|
6
7
|
const boundary_codec_model_1 = require("./boundary-codec-model");
|
|
7
8
|
function indent(level) {
|
|
8
9
|
return " ".repeat(level);
|
|
9
10
|
}
|
|
11
|
+
function cppBase93EncodeFunction() {
|
|
12
|
+
return `${(0, abi_hash_1.anqstWebBaseNamespaceName)()}::anqstBase93Encode`;
|
|
13
|
+
}
|
|
14
|
+
function cppBase93DecodeFunction() {
|
|
15
|
+
return `${(0, abi_hash_1.anqstWebBaseNamespaceName)()}::anqstBase93Decode`;
|
|
16
|
+
}
|
|
10
17
|
class TsEmitterContext {
|
|
11
18
|
constructor() {
|
|
12
19
|
this.nextId = 0;
|
|
@@ -315,10 +322,10 @@ function emitCppInlineScalarRead(leaf, lines, ctx, level) {
|
|
|
315
322
|
}
|
|
316
323
|
}
|
|
317
324
|
function cppInlineBinaryEncodeExpr(valueExpr) {
|
|
318
|
-
return
|
|
325
|
+
return `${cppBase93EncodeFunction()}(std::vector<std::uint8_t>(${valueExpr}.begin(), ${valueExpr}.end()))`;
|
|
319
326
|
}
|
|
320
327
|
function cppInlineBinaryDecodeExpr(encodedExpr) {
|
|
321
|
-
return `([&]() { const auto __bytes =
|
|
328
|
+
return `([&]() { const auto __bytes = ${cppBase93DecodeFunction()}(${encodedExpr}); return QByteArray(reinterpret_cast<const char*>(__bytes.data()), static_cast<int>(__bytes.size())); })()`;
|
|
322
329
|
}
|
|
323
330
|
function binaryEncodeHelperName(binary) {
|
|
324
331
|
return `__anqstEncodeBinary_${binary}`;
|
|
@@ -1366,11 +1373,11 @@ function renderCppFastPathCodec(plan, mapCppType) {
|
|
|
1366
1373
|
return `inline QVariant ${encoderName}(const ${cppType}& value) {
|
|
1367
1374
|
std::vector<std::uint8_t> bytes;
|
|
1368
1375
|
${encodeLines.join("\n")}
|
|
1369
|
-
return
|
|
1376
|
+
return ${cppBase93EncodeFunction()}(bytes);
|
|
1370
1377
|
}
|
|
1371
1378
|
|
|
1372
1379
|
inline ${cppType} ${decoderName}(const QVariant& wire) {
|
|
1373
|
-
const std::vector<std::uint8_t> blob =
|
|
1380
|
+
const std::vector<std::uint8_t> blob = ${cppBase93DecodeFunction()}(wire.toString());
|
|
1374
1381
|
std::size_t dataOffset = 0;
|
|
1375
1382
|
${decodeBody.join("\n")}
|
|
1376
1383
|
const ${cppType} result = ${decodeExpr};
|
|
@@ -1422,8 +1429,8 @@ inline ${cppType} ${decoderName}(const QVariant& wire) {
|
|
|
1422
1429
|
else {
|
|
1423
1430
|
emitCppInlineScalarWrite(plan.root.representation.scalarKind, `static_cast<std::${plan.root.representation.scalarKind}_t>(code)`, encodeLines, encodeCtx, 1);
|
|
1424
1431
|
}
|
|
1425
|
-
encodeLines.push(` return
|
|
1426
|
-
const decodeLines = [
|
|
1432
|
+
encodeLines.push(` return ${cppBase93EncodeFunction()}(bytes);`);
|
|
1433
|
+
const decodeLines = [` const std::vector<std::uint8_t> blob = ${cppBase93DecodeFunction()}(wire.toString());`, " std::size_t dataOffset = 0;"];
|
|
1427
1434
|
const decodeBody = [];
|
|
1428
1435
|
const expr = emitCppDecodeNode(plan.root, decodeBody, new CppEmitterContext(), 1, mapCppType);
|
|
1429
1436
|
return `inline QVariant ${encoderName}(const ${cppType}& value) {
|
|
@@ -1524,7 +1531,7 @@ ${encodeLines.join("\n")}
|
|
|
1524
1531
|
|
|
1525
1532
|
inline ${cppType} ${decoderName}(const QVariant& wire) {
|
|
1526
1533
|
const QVariantList items = anqstNormalizeWireItems(wire);
|
|
1527
|
-
const std::vector<std::uint8_t> blob = ${plan.requirements.hasBlob ? `(items.isEmpty() ? std::vector<std::uint8_t>{} :
|
|
1534
|
+
const std::vector<std::uint8_t> blob = ${plan.requirements.hasBlob ? `(items.isEmpty() ? std::vector<std::uint8_t>{} : ${cppBase93DecodeFunction()}(items.value(0).toString()))` : "std::vector<std::uint8_t>{}"};
|
|
1528
1535
|
std::size_t itemIndex = ${plan.requirements.hasBlob ? 1 : 0};
|
|
1529
1536
|
std::size_t dataOffset = 0;
|
|
1530
1537
|
${decodeLines.join("\n")}
|
|
@@ -1596,7 +1603,7 @@ function renderCppRuntimeSupport(catalog, mapCppType) {
|
|
|
1596
1603
|
else {
|
|
1597
1604
|
lines.push(" QVariantList out;");
|
|
1598
1605
|
lines.push(" out.reserve(static_cast<qsizetype>(items.size() + 1));");
|
|
1599
|
-
lines.push(
|
|
1606
|
+
lines.push(` out.push_back(${cppBase93EncodeFunction()}(bytes));`);
|
|
1600
1607
|
lines.push(" for (const auto& item : items) out.push_back(item);");
|
|
1601
1608
|
lines.push(" return out;");
|
|
1602
1609
|
lines.push("}");
|
|
@@ -1719,11 +1726,11 @@ function renderCppRuntimeSupport(catalog, mapCppType) {
|
|
|
1719
1726
|
}
|
|
1720
1727
|
if (support.needsBinaryHelpers) {
|
|
1721
1728
|
lines.push("inline QString anqstEncodeBinary(const QByteArray& value) {");
|
|
1722
|
-
lines.push(
|
|
1729
|
+
lines.push(` return ${cppBase93EncodeFunction()}(std::vector<std::uint8_t>(value.begin(), value.end()));`);
|
|
1723
1730
|
lines.push("}");
|
|
1724
1731
|
lines.push("");
|
|
1725
1732
|
lines.push("inline QByteArray anqstDecodeBinary(const QString& encoded) {");
|
|
1726
|
-
lines.push(
|
|
1733
|
+
lines.push(` const auto bytes = ${cppBase93DecodeFunction()}(encoded);`);
|
|
1727
1734
|
lines.push(" return QByteArray(reinterpret_cast<const char*>(bytes.data()), static_cast<int>(bytes.size()));");
|
|
1728
1735
|
lines.push("}");
|
|
1729
1736
|
}
|
package/dist/src/emit.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.generateOutputs = generateOutputs;
|
|
7
7
|
exports.writeGeneratedOutputs = writeGeneratedOutputs;
|
|
8
|
+
exports.installVendoredAnQstWebBase = installVendoredAnQstWebBase;
|
|
8
9
|
exports.buildVanillaJsBrowserBundle = buildVanillaJsBrowserBundle;
|
|
9
10
|
exports.installEmbeddedWebBundle = installEmbeddedWebBundle;
|
|
10
11
|
exports.installQtIntegrationCMake = installQtIntegrationCMake;
|
|
@@ -13,7 +14,9 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
13
14
|
const node_path_1 = __importDefault(require("node:path"));
|
|
14
15
|
const typescript_1 = __importDefault(require("typescript"));
|
|
15
16
|
const pngjs_1 = require("pngjs");
|
|
17
|
+
const abi_hash_1 = require("./abi-hash");
|
|
16
18
|
const layout_1 = require("./layout");
|
|
19
|
+
const webbase_1 = require("./webbase");
|
|
17
20
|
const boundary_codecs_1 = require("./boundary-codecs");
|
|
18
21
|
function stripAnQstType(typeText) {
|
|
19
22
|
return typeText
|
|
@@ -1226,6 +1229,7 @@ function renderWidgetUmbrellaHeader(spec) {
|
|
|
1226
1229
|
}
|
|
1227
1230
|
function renderWidgetHeader(spec, cppTypes, cppCodecCatalog) {
|
|
1228
1231
|
const widgetClassName = `${spec.widgetName}Widget`;
|
|
1232
|
+
const webBaseNamespace = (0, abi_hash_1.anqstWebBaseNamespaceName)();
|
|
1229
1233
|
const dragDropPayloadHelpers = collectDragDropPayloadHelpers(spec, cppTypes, cppCodecCatalog);
|
|
1230
1234
|
const callbackAliases = [];
|
|
1231
1235
|
const publicMethods = [];
|
|
@@ -1319,7 +1323,7 @@ namespace ${spec.widgetName} {
|
|
|
1319
1323
|
|
|
1320
1324
|
using namespace ${spec.widgetName};
|
|
1321
1325
|
|
|
1322
|
-
class ${widgetClassName} : public AnQstWebHostBase {
|
|
1326
|
+
class ${widgetClassName} : public ${webBaseNamespace}::AnQstWebHostBase {
|
|
1323
1327
|
Q_OBJECT
|
|
1324
1328
|
${properties.map((p) => ` ${p}`).join("\n")}
|
|
1325
1329
|
|
|
@@ -1387,6 +1391,8 @@ ${fields.map((f) => ` ${f}`).join("\n")}
|
|
|
1387
1391
|
}
|
|
1388
1392
|
function renderCppStub(spec, cppTypes, cppCodecCatalog) {
|
|
1389
1393
|
const widgetClassName = `${spec.widgetName}Widget`;
|
|
1394
|
+
const webBaseNamespace = (0, abi_hash_1.anqstWebBaseNamespaceName)();
|
|
1395
|
+
const webBaseClassName = `${webBaseNamespace}::AnQstWebHostBase`;
|
|
1390
1396
|
const dragDropPayloadHelpers = collectDragDropPayloadHelpers(spec, cppTypes, cppCodecCatalog);
|
|
1391
1397
|
const cppCodecHelpers = (0, boundary_codecs_1.renderCppBoundaryCodecHelpers)(cppCodecCatalog, (typeText, pathHintParts) => cppTypes.mapTypeText(typeText, pathHintParts)).trim();
|
|
1392
1398
|
const lines = [];
|
|
@@ -1520,7 +1526,7 @@ function renderCppStub(spec, cppTypes, cppCodecCatalog) {
|
|
|
1520
1526
|
lines.push("");
|
|
1521
1527
|
}
|
|
1522
1528
|
}
|
|
1523
|
-
lines.push(`${widgetClassName}::${widgetClassName}(QWidget* parent) :
|
|
1529
|
+
lines.push(`${widgetClassName}::${widgetClassName}(QWidget* parent) : ${webBaseClassName}(parent), handle(this) {`);
|
|
1524
1530
|
lines.push(` static const bool kResourcesInitialized = []() {`);
|
|
1525
1531
|
lines.push(` ::qInitResources_${spec.widgetName}();`);
|
|
1526
1532
|
lines.push(` return true;`);
|
|
@@ -1548,7 +1554,7 @@ function renderCppStub(spec, cppTypes, cppCodecCatalog) {
|
|
|
1548
1554
|
const cppType = cppTypes.mapTypeText(member.payloadTypeText, [service.name, member.name, "Payload"]);
|
|
1549
1555
|
const payloadSite = (0, boundary_codecs_1.getBoundaryPayloadSite)(cppCodecCatalog, service.name, member.name);
|
|
1550
1556
|
const typeName = member.payloadTypeText.replace(/\s/g, "");
|
|
1551
|
-
lines.push(` QObject::connect(this,
|
|
1557
|
+
lines.push(` QObject::connect(this, &${webBaseClassName}::anQstBridge_dropReceived, this, [this](const QString& service, const QString& member, const QVariant& payload, double x, double y) {`);
|
|
1552
1558
|
lines.push(` if (service == QStringLiteral("${service.name}") && member == QStringLiteral("${member.name}")) {`);
|
|
1553
1559
|
if (payloadSite) {
|
|
1554
1560
|
lines.push(` if (payload.type() != QVariant::String) {`);
|
|
@@ -1592,7 +1598,7 @@ function renderCppStub(spec, cppTypes, cppCodecCatalog) {
|
|
|
1592
1598
|
const cppType = cppTypes.mapTypeText(member.payloadTypeText, [service.name, member.name, "Payload"]);
|
|
1593
1599
|
const payloadSite = (0, boundary_codecs_1.getBoundaryPayloadSite)(cppCodecCatalog, service.name, member.name);
|
|
1594
1600
|
const typeName = member.payloadTypeText.replace(/\s/g, "");
|
|
1595
|
-
lines.push(` QObject::connect(this,
|
|
1601
|
+
lines.push(` QObject::connect(this, &${webBaseClassName}::anQstBridge_hoverUpdated, this, [this](const QString& service, const QString& member, const QVariant& payload, double x, double y) {`);
|
|
1596
1602
|
lines.push(` if (service == QStringLiteral("${service.name}") && member == QStringLiteral("${member.name}")) {`);
|
|
1597
1603
|
if (payloadSite) {
|
|
1598
1604
|
lines.push(` if (payload.type() != QVariant::String) {`);
|
|
@@ -1631,7 +1637,7 @@ function renderCppStub(spec, cppTypes, cppCodecCatalog) {
|
|
|
1631
1637
|
}
|
|
1632
1638
|
lines.push(` }`);
|
|
1633
1639
|
lines.push(` });`);
|
|
1634
|
-
lines.push(` QObject::connect(this,
|
|
1640
|
+
lines.push(` QObject::connect(this, &${webBaseClassName}::anQstBridge_hoverLeft, this, [this](const QString& service, const QString& member) {`);
|
|
1635
1641
|
lines.push(` if (service == QStringLiteral("${service.name}") && member == QStringLiteral("${member.name}")) {`);
|
|
1636
1642
|
lines.push(` emit ${member.name}Left();`);
|
|
1637
1643
|
lines.push(` }`);
|
|
@@ -1639,7 +1645,7 @@ function renderCppStub(spec, cppTypes, cppCodecCatalog) {
|
|
|
1639
1645
|
}
|
|
1640
1646
|
}
|
|
1641
1647
|
}
|
|
1642
|
-
lines.push(` QObject::connect(this,
|
|
1648
|
+
lines.push(` QObject::connect(this, &${webBaseClassName}::onHostError, this, &${widgetClassName}::diagnosticsForwarded);`);
|
|
1643
1649
|
lines.push(` const bool rootOk = setContentRoot(QString::fromUtf8(kBootstrapContentRoot));`);
|
|
1644
1650
|
lines.push(` const bool bridgeOk = setBridgeObject(this, QString::fromUtf8(kBootstrapBridgeObject));`);
|
|
1645
1651
|
lines.push(` const bool loadOk = rootOk && bridgeOk && loadEntryPoint(QString::fromUtf8(kBootstrapEntryPoint));`);
|
|
@@ -1651,7 +1657,7 @@ function renderCppStub(spec, cppTypes, cppCodecCatalog) {
|
|
|
1651
1657
|
lines.push(`${widgetClassName}::~${widgetClassName}() = default;`);
|
|
1652
1658
|
lines.push("");
|
|
1653
1659
|
lines.push(`bool ${widgetClassName}::enableDebug() {`);
|
|
1654
|
-
lines.push(` return
|
|
1660
|
+
lines.push(` return ${webBaseClassName}::enableDebug();`);
|
|
1655
1661
|
lines.push("}");
|
|
1656
1662
|
lines.push("");
|
|
1657
1663
|
lines.push(`QString ${widgetClassName}::makeBindingKey(const QString& service, const QString& member) {`);
|
|
@@ -1941,18 +1947,37 @@ function renderCppStub(spec, cppTypes, cppCodecCatalog) {
|
|
|
1941
1947
|
}
|
|
1942
1948
|
}
|
|
1943
1949
|
lines.push(`void ${widgetClassName}::connectNotify(const QMetaMethod& signal) {`);
|
|
1944
|
-
lines.push(`
|
|
1950
|
+
lines.push(` ${webBaseClassName}::connectNotify(signal);`);
|
|
1945
1951
|
lines.push(` Q_UNUSED(signal);`);
|
|
1946
1952
|
lines.push(`}`);
|
|
1947
1953
|
lines.push("");
|
|
1948
1954
|
lines.push(`void ${widgetClassName}::disconnectNotify(const QMetaMethod& signal) {`);
|
|
1949
|
-
lines.push(`
|
|
1955
|
+
lines.push(` ${webBaseClassName}::disconnectNotify(signal);`);
|
|
1950
1956
|
lines.push(` Q_UNUSED(signal);`);
|
|
1951
1957
|
lines.push(`}`);
|
|
1952
1958
|
lines.push("");
|
|
1953
1959
|
return lines.join("\n");
|
|
1954
1960
|
}
|
|
1955
|
-
function
|
|
1961
|
+
function renderWebBaseTargetCMake(widgetName, useSharedBaseWidget) {
|
|
1962
|
+
const webBaseTarget = (0, abi_hash_1.anqstWebBaseTargetName)();
|
|
1963
|
+
if (useSharedBaseWidget) {
|
|
1964
|
+
return `if(NOT TARGET ${webBaseTarget})
|
|
1965
|
+
message(FATAL_ERROR "Target '${webBaseTarget}' is required before adding generated widget library ${widgetName}Widget.")
|
|
1966
|
+
endif()`;
|
|
1967
|
+
}
|
|
1968
|
+
return `set(ANQST_GENERATED_WEBBASE_DIR "\${CMAKE_CURRENT_SOURCE_DIR}/${webbase_1.ANQST_WEBBASE_DIR_NAME}")
|
|
1969
|
+
if(NOT EXISTS "\${ANQST_GENERATED_WEBBASE_DIR}/CMakeLists.txt")
|
|
1970
|
+
message(FATAL_ERROR "Generated ${webbase_1.ANQST_WEBBASE_DIR_NAME} sources are missing for ${widgetName}Widget. Run 'npx anqst build' again.")
|
|
1971
|
+
endif()
|
|
1972
|
+
set(ANQSTWEBBASE_BUILD_TESTS OFF CACHE BOOL "Build ${webbase_1.ANQST_WEBBASE_DIR_NAME} unit tests" FORCE)
|
|
1973
|
+
if(NOT TARGET ${webBaseTarget})
|
|
1974
|
+
add_subdirectory("\${ANQST_GENERATED_WEBBASE_DIR}" "\${CMAKE_CURRENT_BINARY_DIR}/anqstwebbase")
|
|
1975
|
+
endif()
|
|
1976
|
+
if(NOT TARGET ${webBaseTarget})
|
|
1977
|
+
message(FATAL_ERROR "Target '${webBaseTarget}' was not created from generated ${webbase_1.ANQST_WEBBASE_DIR_NAME} sources for ${widgetName}Widget.")
|
|
1978
|
+
endif()`;
|
|
1979
|
+
}
|
|
1980
|
+
function renderCMake(spec, useSharedBaseWidget = true) {
|
|
1956
1981
|
return `cmake_minimum_required(VERSION 3.21)
|
|
1957
1982
|
project(${spec.widgetName}Library LANGUAGES CXX)
|
|
1958
1983
|
|
|
@@ -1961,9 +1986,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
1961
1986
|
set(CMAKE_AUTOMOC ON)
|
|
1962
1987
|
set(CMAKE_AUTORCC ON)
|
|
1963
1988
|
|
|
1964
|
-
|
|
1965
|
-
message(FATAL_ERROR "Target 'anqstwebhostbase' is required before adding generated widget library ${spec.widgetName}Widget.")
|
|
1966
|
-
endif()
|
|
1989
|
+
${renderWebBaseTargetCMake(spec.widgetName, useSharedBaseWidget)}
|
|
1967
1990
|
|
|
1968
1991
|
add_library(${spec.widgetName}Widget
|
|
1969
1992
|
${spec.widgetName}.cpp
|
|
@@ -1978,10 +2001,10 @@ target_include_directories(${spec.widgetName}Widget
|
|
|
1978
2001
|
)
|
|
1979
2002
|
target_link_libraries(${spec.widgetName}Widget
|
|
1980
2003
|
PUBLIC
|
|
1981
|
-
|
|
2004
|
+
${(0, abi_hash_1.anqstWebBaseTargetName)()}
|
|
1982
2005
|
)
|
|
1983
2006
|
|
|
1984
|
-
# Uses transitive Qt and include requirements from
|
|
2007
|
+
# Uses transitive Qt and include requirements from ${(0, abi_hash_1.anqstWebBaseTargetName)()}.
|
|
1985
2008
|
`;
|
|
1986
2009
|
}
|
|
1987
2010
|
function escapeXml(text) {
|
|
@@ -5315,7 +5338,8 @@ function generateOutputs(spec, options = {}) {
|
|
|
5315
5338
|
emitAngularService: options.emitAngularService ?? true,
|
|
5316
5339
|
emitVanillaTS: options.emitVanillaTS ?? useDefaultBrowserTargets,
|
|
5317
5340
|
emitVanillaJS: options.emitVanillaJS ?? useDefaultBrowserTargets,
|
|
5318
|
-
emitNodeExpressWs: options.emitNodeExpressWs ?? false
|
|
5341
|
+
emitNodeExpressWs: options.emitNodeExpressWs ?? false,
|
|
5342
|
+
useSharedBaseWidget: options.useSharedBaseWidget ?? true
|
|
5319
5343
|
};
|
|
5320
5344
|
const angularFrontendDir = `frontend/${(0, layout_1.generatedFrontendDirName)(spec.widgetName, "AngularService")}`;
|
|
5321
5345
|
const vanillaTsFrontendDir = `frontend/${(0, layout_1.generatedFrontendDirName)(spec.widgetName, "VanillaTS")}`;
|
|
@@ -5353,7 +5377,7 @@ function generateOutputs(spec, options = {}) {
|
|
|
5353
5377
|
}
|
|
5354
5378
|
if (normalizedOptions.emitQWidget) {
|
|
5355
5379
|
const cppTypes = buildCppTypeContext(spec);
|
|
5356
|
-
outputs[`${cppDir}/CMakeLists.txt`] = renderCMake(spec);
|
|
5380
|
+
outputs[`${cppDir}/CMakeLists.txt`] = renderCMake(spec, normalizedOptions.useSharedBaseWidget);
|
|
5357
5381
|
outputs[`${cppDir}/${spec.widgetName}.qrc`] = renderEmbeddedQrc(spec.widgetName, []);
|
|
5358
5382
|
outputs[`${cppDir}/include/${spec.widgetName}.h`] = renderWidgetUmbrellaHeader(spec);
|
|
5359
5383
|
outputs[`${cppDir}/include/${spec.widgetName}Widget.h`] = renderWidgetHeader(spec, cppTypes, codecCatalog);
|
|
@@ -5375,6 +5399,10 @@ function writeGeneratedOutputs(cwd, outputs) {
|
|
|
5375
5399
|
node_fs_1.default.writeFileSync(filePath, withBuildStamp(relPath, content), "utf8");
|
|
5376
5400
|
}
|
|
5377
5401
|
}
|
|
5402
|
+
function installVendoredAnQstWebBase(cwd, widgetName) {
|
|
5403
|
+
const webBaseRoot = node_path_1.default.join((0, layout_1.resolveGeneratedLayoutPaths)(cwd, widgetName).cppQtWidgetRoot, webbase_1.ANQST_WEBBASE_DIR_NAME);
|
|
5404
|
+
(0, webbase_1.installAnQstWebBaseTree)(webBaseRoot);
|
|
5405
|
+
}
|
|
5378
5406
|
function normalizeVanillaJsIndexHtml(html) {
|
|
5379
5407
|
let normalized = html.replace(/<script\b[^>]*src=["'](?:\.\/)?main\.js["'][^>]*>\s*<\/script>\s*/gi, "");
|
|
5380
5408
|
const bundleScriptTag = ' <script defer src="./main.js"></script>\n';
|
|
@@ -5585,13 +5613,30 @@ function normalizeEmbeddedIndexHtml(indexPath, webRoot) {
|
|
|
5585
5613
|
});
|
|
5586
5614
|
node_fs_1.default.writeFileSync(indexPath, html, "utf8");
|
|
5587
5615
|
}
|
|
5588
|
-
function
|
|
5616
|
+
function renderQtIntegrationWebBaseCMake(widgetName, generatedRootVar, useSharedBaseWidget) {
|
|
5617
|
+
const webBaseTarget = (0, abi_hash_1.anqstWebBaseTargetName)();
|
|
5618
|
+
if (useSharedBaseWidget) {
|
|
5619
|
+
return `if(NOT TARGET ${webBaseTarget})
|
|
5620
|
+
message(FATAL_ERROR "Target '${webBaseTarget}' must exist before including generated AnQst CMake for ${widgetName}.")
|
|
5621
|
+
endif()`;
|
|
5622
|
+
}
|
|
5623
|
+
return `set(ANQST_GENERATED_WEBBASE_DIR "\${${generatedRootVar}}/${webbase_1.ANQST_WEBBASE_DIR_NAME}")
|
|
5624
|
+
set(ANQSTWEBBASE_BUILD_TESTS OFF CACHE BOOL "Build ${webbase_1.ANQST_WEBBASE_DIR_NAME} unit tests" FORCE)
|
|
5625
|
+
if(NOT TARGET ${webBaseTarget})
|
|
5626
|
+
add_subdirectory("\${ANQST_GENERATED_WEBBASE_DIR}" "\${CMAKE_CURRENT_BINARY_DIR}/anqstwebbase")
|
|
5627
|
+
endif()`;
|
|
5628
|
+
}
|
|
5629
|
+
function renderQtIntegrationCMake(widgetName, options = {}) {
|
|
5589
5630
|
const generatedRootVar = "ANQST_GENERATED_WIDGET_DIR";
|
|
5590
5631
|
const generatedIncludeVar = "ANQST_GENERATED_INCLUDE_DIR";
|
|
5591
5632
|
const projectRootVar = "ANQST_PROJECT_ROOT";
|
|
5592
5633
|
const requiredFilesVar = "ANQST_REQUIRED_GENERATED_FILES";
|
|
5593
5634
|
const widgetBinaryDirVar = "ANQST_GENERATED_WIDGET_BINARY_DIR";
|
|
5594
5635
|
const widgetTarget = `${widgetName}Widget`;
|
|
5636
|
+
const useSharedBaseWidget = options.useSharedBaseWidget ?? true;
|
|
5637
|
+
const vendoredRequiredFiles = useSharedBaseWidget
|
|
5638
|
+
? ""
|
|
5639
|
+
: ` "\${${generatedRootVar}}/${webbase_1.ANQST_WEBBASE_DIR_NAME}/CMakeLists.txt"\n`;
|
|
5595
5640
|
return `cmake_minimum_required(VERSION 3.21)
|
|
5596
5641
|
|
|
5597
5642
|
set(${projectRootVar} "\${CMAKE_CURRENT_LIST_DIR}/../../../../..")
|
|
@@ -5603,10 +5648,6 @@ if(TARGET ${widgetTarget})
|
|
|
5603
5648
|
return()
|
|
5604
5649
|
endif()
|
|
5605
5650
|
|
|
5606
|
-
if(NOT TARGET anqstwebhostbase)
|
|
5607
|
-
message(FATAL_ERROR "Target 'anqstwebhostbase' must exist before including generated AnQst CMake for ${widgetName}.")
|
|
5608
|
-
endif()
|
|
5609
|
-
|
|
5610
5651
|
set(${requiredFilesVar}
|
|
5611
5652
|
"\${${generatedRootVar}}/CMakeLists.txt"
|
|
5612
5653
|
"\${${generatedRootVar}}/${widgetName}.qrc"
|
|
@@ -5615,7 +5656,7 @@ set(${requiredFilesVar}
|
|
|
5615
5656
|
"\${${generatedIncludeVar}}/${widgetName}Widget.h"
|
|
5616
5657
|
"\${${generatedIncludeVar}}/${widgetName}Types.h"
|
|
5617
5658
|
"\${${generatedRootVar}}/webapp/index.html"
|
|
5618
|
-
)
|
|
5659
|
+
${vendoredRequiredFiles})
|
|
5619
5660
|
|
|
5620
5661
|
foreach(required_file IN LISTS ${requiredFilesVar})
|
|
5621
5662
|
if(NOT EXISTS "\${required_file}")
|
|
@@ -5627,13 +5668,15 @@ foreach(required_file IN LISTS ${requiredFilesVar})
|
|
|
5627
5668
|
endif()
|
|
5628
5669
|
endforeach()
|
|
5629
5670
|
|
|
5671
|
+
${renderQtIntegrationWebBaseCMake(widgetName, generatedRootVar, useSharedBaseWidget)}
|
|
5672
|
+
|
|
5630
5673
|
add_subdirectory("\${${generatedRootVar}}" "\${${widgetBinaryDirVar}}")
|
|
5631
5674
|
`;
|
|
5632
5675
|
}
|
|
5633
|
-
function installQtIntegrationCMake(cwd, widgetName) {
|
|
5676
|
+
function installQtIntegrationCMake(cwd, widgetName, options = {}) {
|
|
5634
5677
|
const integrationDir = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, widgetName).cppCmakeRoot;
|
|
5635
5678
|
node_fs_1.default.mkdirSync(integrationDir, { recursive: true });
|
|
5636
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(integrationDir, "CMakeLists.txt"), withBuildStamp("backend/cpp/cmake/CMakeLists.txt", renderQtIntegrationCMake(widgetName)), "utf8");
|
|
5679
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(integrationDir, "CMakeLists.txt"), withBuildStamp("backend/cpp/cmake/CMakeLists.txt", renderQtIntegrationCMake(widgetName, options)), "utf8");
|
|
5637
5680
|
}
|
|
5638
5681
|
function normalizeIcoSize(dim) {
|
|
5639
5682
|
return dim === 0 ? 256 : dim;
|
|
@@ -5858,10 +5901,12 @@ public:
|
|
|
5858
5901
|
#include "${pluginClass}.moc"
|
|
5859
5902
|
`;
|
|
5860
5903
|
}
|
|
5861
|
-
function renderQtDesignerPluginCMake(widgetName, hasIcon) {
|
|
5904
|
+
function renderQtDesignerPluginCMake(widgetName, hasIcon, useSharedBaseWidget = true) {
|
|
5862
5905
|
const widgetTarget = `${widgetName}Widget`;
|
|
5863
5906
|
const pluginTarget = `${widgetName}DesignerPlugin`;
|
|
5907
|
+
const webBaseTarget = (0, abi_hash_1.anqstWebBaseTargetName)();
|
|
5864
5908
|
const resourceLine = hasIcon ? " \"${CMAKE_CURRENT_LIST_DIR}/designerplugin.qrc\"\n" : "";
|
|
5909
|
+
const defaultWebBaseDir = useSharedBaseWidget ? "" : `\${ANQST_WIDGET_DIR}/${webbase_1.ANQST_WEBBASE_DIR_NAME}`;
|
|
5865
5910
|
return `cmake_minimum_required(VERSION 3.21)
|
|
5866
5911
|
project(${pluginTarget} LANGUAGES CXX)
|
|
5867
5912
|
|
|
@@ -5873,7 +5918,7 @@ set(CMAKE_AUTORCC ON)
|
|
|
5873
5918
|
|
|
5874
5919
|
set(ANQST_PROJECT_ROOT "\${CMAKE_CURRENT_LIST_DIR}/../../../../../../..")
|
|
5875
5920
|
set(ANQST_WIDGET_DIR "\${CMAKE_CURRENT_LIST_DIR}/..")
|
|
5876
|
-
set(ANQST_WEBBASE_DIR "" CACHE PATH "Path to
|
|
5921
|
+
set(ANQST_WEBBASE_DIR "${defaultWebBaseDir}" CACHE PATH "Path to ${webbase_1.ANQST_WEBBASE_DIR_NAME} source directory")
|
|
5877
5922
|
|
|
5878
5923
|
if(NOT EXISTS "\${ANQST_WIDGET_DIR}/CMakeLists.txt")
|
|
5879
5924
|
message(FATAL_ERROR "Missing generated widget CMake project at \${ANQST_WIDGET_DIR}. Run 'anqst build' first.")
|
|
@@ -5881,6 +5926,7 @@ endif()
|
|
|
5881
5926
|
|
|
5882
5927
|
if(NOT ANQST_WEBBASE_DIR)
|
|
5883
5928
|
foreach(candidate
|
|
5929
|
+
"\${ANQST_PROJECT_ROOT}/node_modules/@dusted/anqst/${webbase_1.ANQST_WEBBASE_DIR_NAME}"
|
|
5884
5930
|
"\${ANQST_PROJECT_ROOT}/AnQstWidget/AnQstWebBase"
|
|
5885
5931
|
"\${ANQST_PROJECT_ROOT}/../AnQstWidget/AnQstWebBase"
|
|
5886
5932
|
"\${ANQST_PROJECT_ROOT}/../../AnQstWidget/AnQstWebBase"
|
|
@@ -5893,13 +5939,13 @@ if(NOT ANQST_WEBBASE_DIR)
|
|
|
5893
5939
|
endif()
|
|
5894
5940
|
|
|
5895
5941
|
if(NOT ANQST_WEBBASE_DIR OR NOT EXISTS "\${ANQST_WEBBASE_DIR}/CMakeLists.txt")
|
|
5896
|
-
message(FATAL_ERROR "Unable to locate
|
|
5942
|
+
message(FATAL_ERROR "Unable to locate ${webbase_1.ANQST_WEBBASE_DIR_NAME} sources. Set -DANQST_WEBBASE_DIR=<path/to/${webbase_1.ANQST_WEBBASE_DIR_NAME}>.")
|
|
5897
5943
|
endif()
|
|
5898
5944
|
|
|
5899
5945
|
find_package(Qt5 REQUIRED COMPONENTS Core Widgets UiPlugin)
|
|
5900
5946
|
|
|
5901
5947
|
set(ANQSTWEBBASE_BUILD_TESTS OFF CACHE BOOL "Build AnQstWebBase unit tests" FORCE)
|
|
5902
|
-
if(NOT TARGET
|
|
5948
|
+
if(NOT TARGET ${webBaseTarget})
|
|
5903
5949
|
add_subdirectory("\${ANQST_WEBBASE_DIR}" "\${CMAKE_CURRENT_BINARY_DIR}/anqstwebbase")
|
|
5904
5950
|
endif()
|
|
5905
5951
|
|
|
@@ -5933,6 +5979,6 @@ function installQtDesignerPluginCMake(cwd, widgetName, options = {}) {
|
|
|
5933
5979
|
const assets = installDesignerPluginIconAssets(cwd, pluginDir);
|
|
5934
5980
|
const pluginTarget = `${widgetName}DesignerPlugin`;
|
|
5935
5981
|
const widgetCategory = options.widgetCategory ?? "AnQst Widgets";
|
|
5936
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(pluginDir, "CMakeLists.txt"), withBuildStamp(`backend/cpp/qt/${generatedCppLibraryDirName(widgetName)}/designerPlugin/CMakeLists.txt`, renderQtDesignerPluginCMake(widgetName, assets.hasIcon)), "utf8");
|
|
5982
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(pluginDir, "CMakeLists.txt"), withBuildStamp(`backend/cpp/qt/${generatedCppLibraryDirName(widgetName)}/designerPlugin/CMakeLists.txt`, renderQtDesignerPluginCMake(widgetName, assets.hasIcon, options.useSharedBaseWidget ?? true)), "utf8");
|
|
5937
5983
|
node_fs_1.default.writeFileSync(node_path_1.default.join(pluginDir, `${pluginTarget}.cpp`), withBuildStamp(`backend/cpp/qt/${generatedCppLibraryDirName(widgetName)}/designerPlugin/${pluginTarget}.cpp`, renderQtDesignerPluginCpp(widgetName, widgetCategory, assets.hasIcon)), "utf8");
|
|
5938
5984
|
}
|