@dusted/anqst 0.1.1 → 0.1.2
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/README.md +99 -117
- package/dist/src/app.js +119 -194
- package/dist/src/{backend/tsc/debug-dump.js → debug-dump.js} +2 -1
- package/dist/src/emit.js +42 -66
- package/dist/src/layout.js +70 -0
- package/dist/src/parser.js +16 -1
- package/dist/src/{backend/tsc/program.js → program.js} +1 -1
- package/dist/src/project.js +220 -137
- package/dist/src/verify.js +9 -1
- package/index.d.ts +1 -0
- package/package.json +7 -2
- package/spec/AnQst-Spec-DSL.d.ts +2 -2
- package/dist/src/backend/ast/emit.js +0 -5
- package/dist/src/backend/ast/index.js +0 -13
- package/dist/src/backend/ast/parser.js +0 -5
- package/dist/src/backend/ast/verify.js +0 -5
- package/dist/src/backend/index.js +0 -16
- package/dist/src/backend/tsc/emit-cpp.js +0 -13
- package/dist/src/backend/tsc/emit-node.js +0 -13
- package/dist/src/backend/tsc/index.js +0 -41
- package/dist/src/backend/tsc/parser.js +0 -19
- package/dist/src/backend/tsc/verify.js +0 -13
- package/dist/src/backend/types.js +0 -2
- /package/dist/src/{backend/tsc/typegraph.js → typegraph.js} +0 -0
package/dist/src/emit.js
CHANGED
|
@@ -5,7 +5,6 @@ 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.installTypeScriptOutputs = installTypeScriptOutputs;
|
|
9
8
|
exports.installEmbeddedWebBundle = installEmbeddedWebBundle;
|
|
10
9
|
exports.installQtIntegrationCMake = installQtIntegrationCMake;
|
|
11
10
|
exports.installQtDesignerPluginCMake = installQtDesignerPluginCMake;
|
|
@@ -13,6 +12,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
13
12
|
const node_path_1 = __importDefault(require("node:path"));
|
|
14
13
|
const typescript_1 = __importDefault(require("typescript"));
|
|
15
14
|
const pngjs_1 = require("pngjs");
|
|
15
|
+
const layout_1 = require("./layout");
|
|
16
16
|
function stripAnQstType(typeText) {
|
|
17
17
|
return typeText
|
|
18
18
|
.replace(/\bAnQst\.Type\.stringArray\b/g, "string[]")
|
|
@@ -349,7 +349,7 @@ function normalizeImportPathForGenerated(specFilePath, generatedFileRelPath, mod
|
|
|
349
349
|
return moduleSpecifier;
|
|
350
350
|
}
|
|
351
351
|
const specDir = node_path_1.default.dirname(specFilePath);
|
|
352
|
-
const generatedAbs = node_path_1.default.resolve(node_path_1.default.dirname(specFilePath), "
|
|
352
|
+
const generatedAbs = node_path_1.default.resolve(node_path_1.default.dirname(specFilePath), "generated", generatedFileRelPath);
|
|
353
353
|
const generatedDir = node_path_1.default.dirname(generatedAbs);
|
|
354
354
|
const resolvedModulePath = node_path_1.default.resolve(specDir, moduleSpecifier);
|
|
355
355
|
const relative = node_path_1.default.relative(generatedDir, resolvedModulePath);
|
|
@@ -1226,7 +1226,7 @@ export declare class ${serviceName} {
|
|
|
1226
1226
|
}
|
|
1227
1227
|
function renderTsServices(spec) {
|
|
1228
1228
|
const serviceClasses = spec.services.map((s) => renderTsService(spec, s.name)).join("\n");
|
|
1229
|
-
const externalTypeImports = renderRequiredTypeImports(spec,
|
|
1229
|
+
const externalTypeImports = renderRequiredTypeImports(spec, `frontend/${(0, layout_1.generatedFrontendDirName)(spec.widgetName)}/services.ts`).trim();
|
|
1230
1230
|
const localTypeImports = renderLocalTypeImports(spec).trim();
|
|
1231
1231
|
const typeImports = [externalTypeImports, localTypeImports].filter((s) => s.length > 0).join("\n");
|
|
1232
1232
|
const typeImportsBlock = typeImports.length > 0 ? `${typeImports}\n\n` : "";
|
|
@@ -1551,13 +1551,13 @@ ${serviceClasses}
|
|
|
1551
1551
|
`;
|
|
1552
1552
|
}
|
|
1553
1553
|
function renderTsTypes(spec) {
|
|
1554
|
-
const typeImports = renderRequiredTypeImports(spec,
|
|
1554
|
+
const typeImports = renderRequiredTypeImports(spec, `frontend/${(0, layout_1.generatedFrontendDirName)(spec.widgetName)}/types.ts`).trim();
|
|
1555
1555
|
const typeDecls = renderTypeDeclarations(spec, true).trim();
|
|
1556
1556
|
const sections = [typeImports, typeDecls].filter((s) => s.length > 0);
|
|
1557
1557
|
return sections.length > 0 ? `${sections.join("\n\n")}\n` : "";
|
|
1558
1558
|
}
|
|
1559
1559
|
function renderTypeServicesDts(spec) {
|
|
1560
|
-
const externalTypeImports = renderRequiredTypeImports(spec,
|
|
1560
|
+
const externalTypeImports = renderRequiredTypeImports(spec, `frontend/${(0, layout_1.generatedFrontendDirName)(spec.widgetName)}/types/services.d.ts`).trim();
|
|
1561
1561
|
const localTypeImports = renderLocalTypeImports(spec).trim();
|
|
1562
1562
|
const serviceDecls = spec.services
|
|
1563
1563
|
.map((s) => renderTsServiceDts(spec, s.name))
|
|
@@ -1566,7 +1566,7 @@ function renderTypeServicesDts(spec) {
|
|
|
1566
1566
|
return sections.length > 0 ? `${sections.join("\n\n")}\n` : "";
|
|
1567
1567
|
}
|
|
1568
1568
|
function renderTypeTypesDts(spec) {
|
|
1569
|
-
const typeImports = renderRequiredTypeImports(spec,
|
|
1569
|
+
const typeImports = renderRequiredTypeImports(spec, `frontend/${(0, layout_1.generatedFrontendDirName)(spec.widgetName)}/types/types.d.ts`).trim();
|
|
1570
1570
|
const typeDecls = renderTypeDeclarations(spec, true).trim();
|
|
1571
1571
|
const sections = [typeImports, typeDecls].filter((s) => s.length > 0);
|
|
1572
1572
|
return sections.length > 0 ? `${sections.join("\n\n")}\n` : "";
|
|
@@ -1632,13 +1632,13 @@ function nodeCap(value) {
|
|
|
1632
1632
|
return value.length === 0 ? value : `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
|
|
1633
1633
|
}
|
|
1634
1634
|
function renderNodeExpressWsTypes(spec) {
|
|
1635
|
-
const typeImports = renderRequiredTypeImports(spec,
|
|
1635
|
+
const typeImports = renderRequiredTypeImports(spec, `backend/node/express/${generatedNodeExpressWsDirName(spec.widgetName)}/types/index.d.ts`).trim();
|
|
1636
1636
|
const typeDecls = renderTypeDeclarations(spec, true).trim();
|
|
1637
1637
|
const sections = [typeImports, typeDecls].filter((s) => s.length > 0);
|
|
1638
1638
|
return sections.length > 0 ? `${sections.join("\n\n")}\n` : "";
|
|
1639
1639
|
}
|
|
1640
1640
|
function renderNodeExpressWsIndex(spec) {
|
|
1641
|
-
const typeImports = renderRequiredTypeImports(spec,
|
|
1641
|
+
const typeImports = renderRequiredTypeImports(spec, `backend/node/express/${generatedNodeExpressWsDirName(spec.widgetName)}/index.ts`);
|
|
1642
1642
|
const typeDecls = renderTypeDeclarations(spec, true);
|
|
1643
1643
|
const handlerBridgeTypeName = `${spec.widgetName}HandlerBridge`;
|
|
1644
1644
|
const sessionBridgeTypeName = `${spec.widgetName}SessionBridge`;
|
|
@@ -2337,26 +2337,27 @@ function renderTypeRootIndexDts(spec) {
|
|
|
2337
2337
|
return sections.length > 0 ? `${sections.join("\n\n")}\n` : "";
|
|
2338
2338
|
}
|
|
2339
2339
|
function generatedCppLibraryDirName(widgetName) {
|
|
2340
|
-
return
|
|
2340
|
+
return (0, layout_1.generatedQtWidgetDirName)(widgetName);
|
|
2341
2341
|
}
|
|
2342
2342
|
function generatedNodeExpressWsDirName(widgetName) {
|
|
2343
|
-
return
|
|
2343
|
+
return (0, layout_1.generatedNodeExpressDirName)(widgetName);
|
|
2344
2344
|
}
|
|
2345
2345
|
function generateOutputs(spec, options = { emitQWidget: true, emitAngularService: true, emitNodeExpressWs: false }) {
|
|
2346
|
-
const
|
|
2347
|
-
const
|
|
2346
|
+
const frontendDir = `frontend/${(0, layout_1.generatedFrontendDirName)(spec.widgetName)}`;
|
|
2347
|
+
const cppDir = `backend/cpp/qt/${generatedCppLibraryDirName(spec.widgetName)}`;
|
|
2348
|
+
const nodeDir = `backend/node/express/${generatedNodeExpressWsDirName(spec.widgetName)}`;
|
|
2348
2349
|
const outputs = {};
|
|
2349
2350
|
if (options.emitAngularService) {
|
|
2350
|
-
outputs[
|
|
2351
|
-
outputs[
|
|
2352
|
-
outputs[
|
|
2353
|
-
outputs[
|
|
2354
|
-
outputs[
|
|
2355
|
-
outputs[
|
|
2356
|
-
outputs[
|
|
2357
|
-
outputs[
|
|
2358
|
-
outputs[
|
|
2359
|
-
outputs[
|
|
2351
|
+
outputs[`${frontendDir}/package.json`] = renderNpmPackage(spec);
|
|
2352
|
+
outputs[`${frontendDir}/index.ts`] = renderTsIndex();
|
|
2353
|
+
outputs[`${frontendDir}/services.ts`] = renderTsServices(spec);
|
|
2354
|
+
outputs[`${frontendDir}/types.ts`] = renderTsTypes(spec);
|
|
2355
|
+
outputs[`${frontendDir}/index.js`] = renderJsIndex();
|
|
2356
|
+
outputs[`${frontendDir}/services.js`] = renderJsServices();
|
|
2357
|
+
outputs[`${frontendDir}/types.js`] = renderJsTypes();
|
|
2358
|
+
outputs[`${frontendDir}/types/index.d.ts`] = renderTypeRootIndexDts(spec);
|
|
2359
|
+
outputs[`${frontendDir}/types/services.d.ts`] = renderTypeServicesDts(spec);
|
|
2360
|
+
outputs[`${frontendDir}/types/types.d.ts`] = renderTypeTypesDts(spec);
|
|
2360
2361
|
}
|
|
2361
2362
|
if (options.emitQWidget) {
|
|
2362
2363
|
const cppTypes = buildCppTypeContext(spec);
|
|
@@ -2374,38 +2375,13 @@ function generateOutputs(spec, options = { emitQWidget: true, emitAngularService
|
|
|
2374
2375
|
return outputs;
|
|
2375
2376
|
}
|
|
2376
2377
|
function writeGeneratedOutputs(cwd, outputs) {
|
|
2377
|
-
const outputRoot =
|
|
2378
|
+
const outputRoot = (0, layout_1.anqstGeneratedRootDir)(cwd);
|
|
2378
2379
|
for (const [relPath, content] of Object.entries(outputs)) {
|
|
2379
2380
|
const filePath = node_path_1.default.join(outputRoot, relPath);
|
|
2380
2381
|
node_fs_1.default.mkdirSync(node_path_1.default.dirname(filePath), { recursive: true });
|
|
2381
2382
|
node_fs_1.default.writeFileSync(filePath, withBuildStamp(relPath, content), "utf8");
|
|
2382
2383
|
}
|
|
2383
2384
|
}
|
|
2384
|
-
function installTypeScriptOutputs(cwd) {
|
|
2385
|
-
const sourceDir = node_path_1.default.join(cwd, "generated_output", "npmpackage");
|
|
2386
|
-
const targetDir = node_path_1.default.join(cwd, "src", "anqst-generated");
|
|
2387
|
-
if (!node_fs_1.default.existsSync(sourceDir))
|
|
2388
|
-
return;
|
|
2389
|
-
node_fs_1.default.rmSync(targetDir, { recursive: true, force: true });
|
|
2390
|
-
node_fs_1.default.mkdirSync(targetDir, { recursive: true });
|
|
2391
|
-
const queue = [sourceDir];
|
|
2392
|
-
while (queue.length > 0) {
|
|
2393
|
-
const current = queue.shift();
|
|
2394
|
-
for (const entry of node_fs_1.default.readdirSync(current, { withFileTypes: true })) {
|
|
2395
|
-
const abs = node_path_1.default.join(current, entry.name);
|
|
2396
|
-
const rel = node_path_1.default.relative(sourceDir, abs);
|
|
2397
|
-
const dst = node_path_1.default.join(targetDir, rel);
|
|
2398
|
-
if (entry.isDirectory()) {
|
|
2399
|
-
node_fs_1.default.mkdirSync(dst, { recursive: true });
|
|
2400
|
-
queue.push(abs);
|
|
2401
|
-
}
|
|
2402
|
-
else if (entry.isFile()) {
|
|
2403
|
-
node_fs_1.default.mkdirSync(node_path_1.default.dirname(dst), { recursive: true });
|
|
2404
|
-
node_fs_1.default.copyFileSync(abs, dst);
|
|
2405
|
-
}
|
|
2406
|
-
}
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2409
2385
|
function listFilesRecursively(rootDir) {
|
|
2410
2386
|
const output = [];
|
|
2411
2387
|
const queue = [rootDir];
|
|
@@ -2539,7 +2515,7 @@ function installEmbeddedWebBundle(cwd, widgetName) {
|
|
|
2539
2515
|
if (!node_fs_1.default.existsSync(node_path_1.default.join(distWebRoot, "index.html"))) {
|
|
2540
2516
|
return false;
|
|
2541
2517
|
}
|
|
2542
|
-
const cppLibraryRoot =
|
|
2518
|
+
const cppLibraryRoot = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, widgetName).cppQtWidgetRoot;
|
|
2543
2519
|
const cppLibraryWebRoot = node_path_1.default.join(cppLibraryRoot, "webapp");
|
|
2544
2520
|
node_fs_1.default.rmSync(cppLibraryWebRoot, { recursive: true, force: true });
|
|
2545
2521
|
node_fs_1.default.mkdirSync(cppLibraryWebRoot, { recursive: true });
|
|
@@ -2571,15 +2547,15 @@ function normalizeEmbeddedIndexHtml(indexPath, webRoot) {
|
|
|
2571
2547
|
node_fs_1.default.writeFileSync(indexPath, html, "utf8");
|
|
2572
2548
|
}
|
|
2573
2549
|
function renderQtIntegrationCMake(widgetName) {
|
|
2574
|
-
const generatedRootVar = "
|
|
2550
|
+
const generatedRootVar = "ANQST_GENERATED_WIDGET_DIR";
|
|
2575
2551
|
const generatedIncludeVar = "ANQST_GENERATED_INCLUDE_DIR";
|
|
2576
|
-
const
|
|
2552
|
+
const projectRootVar = "ANQST_PROJECT_ROOT";
|
|
2577
2553
|
const widgetTarget = `${widgetName}Widget`;
|
|
2578
2554
|
const autogenTarget = `${widgetTarget}_anqst_codegen`;
|
|
2579
2555
|
return `cmake_minimum_required(VERSION 3.21)
|
|
2580
2556
|
|
|
2581
|
-
set(${
|
|
2582
|
-
set(${generatedRootVar} "\${
|
|
2557
|
+
set(${projectRootVar} "\${CMAKE_CURRENT_LIST_DIR}/../../../../..")
|
|
2558
|
+
set(${generatedRootVar} "\${CMAKE_CURRENT_LIST_DIR}/../qt/${generatedCppLibraryDirName(widgetName)}")
|
|
2583
2559
|
set(${generatedIncludeVar} "\${${generatedRootVar}}/include")
|
|
2584
2560
|
|
|
2585
2561
|
if(TARGET ${widgetTarget})
|
|
@@ -2587,7 +2563,7 @@ if(TARGET ${widgetTarget})
|
|
|
2587
2563
|
endif()
|
|
2588
2564
|
|
|
2589
2565
|
if(NOT TARGET anqstwebhostbase)
|
|
2590
|
-
message(FATAL_ERROR "Target 'anqstwebhostbase' must exist before including
|
|
2566
|
+
message(FATAL_ERROR "Target 'anqstwebhostbase' must exist before including generated AnQst CMake for ${widgetName}.")
|
|
2591
2567
|
endif()
|
|
2592
2568
|
|
|
2593
2569
|
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
|
|
@@ -2607,7 +2583,7 @@ add_custom_command(
|
|
|
2607
2583
|
"\${${generatedRootVar}}/webapp/index.html"
|
|
2608
2584
|
COMMAND "\${ANQST_NPM_EXECUTABLE}" install
|
|
2609
2585
|
COMMAND "\${ANQST_NPM_EXECUTABLE}" run anqst:build
|
|
2610
|
-
WORKING_DIRECTORY "\${${
|
|
2586
|
+
WORKING_DIRECTORY "\${${projectRootVar}}"
|
|
2611
2587
|
COMMENT "Generating AnQst widget library (${widgetTarget}) from Angular project"
|
|
2612
2588
|
VERBATIM
|
|
2613
2589
|
)
|
|
@@ -2648,9 +2624,9 @@ target_link_libraries(${widgetTarget}
|
|
|
2648
2624
|
`;
|
|
2649
2625
|
}
|
|
2650
2626
|
function installQtIntegrationCMake(cwd, widgetName) {
|
|
2651
|
-
const integrationDir =
|
|
2627
|
+
const integrationDir = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, widgetName).cppCmakeRoot;
|
|
2652
2628
|
node_fs_1.default.mkdirSync(integrationDir, { recursive: true });
|
|
2653
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(integrationDir, "CMakeLists.txt"), withBuildStamp("
|
|
2629
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(integrationDir, "CMakeLists.txt"), withBuildStamp("backend/cpp/cmake/CMakeLists.txt", renderQtIntegrationCMake(widgetName)), "utf8");
|
|
2654
2630
|
}
|
|
2655
2631
|
function normalizeIcoSize(dim) {
|
|
2656
2632
|
return dim === 0 ? 256 : dim;
|
|
@@ -2881,8 +2857,8 @@ set(CMAKE_AUTOMOC ON)
|
|
|
2881
2857
|
set(CMAKE_AUTOUIC ON)
|
|
2882
2858
|
set(CMAKE_AUTORCC ON)
|
|
2883
2859
|
|
|
2884
|
-
set(
|
|
2885
|
-
set(ANQST_WIDGET_DIR "\${
|
|
2860
|
+
set(ANQST_PROJECT_ROOT "\${CMAKE_CURRENT_LIST_DIR}/../../../../../../..")
|
|
2861
|
+
set(ANQST_WIDGET_DIR "\${CMAKE_CURRENT_LIST_DIR}/..")
|
|
2886
2862
|
set(ANQST_WEBBASE_DIR "" CACHE PATH "Path to AnQstWebBase source directory")
|
|
2887
2863
|
|
|
2888
2864
|
if(NOT EXISTS "\${ANQST_WIDGET_DIR}/CMakeLists.txt")
|
|
@@ -2891,10 +2867,10 @@ endif()
|
|
|
2891
2867
|
|
|
2892
2868
|
if(NOT ANQST_WEBBASE_DIR)
|
|
2893
2869
|
foreach(candidate
|
|
2894
|
-
"\${
|
|
2895
|
-
"\${
|
|
2896
|
-
"\${
|
|
2897
|
-
"\${
|
|
2870
|
+
"\${ANQST_PROJECT_ROOT}/AnQstWidget/AnQstWebBase"
|
|
2871
|
+
"\${ANQST_PROJECT_ROOT}/../AnQstWidget/AnQstWebBase"
|
|
2872
|
+
"\${ANQST_PROJECT_ROOT}/../../AnQstWidget/AnQstWebBase"
|
|
2873
|
+
"\${ANQST_PROJECT_ROOT}/../../../AnQstWidget/AnQstWebBase")
|
|
2898
2874
|
if(EXISTS "\${candidate}/CMakeLists.txt")
|
|
2899
2875
|
set(ANQST_WEBBASE_DIR "\${candidate}")
|
|
2900
2876
|
break()
|
|
@@ -2938,11 +2914,11 @@ set_target_properties(${pluginTarget} PROPERTIES
|
|
|
2938
2914
|
`;
|
|
2939
2915
|
}
|
|
2940
2916
|
function installQtDesignerPluginCMake(cwd, widgetName, options = {}) {
|
|
2941
|
-
const pluginDir =
|
|
2917
|
+
const pluginDir = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, widgetName).designerPluginRoot;
|
|
2942
2918
|
node_fs_1.default.mkdirSync(pluginDir, { recursive: true });
|
|
2943
2919
|
const assets = installDesignerPluginIconAssets(cwd, pluginDir);
|
|
2944
2920
|
const pluginTarget = `${widgetName}DesignerPlugin`;
|
|
2945
2921
|
const widgetCategory = options.widgetCategory ?? "AnQst Widgets";
|
|
2946
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(pluginDir, "CMakeLists.txt"), withBuildStamp(
|
|
2947
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(pluginDir, `${pluginTarget}.cpp`), withBuildStamp(`
|
|
2922
|
+
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");
|
|
2923
|
+
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");
|
|
2948
2924
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ANQST_LAYOUT_VERSION = exports.ANQST_GENERATED_DIRNAME = exports.ANQST_ROOT_DIRNAME = void 0;
|
|
7
|
+
exports.normalizeSlashes = normalizeSlashes;
|
|
8
|
+
exports.anqstRootDir = anqstRootDir;
|
|
9
|
+
exports.anqstGeneratedRootDir = anqstGeneratedRootDir;
|
|
10
|
+
exports.anqstDebugIntermediateRootDir = anqstDebugIntermediateRootDir;
|
|
11
|
+
exports.anqstSpecFileName = anqstSpecFileName;
|
|
12
|
+
exports.anqstSettingsFileName = anqstSettingsFileName;
|
|
13
|
+
exports.anqstSettingsRelativePath = anqstSettingsRelativePath;
|
|
14
|
+
exports.generatedFrontendDirName = generatedFrontendDirName;
|
|
15
|
+
exports.generatedNodeExpressDirName = generatedNodeExpressDirName;
|
|
16
|
+
exports.generatedQtWidgetDirName = generatedQtWidgetDirName;
|
|
17
|
+
exports.resolveGeneratedLayoutPaths = resolveGeneratedLayoutPaths;
|
|
18
|
+
exports.toProjectRelative = toProjectRelative;
|
|
19
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
20
|
+
exports.ANQST_ROOT_DIRNAME = "AnQst";
|
|
21
|
+
exports.ANQST_GENERATED_DIRNAME = "generated";
|
|
22
|
+
exports.ANQST_LAYOUT_VERSION = 2;
|
|
23
|
+
function normalizeSlashes(inputPath) {
|
|
24
|
+
return inputPath.split(node_path_1.default.sep).join("/");
|
|
25
|
+
}
|
|
26
|
+
function anqstRootDir(cwd) {
|
|
27
|
+
return node_path_1.default.join(cwd, exports.ANQST_ROOT_DIRNAME);
|
|
28
|
+
}
|
|
29
|
+
function anqstGeneratedRootDir(cwd) {
|
|
30
|
+
return node_path_1.default.join(anqstRootDir(cwd), exports.ANQST_GENERATED_DIRNAME);
|
|
31
|
+
}
|
|
32
|
+
function anqstDebugIntermediateRootDir(cwd) {
|
|
33
|
+
return node_path_1.default.join(anqstGeneratedRootDir(cwd), "debug", "intermediate");
|
|
34
|
+
}
|
|
35
|
+
function anqstSpecFileName(widgetName) {
|
|
36
|
+
return `${widgetName}.AnQst.d.ts`;
|
|
37
|
+
}
|
|
38
|
+
function anqstSettingsFileName(widgetName) {
|
|
39
|
+
return `${widgetName}.settings.json`;
|
|
40
|
+
}
|
|
41
|
+
function anqstSettingsRelativePath(widgetName) {
|
|
42
|
+
return `./${exports.ANQST_ROOT_DIRNAME}/${anqstSettingsFileName(widgetName)}`;
|
|
43
|
+
}
|
|
44
|
+
function generatedFrontendDirName(widgetName) {
|
|
45
|
+
return `${widgetName}_Angular`;
|
|
46
|
+
}
|
|
47
|
+
function generatedNodeExpressDirName(widgetName) {
|
|
48
|
+
return `${widgetName}_anQst`;
|
|
49
|
+
}
|
|
50
|
+
function generatedQtWidgetDirName(widgetName) {
|
|
51
|
+
return `${widgetName}_widget`;
|
|
52
|
+
}
|
|
53
|
+
function resolveGeneratedLayoutPaths(cwd, widgetName) {
|
|
54
|
+
const generatedRoot = anqstGeneratedRootDir(cwd);
|
|
55
|
+
const cppQtWidgetRoot = node_path_1.default.join(generatedRoot, "backend", "cpp", "qt", generatedQtWidgetDirName(widgetName));
|
|
56
|
+
const designerPluginRoot = node_path_1.default.join(cppQtWidgetRoot, "designerPlugin");
|
|
57
|
+
return {
|
|
58
|
+
generatedRoot,
|
|
59
|
+
frontendRoot: node_path_1.default.join(generatedRoot, "frontend", generatedFrontendDirName(widgetName)),
|
|
60
|
+
nodeExpressRoot: node_path_1.default.join(generatedRoot, "backend", "node", "express", generatedNodeExpressDirName(widgetName)),
|
|
61
|
+
cppCmakeRoot: node_path_1.default.join(generatedRoot, "backend", "cpp", "cmake"),
|
|
62
|
+
cppQtWidgetRoot,
|
|
63
|
+
designerPluginRoot,
|
|
64
|
+
designerPluginBuildRoot: node_path_1.default.join(designerPluginRoot, "build"),
|
|
65
|
+
debugIntermediateRoot: anqstDebugIntermediateRootDir(cwd)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function toProjectRelative(cwd, absolutePath) {
|
|
69
|
+
return normalizeSlashes(node_path_1.default.relative(cwd, absolutePath));
|
|
70
|
+
}
|
package/dist/src/parser.js
CHANGED
|
@@ -8,6 +8,9 @@ const node_fs_1 = __importDefault(require("node:fs"));
|
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const typescript_1 = __importDefault(require("typescript"));
|
|
10
10
|
const errors_1 = require("./errors");
|
|
11
|
+
const program_1 = require("./program");
|
|
12
|
+
const typegraph_1 = require("./typegraph");
|
|
13
|
+
const debug_dump_1 = require("./debug-dump");
|
|
11
14
|
function locFromNode(source, node) {
|
|
12
15
|
const lc = source.getLineAndCharacterOfPosition(node.getStart(source));
|
|
13
16
|
return {
|
|
@@ -207,7 +210,7 @@ function serviceBaseType(iface) {
|
|
|
207
210
|
}
|
|
208
211
|
return null;
|
|
209
212
|
}
|
|
210
|
-
function
|
|
213
|
+
function parseSpecFileAst(specFilePath) {
|
|
211
214
|
if (!node_fs_1.default.existsSync(specFilePath))
|
|
212
215
|
throw new errors_1.VerifyError(`Spec file does not exist: ${specFilePath}`);
|
|
213
216
|
const text = node_fs_1.default.readFileSync(specFilePath, "utf8");
|
|
@@ -257,3 +260,15 @@ function parseSpecFile(specFilePath) {
|
|
|
257
260
|
specImports: importInfo.specImports
|
|
258
261
|
};
|
|
259
262
|
}
|
|
263
|
+
function parseSpecFile(specFilePath) {
|
|
264
|
+
(0, program_1.createTscProgramContext)(specFilePath);
|
|
265
|
+
const parsed = parseSpecFileAst(specFilePath);
|
|
266
|
+
if ((0, debug_dump_1.isDebugEnabled)()) {
|
|
267
|
+
(0, debug_dump_1.writeDebugFile)(process.cwd(), "anqstmodel/parsed-before-typegraph.txt", `${(0, debug_dump_1.inspectText)(parsed)}\n`);
|
|
268
|
+
}
|
|
269
|
+
const normalized = (0, typegraph_1.applyResolvedTypeGraph)(parsed);
|
|
270
|
+
if ((0, debug_dump_1.isDebugEnabled)()) {
|
|
271
|
+
(0, debug_dump_1.writeDebugFile)(process.cwd(), "anqstmodel/parsed-after-typegraph.txt", `${(0, debug_dump_1.inspectText)(normalized)}\n`);
|
|
272
|
+
}
|
|
273
|
+
return normalized;
|
|
274
|
+
}
|
|
@@ -9,7 +9,7 @@ exports.getProgramDiagnostics = getProgramDiagnostics;
|
|
|
9
9
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
10
10
|
const node_path_1 = __importDefault(require("node:path"));
|
|
11
11
|
const typescript_1 = __importDefault(require("typescript"));
|
|
12
|
-
const errors_1 = require("
|
|
12
|
+
const errors_1 = require("./errors");
|
|
13
13
|
const debug_dump_1 = require("./debug-dump");
|
|
14
14
|
const contextBySpecPath = new Map();
|
|
15
15
|
function diagnosticText(diagnostic) {
|