@holoscript/core 6.0.4 → 7.0.0
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/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/compiler/index.d.ts +82 -0
- package/dist/constants.d.ts +3 -2
- package/dist/coordinators/index.d.ts +189 -0
- package/dist/index.d.ts +501 -19
- package/dist/paper-0c-spike/index.d.ts +29 -0
- package/dist/reconstruction/index.d.ts +78 -0
- package/dist/tools/index.d.ts +22 -1
- package/dist/traitDocs/traitDocs.d.ts +69 -0
- package/dist/traits/index.d.ts +61 -0
- package/package.json +105 -57
- package/dist/GLTFPipeline-DEN36VNK.js +0 -12
- package/dist/GLTFPipeline-YPCAK236.cjs +0 -33
- package/dist/HoloScriptPlusParser-BN6KVRCM.js +0 -692
- package/dist/HoloScriptPlusParser-NC5FE6AL.cjs +0 -697
- package/dist/USDZExporter-NTMBNTDB.js +0 -707
- package/dist/USDZExporter-UWGWNMMD.cjs +0 -709
- package/dist/chunk-27LWW5FU.cjs +0 -410
- package/dist/chunk-2CWOLHTE.js +0 -69
- package/dist/chunk-33LSUQDD.cjs +0 -835
- package/dist/chunk-3FJCK5XA.js +0 -2232
- package/dist/chunk-3FXV5S25.cjs +0 -633
- package/dist/chunk-3FYZOR7S.cjs +0 -69
- package/dist/chunk-3SAK5KFL.cjs +0 -83
- package/dist/chunk-4XSNJCLC.cjs +0 -1859
- package/dist/chunk-54FHG2MX.js +0 -655
- package/dist/chunk-56IF4NTA.js +0 -56
- package/dist/chunk-5BGSECRJ.cjs +0 -2237
- package/dist/chunk-5GLCTO44.js +0 -161
- package/dist/chunk-5O6TQC6M.cjs +0 -1871
- package/dist/chunk-5OEOHAAW.cjs +0 -682
- package/dist/chunk-5TOFIR6L.js +0 -407
- package/dist/chunk-5WUNN6ZN.cjs +0 -428
- package/dist/chunk-6TZPZCOJ.cjs +0 -1404
- package/dist/chunk-6UEHYZ7V.cjs +0 -773
- package/dist/chunk-6XSERL6L.js +0 -5678
- package/dist/chunk-72EQECGT.cjs +0 -908
- package/dist/chunk-7AGYRWKW.cjs +0 -507
- package/dist/chunk-7LCYLPW2.cjs +0 -663
- package/dist/chunk-A7PIMZGU.js +0 -263
- package/dist/chunk-ATSKSYVE.cjs +0 -51683
- package/dist/chunk-B5TCIAPQ.cjs +0 -117
- package/dist/chunk-BF2235SI.cjs +0 -5714
- package/dist/chunk-BKIGPPVM.js +0 -629
- package/dist/chunk-BND3ST2K.cjs +0 -662
- package/dist/chunk-BU7VWW2K.js +0 -2522
- package/dist/chunk-BWFJEM5A.js +0 -5419
- package/dist/chunk-CAUCGUEA.cjs +0 -130
- package/dist/chunk-CBJSLA2E.cjs +0 -5423
- package/dist/chunk-CDPGV4DN.js +0 -114
- package/dist/chunk-CLYEIWA5.cjs +0 -408
- package/dist/chunk-CS2EMTGF.js +0 -1966
- package/dist/chunk-DMG7C4H2.js +0 -975
- package/dist/chunk-DXJQDCFL.js +0 -468
- package/dist/chunk-E3FWRT3Z.js +0 -608
- package/dist/chunk-E3UALNFA.js +0 -421
- package/dist/chunk-EONILVMF.js +0 -762
- package/dist/chunk-EQV4R3EV.cjs +0 -769
- package/dist/chunk-F3HH56EB.cjs +0 -5538
- package/dist/chunk-F4IULT7N.js +0 -1488
- package/dist/chunk-FF3Q7ADR.js +0 -380
- package/dist/chunk-FFKU7BTK.cjs +0 -1046
- package/dist/chunk-FHQVYCH2.js +0 -70
- package/dist/chunk-FSF7EQVA.cjs +0 -1974
- package/dist/chunk-G4VZTCIB.js +0 -659
- package/dist/chunk-G7CT3EMP.cjs +0 -1002
- package/dist/chunk-GGHSW2NN.js +0 -51334
- package/dist/chunk-GVUR45UF.cjs +0 -777
- package/dist/chunk-H5Z7NASB.js +0 -9662
- package/dist/chunk-HE7ULERA.cjs +0 -697
- package/dist/chunk-HJJLD366.js +0 -1169
- package/dist/chunk-HPS76H7Q.js +0 -309
- package/dist/chunk-HQUEA5R6.cjs +0 -424
- package/dist/chunk-HYNTS5CP.js +0 -422
- package/dist/chunk-I6XZ5DZF.cjs +0 -488
- package/dist/chunk-IBDG74G2.cjs +0 -1219
- package/dist/chunk-IFNQFCTM.js +0 -3098
- package/dist/chunk-IHOUYQIA.js +0 -406
- package/dist/chunk-ILRBGFVD.cjs +0 -72
- package/dist/chunk-IWI6J7FX.js +0 -421
- package/dist/chunk-K3JDKWGI.cjs +0 -270
- package/dist/chunk-K6EKD26I.js +0 -630
- package/dist/chunk-KCQ5NDYC.cjs +0 -3172
- package/dist/chunk-KED34ILP.js +0 -832
- package/dist/chunk-KSGXLT74.cjs +0 -457
- package/dist/chunk-L4G4RLXX.js +0 -767
- package/dist/chunk-LDP5OK6G.js +0 -1216
- package/dist/chunk-LGGRPKTV.cjs +0 -735
- package/dist/chunk-LK5IAVH6.cjs +0 -1173
- package/dist/chunk-LSW7P7ML.js +0 -3675
- package/dist/chunk-LXJ4667L.cjs +0 -3874
- package/dist/chunk-LZ266PCM.cjs +0 -4499
- package/dist/chunk-MD6KDHVE.cjs +0 -237
- package/dist/chunk-MEASWI2Y.js +0 -126
- package/dist/chunk-MPXBVFHQ.js +0 -768
- package/dist/chunk-N5FTS757.cjs +0 -415
- package/dist/chunk-NCUKG4SK.cjs +0 -3075
- package/dist/chunk-NDQNIJEH.js +0 -1715
- package/dist/chunk-NOZZ46QU.js +0 -168
- package/dist/chunk-OFKWH2IP.js +0 -449
- package/dist/chunk-PHENW4MQ.js +0 -65
- package/dist/chunk-PMGODDJA.cjs +0 -319
- package/dist/chunk-Q4QX3AET.cjs +0 -1505
- package/dist/chunk-Q56TT7IL.js +0 -483
- package/dist/chunk-Q5JT3YML.cjs +0 -129
- package/dist/chunk-Q5SJOGHQ.cjs +0 -4256
- package/dist/chunk-QGKNANZ3.js +0 -3071
- package/dist/chunk-QLEAOI3Q.cjs +0 -424
- package/dist/chunk-R7MA7QWV.js +0 -732
- package/dist/chunk-RVYPEYPX.js +0 -678
- package/dist/chunk-S2N5TNMA.js +0 -1855
- package/dist/chunk-S565K7NK.js +0 -752
- package/dist/chunk-SDAMZIRE.js +0 -765
- package/dist/chunk-T36DDXSF.js +0 -4250
- package/dist/chunk-T4NKMBDL.js +0 -5474
- package/dist/chunk-T7LEXZUZ.cjs +0 -2526
- package/dist/chunk-TEWCN33Y.js +0 -694
- package/dist/chunk-TQSZUOW5.cjs +0 -793
- package/dist/chunk-TSH3MSQU.cjs +0 -129
- package/dist/chunk-UERJ3YJV.js +0 -504
- package/dist/chunk-UPJBDCVF.js +0 -1395
- package/dist/chunk-V3NN3HPP.js +0 -4462
- package/dist/chunk-VJ3L7CHT.cjs +0 -169
- package/dist/chunk-WB4Z63GG.js +0 -229
- package/dist/chunk-WDW67DZB.cjs +0 -9728
- package/dist/chunk-WGMEAYBG.js +0 -126
- package/dist/chunk-X4ZF6CNE.cjs +0 -473
- package/dist/chunk-X6SEAXAX.cjs +0 -3681
- package/dist/chunk-XCWFGZAA.js +0 -1043
- package/dist/chunk-XD6IYDUX.js +0 -903
- package/dist/chunk-XG23EUQX.cjs +0 -1717
- package/dist/chunk-XRKWN5PL.cjs +0 -173
- package/dist/chunk-XUILI4KB.cjs +0 -430
- package/dist/chunk-XUTX5CBW.js +0 -126
- package/dist/chunk-XWPNTWDN.cjs +0 -755
- package/dist/chunk-XXINBTZK.cjs +0 -633
- package/dist/chunk-YCXFCXDS.js +0 -1868
- package/dist/chunk-YQK5JNFK.js +0 -3725
- package/dist/chunk-YYXH45E2.js +0 -426
- package/dist/chunk-Z34RLXRA.cjs +0 -612
- package/dist/chunk-ZP4D3CSX.cjs +0 -72
- package/dist/cli/holoscript-runner.cjs +0 -2259
- package/dist/cli/holoscript-runner.js +0 -2234
- package/dist/codebase/index.cjs +0 -336
- package/dist/codebase/index.js +0 -331
- package/dist/compiler/agent-inference.cjs +0 -28
- package/dist/compiler/agent-inference.js +0 -5
- package/dist/compiler/android-xr.cjs +0 -19
- package/dist/compiler/android-xr.js +0 -9
- package/dist/compiler/android.cjs +0 -20
- package/dist/compiler/android.js +0 -10
- package/dist/compiler/ar.cjs +0 -20
- package/dist/compiler/ar.js +0 -8
- package/dist/compiler/babylon.cjs +0 -17
- package/dist/compiler/babylon.js +0 -11
- package/dist/compiler/coco.cjs +0 -27
- package/dist/compiler/coco.js +0 -4
- package/dist/compiler/domain-block-utils.cjs +0 -602
- package/dist/compiler/domain-block-utils.js +0 -8
- package/dist/compiler/dtdl.cjs +0 -24
- package/dist/compiler/dtdl.js +0 -8
- package/dist/compiler/gltf-pipeline.cjs +0 -39
- package/dist/compiler/gltf-pipeline.js +0 -4
- package/dist/compiler/godot.cjs +0 -15
- package/dist/compiler/godot.js +0 -9
- package/dist/compiler/incremental.cjs +0 -29
- package/dist/compiler/incremental.js +0 -4
- package/dist/compiler/index.cjs +0 -2578
- package/dist/compiler/index.js +0 -2383
- package/dist/compiler/ios.cjs +0 -20
- package/dist/compiler/ios.js +0 -10
- package/dist/compiler/multi-layer.cjs +0 -20
- package/dist/compiler/multi-layer.js +0 -11
- package/dist/compiler/nodetoy.cjs +0 -23
- package/dist/compiler/nodetoy.js +0 -4
- package/dist/compiler/openxr.cjs +0 -15
- package/dist/compiler/openxr.js +0 -9
- package/dist/compiler/playcanvas.cjs +0 -16
- package/dist/compiler/playcanvas.js +0 -10
- package/dist/compiler/r3f.cjs +0 -34
- package/dist/compiler/r3f.js +0 -12
- package/dist/compiler/remotion.cjs +0 -23
- package/dist/compiler/remotion.js +0 -4
- package/dist/compiler/reproducibility.cjs +0 -39
- package/dist/compiler/reproducibility.js +0 -4
- package/dist/compiler/sdf.cjs +0 -21
- package/dist/compiler/sdf.js +0 -9
- package/dist/compiler/semantic-scene.cjs +0 -31
- package/dist/compiler/semantic-scene.js +0 -4
- package/dist/compiler/state.cjs +0 -17
- package/dist/compiler/state.js +0 -7
- package/dist/compiler/trait-composition.cjs +0 -26
- package/dist/compiler/trait-composition.js +0 -5
- package/dist/compiler/unity.cjs +0 -15
- package/dist/compiler/unity.js +0 -9
- package/dist/compiler/unreal.cjs +0 -19
- package/dist/compiler/unreal.js +0 -9
- package/dist/compiler/urdf.cjs +0 -45
- package/dist/compiler/urdf.js +0 -9
- package/dist/compiler/usd-physics.cjs +0 -23
- package/dist/compiler/usd-physics.js +0 -6
- package/dist/compiler/visionos.cjs +0 -15
- package/dist/compiler/visionos.js +0 -9
- package/dist/compiler/vrchat.cjs +0 -19
- package/dist/compiler/vrchat.js +0 -9
- package/dist/compiler/vrr.cjs +0 -21
- package/dist/compiler/vrr.js +0 -9
- package/dist/compiler/wasm.cjs +0 -33
- package/dist/compiler/wasm.js +0 -9
- package/dist/compiler/webgpu.cjs +0 -15
- package/dist/compiler/webgpu.js +0 -9
- package/dist/debugger.cjs +0 -21
- package/dist/debugger.js +0 -8
- package/dist/entries/interop.cjs +0 -62
- package/dist/entries/interop.js +0 -5
- package/dist/entries/scripting.cjs +0 -68
- package/dist/entries/scripting.js +0 -11
- package/dist/index.cjs +0 -40921
- package/dist/index.js +0 -37763
- package/dist/math/vec3.cjs +0 -57
- package/dist/math/vec3.js +0 -4
- package/dist/ml-dsa-PHCWUBPX.cjs +0 -1178
- package/dist/ml-dsa-WYLJHJO6.js +0 -1178
- package/dist/parser.cjs +0 -27
- package/dist/parser.js +0 -10
- package/dist/playwright-5OSAPTNH.js +0 -98660
- package/dist/playwright-RL6GY4F7.cjs +0 -98673
- package/dist/runtime.cjs +0 -16
- package/dist/runtime.js +0 -7
- package/dist/storage/index.cjs +0 -37
- package/dist/storage/index.js +0 -4
- package/dist/traits/index.cjs +0 -14649
- package/dist/traits/index.js +0 -12243
- package/dist/type-checker.cjs +0 -18
- package/dist/type-checker.js +0 -5
package/dist/compiler/index.cjs
DELETED
|
@@ -1,2578 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkVJ3L7CHT_cjs = require('../chunk-VJ3L7CHT.cjs');
|
|
4
|
-
var chunkKSGXLT74_cjs = require('../chunk-KSGXLT74.cjs');
|
|
5
|
-
var chunk27LWW5FU_cjs = require('../chunk-27LWW5FU.cjs');
|
|
6
|
-
var chunkF3HH56EB_cjs = require('../chunk-F3HH56EB.cjs');
|
|
7
|
-
var chunkLK5IAVH6_cjs = require('../chunk-LK5IAVH6.cjs');
|
|
8
|
-
var chunkXUILI4KB_cjs = require('../chunk-XUILI4KB.cjs');
|
|
9
|
-
var chunk5WUNN6ZN_cjs = require('../chunk-5WUNN6ZN.cjs');
|
|
10
|
-
require('../chunk-72EQECGT.cjs');
|
|
11
|
-
var chunkI6XZ5DZF_cjs = require('../chunk-I6XZ5DZF.cjs');
|
|
12
|
-
var chunkQLEAOI3Q_cjs = require('../chunk-QLEAOI3Q.cjs');
|
|
13
|
-
var chunk6TZPZCOJ_cjs = require('../chunk-6TZPZCOJ.cjs');
|
|
14
|
-
var chunkEQV4R3EV_cjs = require('../chunk-EQV4R3EV.cjs');
|
|
15
|
-
var chunk7AGYRWKW_cjs = require('../chunk-7AGYRWKW.cjs');
|
|
16
|
-
var chunkB5TCIAPQ_cjs = require('../chunk-B5TCIAPQ.cjs');
|
|
17
|
-
var chunkXRKWN5PL_cjs = require('../chunk-XRKWN5PL.cjs');
|
|
18
|
-
var chunkFSF7EQVA_cjs = require('../chunk-FSF7EQVA.cjs');
|
|
19
|
-
var chunkQ5SJOGHQ_cjs = require('../chunk-Q5SJOGHQ.cjs');
|
|
20
|
-
require('../chunk-WDW67DZB.cjs');
|
|
21
|
-
var chunkXWPNTWDN_cjs = require('../chunk-XWPNTWDN.cjs');
|
|
22
|
-
var chunkNCUKG4SK_cjs = require('../chunk-NCUKG4SK.cjs');
|
|
23
|
-
var chunk4XSNJCLC_cjs = require('../chunk-4XSNJCLC.cjs');
|
|
24
|
-
var chunkCBJSLA2E_cjs = require('../chunk-CBJSLA2E.cjs');
|
|
25
|
-
var chunk5O6TQC6M_cjs = require('../chunk-5O6TQC6M.cjs');
|
|
26
|
-
var chunk6UEHYZ7V_cjs = require('../chunk-6UEHYZ7V.cjs');
|
|
27
|
-
var chunkBND3ST2K_cjs = require('../chunk-BND3ST2K.cjs');
|
|
28
|
-
var chunkZP4D3CSX_cjs = require('../chunk-ZP4D3CSX.cjs');
|
|
29
|
-
var chunkQ5JT3YML_cjs = require('../chunk-Q5JT3YML.cjs');
|
|
30
|
-
var chunkFFKU7BTK_cjs = require('../chunk-FFKU7BTK.cjs');
|
|
31
|
-
var chunkZ34RLXRA_cjs = require('../chunk-Z34RLXRA.cjs');
|
|
32
|
-
var chunk33LSUQDD_cjs = require('../chunk-33LSUQDD.cjs');
|
|
33
|
-
require('../chunk-K3JDKWGI.cjs');
|
|
34
|
-
require('../chunk-X4ZF6CNE.cjs');
|
|
35
|
-
var chunkHE7ULERA_cjs = require('../chunk-HE7ULERA.cjs');
|
|
36
|
-
var chunk5OEOHAAW_cjs = require('../chunk-5OEOHAAW.cjs');
|
|
37
|
-
var chunkXXINBTZK_cjs = require('../chunk-XXINBTZK.cjs');
|
|
38
|
-
require('../chunk-3FYZOR7S.cjs');
|
|
39
|
-
var chunkXG23EUQX_cjs = require('../chunk-XG23EUQX.cjs');
|
|
40
|
-
require('../chunk-KCQ5NDYC.cjs');
|
|
41
|
-
require('../chunk-PMGODDJA.cjs');
|
|
42
|
-
require('../chunk-MD6KDHVE.cjs');
|
|
43
|
-
require('../chunk-CAUCGUEA.cjs');
|
|
44
|
-
var chunkLGGRPKTV_cjs = require('../chunk-LGGRPKTV.cjs');
|
|
45
|
-
require('../chunk-LXJ4667L.cjs');
|
|
46
|
-
var chunkBF2235SI_cjs = require('../chunk-BF2235SI.cjs');
|
|
47
|
-
var chunk3SAK5KFL_cjs = require('../chunk-3SAK5KFL.cjs');
|
|
48
|
-
|
|
49
|
-
// src/compiler/Native2DCompiler.ts
|
|
50
|
-
var Native2DCompiler_exports = {};
|
|
51
|
-
chunk3SAK5KFL_cjs.__export(Native2DCompiler_exports, {
|
|
52
|
-
Native2DCompiler: () => exports.Native2DCompiler
|
|
53
|
-
});
|
|
54
|
-
exports.Native2DCompiler = void 0;
|
|
55
|
-
var init_Native2DCompiler = chunk3SAK5KFL_cjs.__esm({
|
|
56
|
-
"src/compiler/Native2DCompiler.ts"() {
|
|
57
|
-
chunkBF2235SI_cjs.init_CompilerBase();
|
|
58
|
-
exports.Native2DCompiler = class extends chunkBF2235SI_cjs.CompilerBase {
|
|
59
|
-
constructor() {
|
|
60
|
-
super(...arguments);
|
|
61
|
-
this.compilerName = "Native2DCompiler";
|
|
62
|
-
// ============================================================================
|
|
63
|
-
// REACT GENERATION
|
|
64
|
-
// ============================================================================
|
|
65
|
-
/** Collected during node traversal — used to generate imports and hooks */
|
|
66
|
-
this._slotImports = /* @__PURE__ */ new Map();
|
|
67
|
-
this._uiImports = /* @__PURE__ */ new Set();
|
|
68
|
-
this._stateFields = /* @__PURE__ */ new Map();
|
|
69
|
-
this._fetchCalls = [];
|
|
70
|
-
this._options = {};
|
|
71
|
-
}
|
|
72
|
-
// @ts-expect-error During migration
|
|
73
|
-
compile(composition, agentToken, outputPath, options) {
|
|
74
|
-
this.validateCompilerAccess(agentToken, outputPath);
|
|
75
|
-
const isReact = options?.format === "react";
|
|
76
|
-
const elements = composition.ui?.elements || composition.objects || [];
|
|
77
|
-
if (isReact) {
|
|
78
|
-
const code = this.generateReactComponent(composition.name, elements, composition, options);
|
|
79
|
-
if (options?.generateDocs) {
|
|
80
|
-
return {
|
|
81
|
-
output: code,
|
|
82
|
-
documentation: this.generateDocumentation(composition, code, options.docsOptions)
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return code;
|
|
86
|
-
} else {
|
|
87
|
-
const code = this.generateHTMLPage(composition.name, elements, composition);
|
|
88
|
-
if (options?.generateDocs) {
|
|
89
|
-
return {
|
|
90
|
-
output: code,
|
|
91
|
-
documentation: this.generateDocumentation(composition, code, options.docsOptions)
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
return code;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
generateReactComponent(name, objects, composition, options) {
|
|
98
|
-
this._slotImports.clear();
|
|
99
|
-
this._uiImports.clear();
|
|
100
|
-
this._stateFields.clear();
|
|
101
|
-
this._fetchCalls = [];
|
|
102
|
-
this._options = options || {};
|
|
103
|
-
const safeName = name.replace(/[^a-zA-Z0-9]/g, "");
|
|
104
|
-
if (composition?.state?.properties) {
|
|
105
|
-
for (const prop of composition.state.properties) {
|
|
106
|
-
this._stateFields.set(prop.key, prop.value ?? null);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const jsx = objects.map((obj) => this.generateReactNode(obj)).join("\n ");
|
|
110
|
-
const imports = [];
|
|
111
|
-
const reactImports = /* @__PURE__ */ new Set();
|
|
112
|
-
if (this._stateFields.size > 0) reactImports.add("useState");
|
|
113
|
-
if (this._fetchCalls.length > 0) reactImports.add("useEffect");
|
|
114
|
-
imports.push(
|
|
115
|
-
reactImports.size > 0 ? `import React, { ${[...reactImports].join(", ")} } from 'react';` : `import React from 'react';`
|
|
116
|
-
);
|
|
117
|
-
if (this._uiImports.size > 0) {
|
|
118
|
-
imports.push(`import { ${[...this._uiImports].join(", ")} } from '@holoscript/ui';`);
|
|
119
|
-
}
|
|
120
|
-
for (const [, slot] of this._slotImports) {
|
|
121
|
-
imports.push(`import { ${slot.component} } from '${slot.importPath}';`);
|
|
122
|
-
}
|
|
123
|
-
const stateHooks = [];
|
|
124
|
-
for (const [key, value] of this._stateFields) {
|
|
125
|
-
const capitalKey = key.charAt(0).toUpperCase() + key.slice(1);
|
|
126
|
-
const initValue = JSON.stringify(value);
|
|
127
|
-
stateHooks.push(
|
|
128
|
-
` const [${key}, set${capitalKey}] = useState(${initValue === void 0 ? "null" : initValue});`
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
const fetchEffects = [];
|
|
132
|
-
for (const f of this._fetchCalls) {
|
|
133
|
-
fetchEffects.push(` useEffect(() => {
|
|
134
|
-
fetch(\`${f.endpoint}\`${f.method !== "GET" ? `, { method: '${f.method}' }` : ""})
|
|
135
|
-
.then(r => r.json())
|
|
136
|
-
.then(set${f.name.charAt(0).toUpperCase() + f.name.slice(1)})
|
|
137
|
-
.catch(console.error);
|
|
138
|
-
}, []);`);
|
|
139
|
-
}
|
|
140
|
-
return `${imports.join("\n")}
|
|
141
|
-
|
|
142
|
-
// @generated by HoloScript Native2DCompiler \u2014 DO NOT EDIT
|
|
143
|
-
export function ${safeName}Component() {
|
|
144
|
-
${stateHooks.join("\n")}
|
|
145
|
-
${fetchEffects.join("\n")}
|
|
146
|
-
|
|
147
|
-
return (
|
|
148
|
-
<div className="holoscript-2d-root w-full h-full">
|
|
149
|
-
${jsx}
|
|
150
|
-
</div>
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export default ${safeName}Component;
|
|
155
|
-
`;
|
|
156
|
-
}
|
|
157
|
-
generateReactNode(obj) {
|
|
158
|
-
const traits = this.extractTraits(obj);
|
|
159
|
-
if (traits.slot) {
|
|
160
|
-
const slotName = traits.slot.name || obj.name || "Slot";
|
|
161
|
-
const configuredSlot = this._options.slots?.[String(slotName)];
|
|
162
|
-
const component = traits.slot.component || configuredSlot?.component || slotName;
|
|
163
|
-
const importPath = traits.slot.import || configuredSlot?.importPath || `@/components/${component}`;
|
|
164
|
-
this._slotImports.set(slotName, { component, importPath });
|
|
165
|
-
const propsStr = traits.slot.props ? ` {...${JSON.stringify(traits.slot.props)}}` : "";
|
|
166
|
-
return `<div data-holo-slot="${slotName}">
|
|
167
|
-
<${component}${propsStr} />
|
|
168
|
-
</div>`;
|
|
169
|
-
}
|
|
170
|
-
if (traits.fetch) {
|
|
171
|
-
const name = traits.fetch.into || "data";
|
|
172
|
-
const endpoint = traits.fetch.endpoint || "/api/data";
|
|
173
|
-
const method = traits.fetch.method || "GET";
|
|
174
|
-
this._fetchCalls.push({ name, endpoint, method });
|
|
175
|
-
if (!this._stateFields.has(name)) {
|
|
176
|
-
this._stateFields.set(name, null);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
let tag = traits.theme?.tag || traits.panel?.tag || (typeof obj.type === "string" ? obj.type.toLowerCase() : void 0) || "div";
|
|
180
|
-
if ([
|
|
181
|
-
"nav",
|
|
182
|
-
"section",
|
|
183
|
-
"main",
|
|
184
|
-
"footer",
|
|
185
|
-
"form",
|
|
186
|
-
"style",
|
|
187
|
-
"a",
|
|
188
|
-
"header",
|
|
189
|
-
"h1",
|
|
190
|
-
"h2",
|
|
191
|
-
"h3"
|
|
192
|
-
].includes(tag)) ; else if (tag === "container") {
|
|
193
|
-
tag = "div";
|
|
194
|
-
} else if (traits.link || tag === "link") {
|
|
195
|
-
tag = "a";
|
|
196
|
-
} else if (traits.button || tag === "button") {
|
|
197
|
-
tag = "button";
|
|
198
|
-
} else if (traits.image || tag === "image") {
|
|
199
|
-
tag = "img";
|
|
200
|
-
} else if (traits.input || tag === "input") {
|
|
201
|
-
tag = "input";
|
|
202
|
-
} else if (traits.text || tag === "text") {
|
|
203
|
-
tag = this.mapTextVariantToTag(traits.text?.variant || "body");
|
|
204
|
-
} else {
|
|
205
|
-
tag = "div";
|
|
206
|
-
}
|
|
207
|
-
const styles = this.buildStyles(traits);
|
|
208
|
-
const classes = this.buildClasses(traits);
|
|
209
|
-
let props = ``;
|
|
210
|
-
if (traits.theme?.className) {
|
|
211
|
-
classes.push(traits.theme.className);
|
|
212
|
-
}
|
|
213
|
-
if (traits.theme?.id) {
|
|
214
|
-
props += ` id="${traits.theme.id}"`;
|
|
215
|
-
}
|
|
216
|
-
const combinedStyles = { ...styles };
|
|
217
|
-
if (traits.theme?.style) {
|
|
218
|
-
traits.theme.style.split(";").forEach((rule) => {
|
|
219
|
-
const [key, ...valueParts] = rule.split(":");
|
|
220
|
-
const value = valueParts.join(":");
|
|
221
|
-
if (key && value) {
|
|
222
|
-
const camelKey = key.trim().replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
223
|
-
combinedStyles[camelKey] = value.trim();
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
if (Object.keys(combinedStyles).length > 0) {
|
|
228
|
-
props += ` style={${JSON.stringify(combinedStyles)}}`;
|
|
229
|
-
}
|
|
230
|
-
if (classes.length > 0) {
|
|
231
|
-
props += ` className="${classes.join(" ")}"`;
|
|
232
|
-
}
|
|
233
|
-
if (traits.theme?.attributes) {
|
|
234
|
-
try {
|
|
235
|
-
const parsedAttrs = JSON.parse(traits.theme.attributes);
|
|
236
|
-
for (const [key, value] of Object.entries(parsedAttrs)) {
|
|
237
|
-
props += ` ${key}="${value}"`;
|
|
238
|
-
}
|
|
239
|
-
} catch (e) {
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
if (traits.button?.onClick || traits.form?.onSubmit) {
|
|
243
|
-
const action = traits.button?.onClick || traits.form?.onSubmit;
|
|
244
|
-
if (action) {
|
|
245
|
-
const cleanAction = action.replace(/["']/g, "'");
|
|
246
|
-
if (cleanAction.includes("navigate")) {
|
|
247
|
-
props += ` onClick={() => ${cleanAction}}`;
|
|
248
|
-
} else if (cleanAction.includes("submit")) {
|
|
249
|
-
props += ` onSubmit={${cleanAction}}`;
|
|
250
|
-
} else if (cleanAction.includes("window.open")) {
|
|
251
|
-
props += ` onClick={() => ${cleanAction}}`;
|
|
252
|
-
} else {
|
|
253
|
-
props += ` onClick={() => console.log('${cleanAction}')}`;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
if (traits.image?.src) props += ` src="${traits.image.src}"`;
|
|
258
|
-
if (traits.image?.alt) props += ` alt="${traits.image.alt}"`;
|
|
259
|
-
if (traits.link?.href) props += ` href="${traits.link.href}"`;
|
|
260
|
-
if (traits.input?.placeholder) props += ` placeholder="${traits.input.placeholder}"`;
|
|
261
|
-
if (traits.input?.type) props += ` type="${traits.input.type}"`;
|
|
262
|
-
if (traits.input?.required) props += ` required`;
|
|
263
|
-
if (traits.button?.type) props += ` type="${traits.button.type}"`;
|
|
264
|
-
const childrenMarkup = (obj.children || obj.objects || []).map((child) => this.generateReactNode(child)).join("\n");
|
|
265
|
-
const content = traits.text?.content || traits.button?.content || traits.link?.content || traits.icon?.name;
|
|
266
|
-
let safeContent = "";
|
|
267
|
-
if (content) {
|
|
268
|
-
safeContent = `{\`${content.replace(/`/g, "\\`").replace(/\$/g, "\\$")}\`}`;
|
|
269
|
-
}
|
|
270
|
-
if (tag === "style") {
|
|
271
|
-
const escapedStyle = (content || "").replace(/`/g, "\\`").replace(/\$/g, "\\$");
|
|
272
|
-
return `<style dangerouslySetInnerHTML={{ __html: \`${escapedStyle}\` }} />`;
|
|
273
|
-
}
|
|
274
|
-
if (tag === "img" || tag === "input") {
|
|
275
|
-
return `<${tag}${props} />`;
|
|
276
|
-
}
|
|
277
|
-
return `<${tag}${props}>
|
|
278
|
-
${safeContent}
|
|
279
|
-
${childrenMarkup}
|
|
280
|
-
</${tag}>`;
|
|
281
|
-
}
|
|
282
|
-
// ============================================================================
|
|
283
|
-
// HTML GENERATION
|
|
284
|
-
// ============================================================================
|
|
285
|
-
generateHTMLPage(name, objects, composition) {
|
|
286
|
-
const content = objects.map((obj) => this.generateHTMLNode(obj)).join("\n ");
|
|
287
|
-
let bgColor = "#ffffff";
|
|
288
|
-
let color = "#000000";
|
|
289
|
-
if (composition.environment?.properties) {
|
|
290
|
-
const themeProp = composition.environment.properties.find((p) => p.key === "theme");
|
|
291
|
-
const bgProp = composition.environment.properties.find((p) => p.key === "backgroundColor");
|
|
292
|
-
if (themeProp?.value === "dark" || composition.traits?.some((t) => t.name === "theme" && t.config?.dark)) {
|
|
293
|
-
bgColor = bgProp?.value || "#050510";
|
|
294
|
-
color = "#ffffff";
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return `<!DOCTYPE html>
|
|
298
|
-
<html lang="en">
|
|
299
|
-
<head>
|
|
300
|
-
<meta charset="UTF-8">
|
|
301
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
302
|
-
<title>${name}</title>
|
|
303
|
-
<script src="https://cdn.tailwindcss.com"></script>
|
|
304
|
-
<style>
|
|
305
|
-
body { margin: 0; padding: 0; background-color: ${bgColor}; color: ${color}; font-family: system-ui, -apple-system, sans-serif; }
|
|
306
|
-
/* Basic resets and custom trait animations to mirror React Framer variants */
|
|
307
|
-
.glow-btn:hover { box-shadow: 0 0 15px rgba(255,255,255,0.5); }
|
|
308
|
-
.lift-card { transition: transform 0.2s ease, box-shadow 0.2s ease; }
|
|
309
|
-
.lift-card:hover { transform: translateY(-4px); box-shadow: 0 10px 20px rgba(0,0,0,0.2); }
|
|
310
|
-
</style>
|
|
311
|
-
</head>
|
|
312
|
-
<body>
|
|
313
|
-
<div id="holoscript-native-root">
|
|
314
|
-
${content}
|
|
315
|
-
</div>
|
|
316
|
-
<script>
|
|
317
|
-
function navigate(path) { window.location.href = path; }
|
|
318
|
-
function submitNewsletter(e) { e.preventDefault(); alert('Subscribed!'); }
|
|
319
|
-
</script>
|
|
320
|
-
</body>
|
|
321
|
-
</html>`;
|
|
322
|
-
}
|
|
323
|
-
generateHTMLNode(obj) {
|
|
324
|
-
const node = obj;
|
|
325
|
-
const traits = this.extractTraits(obj);
|
|
326
|
-
const nodeType = typeof node.type === "string" ? node.type.toLowerCase() : void 0;
|
|
327
|
-
let tag = traits.theme?.tag || traits.panel?.tag || nodeType || "div";
|
|
328
|
-
if ([
|
|
329
|
-
"nav",
|
|
330
|
-
"section",
|
|
331
|
-
"main",
|
|
332
|
-
"footer",
|
|
333
|
-
"form",
|
|
334
|
-
"style",
|
|
335
|
-
"a",
|
|
336
|
-
"header",
|
|
337
|
-
"h1",
|
|
338
|
-
"h2",
|
|
339
|
-
"h3"
|
|
340
|
-
].includes(tag)) ; else if (tag === "container") {
|
|
341
|
-
tag = "div";
|
|
342
|
-
} else if (traits.link || tag === "link") {
|
|
343
|
-
tag = "a";
|
|
344
|
-
} else if (traits.button || tag === "button") {
|
|
345
|
-
tag = "button";
|
|
346
|
-
} else if (traits.image || tag === "image") {
|
|
347
|
-
tag = "img";
|
|
348
|
-
} else if (traits.input || tag === "input") {
|
|
349
|
-
tag = "input";
|
|
350
|
-
} else if (traits.text || tag === "text") {
|
|
351
|
-
tag = this.mapTextVariantToTag(traits.text?.variant || "body");
|
|
352
|
-
} else {
|
|
353
|
-
tag = "div";
|
|
354
|
-
}
|
|
355
|
-
const styles = this.buildStyles(traits);
|
|
356
|
-
const classes = this.buildClasses(traits);
|
|
357
|
-
let props = ``;
|
|
358
|
-
if (traits.theme?.className) {
|
|
359
|
-
classes.push(traits.theme.className);
|
|
360
|
-
}
|
|
361
|
-
if (traits.theme?.id) {
|
|
362
|
-
props += ` id="${traits.theme.id}"`;
|
|
363
|
-
}
|
|
364
|
-
if (Object.keys(styles).length > 0 || traits.theme?.style) {
|
|
365
|
-
let styleStr = Object.entries(styles).map(([k, v]) => `${this.camelToKebab(k)}: ${v}`).join("; ");
|
|
366
|
-
if (traits.theme?.style) {
|
|
367
|
-
styleStr += (styleStr ? "; " : "") + traits.theme.style;
|
|
368
|
-
}
|
|
369
|
-
props += ` style="${styleStr}"`;
|
|
370
|
-
}
|
|
371
|
-
if (classes.length > 0) {
|
|
372
|
-
props += ` class="${classes.join(" ")}"`;
|
|
373
|
-
}
|
|
374
|
-
if (traits.theme?.attributes) {
|
|
375
|
-
try {
|
|
376
|
-
const parsedAttrs = JSON.parse(traits.theme.attributes);
|
|
377
|
-
for (const [key, value] of Object.entries(parsedAttrs)) {
|
|
378
|
-
props += ` ${key}="${value}"`;
|
|
379
|
-
}
|
|
380
|
-
} catch (e) {
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
if (traits.button?.onClick) props += ` onclick="${traits.button.onClick}"`;
|
|
384
|
-
if (traits.form?.onSubmit) props += ` onsubmit="${traits.form.onSubmit}"`;
|
|
385
|
-
if (traits.image?.src) props += ` src="${traits.image.src}"`;
|
|
386
|
-
if (traits.image?.alt) props += ` alt="${traits.image.alt}"`;
|
|
387
|
-
if (traits.link?.href) props += ` href="${traits.link.href}"`;
|
|
388
|
-
if (traits.input?.placeholder) props += ` placeholder="${traits.input.placeholder}"`;
|
|
389
|
-
if (traits.input?.type) props += ` type="${traits.input.type}"`;
|
|
390
|
-
if (traits.input?.required) props += ` required`;
|
|
391
|
-
const children = node.children || node.objects || [];
|
|
392
|
-
const childrenMarkup = children.map((child) => this.generateHTMLNode(child)).join("\n");
|
|
393
|
-
const content = traits.text?.content || traits.button?.content || traits.link?.content || traits.icon?.name;
|
|
394
|
-
if (tag === "img" || tag === "input") {
|
|
395
|
-
return `<${tag}${props}>`;
|
|
396
|
-
}
|
|
397
|
-
return `<${tag}${props}>
|
|
398
|
-
${content ? content : ""}
|
|
399
|
-
${childrenMarkup}
|
|
400
|
-
</${tag}>`;
|
|
401
|
-
}
|
|
402
|
-
// ============================================================================
|
|
403
|
-
// UTILITIES
|
|
404
|
-
// ============================================================================
|
|
405
|
-
extractTraits(obj) {
|
|
406
|
-
const map = {};
|
|
407
|
-
const node = obj;
|
|
408
|
-
if (!node.traits) return map;
|
|
409
|
-
for (const t of node.traits) {
|
|
410
|
-
map[t.name] = t.config || {};
|
|
411
|
-
if (t.name === "tailwind" && typeof t.config === "string") {
|
|
412
|
-
map[t.name] = { classes: t.config };
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
return map;
|
|
416
|
-
}
|
|
417
|
-
mapTextVariantToTag(variant) {
|
|
418
|
-
switch (variant) {
|
|
419
|
-
case "h1":
|
|
420
|
-
return "h1";
|
|
421
|
-
case "h2":
|
|
422
|
-
return "h2";
|
|
423
|
-
case "h3":
|
|
424
|
-
return "h3";
|
|
425
|
-
case "subtitle":
|
|
426
|
-
return "h4";
|
|
427
|
-
case "caption":
|
|
428
|
-
return "span";
|
|
429
|
-
case "emoji":
|
|
430
|
-
return "span";
|
|
431
|
-
default:
|
|
432
|
-
return "p";
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
buildStyles(traits) {
|
|
436
|
-
const styles = {};
|
|
437
|
-
const layout = traits.layout;
|
|
438
|
-
const theme = traits.theme;
|
|
439
|
-
if (layout) {
|
|
440
|
-
if (layout.flex) {
|
|
441
|
-
styles.display = "flex";
|
|
442
|
-
styles.flexDirection = layout.flex === "row" ? "row" : "column";
|
|
443
|
-
}
|
|
444
|
-
if (layout.grid) {
|
|
445
|
-
styles.display = "grid";
|
|
446
|
-
styles.gridTemplateColumns = `repeat(${layout.columns || 1}, minmax(0, 1fr))`;
|
|
447
|
-
}
|
|
448
|
-
if (layout.justify) styles.justifyContent = layout.justify;
|
|
449
|
-
if (layout.align) styles.alignItems = layout.align;
|
|
450
|
-
if (layout.gap) styles.gap = typeof layout.gap === "number" ? `${layout.gap}px` : layout.gap;
|
|
451
|
-
if (layout.padding)
|
|
452
|
-
styles.padding = typeof layout.padding === "number" ? `${layout.padding}px` : layout.padding;
|
|
453
|
-
}
|
|
454
|
-
if (theme) {
|
|
455
|
-
if (theme.backgroundColor) styles.backgroundColor = theme.backgroundColor;
|
|
456
|
-
if (theme.color) styles.color = theme.color;
|
|
457
|
-
if (theme.padding)
|
|
458
|
-
styles.padding = typeof theme.padding === "number" ? `${theme.padding}px` : theme.padding;
|
|
459
|
-
if (theme.borderRadius)
|
|
460
|
-
styles.borderRadius = typeof theme.borderRadius === "number" ? `${theme.borderRadius}px` : theme.borderRadius;
|
|
461
|
-
if (theme.border) styles.border = theme.border;
|
|
462
|
-
if (theme.borderTop) styles.borderTop = theme.borderTop;
|
|
463
|
-
}
|
|
464
|
-
if (traits.text) {
|
|
465
|
-
if (traits.text.align) styles.textAlign = traits.text.align;
|
|
466
|
-
if (traits.text.maxWidth)
|
|
467
|
-
styles.maxWidth = typeof traits.text.maxWidth === "number" ? `${traits.text.maxWidth}px` : traits.text.maxWidth;
|
|
468
|
-
if (traits.text.weight) styles.fontWeight = traits.text.weight;
|
|
469
|
-
}
|
|
470
|
-
return styles;
|
|
471
|
-
}
|
|
472
|
-
buildClasses(traits) {
|
|
473
|
-
const classes = [];
|
|
474
|
-
if (traits.text) {
|
|
475
|
-
if (traits.text.variant === "h1") classes.push("text-5xl font-bold tracking-tight");
|
|
476
|
-
if (traits.text.variant === "h2") classes.push("text-3xl font-bold");
|
|
477
|
-
if (traits.text.variant === "h3") classes.push("text-xl font-semibold");
|
|
478
|
-
if (traits.text.variant === "subtitle") classes.push("text-xl text-gray-400");
|
|
479
|
-
if (traits.text.variant === "caption") classes.push("text-sm text-gray-500");
|
|
480
|
-
if (traits.text.variant === "emoji") classes.push("text-2xl");
|
|
481
|
-
}
|
|
482
|
-
if (traits.button) {
|
|
483
|
-
classes.push("px-4 py-2 rounded-lg font-medium transition-all");
|
|
484
|
-
if (traits.button.variant === "primary")
|
|
485
|
-
classes.push("bg-blue-600 hover:bg-blue-700 text-white");
|
|
486
|
-
if (traits.button.variant === "outline")
|
|
487
|
-
classes.push("border border-gray-600 hover:bg-gray-800 text-white");
|
|
488
|
-
if (traits.button.variant === "ghost")
|
|
489
|
-
classes.push("hover:bg-gray-800 text-gray-300 hover:text-white");
|
|
490
|
-
if (traits.button.variant === "glow")
|
|
491
|
-
classes.push("bg-indigo-600 text-white glow-btn hover:bg-indigo-500");
|
|
492
|
-
if (traits.button.size === "lg") classes.push("px-6 py-3 text-lg");
|
|
493
|
-
if (traits.button.size === "sm") classes.push("px-3 py-1 text-sm");
|
|
494
|
-
}
|
|
495
|
-
if (traits.card) {
|
|
496
|
-
if (traits.card.shadow === "md") classes.push("shadow-md");
|
|
497
|
-
if (traits.card.shadow === "lg") classes.push("shadow-lg");
|
|
498
|
-
if (traits.card.hover === "glow") classes.push("lift-card");
|
|
499
|
-
}
|
|
500
|
-
if (traits.input) {
|
|
501
|
-
classes.push(
|
|
502
|
-
"px-4 py-2 rounded-lg border border-gray-700 bg-gray-900 text-white focus:ring-2 focus:ring-indigo-500 outline-none"
|
|
503
|
-
);
|
|
504
|
-
}
|
|
505
|
-
if (traits.tailwind?.classes) {
|
|
506
|
-
classes.push(traits.tailwind.classes);
|
|
507
|
-
}
|
|
508
|
-
return classes;
|
|
509
|
-
}
|
|
510
|
-
camelToKebab(str) {
|
|
511
|
-
return str.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
|
|
517
|
-
// src/compiler/NextJSAPICompiler.ts
|
|
518
|
-
var NextJSAPICompiler_exports = {};
|
|
519
|
-
chunk3SAK5KFL_cjs.__export(NextJSAPICompiler_exports, {
|
|
520
|
-
NextJSAPICompiler: () => NextJSAPICompiler,
|
|
521
|
-
compileAllToNextJSAPI: () => compileAllToNextJSAPI,
|
|
522
|
-
compileToNextJSAPI: () => compileToNextJSAPI
|
|
523
|
-
});
|
|
524
|
-
function toScalar(val) {
|
|
525
|
-
if (val === null || val === void 0) return void 0;
|
|
526
|
-
if (typeof val === "string" || typeof val === "number") return val;
|
|
527
|
-
if (typeof val === "object" && !Array.isArray(val) && "value" in val) {
|
|
528
|
-
return toScalar(val.value);
|
|
529
|
-
}
|
|
530
|
-
return void 0;
|
|
531
|
-
}
|
|
532
|
-
function findRootTrait(composition, traitName) {
|
|
533
|
-
if (!composition.traits) return null;
|
|
534
|
-
const found = composition.traits.find((t) => t.name === traitName);
|
|
535
|
-
return found ? found.config : null;
|
|
536
|
-
}
|
|
537
|
-
function buildPropMap(obj) {
|
|
538
|
-
const map = /* @__PURE__ */ new Map();
|
|
539
|
-
for (const prop of obj.properties) {
|
|
540
|
-
const scalar = toScalar(prop.value);
|
|
541
|
-
if (scalar !== void 0) map.set(prop.key, scalar);
|
|
542
|
-
}
|
|
543
|
-
return map;
|
|
544
|
-
}
|
|
545
|
-
function toApiRouteSegment(name, override) {
|
|
546
|
-
if (override) {
|
|
547
|
-
return override.replace(/^\/+api\/+/, "").replace(/^\/+/, "").replace(/\/+$/, "");
|
|
548
|
-
}
|
|
549
|
-
return name.replace(/API$/, "").replace(/Api$/, "").replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/([A-Z]{2,})([A-Z][a-z])/g, "$1-$2").toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "") || "api";
|
|
550
|
-
}
|
|
551
|
-
function parseMethod(raw) {
|
|
552
|
-
if (raw === void 0) return void 0;
|
|
553
|
-
const upper = String(raw).trim().toUpperCase();
|
|
554
|
-
return VALID_METHODS.has(upper) ? upper : void 0;
|
|
555
|
-
}
|
|
556
|
-
function extractHandlers(composition) {
|
|
557
|
-
const byMethod = /* @__PURE__ */ new Map();
|
|
558
|
-
const rootHttp = findRootTrait(composition, "http");
|
|
559
|
-
if (rootHttp) {
|
|
560
|
-
const method = parseMethod(toScalar(rootHttp["method"]));
|
|
561
|
-
if (method) {
|
|
562
|
-
byMethod.set(method, {
|
|
563
|
-
method,
|
|
564
|
-
statusCode: Number(toScalar(rootHttp["statusCode"]) ?? toScalar(rootHttp["status"]) ?? 200),
|
|
565
|
-
description: String(toScalar(rootHttp["description"]) ?? "")
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
for (const obj of composition.objects) {
|
|
570
|
-
const hasHttpTrait = obj.traits.some((t) => t.name === "http");
|
|
571
|
-
if (!hasHttpTrait) continue;
|
|
572
|
-
const traitConfig = obj.traits.find((t) => t.name === "http")?.config ?? {};
|
|
573
|
-
const props = buildPropMap(obj);
|
|
574
|
-
const rawMethod = toScalar(traitConfig["method"]) ?? props.get("method");
|
|
575
|
-
const method = parseMethod(rawMethod);
|
|
576
|
-
if (!method) continue;
|
|
577
|
-
const traitStatus = toScalar(traitConfig["statusCode"] ?? traitConfig["status"]);
|
|
578
|
-
const propStatus = props.get("statusCode") ?? props.get("status");
|
|
579
|
-
byMethod.set(method, {
|
|
580
|
-
method,
|
|
581
|
-
statusCode: Number(traitStatus ?? propStatus ?? 200),
|
|
582
|
-
description: String(
|
|
583
|
-
props.get("description") ?? toScalar(traitConfig["description"]) ?? obj.name ?? ""
|
|
584
|
-
)
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
return [...byMethod.values()];
|
|
588
|
-
}
|
|
589
|
-
function emitHandler(handler) {
|
|
590
|
-
const { method, statusCode, description } = handler;
|
|
591
|
-
const lines = [];
|
|
592
|
-
const hasBody = BODY_METHODS.has(method);
|
|
593
|
-
const isPassthrough = PASSTHROUGH_METHODS.has(method);
|
|
594
|
-
if (description) {
|
|
595
|
-
lines.push(`/** ${description} */`);
|
|
596
|
-
}
|
|
597
|
-
const param = isPassthrough ? "_request: Request" : "_request: NextRequest";
|
|
598
|
-
lines.push(`export async function ${method}(${param}): Promise<NextResponse> {`);
|
|
599
|
-
if (method === "HEAD") {
|
|
600
|
-
lines.push(` return new NextResponse(null, { status: 200 });`);
|
|
601
|
-
} else if (method === "DELETE") {
|
|
602
|
-
const code = statusCode === 200 ? 204 : statusCode;
|
|
603
|
-
lines.push(` return new NextResponse(null, { status: ${code} });`);
|
|
604
|
-
} else if (hasBody) {
|
|
605
|
-
lines.push(` let body: unknown;`);
|
|
606
|
-
lines.push(` try {`);
|
|
607
|
-
lines.push(` body = await _request.json();`);
|
|
608
|
-
lines.push(` } catch {`);
|
|
609
|
-
lines.push(` return NextResponse.json({ error: 'Invalid JSON body' }, { status: 400 });`);
|
|
610
|
-
lines.push(` }`);
|
|
611
|
-
lines.push(``);
|
|
612
|
-
lines.push(` void body; // TODO: validate and process body`);
|
|
613
|
-
lines.push(``);
|
|
614
|
-
lines.push(` return NextResponse.json(`);
|
|
615
|
-
lines.push(` { /* TODO: return response data */ },`);
|
|
616
|
-
lines.push(` { status: ${statusCode} }`);
|
|
617
|
-
lines.push(` );`);
|
|
618
|
-
} else {
|
|
619
|
-
lines.push(` return NextResponse.json(`);
|
|
620
|
-
lines.push(` { /* TODO: return response data */ },`);
|
|
621
|
-
lines.push(` { status: ${statusCode} }`);
|
|
622
|
-
lines.push(` );`);
|
|
623
|
-
}
|
|
624
|
-
lines.push(`}`);
|
|
625
|
-
return lines;
|
|
626
|
-
}
|
|
627
|
-
function compileToNextJSAPI(composition, options = {}) {
|
|
628
|
-
let handlers = extractHandlers(composition);
|
|
629
|
-
if (handlers.length === 0) {
|
|
630
|
-
handlers = [
|
|
631
|
-
{
|
|
632
|
-
method: "GET",
|
|
633
|
-
statusCode: 200,
|
|
634
|
-
description: `${composition.name} API endpoint`
|
|
635
|
-
}
|
|
636
|
-
];
|
|
637
|
-
}
|
|
638
|
-
const routeSegment = toApiRouteSegment(composition.name, options.apiRoute);
|
|
639
|
-
const outputBase = options.outputDir ? options.outputDir.replace(/\/$/, "") : "api";
|
|
640
|
-
const filePath = `${outputBase}/${routeSegment}/route.ts`;
|
|
641
|
-
const lines = [];
|
|
642
|
-
if (options.includeJsDoc !== false) {
|
|
643
|
-
lines.push(`// @generated by HoloScript NextJSAPICompiler \u2014 DO NOT EDIT`);
|
|
644
|
-
lines.push(`// Source composition: "${composition.name}"`);
|
|
645
|
-
lines.push(`// Route: /${outputBase}/${routeSegment}`);
|
|
646
|
-
lines.push(``);
|
|
647
|
-
}
|
|
648
|
-
const needsNextRequest = handlers.some((h) => !PASSTHROUGH_METHODS.has(h.method));
|
|
649
|
-
if (needsNextRequest) {
|
|
650
|
-
lines.push(`import { NextRequest, NextResponse } from 'next/server';`);
|
|
651
|
-
} else {
|
|
652
|
-
lines.push(`import { NextResponse } from 'next/server';`);
|
|
653
|
-
}
|
|
654
|
-
lines.push(``);
|
|
655
|
-
for (let i = 0; i < handlers.length; i++) {
|
|
656
|
-
lines.push(...emitHandler(handlers[i]));
|
|
657
|
-
if (i < handlers.length - 1) {
|
|
658
|
-
lines.push(``);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
return {
|
|
662
|
-
path: filePath,
|
|
663
|
-
code: lines.join("\n").trimEnd() + "\n"
|
|
664
|
-
};
|
|
665
|
-
}
|
|
666
|
-
function compileAllToNextJSAPI(compositions, options = {}) {
|
|
667
|
-
return compositions.map(({ composition }) => compileToNextJSAPI(composition, options));
|
|
668
|
-
}
|
|
669
|
-
var VALID_METHODS, BODY_METHODS, PASSTHROUGH_METHODS, NextJSAPICompiler;
|
|
670
|
-
var init_NextJSAPICompiler = chunk3SAK5KFL_cjs.__esm({
|
|
671
|
-
"src/compiler/NextJSAPICompiler.ts"() {
|
|
672
|
-
chunkBF2235SI_cjs.init_CompilerBase();
|
|
673
|
-
VALID_METHODS = /* @__PURE__ */ new Set([
|
|
674
|
-
"GET",
|
|
675
|
-
"POST",
|
|
676
|
-
"PUT",
|
|
677
|
-
"PATCH",
|
|
678
|
-
"DELETE",
|
|
679
|
-
"HEAD",
|
|
680
|
-
"OPTIONS"
|
|
681
|
-
]);
|
|
682
|
-
BODY_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH"]);
|
|
683
|
-
PASSTHROUGH_METHODS = /* @__PURE__ */ new Set(["HEAD", "DELETE"]);
|
|
684
|
-
NextJSAPICompiler = class extends chunkBF2235SI_cjs.CompilerBase {
|
|
685
|
-
constructor(options = {}) {
|
|
686
|
-
super();
|
|
687
|
-
this.options = options;
|
|
688
|
-
}
|
|
689
|
-
get name() {
|
|
690
|
-
return "nextjs-api";
|
|
691
|
-
}
|
|
692
|
-
compile(composition, agentToken) {
|
|
693
|
-
const comp = composition;
|
|
694
|
-
const result = compileAllToNextJSAPI(comp);
|
|
695
|
-
return {
|
|
696
|
-
code: result.map((r) => r.code).join("\n\n"),
|
|
697
|
-
files: result.map((r) => ({ path: r.routePath, content: r.code }))
|
|
698
|
-
};
|
|
699
|
-
}
|
|
700
|
-
compileSingle(composition, agentToken) {
|
|
701
|
-
const comp = composition;
|
|
702
|
-
return compileToNextJSAPI(comp);
|
|
703
|
-
}
|
|
704
|
-
};
|
|
705
|
-
}
|
|
706
|
-
});
|
|
707
|
-
|
|
708
|
-
// src/compiler/NodeServiceCompiler.ts
|
|
709
|
-
var NodeServiceCompiler_exports = {};
|
|
710
|
-
chunk3SAK5KFL_cjs.__export(NodeServiceCompiler_exports, {
|
|
711
|
-
NodeServiceCompiler: () => exports.NodeServiceCompiler
|
|
712
|
-
});
|
|
713
|
-
exports.NodeServiceCompiler = void 0;
|
|
714
|
-
var init_NodeServiceCompiler = chunk3SAK5KFL_cjs.__esm({
|
|
715
|
-
"src/compiler/NodeServiceCompiler.ts"() {
|
|
716
|
-
chunkBF2235SI_cjs.init_CompilerBase();
|
|
717
|
-
chunkBF2235SI_cjs.init_identity();
|
|
718
|
-
init_DialectRegistry();
|
|
719
|
-
chunkXG23EUQX_cjs.init_constants();
|
|
720
|
-
exports.NodeServiceCompiler = class extends chunkBF2235SI_cjs.CompilerBase {
|
|
721
|
-
constructor(options = {}) {
|
|
722
|
-
super();
|
|
723
|
-
this.compilerName = "NodeServiceCompiler";
|
|
724
|
-
this.services = [];
|
|
725
|
-
this.options = {
|
|
726
|
-
framework: options.framework ?? "express",
|
|
727
|
-
port: options.port ?? 3e3,
|
|
728
|
-
apiPrefix: options.apiPrefix ?? "/api",
|
|
729
|
-
typescript: options.typescript ?? true,
|
|
730
|
-
nodeVersion: options.nodeVersion ?? "20",
|
|
731
|
-
includeDocker: options.includeDocker ?? false
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
|
-
getRequiredCapability() {
|
|
735
|
-
return chunkBF2235SI_cjs.ANSCapabilityPath.NODE_SERVICE;
|
|
736
|
-
}
|
|
737
|
-
compile(composition, agentToken, outputPath) {
|
|
738
|
-
console.log("DEBUG: Composition:", JSON.stringify(composition, null, 2));
|
|
739
|
-
this.validateCompilerAccess(agentToken, outputPath);
|
|
740
|
-
this.services = [];
|
|
741
|
-
this.extractServices(composition);
|
|
742
|
-
const output = {};
|
|
743
|
-
output[this.ext("index")] = this.emitEntryPoint();
|
|
744
|
-
for (const service of this.services) {
|
|
745
|
-
output[this.ext(`routes/${this.toFileName(service.name)}`)] = this.emitRouteModule(service);
|
|
746
|
-
}
|
|
747
|
-
const allMiddleware = this.collectMiddleware();
|
|
748
|
-
if (allMiddleware.length > 0) {
|
|
749
|
-
output[this.ext("middleware/index")] = this.emitMiddlewareIndex(allMiddleware);
|
|
750
|
-
}
|
|
751
|
-
const allEnvVars = this.collectEnvVars();
|
|
752
|
-
if (allEnvVars.length > 0) {
|
|
753
|
-
output[this.ext("config/env")] = this.emitEnvConfig(allEnvVars);
|
|
754
|
-
}
|
|
755
|
-
const allConnectors = this.collectConnectors();
|
|
756
|
-
if (allConnectors.length > 0) {
|
|
757
|
-
output[this.ext("connectors/index")] = this.emitConnectorsIndex(allConnectors);
|
|
758
|
-
}
|
|
759
|
-
const railwayService = this.services.find((s) => s.deploy?.platform === "railway");
|
|
760
|
-
if (railwayService?.deploy) {
|
|
761
|
-
output["railway.json"] = this.emitRailwayConfig(railwayService.deploy);
|
|
762
|
-
}
|
|
763
|
-
output["package.json"] = this.emitPackageJson(composition.name);
|
|
764
|
-
if (this.options.typescript) {
|
|
765
|
-
output["tsconfig.json"] = this.emitTsConfig();
|
|
766
|
-
}
|
|
767
|
-
if (this.options.includeDocker) {
|
|
768
|
-
output["Dockerfile"] = this.emitDockerfile();
|
|
769
|
-
}
|
|
770
|
-
this.validateConnectorIntegration();
|
|
771
|
-
return output;
|
|
772
|
-
}
|
|
773
|
-
// ── Extraction ─────────────────────────────────────────────────────────
|
|
774
|
-
extractServices(composition) {
|
|
775
|
-
if (composition.domainBlocks) {
|
|
776
|
-
for (const block of composition.domainBlocks) {
|
|
777
|
-
if (this.isServiceBlock(block)) {
|
|
778
|
-
this.services.push(this.parseServiceBlock(block));
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
if (composition.objects) {
|
|
783
|
-
for (const obj of composition.objects) {
|
|
784
|
-
if (this.hasServiceTraits(obj)) {
|
|
785
|
-
this.services.push(this.parseServiceObject(obj));
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
if (this.services.length === 0) {
|
|
790
|
-
this.services.push({
|
|
791
|
-
name: composition.name || "App",
|
|
792
|
-
routes: [],
|
|
793
|
-
middleware: [],
|
|
794
|
-
connectors: [],
|
|
795
|
-
envVars: [],
|
|
796
|
-
port: this.options.port
|
|
797
|
-
});
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
isServiceBlock(block) {
|
|
801
|
-
return block.keyword === "service" || block.keyword === "endpoint" || block.keyword === "gateway" || block.keyword === "handler";
|
|
802
|
-
}
|
|
803
|
-
hasServiceTraits(obj) {
|
|
804
|
-
if (!obj.traits) return false;
|
|
805
|
-
const serviceTraits = ["service", "endpoint", "http", "handler", "route", "connector", "env", "deploy"];
|
|
806
|
-
return obj.traits.some((t) => serviceTraits.includes(t.name));
|
|
807
|
-
}
|
|
808
|
-
parseServiceBlock(block) {
|
|
809
|
-
const service = {
|
|
810
|
-
name: block.name,
|
|
811
|
-
routes: [],
|
|
812
|
-
middleware: [],
|
|
813
|
-
port: this.resolveNumber(block.properties["port"]) ?? this.options.port,
|
|
814
|
-
connectors: [],
|
|
815
|
-
envVars: []
|
|
816
|
-
};
|
|
817
|
-
if (block.traits) {
|
|
818
|
-
service.middleware = this.extractMiddlewareFromTraits(block.traits);
|
|
819
|
-
service.connectors = this.extractConnectors(block.traits, block.properties);
|
|
820
|
-
service.envVars = this.extractEnvVars(block.traits, block.properties);
|
|
821
|
-
service.deploy = this.extractDeploy(block.traits, block.properties);
|
|
822
|
-
}
|
|
823
|
-
if (block.children) {
|
|
824
|
-
for (const child of block.children) {
|
|
825
|
-
const route = this.extractRoute(child, block.name);
|
|
826
|
-
if (route) service.routes.push(route);
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
const inlineRoute = this.extractInlineRoute(block);
|
|
830
|
-
if (inlineRoute) service.routes.push(inlineRoute);
|
|
831
|
-
return service;
|
|
832
|
-
}
|
|
833
|
-
parseServiceObject(obj) {
|
|
834
|
-
const service = {
|
|
835
|
-
name: obj.name,
|
|
836
|
-
routes: [],
|
|
837
|
-
middleware: [],
|
|
838
|
-
port: this.options.port,
|
|
839
|
-
connectors: [],
|
|
840
|
-
envVars: []
|
|
841
|
-
};
|
|
842
|
-
if (obj.traits) {
|
|
843
|
-
const traitNames = obj.traits.map((t) => t.name);
|
|
844
|
-
service.middleware = this.extractMiddlewareFromTraits(traitNames);
|
|
845
|
-
service.connectors = this.extractConnectors(traitNames, this.objectPropsToMap(obj.properties));
|
|
846
|
-
service.envVars = this.extractEnvVars(traitNames, this.objectPropsToMap(obj.properties));
|
|
847
|
-
service.deploy = this.extractDeploy(traitNames, this.objectPropsToMap(obj.properties));
|
|
848
|
-
}
|
|
849
|
-
const route = this.extractRoute(obj, obj.name);
|
|
850
|
-
if (route) service.routes.push(route);
|
|
851
|
-
return service;
|
|
852
|
-
}
|
|
853
|
-
extractRoute(obj, serviceName) {
|
|
854
|
-
const propMap = this.objectPropsToMap(obj.properties);
|
|
855
|
-
const traits = (obj.traits || []).map((t) => t.name);
|
|
856
|
-
const method = this.resolveString(propMap.get("method"))?.toUpperCase() || "GET";
|
|
857
|
-
const path = this.resolveString(propMap.get("path")) || `/${this.toKebab(obj.name)}`;
|
|
858
|
-
const handlerName = this.resolveString(propMap.get("handler")) || this.toCamelCase(obj.name);
|
|
859
|
-
const hasHttpInfo = propMap.has("method") || propMap.has("path") || traits.includes("http") || traits.includes("route");
|
|
860
|
-
if (!hasHttpInfo) return null;
|
|
861
|
-
return {
|
|
862
|
-
method,
|
|
863
|
-
path,
|
|
864
|
-
handlerName,
|
|
865
|
-
middleware: this.extractMiddlewareFromTraits(traits),
|
|
866
|
-
serviceName
|
|
867
|
-
};
|
|
868
|
-
}
|
|
869
|
-
extractInlineRoute(block) {
|
|
870
|
-
const props = block.properties;
|
|
871
|
-
if (!props["method"] && !props["path"]) return null;
|
|
872
|
-
return {
|
|
873
|
-
method: this.resolveString(props["method"])?.toUpperCase() || "GET",
|
|
874
|
-
path: this.resolveString(props["path"]) || `/${this.toKebab(block.name)}`,
|
|
875
|
-
handlerName: this.resolveString(props["handler"]) || this.toCamelCase(block.name),
|
|
876
|
-
middleware: [],
|
|
877
|
-
serviceName: block.name
|
|
878
|
-
};
|
|
879
|
-
}
|
|
880
|
-
extractMiddlewareFromTraits(traits) {
|
|
881
|
-
const mw = [];
|
|
882
|
-
for (const t of traits) {
|
|
883
|
-
if (t === "middleware" || t === "auth" || t === "rate_limit" || t === "cors" || t === "validation") {
|
|
884
|
-
mw.push(t);
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
return mw;
|
|
888
|
-
}
|
|
889
|
-
collectMiddleware() {
|
|
890
|
-
const set = /* @__PURE__ */ new Set();
|
|
891
|
-
for (const service of this.services) {
|
|
892
|
-
for (const mw of service.middleware) set.add(mw);
|
|
893
|
-
for (const route of service.routes) {
|
|
894
|
-
for (const mw of route.middleware) set.add(mw);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
return [...set];
|
|
898
|
-
}
|
|
899
|
-
// ── Connector Extraction ──────────────────────────────────────────────
|
|
900
|
-
extractConnectors(traits, props) {
|
|
901
|
-
const connectors = [];
|
|
902
|
-
const propMap = props instanceof Map ? props : this.objectPropsToMapFromRecord(props);
|
|
903
|
-
for (const t of traits) {
|
|
904
|
-
if (t === "connector" || t === "@connector") {
|
|
905
|
-
const name = this.resolveString(propMap.get("connector_name")) || "unknown";
|
|
906
|
-
connectors.push({ name, config: {} });
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
return connectors;
|
|
910
|
-
}
|
|
911
|
-
extractEnvVars(traits, props) {
|
|
912
|
-
const envVars = [];
|
|
913
|
-
const propMap = props instanceof Map ? props : this.objectPropsToMapFromRecord(props);
|
|
914
|
-
for (const t of traits) {
|
|
915
|
-
if (t === "env" || t === "@env") {
|
|
916
|
-
const name = this.resolveString(propMap.get("env_name")) || "UNKNOWN_VAR";
|
|
917
|
-
envVars.push({
|
|
918
|
-
name,
|
|
919
|
-
required: this.resolveBoolean(propMap.get("env_required")) ?? true,
|
|
920
|
-
defaultValue: this.resolveString(propMap.get("env_default"))
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
return envVars;
|
|
925
|
-
}
|
|
926
|
-
extractDeploy(traits, props) {
|
|
927
|
-
if (!traits.some((t) => t === "deploy" || t === "@deploy")) return void 0;
|
|
928
|
-
const propMap = props instanceof Map ? props : this.objectPropsToMapFromRecord(props);
|
|
929
|
-
return {
|
|
930
|
-
platform: this.resolveString(propMap.get("platform")) || "railway",
|
|
931
|
-
service: this.resolveString(propMap.get("service")),
|
|
932
|
-
environment: this.resolveString(propMap.get("environment")),
|
|
933
|
-
healthPath: this.resolveString(propMap.get("healthPath")) || "/health"
|
|
934
|
-
};
|
|
935
|
-
}
|
|
936
|
-
objectPropsToMapFromRecord(props) {
|
|
937
|
-
const map = /* @__PURE__ */ new Map();
|
|
938
|
-
for (const [k, v] of Object.entries(props)) {
|
|
939
|
-
map.set(k, v);
|
|
940
|
-
}
|
|
941
|
-
return map;
|
|
942
|
-
}
|
|
943
|
-
resolveBoolean(val) {
|
|
944
|
-
if (val === void 0 || val === null) return void 0;
|
|
945
|
-
if (typeof val === "boolean") return val;
|
|
946
|
-
if (typeof val === "string") return val === "true";
|
|
947
|
-
return void 0;
|
|
948
|
-
}
|
|
949
|
-
// ── Code Emission ──────────────────────────────────────────────────────
|
|
950
|
-
emitEntryPoint() {
|
|
951
|
-
const isExpress = this.options.framework === "express";
|
|
952
|
-
const lines = [];
|
|
953
|
-
lines.push(`/**`);
|
|
954
|
-
lines.push(` * Auto-generated by HoloScript NodeServiceCompiler v0.1.0`);
|
|
955
|
-
lines.push(` * Framework: ${this.options.framework}`);
|
|
956
|
-
lines.push(` */`);
|
|
957
|
-
lines.push("");
|
|
958
|
-
if (isExpress) {
|
|
959
|
-
lines.push(`import express from 'express';`);
|
|
960
|
-
lines.push(`import './config/env';`);
|
|
961
|
-
const hasConnectors = this.collectConnectors().length > 0;
|
|
962
|
-
if (hasConnectors) {
|
|
963
|
-
lines.push(`import { initConnectors } from './connectors';`);
|
|
964
|
-
}
|
|
965
|
-
for (const service of this.services) {
|
|
966
|
-
const importName = `${this.toCamelCase(service.name)}Routes`;
|
|
967
|
-
lines.push(`import { ${importName} } from './routes/${this.toFileName(service.name)}';`);
|
|
968
|
-
}
|
|
969
|
-
lines.push("");
|
|
970
|
-
lines.push(`const app = express();`);
|
|
971
|
-
lines.push(`app.use(express.json());`);
|
|
972
|
-
lines.push(`app.use(express.urlencoded({ extended: true }));`);
|
|
973
|
-
lines.push("");
|
|
974
|
-
for (const service of this.services) {
|
|
975
|
-
const importName = `${this.toCamelCase(service.name)}Routes`;
|
|
976
|
-
lines.push(
|
|
977
|
-
`app.use('${this.escapeStringValue(this.options.apiPrefix, "TypeScript")}', ${importName});`
|
|
978
|
-
);
|
|
979
|
-
}
|
|
980
|
-
lines.push("");
|
|
981
|
-
lines.push(`const PORT = process.env['PORT'] || ${this.options.port};`);
|
|
982
|
-
if (hasConnectors) {
|
|
983
|
-
lines.push(`initConnectors().then(() => {`);
|
|
984
|
-
lines.push(` app.listen(PORT, () => {`);
|
|
985
|
-
lines.push(` console.log(\`Server running on port \${PORT}\`);`);
|
|
986
|
-
lines.push(` });`);
|
|
987
|
-
lines.push(`});`);
|
|
988
|
-
} else {
|
|
989
|
-
lines.push(`app.listen(PORT, () => {`);
|
|
990
|
-
lines.push(` console.log(\`Server running on port \${PORT}\`);`);
|
|
991
|
-
lines.push(`});`);
|
|
992
|
-
}
|
|
993
|
-
lines.push("");
|
|
994
|
-
lines.push(`export { app };`);
|
|
995
|
-
} else {
|
|
996
|
-
lines.push(`import Fastify from 'fastify';`);
|
|
997
|
-
for (const service of this.services) {
|
|
998
|
-
const importName = `${this.toCamelCase(service.name)}Routes`;
|
|
999
|
-
lines.push(`import { ${importName} } from './routes/${this.toFileName(service.name)}';`);
|
|
1000
|
-
}
|
|
1001
|
-
lines.push("");
|
|
1002
|
-
lines.push(`const app = Fastify({ logger: true });`);
|
|
1003
|
-
lines.push("");
|
|
1004
|
-
for (const service of this.services) {
|
|
1005
|
-
const importName = `${this.toCamelCase(service.name)}Routes`;
|
|
1006
|
-
lines.push(
|
|
1007
|
-
`app.register(${importName}, { prefix: '${this.escapeStringValue(this.options.apiPrefix, "TypeScript")}' });`
|
|
1008
|
-
);
|
|
1009
|
-
}
|
|
1010
|
-
lines.push("");
|
|
1011
|
-
lines.push(`const PORT = Number(process.env['PORT']) || ${this.options.port};`);
|
|
1012
|
-
lines.push(`app.listen({ port: PORT, host: '0.0.0.0' }).then((address) => {`);
|
|
1013
|
-
lines.push(` console.log(\`Server running at \${address}\`);`);
|
|
1014
|
-
lines.push(`});`);
|
|
1015
|
-
lines.push("");
|
|
1016
|
-
lines.push(`export { app };`);
|
|
1017
|
-
}
|
|
1018
|
-
return lines.join("\n");
|
|
1019
|
-
}
|
|
1020
|
-
emitRouteModule(service) {
|
|
1021
|
-
const isExpress = this.options.framework === "express";
|
|
1022
|
-
const lines = [];
|
|
1023
|
-
const routerName = `${this.toCamelCase(service.name)}Routes`;
|
|
1024
|
-
lines.push(`/**`);
|
|
1025
|
-
lines.push(` * Routes for ${service.name}`);
|
|
1026
|
-
lines.push(` * Auto-generated by HoloScript NodeServiceCompiler`);
|
|
1027
|
-
lines.push(` */`);
|
|
1028
|
-
lines.push("");
|
|
1029
|
-
if (isExpress) {
|
|
1030
|
-
lines.push(`import { Router } from 'express';`);
|
|
1031
|
-
if (this.options.typescript) {
|
|
1032
|
-
lines.push(`import type { Request, Response } from 'express';`);
|
|
1033
|
-
}
|
|
1034
|
-
lines.push("");
|
|
1035
|
-
lines.push(`const router = Router();`);
|
|
1036
|
-
lines.push("");
|
|
1037
|
-
for (const route of service.routes) {
|
|
1038
|
-
const methodLower = route.method.toLowerCase();
|
|
1039
|
-
const mwArgs = route.middleware.length > 0 ? route.middleware.map((mw) => `/* ${mw} */`).join(", ") + ", " : "";
|
|
1040
|
-
lines.push(`// ${route.method} ${route.path}`);
|
|
1041
|
-
if (this.options.typescript) {
|
|
1042
|
-
lines.push(
|
|
1043
|
-
`router.${methodLower}('${this.escapeStringValue(route.path, "TypeScript")}', ${mwArgs}(req: Request, res: Response) => {`
|
|
1044
|
-
);
|
|
1045
|
-
} else {
|
|
1046
|
-
lines.push(
|
|
1047
|
-
`router.${methodLower}('${this.escapeStringValue(route.path, "TypeScript")}', ${mwArgs}(req, res) => {`
|
|
1048
|
-
);
|
|
1049
|
-
}
|
|
1050
|
-
lines.push(` // TODO: Implement ${route.handlerName}`);
|
|
1051
|
-
lines.push(
|
|
1052
|
-
` res.json({ message: '${this.escapeStringValue(route.handlerName, "TypeScript")} not implemented' });`
|
|
1053
|
-
);
|
|
1054
|
-
lines.push(`});`);
|
|
1055
|
-
lines.push("");
|
|
1056
|
-
}
|
|
1057
|
-
if (service.routes.length === 0) {
|
|
1058
|
-
lines.push(`// Default health check`);
|
|
1059
|
-
if (this.options.typescript) {
|
|
1060
|
-
lines.push(`router.get('/health', (_req: Request, res: Response) => {`);
|
|
1061
|
-
} else {
|
|
1062
|
-
lines.push(`router.get('/health', (_req, res) => {`);
|
|
1063
|
-
}
|
|
1064
|
-
lines.push(
|
|
1065
|
-
` res.json({ status: 'ok', service: '${this.escapeStringValue(service.name, "TypeScript")}' });`
|
|
1066
|
-
);
|
|
1067
|
-
lines.push(`});`);
|
|
1068
|
-
lines.push("");
|
|
1069
|
-
}
|
|
1070
|
-
lines.push(`export { router as ${routerName} };`);
|
|
1071
|
-
} else {
|
|
1072
|
-
lines.push(`import type { FastifyInstance } from 'fastify';`);
|
|
1073
|
-
lines.push("");
|
|
1074
|
-
lines.push(`export async function ${routerName}(app: FastifyInstance) {`);
|
|
1075
|
-
for (const route of service.routes) {
|
|
1076
|
-
const methodLower = route.method.toLowerCase();
|
|
1077
|
-
lines.push(` // ${route.method} ${route.path}`);
|
|
1078
|
-
lines.push(
|
|
1079
|
-
` app.${methodLower}('${this.escapeStringValue(route.path, "TypeScript")}', async (request, reply) => {`
|
|
1080
|
-
);
|
|
1081
|
-
lines.push(` // TODO: Implement ${route.handlerName}`);
|
|
1082
|
-
lines.push(
|
|
1083
|
-
` return { message: '${this.escapeStringValue(route.handlerName, "TypeScript")} not implemented' };`
|
|
1084
|
-
);
|
|
1085
|
-
lines.push(` });`);
|
|
1086
|
-
lines.push("");
|
|
1087
|
-
}
|
|
1088
|
-
if (service.routes.length === 0) {
|
|
1089
|
-
lines.push(` // Default health check`);
|
|
1090
|
-
lines.push(` app.get('/health', async () => {`);
|
|
1091
|
-
lines.push(
|
|
1092
|
-
` return { status: 'ok', service: '${this.escapeStringValue(service.name, "TypeScript")}' };`
|
|
1093
|
-
);
|
|
1094
|
-
lines.push(` });`);
|
|
1095
|
-
lines.push("");
|
|
1096
|
-
}
|
|
1097
|
-
lines.push(`}`);
|
|
1098
|
-
}
|
|
1099
|
-
return lines.join("\n");
|
|
1100
|
-
}
|
|
1101
|
-
emitMiddlewareIndex(middleware) {
|
|
1102
|
-
const lines = [];
|
|
1103
|
-
lines.push(`/**`);
|
|
1104
|
-
lines.push(` * Middleware stubs`);
|
|
1105
|
-
lines.push(` * Auto-generated by HoloScript NodeServiceCompiler`);
|
|
1106
|
-
lines.push(` */`);
|
|
1107
|
-
lines.push("");
|
|
1108
|
-
if (this.options.framework === "express") {
|
|
1109
|
-
lines.push(`import type { Request, Response, NextFunction } from 'express';`);
|
|
1110
|
-
lines.push("");
|
|
1111
|
-
for (const mw of middleware) {
|
|
1112
|
-
const fnName = this.toCamelCase(mw) + "Middleware";
|
|
1113
|
-
lines.push(`export function ${fnName}(req: Request, _res: Response, next: NextFunction) {`);
|
|
1114
|
-
lines.push(` // TODO: Implement ${mw} middleware`);
|
|
1115
|
-
lines.push(` next();`);
|
|
1116
|
-
lines.push(`}`);
|
|
1117
|
-
lines.push("");
|
|
1118
|
-
}
|
|
1119
|
-
} else {
|
|
1120
|
-
lines.push(
|
|
1121
|
-
`import type { FastifyRequest, FastifyReply, HookHandlerDoneFunction } from 'fastify';`
|
|
1122
|
-
);
|
|
1123
|
-
lines.push("");
|
|
1124
|
-
for (const mw of middleware) {
|
|
1125
|
-
const fnName = this.toCamelCase(mw) + "Middleware";
|
|
1126
|
-
lines.push(
|
|
1127
|
-
`export function ${fnName}(request: FastifyRequest, _reply: FastifyReply, done: HookHandlerDoneFunction) {`
|
|
1128
|
-
);
|
|
1129
|
-
lines.push(` // TODO: Implement ${mw} middleware`);
|
|
1130
|
-
lines.push(` done();`);
|
|
1131
|
-
lines.push(`}`);
|
|
1132
|
-
lines.push("");
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
return lines.join("\n");
|
|
1136
|
-
}
|
|
1137
|
-
emitPackageJson(projectName) {
|
|
1138
|
-
const name = this.toKebab(projectName || "holoscript-service");
|
|
1139
|
-
const isExpress = this.options.framework === "express";
|
|
1140
|
-
const dependencies = isExpress ? { express: "^4.21.0", dotenv: "^16.4.0" } : { fastify: "^5.0.0", dotenv: "^16.4.0" };
|
|
1141
|
-
const connectors = this.collectConnectors();
|
|
1142
|
-
for (const conn of connectors) {
|
|
1143
|
-
const pkg2 = chunkXG23EUQX_cjs.CONNECTOR_PACKAGES[conn.name];
|
|
1144
|
-
if (pkg2) {
|
|
1145
|
-
dependencies[pkg2] = "latest";
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
const pkg = {
|
|
1149
|
-
name,
|
|
1150
|
-
version: "0.1.0",
|
|
1151
|
-
description: `Generated by HoloScript NodeServiceCompiler`,
|
|
1152
|
-
main: this.options.typescript ? "dist/index.js" : "index.js",
|
|
1153
|
-
scripts: {
|
|
1154
|
-
...this.options.typescript ? {
|
|
1155
|
-
build: "tsc",
|
|
1156
|
-
start: "node dist/index.js",
|
|
1157
|
-
dev: "tsx watch index.ts"
|
|
1158
|
-
} : {
|
|
1159
|
-
start: "node index.js",
|
|
1160
|
-
dev: "node --watch index.js"
|
|
1161
|
-
}
|
|
1162
|
-
},
|
|
1163
|
-
dependencies,
|
|
1164
|
-
...this.options.typescript && {
|
|
1165
|
-
devDependencies: {
|
|
1166
|
-
typescript: "^5.5.0",
|
|
1167
|
-
tsx: "^4.0.0",
|
|
1168
|
-
...isExpress ? { "@types/express": "^4.17.21", "@types/node": "^20.0.0" } : { "@types/node": "^20.0.0" }
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
return JSON.stringify(pkg, null, 2);
|
|
1173
|
-
}
|
|
1174
|
-
emitTsConfig() {
|
|
1175
|
-
const config = {
|
|
1176
|
-
compilerOptions: {
|
|
1177
|
-
target: "ES2022",
|
|
1178
|
-
module: "NodeNext",
|
|
1179
|
-
moduleResolution: "NodeNext",
|
|
1180
|
-
outDir: "./dist",
|
|
1181
|
-
rootDir: "./",
|
|
1182
|
-
strict: true,
|
|
1183
|
-
esModuleInterop: true,
|
|
1184
|
-
skipLibCheck: true,
|
|
1185
|
-
declaration: true
|
|
1186
|
-
},
|
|
1187
|
-
include: ["./**/*.ts"],
|
|
1188
|
-
exclude: ["node_modules", "dist"]
|
|
1189
|
-
};
|
|
1190
|
-
return JSON.stringify(config, null, 2);
|
|
1191
|
-
}
|
|
1192
|
-
emitDockerfile() {
|
|
1193
|
-
const nodeVer = this.options.nodeVersion;
|
|
1194
|
-
return [
|
|
1195
|
-
`FROM node:${nodeVer}-alpine AS builder`,
|
|
1196
|
-
`WORKDIR /app`,
|
|
1197
|
-
`COPY package*.json ./`,
|
|
1198
|
-
`RUN npm ci`,
|
|
1199
|
-
`COPY . .`,
|
|
1200
|
-
...this.options.typescript ? [`RUN npm run build`] : [],
|
|
1201
|
-
``,
|
|
1202
|
-
`FROM node:${nodeVer}-alpine`,
|
|
1203
|
-
`WORKDIR /app`,
|
|
1204
|
-
`COPY --from=builder /app/package*.json ./`,
|
|
1205
|
-
`RUN npm ci --omit=dev`,
|
|
1206
|
-
...this.options.typescript ? [`COPY --from=builder /app/dist ./dist`] : [`COPY --from=builder /app/*.js ./`],
|
|
1207
|
-
`EXPOSE ${this.options.port}`,
|
|
1208
|
-
`CMD ["npm", "start"]`,
|
|
1209
|
-
``
|
|
1210
|
-
].join("\n");
|
|
1211
|
-
}
|
|
1212
|
-
// ── Utilities ──────────────────────────────────────────────────────────
|
|
1213
|
-
collectEnvVars() {
|
|
1214
|
-
const map = /* @__PURE__ */ new Map();
|
|
1215
|
-
for (const service of this.services) {
|
|
1216
|
-
for (const env of service.envVars) {
|
|
1217
|
-
map.set(env.name, env);
|
|
1218
|
-
}
|
|
1219
|
-
for (const conn of service.connectors) {
|
|
1220
|
-
const requirements = chunkXG23EUQX_cjs.CONNECTOR_ENV_REQUIREMENTS[conn.name] || [];
|
|
1221
|
-
for (const req of requirements) {
|
|
1222
|
-
if (!map.has(req)) {
|
|
1223
|
-
map.set(req, { name: req, required: true });
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
return Array.from(map.values());
|
|
1229
|
-
}
|
|
1230
|
-
collectConnectors() {
|
|
1231
|
-
const map = /* @__PURE__ */ new Map();
|
|
1232
|
-
for (const service of this.services) {
|
|
1233
|
-
for (const conn of service.connectors) {
|
|
1234
|
-
map.set(conn.name, conn);
|
|
1235
|
-
}
|
|
1236
|
-
}
|
|
1237
|
-
return Array.from(map.values());
|
|
1238
|
-
}
|
|
1239
|
-
// ── Emitters ──────────────────────────────────────────────────────────
|
|
1240
|
-
emitEnvConfig(envVars) {
|
|
1241
|
-
const lines = [];
|
|
1242
|
-
lines.push(`/**`);
|
|
1243
|
-
lines.push(` * Environment Configuration`);
|
|
1244
|
-
lines.push(` * Auto-generated by HoloScript NodeServiceCompiler`);
|
|
1245
|
-
lines.push(` */`);
|
|
1246
|
-
lines.push(``);
|
|
1247
|
-
lines.push(`import dotenv from 'dotenv';`);
|
|
1248
|
-
lines.push(`dotenv.config();`);
|
|
1249
|
-
lines.push(``);
|
|
1250
|
-
lines.push(`export const env = {`);
|
|
1251
|
-
for (const ev of envVars) {
|
|
1252
|
-
const fallback = ev.defaultValue ? ` || '${ev.defaultValue}'` : "";
|
|
1253
|
-
lines.push(` ${ev.name}: process.env['${ev.name}']${fallback},`);
|
|
1254
|
-
}
|
|
1255
|
-
lines.push(`};`);
|
|
1256
|
-
lines.push(``);
|
|
1257
|
-
lines.push(`// Validation`);
|
|
1258
|
-
lines.push(`const missing: string[] = [];`);
|
|
1259
|
-
for (const ev of envVars) {
|
|
1260
|
-
if (ev.required) {
|
|
1261
|
-
lines.push(`if (!env.${ev.name}) missing.push('${ev.name}');`);
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
lines.push(``);
|
|
1265
|
-
lines.push(`if (missing.length > 0) {`);
|
|
1266
|
-
lines.push(` console.error('Missing required environment variables:', missing.join(', '));`);
|
|
1267
|
-
lines.push(` process.exit(1);`);
|
|
1268
|
-
lines.push(`}`);
|
|
1269
|
-
return lines.join("\n");
|
|
1270
|
-
}
|
|
1271
|
-
emitConnectorsIndex(connectors) {
|
|
1272
|
-
const lines = [];
|
|
1273
|
-
lines.push(`/**`);
|
|
1274
|
-
lines.push(` * Connector Registry`);
|
|
1275
|
-
lines.push(` * Auto-generated by HoloScript NodeServiceCompiler`);
|
|
1276
|
-
lines.push(` */`);
|
|
1277
|
-
lines.push(``);
|
|
1278
|
-
for (const conn of connectors) {
|
|
1279
|
-
const pkg = chunkXG23EUQX_cjs.CONNECTOR_PACKAGES[conn.name];
|
|
1280
|
-
if (pkg) {
|
|
1281
|
-
lines.push(`import { ${this.toClassName(conn.name)}Connector } from '${pkg}';`);
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
lines.push(``);
|
|
1285
|
-
for (const conn of connectors) {
|
|
1286
|
-
const className = this.toClassName(conn.name);
|
|
1287
|
-
lines.push(`export const ${conn.name} = new ${className}Connector();`);
|
|
1288
|
-
}
|
|
1289
|
-
lines.push(``);
|
|
1290
|
-
lines.push(`export async function initConnectors(): Promise<void> {`);
|
|
1291
|
-
lines.push(` await Promise.all([`);
|
|
1292
|
-
for (const conn of connectors) {
|
|
1293
|
-
lines.push(` ${conn.name}.connect(),`);
|
|
1294
|
-
}
|
|
1295
|
-
lines.push(` ]);`);
|
|
1296
|
-
for (const conn of connectors) {
|
|
1297
|
-
lines.push(` console.log('[connectors] ${conn.name}: connected');`);
|
|
1298
|
-
}
|
|
1299
|
-
lines.push(`}`);
|
|
1300
|
-
lines.push(``);
|
|
1301
|
-
lines.push(`export async function shutdownConnectors(): Promise<void> {`);
|
|
1302
|
-
lines.push(` await Promise.all([`);
|
|
1303
|
-
for (const conn of connectors) {
|
|
1304
|
-
lines.push(` ${conn.name}.disconnect(),`);
|
|
1305
|
-
}
|
|
1306
|
-
lines.push(` ]);`);
|
|
1307
|
-
lines.push(`}`);
|
|
1308
|
-
return lines.join("\n");
|
|
1309
|
-
}
|
|
1310
|
-
emitRailwayConfig(deploy) {
|
|
1311
|
-
const config = {
|
|
1312
|
-
$schema: "https://railway.app/railway.schema.json",
|
|
1313
|
-
build: {
|
|
1314
|
-
builder: "DOCKERFILE",
|
|
1315
|
-
dockerfilePath: "Dockerfile"
|
|
1316
|
-
},
|
|
1317
|
-
deploy: {
|
|
1318
|
-
numReplicas: 1,
|
|
1319
|
-
sleepApplication: false,
|
|
1320
|
-
restartPolicyType: "ON_FAILURE",
|
|
1321
|
-
healthcheckPath: deploy.healthPath || "/health"
|
|
1322
|
-
}
|
|
1323
|
-
};
|
|
1324
|
-
return JSON.stringify(config, null, 2);
|
|
1325
|
-
}
|
|
1326
|
-
toClassName(name) {
|
|
1327
|
-
return name.charAt(0).toUpperCase() + this.toCamelCase(name).slice(1);
|
|
1328
|
-
}
|
|
1329
|
-
/** Convert HoloObjectProperty[] to a Map for key-based lookup */
|
|
1330
|
-
objectPropsToMap(props) {
|
|
1331
|
-
const map = /* @__PURE__ */ new Map();
|
|
1332
|
-
if (!props) return map;
|
|
1333
|
-
for (const prop of props) {
|
|
1334
|
-
map.set(prop.key, prop.value);
|
|
1335
|
-
}
|
|
1336
|
-
return map;
|
|
1337
|
-
}
|
|
1338
|
-
ext(name) {
|
|
1339
|
-
return this.options.typescript ? `${name}.ts` : `${name}.js`;
|
|
1340
|
-
}
|
|
1341
|
-
toFileName(name) {
|
|
1342
|
-
return name.replace(/[^a-zA-Z0-9]/g, "-").replace(/-+/g, "-");
|
|
1343
|
-
}
|
|
1344
|
-
toKebab(name) {
|
|
1345
|
-
return name.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9]/g, "-").replace(/-+/g, "-").toLowerCase();
|
|
1346
|
-
}
|
|
1347
|
-
toCamelCase(name) {
|
|
1348
|
-
const parts = name.replace(/[^a-zA-Z0-9]/g, " ").split(/\s+/).filter(Boolean);
|
|
1349
|
-
if (parts.length === 0) return "unnamed";
|
|
1350
|
-
return parts[0].toLowerCase() + parts.slice(1).map((p) => p.charAt(0).toUpperCase() + p.slice(1).toLowerCase()).join("");
|
|
1351
|
-
}
|
|
1352
|
-
resolveString(val) {
|
|
1353
|
-
if (val === void 0 || val === null) return void 0;
|
|
1354
|
-
if (typeof val === "string") return val;
|
|
1355
|
-
if (typeof val === "object" && "value" in val) return String(val.value);
|
|
1356
|
-
return String(val);
|
|
1357
|
-
}
|
|
1358
|
-
resolveNumber(val) {
|
|
1359
|
-
if (val === void 0 || val === null) return void 0;
|
|
1360
|
-
if (typeof val === "number") return val;
|
|
1361
|
-
if (typeof val === "string") {
|
|
1362
|
-
const n = Number(val);
|
|
1363
|
-
return isNaN(n) ? void 0 : n;
|
|
1364
|
-
}
|
|
1365
|
-
if (typeof val === "object" && "value" in val) {
|
|
1366
|
-
const n = Number(val.value);
|
|
1367
|
-
return isNaN(n) ? void 0 : n;
|
|
1368
|
-
}
|
|
1369
|
-
return void 0;
|
|
1370
|
-
}
|
|
1371
|
-
validateConnectorIntegration() {
|
|
1372
|
-
const connectors = this.collectConnectors();
|
|
1373
|
-
const envVars = this.collectEnvVars();
|
|
1374
|
-
const envMap = new Map(envVars.map((ev) => [ev.name, ev]));
|
|
1375
|
-
for (const conn of connectors) {
|
|
1376
|
-
if (!chunkXG23EUQX_cjs.KNOWN_CONNECTORS.includes(conn.name)) {
|
|
1377
|
-
console.warn(`[NodeServiceCompiler] Warning: Unknown connector '${conn.name}'. Package dependency will not be added.`);
|
|
1378
|
-
} else {
|
|
1379
|
-
const requirements = chunkXG23EUQX_cjs.CONNECTOR_ENV_REQUIREMENTS[conn.name] || [];
|
|
1380
|
-
for (const req of requirements) {
|
|
1381
|
-
if (!envMap.has(req)) {
|
|
1382
|
-
throw new Error(`Connector '${conn.name}' requires environment variable '${req}'`);
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
const deployable = this.services.find((s) => s.deploy);
|
|
1388
|
-
if (deployable?.deploy) {
|
|
1389
|
-
if (deployable.deploy.platform !== "railway") {
|
|
1390
|
-
console.warn(
|
|
1391
|
-
`[NodeServiceCompiler] Warning: Platform '${deployable.deploy.platform}' is not explicitly supported for config generation yet.`
|
|
1392
|
-
);
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
};
|
|
1397
|
-
exports.DialectRegistry.register({
|
|
1398
|
-
name: "node-service",
|
|
1399
|
-
domain: "service",
|
|
1400
|
-
description: "Compiles @service traits to Express/Fastify Node.js applications",
|
|
1401
|
-
supportedTraits: [
|
|
1402
|
-
"service",
|
|
1403
|
-
"endpoint",
|
|
1404
|
-
"route",
|
|
1405
|
-
"handler",
|
|
1406
|
-
"middleware",
|
|
1407
|
-
"http",
|
|
1408
|
-
"gateway",
|
|
1409
|
-
"proxy",
|
|
1410
|
-
"load_balancer",
|
|
1411
|
-
"auth",
|
|
1412
|
-
"cors",
|
|
1413
|
-
"rate_limit",
|
|
1414
|
-
"validation",
|
|
1415
|
-
"connector",
|
|
1416
|
-
"env",
|
|
1417
|
-
"deploy",
|
|
1418
|
-
"on_connector_event"
|
|
1419
|
-
],
|
|
1420
|
-
riskTier: "standard",
|
|
1421
|
-
factory: (options) => new exports.NodeServiceCompiler(options),
|
|
1422
|
-
outputExtensions: [".ts", ".js", ".json"],
|
|
1423
|
-
experimental: true
|
|
1424
|
-
});
|
|
1425
|
-
}
|
|
1426
|
-
});
|
|
1427
|
-
|
|
1428
|
-
// src/compiler/registerBuiltinDialects.ts
|
|
1429
|
-
var registerBuiltinDialects_exports = {};
|
|
1430
|
-
chunk3SAK5KFL_cjs.__export(registerBuiltinDialects_exports, {
|
|
1431
|
-
registerBuiltinDialects: () => registerBuiltinDialects
|
|
1432
|
-
});
|
|
1433
|
-
function registerBuiltinDialects() {
|
|
1434
|
-
if (_registered) return;
|
|
1435
|
-
_registered = true;
|
|
1436
|
-
const descriptors = [
|
|
1437
|
-
// ── Game Engines ──────────────────────────────────────────────────────
|
|
1438
|
-
{
|
|
1439
|
-
name: "unity",
|
|
1440
|
-
domain: "gamedev",
|
|
1441
|
-
description: "Compiles to Unity C# MonoBehaviours",
|
|
1442
|
-
supportedTraits: [
|
|
1443
|
-
"physics",
|
|
1444
|
-
"collidable",
|
|
1445
|
-
"grabbable",
|
|
1446
|
-
"throwable",
|
|
1447
|
-
"audio",
|
|
1448
|
-
"spatial_audio",
|
|
1449
|
-
"animation",
|
|
1450
|
-
"particles",
|
|
1451
|
-
"material",
|
|
1452
|
-
"ui",
|
|
1453
|
-
"networked",
|
|
1454
|
-
"behavior_tree",
|
|
1455
|
-
"navmesh",
|
|
1456
|
-
"lod"
|
|
1457
|
-
],
|
|
1458
|
-
riskTier: "standard",
|
|
1459
|
-
factory: (opts) => {
|
|
1460
|
-
const { UnityCompiler: UnityCompiler2 } = (chunkHE7ULERA_cjs.init_UnityCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkHE7ULERA_cjs.UnityCompiler_exports));
|
|
1461
|
-
return new UnityCompiler2(opts);
|
|
1462
|
-
},
|
|
1463
|
-
outputExtensions: [".cs"]
|
|
1464
|
-
},
|
|
1465
|
-
{
|
|
1466
|
-
name: "unreal",
|
|
1467
|
-
domain: "gamedev",
|
|
1468
|
-
description: "Compiles to Unreal Engine C++ actors",
|
|
1469
|
-
supportedTraits: [
|
|
1470
|
-
"physics",
|
|
1471
|
-
"collidable",
|
|
1472
|
-
"grabbable",
|
|
1473
|
-
"audio",
|
|
1474
|
-
"animation",
|
|
1475
|
-
"particles",
|
|
1476
|
-
"material",
|
|
1477
|
-
"niagara",
|
|
1478
|
-
"landscape",
|
|
1479
|
-
"behavior_tree",
|
|
1480
|
-
"navmesh",
|
|
1481
|
-
"lod"
|
|
1482
|
-
],
|
|
1483
|
-
riskTier: "standard",
|
|
1484
|
-
factory: (opts) => {
|
|
1485
|
-
const { UnrealCompiler } = (chunk5OEOHAAW_cjs.init_UnrealCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunk5OEOHAAW_cjs.UnrealCompiler_exports));
|
|
1486
|
-
return new UnrealCompiler(opts);
|
|
1487
|
-
},
|
|
1488
|
-
outputExtensions: [".cpp", ".h"]
|
|
1489
|
-
},
|
|
1490
|
-
{
|
|
1491
|
-
name: "godot",
|
|
1492
|
-
domain: "gamedev",
|
|
1493
|
-
description: "Compiles to Godot GDScript nodes",
|
|
1494
|
-
supportedTraits: [
|
|
1495
|
-
"physics",
|
|
1496
|
-
"collidable",
|
|
1497
|
-
"grabbable",
|
|
1498
|
-
"audio",
|
|
1499
|
-
"animation",
|
|
1500
|
-
"particles",
|
|
1501
|
-
"material",
|
|
1502
|
-
"behavior_tree",
|
|
1503
|
-
"navmesh"
|
|
1504
|
-
],
|
|
1505
|
-
riskTier: "standard",
|
|
1506
|
-
factory: (opts) => {
|
|
1507
|
-
const { GodotCompiler: GodotCompiler2 } = (chunkXXINBTZK_cjs.init_GodotCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkXXINBTZK_cjs.GodotCompiler_exports));
|
|
1508
|
-
return new GodotCompiler2(opts);
|
|
1509
|
-
},
|
|
1510
|
-
outputExtensions: [".gd", ".tscn"]
|
|
1511
|
-
},
|
|
1512
|
-
// ── Web 3D ────────────────────────────────────────────────────────────
|
|
1513
|
-
{
|
|
1514
|
-
name: "r3f",
|
|
1515
|
-
domain: "web3d",
|
|
1516
|
-
description: "Compiles to React Three Fiber JSX components",
|
|
1517
|
-
supportedTraits: [
|
|
1518
|
-
"physics",
|
|
1519
|
-
"collidable",
|
|
1520
|
-
"grabbable",
|
|
1521
|
-
"audio",
|
|
1522
|
-
"spatial_audio",
|
|
1523
|
-
"animation",
|
|
1524
|
-
"particles",
|
|
1525
|
-
"material",
|
|
1526
|
-
"ui",
|
|
1527
|
-
"behavior_tree",
|
|
1528
|
-
"lod",
|
|
1529
|
-
"vr_only",
|
|
1530
|
-
"ar_only"
|
|
1531
|
-
],
|
|
1532
|
-
riskTier: "standard",
|
|
1533
|
-
factory: (opts) => {
|
|
1534
|
-
const { R3FCompiler: R3FCompiler2 } = (chunkQ5SJOGHQ_cjs.init_R3FCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkQ5SJOGHQ_cjs.R3FCompiler_exports));
|
|
1535
|
-
return new R3FCompiler2(opts);
|
|
1536
|
-
},
|
|
1537
|
-
outputExtensions: [".tsx", ".jsx"]
|
|
1538
|
-
},
|
|
1539
|
-
{
|
|
1540
|
-
name: "babylon",
|
|
1541
|
-
domain: "web3d",
|
|
1542
|
-
description: "Compiles to Babylon.js scene code",
|
|
1543
|
-
supportedTraits: [
|
|
1544
|
-
"physics",
|
|
1545
|
-
"collidable",
|
|
1546
|
-
"audio",
|
|
1547
|
-
"animation",
|
|
1548
|
-
"particles",
|
|
1549
|
-
"material",
|
|
1550
|
-
"behavior_tree"
|
|
1551
|
-
],
|
|
1552
|
-
riskTier: "standard",
|
|
1553
|
-
factory: (opts) => {
|
|
1554
|
-
const { BabylonCompiler: BabylonCompiler2 } = (chunk33LSUQDD_cjs.init_BabylonCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunk33LSUQDD_cjs.BabylonCompiler_exports));
|
|
1555
|
-
return new BabylonCompiler2(opts);
|
|
1556
|
-
},
|
|
1557
|
-
outputExtensions: [".ts", ".js"]
|
|
1558
|
-
},
|
|
1559
|
-
{
|
|
1560
|
-
name: "playcanvas",
|
|
1561
|
-
domain: "web3d",
|
|
1562
|
-
description: "Compiles to PlayCanvas engine scripts",
|
|
1563
|
-
supportedTraits: ["physics", "collidable", "audio", "animation", "material"],
|
|
1564
|
-
riskTier: "standard",
|
|
1565
|
-
factory: (opts) => {
|
|
1566
|
-
const { PlayCanvasCompiler: PlayCanvasCompiler2 } = (chunkXWPNTWDN_cjs.init_PlayCanvasCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkXWPNTWDN_cjs.PlayCanvasCompiler_exports));
|
|
1567
|
-
return new PlayCanvasCompiler2(opts);
|
|
1568
|
-
},
|
|
1569
|
-
outputExtensions: [".js"]
|
|
1570
|
-
},
|
|
1571
|
-
// ── VR/XR ─────────────────────────────────────────────────────────────
|
|
1572
|
-
{
|
|
1573
|
-
name: "openxr",
|
|
1574
|
-
domain: "xr",
|
|
1575
|
-
description: "Compiles to OpenXR C++ application layer",
|
|
1576
|
-
supportedTraits: [
|
|
1577
|
-
"physics",
|
|
1578
|
-
"hand_tracking",
|
|
1579
|
-
"spatial_anchor",
|
|
1580
|
-
"input",
|
|
1581
|
-
"collidable",
|
|
1582
|
-
"grabbable"
|
|
1583
|
-
],
|
|
1584
|
-
riskTier: "standard",
|
|
1585
|
-
factory: (opts) => {
|
|
1586
|
-
const { OpenXRCompiler: OpenXRCompiler2 } = (chunkFFKU7BTK_cjs.init_OpenXRCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkFFKU7BTK_cjs.OpenXRCompiler_exports));
|
|
1587
|
-
return new OpenXRCompiler2(opts);
|
|
1588
|
-
},
|
|
1589
|
-
outputExtensions: [".cpp", ".h"]
|
|
1590
|
-
},
|
|
1591
|
-
{
|
|
1592
|
-
name: "vrchat",
|
|
1593
|
-
domain: "social-vr",
|
|
1594
|
-
description: "Compiles to VRChat UdonSharp scripts",
|
|
1595
|
-
supportedTraits: [
|
|
1596
|
-
"physics",
|
|
1597
|
-
"collidable",
|
|
1598
|
-
"grabbable",
|
|
1599
|
-
"audio",
|
|
1600
|
-
"animation",
|
|
1601
|
-
"networked",
|
|
1602
|
-
"ui",
|
|
1603
|
-
"interaction"
|
|
1604
|
-
],
|
|
1605
|
-
riskTier: "standard",
|
|
1606
|
-
factory: (opts) => {
|
|
1607
|
-
const { VRChatCompiler: VRChatCompiler2 } = (chunkZ34RLXRA_cjs.init_VRChatCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkZ34RLXRA_cjs.VRChatCompiler_exports));
|
|
1608
|
-
return new VRChatCompiler2(opts);
|
|
1609
|
-
},
|
|
1610
|
-
outputExtensions: [".cs"]
|
|
1611
|
-
},
|
|
1612
|
-
{
|
|
1613
|
-
name: "visionos",
|
|
1614
|
-
domain: "xr",
|
|
1615
|
-
description: "Compiles to visionOS RealityKit Swift",
|
|
1616
|
-
supportedTraits: [
|
|
1617
|
-
"physics",
|
|
1618
|
-
"hand_tracking",
|
|
1619
|
-
"spatial_anchor",
|
|
1620
|
-
"animation",
|
|
1621
|
-
"material",
|
|
1622
|
-
"collidable"
|
|
1623
|
-
],
|
|
1624
|
-
riskTier: "standard",
|
|
1625
|
-
factory: (opts) => {
|
|
1626
|
-
const { VisionOSCompiler: VisionOSCompiler2 } = (chunk5O6TQC6M_cjs.init_VisionOSCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunk5O6TQC6M_cjs.VisionOSCompiler_exports));
|
|
1627
|
-
return new VisionOSCompiler2(opts);
|
|
1628
|
-
},
|
|
1629
|
-
outputExtensions: [".swift"]
|
|
1630
|
-
},
|
|
1631
|
-
{
|
|
1632
|
-
name: "android-xr",
|
|
1633
|
-
domain: "xr",
|
|
1634
|
-
description: "Compiles to Android XR OpenXR Kotlin",
|
|
1635
|
-
supportedTraits: ["physics", "hand_tracking", "spatial_anchor", "input", "collidable"],
|
|
1636
|
-
riskTier: "standard",
|
|
1637
|
-
factory: (opts) => {
|
|
1638
|
-
const { AndroidXRCompiler: AndroidXRCompiler2 } = (chunk4XSNJCLC_cjs.init_AndroidXRCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunk4XSNJCLC_cjs.AndroidXRCompiler_exports));
|
|
1639
|
-
return new AndroidXRCompiler2(opts);
|
|
1640
|
-
},
|
|
1641
|
-
outputExtensions: [".kt"]
|
|
1642
|
-
},
|
|
1643
|
-
// ── Mobile ────────────────────────────────────────────────────────────
|
|
1644
|
-
{
|
|
1645
|
-
name: "ios",
|
|
1646
|
-
domain: "mobile",
|
|
1647
|
-
description: "Compiles to iOS ARKit Swift",
|
|
1648
|
-
supportedTraits: ["physics", "ar_anchor", "animation", "material", "collidable"],
|
|
1649
|
-
riskTier: "standard",
|
|
1650
|
-
factory: (opts) => {
|
|
1651
|
-
const { IOSCompiler: IOSCompiler2 } = (chunkCBJSLA2E_cjs.init_IOSCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkCBJSLA2E_cjs.IOSCompiler_exports));
|
|
1652
|
-
return new IOSCompiler2(opts);
|
|
1653
|
-
},
|
|
1654
|
-
outputExtensions: [".swift"]
|
|
1655
|
-
},
|
|
1656
|
-
{
|
|
1657
|
-
name: "android",
|
|
1658
|
-
domain: "mobile",
|
|
1659
|
-
description: "Compiles to Android ARCore Kotlin",
|
|
1660
|
-
supportedTraits: ["physics", "ar_anchor", "animation", "material", "collidable"],
|
|
1661
|
-
riskTier: "standard",
|
|
1662
|
-
factory: (opts) => {
|
|
1663
|
-
const { AndroidCompiler: AndroidCompiler2 } = (chunkNCUKG4SK_cjs.init_AndroidCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkNCUKG4SK_cjs.AndroidCompiler_exports));
|
|
1664
|
-
return new AndroidCompiler2(opts);
|
|
1665
|
-
},
|
|
1666
|
-
outputExtensions: [".kt"]
|
|
1667
|
-
},
|
|
1668
|
-
{
|
|
1669
|
-
name: "ar",
|
|
1670
|
-
domain: "mobile",
|
|
1671
|
-
description: "Compiles to generic AR platform code",
|
|
1672
|
-
supportedTraits: ["physics", "ar_anchor", "spatial_anchor", "collidable", "material"],
|
|
1673
|
-
riskTier: "standard",
|
|
1674
|
-
factory: (opts) => {
|
|
1675
|
-
const { ARCompiler: ARCompiler2 } = (chunkQ5JT3YML_cjs.init_ARCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkQ5JT3YML_cjs.ARCompiler_exports));
|
|
1676
|
-
return new ARCompiler2(opts);
|
|
1677
|
-
},
|
|
1678
|
-
outputExtensions: [".ts"]
|
|
1679
|
-
},
|
|
1680
|
-
// ── Low-level ─────────────────────────────────────────────────────────
|
|
1681
|
-
{
|
|
1682
|
-
name: "wasm",
|
|
1683
|
-
domain: "runtime",
|
|
1684
|
-
description: "Compiles to WebAssembly modules",
|
|
1685
|
-
supportedTraits: ["physics", "animation", "audio"],
|
|
1686
|
-
riskTier: "high",
|
|
1687
|
-
factory: (opts) => {
|
|
1688
|
-
const { WASMCompiler: WASMCompiler2 } = (chunk6UEHYZ7V_cjs.init_WASMCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunk6UEHYZ7V_cjs.WASMCompiler_exports));
|
|
1689
|
-
return new WASMCompiler2(opts);
|
|
1690
|
-
},
|
|
1691
|
-
outputExtensions: [".wasm", ".js"]
|
|
1692
|
-
},
|
|
1693
|
-
{
|
|
1694
|
-
name: "webgpu",
|
|
1695
|
-
domain: "shader",
|
|
1696
|
-
description: "Compiles to WebGPU compute shaders (WGSL)",
|
|
1697
|
-
supportedTraits: ["physics", "particles", "fluid", "material", "compute"],
|
|
1698
|
-
riskTier: "standard",
|
|
1699
|
-
factory: (opts) => {
|
|
1700
|
-
const { WebGPUCompiler: WebGPUCompiler2 } = (chunkBND3ST2K_cjs.init_WebGPUCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkBND3ST2K_cjs.WebGPUCompiler_exports));
|
|
1701
|
-
return new WebGPUCompiler2(opts);
|
|
1702
|
-
},
|
|
1703
|
-
outputExtensions: [".wgsl", ".ts"]
|
|
1704
|
-
},
|
|
1705
|
-
// ── Robotics & IoT ───────────────────────────────────────────────────
|
|
1706
|
-
{
|
|
1707
|
-
name: "urdf",
|
|
1708
|
-
domain: "robotics",
|
|
1709
|
-
description: "Compiles to URDF robot descriptions",
|
|
1710
|
-
supportedTraits: ["joint", "actuator", "sensor", "collider", "end_effector"],
|
|
1711
|
-
riskTier: "standard",
|
|
1712
|
-
factory: (opts) => {
|
|
1713
|
-
const { URDFCompiler: URDFCompiler2 } = (chunk6TZPZCOJ_cjs.init_URDFCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunk6TZPZCOJ_cjs.URDFCompiler_exports));
|
|
1714
|
-
return new URDFCompiler2(opts);
|
|
1715
|
-
},
|
|
1716
|
-
outputExtensions: [".urdf"]
|
|
1717
|
-
},
|
|
1718
|
-
{
|
|
1719
|
-
name: "sdf",
|
|
1720
|
-
domain: "robotics",
|
|
1721
|
-
description: "Compiles to SDF simulation descriptions (Gazebo)",
|
|
1722
|
-
supportedTraits: ["joint", "actuator", "sensor", "collider", "physics", "environment"],
|
|
1723
|
-
riskTier: "standard",
|
|
1724
|
-
factory: (opts) => {
|
|
1725
|
-
const { SDFCompiler: SDFCompiler2 } = (chunk7AGYRWKW_cjs.init_SDFCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunk7AGYRWKW_cjs.SDFCompiler_exports));
|
|
1726
|
-
return new SDFCompiler2(opts);
|
|
1727
|
-
},
|
|
1728
|
-
outputExtensions: [".sdf"]
|
|
1729
|
-
},
|
|
1730
|
-
{
|
|
1731
|
-
name: "dtdl",
|
|
1732
|
-
domain: "iot",
|
|
1733
|
-
description: "Compiles to DTDL digital twin definitions",
|
|
1734
|
-
supportedTraits: ["sensor", "telemetry", "property", "command", "relationship"],
|
|
1735
|
-
riskTier: "standard",
|
|
1736
|
-
factory: (opts) => {
|
|
1737
|
-
const { DTDLCompiler: DTDLCompiler2 } = (chunkQLEAOI3Q_cjs.init_DTDLCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkQLEAOI3Q_cjs.DTDLCompiler_exports));
|
|
1738
|
-
return new DTDLCompiler2(opts);
|
|
1739
|
-
},
|
|
1740
|
-
outputExtensions: [".json"]
|
|
1741
|
-
},
|
|
1742
|
-
// ── Specialized ───────────────────────────────────────────────────────
|
|
1743
|
-
{
|
|
1744
|
-
name: "state",
|
|
1745
|
-
domain: "meta",
|
|
1746
|
-
description: "Extracts reactive state descriptors from compositions",
|
|
1747
|
-
supportedTraits: ["state", "bind", "reactive"],
|
|
1748
|
-
riskTier: "standard",
|
|
1749
|
-
factory: (opts) => {
|
|
1750
|
-
const { StateCompiler: StateCompiler2 } = (chunkB5TCIAPQ_cjs.init_StateCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkB5TCIAPQ_cjs.StateCompiler_exports));
|
|
1751
|
-
return new StateCompiler2(opts);
|
|
1752
|
-
},
|
|
1753
|
-
outputExtensions: [".json"]
|
|
1754
|
-
},
|
|
1755
|
-
{
|
|
1756
|
-
name: "a2a-agent-card",
|
|
1757
|
-
domain: "ai",
|
|
1758
|
-
description: "Generates A2A Agent Card from composition metadata",
|
|
1759
|
-
supportedTraits: ["agent", "skill", "capability"],
|
|
1760
|
-
riskTier: "standard",
|
|
1761
|
-
factory: (opts) => {
|
|
1762
|
-
const { A2AAgentCardCompiler } = (chunkF3HH56EB_cjs.init_A2AAgentCardCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkF3HH56EB_cjs.A2AAgentCardCompiler_exports));
|
|
1763
|
-
return new A2AAgentCardCompiler(opts);
|
|
1764
|
-
},
|
|
1765
|
-
outputExtensions: [".json"]
|
|
1766
|
-
},
|
|
1767
|
-
{
|
|
1768
|
-
name: "nir",
|
|
1769
|
-
domain: "neuromorphic",
|
|
1770
|
-
description: "Compiles to Neuromorphic Intermediate Representation",
|
|
1771
|
-
supportedTraits: ["snn", "neuron", "synapse", "spike_train"],
|
|
1772
|
-
riskTier: "high",
|
|
1773
|
-
factory: (opts) => {
|
|
1774
|
-
const { NIRCompiler } = (chunkF3HH56EB_cjs.init_NIRCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkF3HH56EB_cjs.NIRCompiler_exports));
|
|
1775
|
-
return new NIRCompiler(opts);
|
|
1776
|
-
},
|
|
1777
|
-
outputExtensions: [".json"]
|
|
1778
|
-
},
|
|
1779
|
-
{
|
|
1780
|
-
name: "vrr",
|
|
1781
|
-
domain: "xr",
|
|
1782
|
-
description: "Compiles with Variable Rate Rendering optimizations",
|
|
1783
|
-
supportedTraits: ["physics", "material", "lod", "rendering"],
|
|
1784
|
-
riskTier: "standard",
|
|
1785
|
-
factory: (opts) => {
|
|
1786
|
-
const { VRRCompiler } = (chunkLGGRPKTV_cjs.init_VRRCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(chunkLGGRPKTV_cjs.VRRCompiler_exports));
|
|
1787
|
-
return new VRRCompiler(opts);
|
|
1788
|
-
},
|
|
1789
|
-
outputExtensions: [".ts"]
|
|
1790
|
-
},
|
|
1791
|
-
{
|
|
1792
|
-
name: "native-2d",
|
|
1793
|
-
domain: "web3d",
|
|
1794
|
-
description: "Compiles to native 2D HTML/CSS/Canvas applications",
|
|
1795
|
-
supportedTraits: ["layout", "style", "animation", "interaction"],
|
|
1796
|
-
riskTier: "standard",
|
|
1797
|
-
factory: (opts) => {
|
|
1798
|
-
const { Native2DCompiler: Native2DCompiler2 } = (init_Native2DCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(Native2DCompiler_exports));
|
|
1799
|
-
return new Native2DCompiler2(opts);
|
|
1800
|
-
},
|
|
1801
|
-
outputExtensions: [".tsx", ".html"]
|
|
1802
|
-
},
|
|
1803
|
-
// ── Next.js API Routes ────────────────────────────────────────────────
|
|
1804
|
-
{
|
|
1805
|
-
name: "nextjs-api",
|
|
1806
|
-
domain: "web",
|
|
1807
|
-
description: "Compiles @http traits to Next.js App Router API route handlers (route.ts)",
|
|
1808
|
-
supportedTraits: ["http", "handler", "middleware", "auth", "rate_limit", "cors"],
|
|
1809
|
-
riskTier: "standard",
|
|
1810
|
-
factory: () => {
|
|
1811
|
-
const { compileToNextJSAPI: compileToNextJSAPI2 } = (init_NextJSAPICompiler(), chunk3SAK5KFL_cjs.__toCommonJS(NextJSAPICompiler_exports));
|
|
1812
|
-
return {
|
|
1813
|
-
compile: (composition, _token) => compileToNextJSAPI2(composition)
|
|
1814
|
-
};
|
|
1815
|
-
},
|
|
1816
|
-
outputExtensions: [".ts"],
|
|
1817
|
-
experimental: true
|
|
1818
|
-
},
|
|
1819
|
-
// ── v6 Universal Service ──────────────────────────────────────────────
|
|
1820
|
-
{
|
|
1821
|
-
name: "node-service",
|
|
1822
|
-
domain: "service",
|
|
1823
|
-
description: "Compiles @service traits to Express/Fastify applications",
|
|
1824
|
-
supportedTraits: [
|
|
1825
|
-
"service",
|
|
1826
|
-
"endpoint",
|
|
1827
|
-
"route",
|
|
1828
|
-
"handler",
|
|
1829
|
-
"middleware",
|
|
1830
|
-
"cors_policy",
|
|
1831
|
-
"rate_limiter",
|
|
1832
|
-
"health_endpoint"
|
|
1833
|
-
],
|
|
1834
|
-
riskTier: "standard",
|
|
1835
|
-
factory: (opts) => {
|
|
1836
|
-
const { NodeServiceCompiler: NodeServiceCompiler2 } = (init_NodeServiceCompiler(), chunk3SAK5KFL_cjs.__toCommonJS(NodeServiceCompiler_exports));
|
|
1837
|
-
return new NodeServiceCompiler2(opts);
|
|
1838
|
-
},
|
|
1839
|
-
outputExtensions: [".ts", ".js"],
|
|
1840
|
-
experimental: true
|
|
1841
|
-
}
|
|
1842
|
-
];
|
|
1843
|
-
for (const desc of descriptors) {
|
|
1844
|
-
if (!exports.DialectRegistry.has(desc.name)) {
|
|
1845
|
-
exports.DialectRegistry.register(desc);
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
var _registered;
|
|
1850
|
-
var init_registerBuiltinDialects = chunk3SAK5KFL_cjs.__esm({
|
|
1851
|
-
"src/compiler/registerBuiltinDialects.ts"() {
|
|
1852
|
-
init_DialectRegistry();
|
|
1853
|
-
_registered = false;
|
|
1854
|
-
}
|
|
1855
|
-
});
|
|
1856
|
-
|
|
1857
|
-
// src/compiler/DialectRegistry.ts
|
|
1858
|
-
function ensureDialectsBooted() {
|
|
1859
|
-
if (_autoBooted) return;
|
|
1860
|
-
_autoBooted = true;
|
|
1861
|
-
try {
|
|
1862
|
-
const { registerBuiltinDialects: registerBuiltinDialects2 } = (init_registerBuiltinDialects(), chunk3SAK5KFL_cjs.__toCommonJS(registerBuiltinDialects_exports));
|
|
1863
|
-
registerBuiltinDialects2();
|
|
1864
|
-
} catch {
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
var DialectRegistryImpl; exports.DialectRegistry = void 0; var _autoBooted;
|
|
1868
|
-
var init_DialectRegistry = chunk3SAK5KFL_cjs.__esm({
|
|
1869
|
-
"src/compiler/DialectRegistry.ts"() {
|
|
1870
|
-
DialectRegistryImpl = class {
|
|
1871
|
-
constructor() {
|
|
1872
|
-
this.dialects = /* @__PURE__ */ new Map();
|
|
1873
|
-
}
|
|
1874
|
-
/**
|
|
1875
|
-
* Register a new compiler dialect.
|
|
1876
|
-
* @throws Error if a dialect with the same name already exists
|
|
1877
|
-
*/
|
|
1878
|
-
register(descriptor) {
|
|
1879
|
-
if (this.dialects.has(descriptor.name)) {
|
|
1880
|
-
throw new Error(
|
|
1881
|
-
`Dialect "${descriptor.name}" is already registered. Use DialectRegistry.override() to replace an existing dialect.`
|
|
1882
|
-
);
|
|
1883
|
-
}
|
|
1884
|
-
if (!descriptor.ansPath) {
|
|
1885
|
-
descriptor.ansPath = `/compile/${descriptor.domain}/${descriptor.name}`;
|
|
1886
|
-
}
|
|
1887
|
-
this.dialects.set(descriptor.name, descriptor);
|
|
1888
|
-
}
|
|
1889
|
-
/**
|
|
1890
|
-
* Override an existing dialect registration.
|
|
1891
|
-
*/
|
|
1892
|
-
override(descriptor) {
|
|
1893
|
-
if (!descriptor.ansPath) {
|
|
1894
|
-
descriptor.ansPath = `/compile/${descriptor.domain}/${descriptor.name}`;
|
|
1895
|
-
}
|
|
1896
|
-
this.dialects.set(descriptor.name, descriptor);
|
|
1897
|
-
}
|
|
1898
|
-
/**
|
|
1899
|
-
* Unregister a dialect.
|
|
1900
|
-
*/
|
|
1901
|
-
unregister(name) {
|
|
1902
|
-
return this.dialects.delete(name);
|
|
1903
|
-
}
|
|
1904
|
-
/**
|
|
1905
|
-
* Check if a dialect is registered.
|
|
1906
|
-
*/
|
|
1907
|
-
has(name) {
|
|
1908
|
-
return this.dialects.has(name);
|
|
1909
|
-
}
|
|
1910
|
-
/**
|
|
1911
|
-
* Get dialect info (without factory, safe for discovery).
|
|
1912
|
-
*/
|
|
1913
|
-
get(name) {
|
|
1914
|
-
const desc = this.dialects.get(name);
|
|
1915
|
-
if (!desc) return void 0;
|
|
1916
|
-
return {
|
|
1917
|
-
name: desc.name,
|
|
1918
|
-
domain: desc.domain,
|
|
1919
|
-
description: desc.description,
|
|
1920
|
-
supportedTraits: desc.supportedTraits,
|
|
1921
|
-
riskTier: desc.riskTier,
|
|
1922
|
-
ansPath: desc.ansPath || `/compile/${desc.domain}/${desc.name}`,
|
|
1923
|
-
outputExtensions: desc.outputExtensions || [],
|
|
1924
|
-
experimental: desc.experimental ?? false
|
|
1925
|
-
};
|
|
1926
|
-
}
|
|
1927
|
-
/**
|
|
1928
|
-
* Create a compiler instance from a registered dialect.
|
|
1929
|
-
* @throws Error if dialect not found
|
|
1930
|
-
*/
|
|
1931
|
-
create(name, options) {
|
|
1932
|
-
const desc = this.dialects.get(name);
|
|
1933
|
-
if (!desc) {
|
|
1934
|
-
const available = [...this.dialects.keys()].join(", ");
|
|
1935
|
-
throw new Error(`Unknown dialect "${name}". Available: ${available}`);
|
|
1936
|
-
}
|
|
1937
|
-
return desc.factory(options);
|
|
1938
|
-
}
|
|
1939
|
-
/**
|
|
1940
|
-
* List all registered dialects.
|
|
1941
|
-
*/
|
|
1942
|
-
list() {
|
|
1943
|
-
return [...this.dialects.values()].map((desc) => ({
|
|
1944
|
-
name: desc.name,
|
|
1945
|
-
domain: desc.domain,
|
|
1946
|
-
description: desc.description,
|
|
1947
|
-
supportedTraits: desc.supportedTraits,
|
|
1948
|
-
riskTier: desc.riskTier,
|
|
1949
|
-
ansPath: desc.ansPath || `/compile/${desc.domain}/${desc.name}`,
|
|
1950
|
-
outputExtensions: desc.outputExtensions || [],
|
|
1951
|
-
experimental: desc.experimental ?? false
|
|
1952
|
-
}));
|
|
1953
|
-
}
|
|
1954
|
-
/**
|
|
1955
|
-
* List dialects filtered by domain.
|
|
1956
|
-
*/
|
|
1957
|
-
listByDomain(domain) {
|
|
1958
|
-
return this.list().filter((d) => d.domain === domain);
|
|
1959
|
-
}
|
|
1960
|
-
/**
|
|
1961
|
-
* Find dialects that support a specific trait.
|
|
1962
|
-
*/
|
|
1963
|
-
findByTrait(traitName) {
|
|
1964
|
-
return this.list().filter((d) => d.supportedTraits.includes(traitName));
|
|
1965
|
-
}
|
|
1966
|
-
/**
|
|
1967
|
-
* Get all registered dialect names.
|
|
1968
|
-
*/
|
|
1969
|
-
names() {
|
|
1970
|
-
return [...this.dialects.keys()];
|
|
1971
|
-
}
|
|
1972
|
-
/**
|
|
1973
|
-
* Get count of registered dialects.
|
|
1974
|
-
*/
|
|
1975
|
-
get size() {
|
|
1976
|
-
return this.dialects.size;
|
|
1977
|
-
}
|
|
1978
|
-
/**
|
|
1979
|
-
* Execute a progressive lowering pipeline for a dialect.
|
|
1980
|
-
* Runs all registered lowering passes in priority order.
|
|
1981
|
-
*/
|
|
1982
|
-
executeLoweringPipeline(dialectName, composition, options = {}) {
|
|
1983
|
-
const desc = this.dialects.get(dialectName);
|
|
1984
|
-
if (!desc) {
|
|
1985
|
-
throw new Error(`Unknown dialect "${dialectName}"`);
|
|
1986
|
-
}
|
|
1987
|
-
const passes = [...desc.loweringPasses || []].sort((a, b) => a.priority - b.priority);
|
|
1988
|
-
if (passes.length === 0) {
|
|
1989
|
-
throw new Error(
|
|
1990
|
-
`Dialect "${dialectName}" has no lowering passes. Use create() for direct compilation.`
|
|
1991
|
-
);
|
|
1992
|
-
}
|
|
1993
|
-
const context = {
|
|
1994
|
-
target: dialectName,
|
|
1995
|
-
options,
|
|
1996
|
-
previousPasses: /* @__PURE__ */ new Map(),
|
|
1997
|
-
diagnostics: []
|
|
1998
|
-
};
|
|
1999
|
-
let lastResult = { output: "" };
|
|
2000
|
-
for (const pass of passes) {
|
|
2001
|
-
lastResult = pass.lower(composition, context);
|
|
2002
|
-
context.previousPasses.set(pass.name, lastResult);
|
|
2003
|
-
if (lastResult.diagnostics) {
|
|
2004
|
-
context.diagnostics.push(...lastResult.diagnostics);
|
|
2005
|
-
}
|
|
2006
|
-
const hasError = lastResult.diagnostics?.some((d) => d.level === "error");
|
|
2007
|
-
if (hasError) break;
|
|
2008
|
-
}
|
|
2009
|
-
lastResult.diagnostics = context.diagnostics;
|
|
2010
|
-
return lastResult;
|
|
2011
|
-
}
|
|
2012
|
-
};
|
|
2013
|
-
exports.DialectRegistry = new DialectRegistryImpl();
|
|
2014
|
-
_autoBooted = false;
|
|
2015
|
-
}
|
|
2016
|
-
});
|
|
2017
|
-
|
|
2018
|
-
// src/compiler/index.ts
|
|
2019
|
-
chunkBF2235SI_cjs.init_CompilerBase();
|
|
2020
|
-
chunkBF2235SI_cjs.init_CompilerDocumentationGenerator();
|
|
2021
|
-
chunkQ5SJOGHQ_cjs.init_R3FCompiler();
|
|
2022
|
-
chunkHE7ULERA_cjs.init_UnityCompiler();
|
|
2023
|
-
chunkXXINBTZK_cjs.init_GodotCompiler();
|
|
2024
|
-
chunk33LSUQDD_cjs.init_BabylonCompiler();
|
|
2025
|
-
chunkXWPNTWDN_cjs.init_PlayCanvasCompiler();
|
|
2026
|
-
chunkQ5JT3YML_cjs.init_ARCompiler();
|
|
2027
|
-
chunkFFKU7BTK_cjs.init_OpenXRCompiler();
|
|
2028
|
-
chunkZ34RLXRA_cjs.init_VRChatCompiler();
|
|
2029
|
-
chunk5O6TQC6M_cjs.init_VisionOSCompiler();
|
|
2030
|
-
chunkNCUKG4SK_cjs.init_AndroidCompiler();
|
|
2031
|
-
chunk4XSNJCLC_cjs.init_AndroidXRCompiler();
|
|
2032
|
-
chunkCBJSLA2E_cjs.init_IOSCompiler();
|
|
2033
|
-
chunk6UEHYZ7V_cjs.init_WASMCompiler();
|
|
2034
|
-
chunkBND3ST2K_cjs.init_WebGPUCompiler();
|
|
2035
|
-
chunk7AGYRWKW_cjs.init_SDFCompiler();
|
|
2036
|
-
chunkQLEAOI3Q_cjs.init_DTDLCompiler();
|
|
2037
|
-
chunk6TZPZCOJ_cjs.init_URDFCompiler();
|
|
2038
|
-
chunkB5TCIAPQ_cjs.init_StateCompiler();
|
|
2039
|
-
|
|
2040
|
-
// src/compiler/NextJSCompiler.ts
|
|
2041
|
-
chunkBF2235SI_cjs.init_CompilerBase();
|
|
2042
|
-
init_Native2DCompiler();
|
|
2043
|
-
function findTrait(composition, traitName) {
|
|
2044
|
-
const traits = composition.traits;
|
|
2045
|
-
if (!traits) return null;
|
|
2046
|
-
const found = traits.find((t) => t.name === traitName);
|
|
2047
|
-
return found?.config || null;
|
|
2048
|
-
}
|
|
2049
|
-
var NextJSCompiler = class extends chunkBF2235SI_cjs.CompilerBase {
|
|
2050
|
-
constructor(options = {}) {
|
|
2051
|
-
super();
|
|
2052
|
-
this.options = options;
|
|
2053
|
-
this.compilerName = "NextJSCompiler";
|
|
2054
|
-
}
|
|
2055
|
-
/**
|
|
2056
|
-
* Compile HoloComposition AST to Next.js App Router Code
|
|
2057
|
-
*
|
|
2058
|
-
* @param composition - HoloScript AST
|
|
2059
|
-
* @param agentToken - JWT or UCAN token proving agent identity
|
|
2060
|
-
* @param outputPath - Optional output file path for scope validation
|
|
2061
|
-
* @param sceneGraph - Optional pre-computed SSG
|
|
2062
|
-
*/
|
|
2063
|
-
async compile(composition, agentToken, outputPath, _sceneGraph) {
|
|
2064
|
-
this.validateCompilerAccess(agentToken, outputPath);
|
|
2065
|
-
return this.buildNextRoute(composition);
|
|
2066
|
-
}
|
|
2067
|
-
validateCompilerAccess(agentToken, outputPath) {
|
|
2068
|
-
if (typeof agentToken === "object" && agentToken !== null) {
|
|
2069
|
-
this.validateCapabilityAccess(agentToken, outputPath);
|
|
2070
|
-
} else {
|
|
2071
|
-
this.validateASTAccess(agentToken);
|
|
2072
|
-
this.validateCodeGeneration(agentToken);
|
|
2073
|
-
if (outputPath) {
|
|
2074
|
-
this.validateOutputPath(agentToken, outputPath);
|
|
2075
|
-
}
|
|
2076
|
-
this.validateSpatialZoneAccess(agentToken);
|
|
2077
|
-
}
|
|
2078
|
-
}
|
|
2079
|
-
buildNextRoute(composition) {
|
|
2080
|
-
const compiler = new exports.Native2DCompiler();
|
|
2081
|
-
const pageTrait = findTrait(composition, "page");
|
|
2082
|
-
const metaTrait = findTrait(composition, "metadata");
|
|
2083
|
-
const route = pageTrait?.route || `/${composition.name.toLowerCase().replace(/\s+/g, "-")}`;
|
|
2084
|
-
const isClient = pageTrait?.client !== false;
|
|
2085
|
-
const slotMap = this.options.slots || {};
|
|
2086
|
-
if (pageTrait?.redirect) {
|
|
2087
|
-
const redirectUrl = pageTrait.redirect;
|
|
2088
|
-
const lines2 = [
|
|
2089
|
-
`// @generated by HoloScript NextJSCompiler \u2014 DO NOT EDIT`,
|
|
2090
|
-
`import { redirect } from 'next/navigation';`,
|
|
2091
|
-
``,
|
|
2092
|
-
`export default function RedirectPage() {`,
|
|
2093
|
-
` redirect(${JSON.stringify(redirectUrl)});`,
|
|
2094
|
-
`}`
|
|
2095
|
-
];
|
|
2096
|
-
if (metaTrait) {
|
|
2097
|
-
const metaEntries = [];
|
|
2098
|
-
if (metaTrait.title) metaEntries.push(` title: ${JSON.stringify(metaTrait.title)},`);
|
|
2099
|
-
if (metaTrait.description)
|
|
2100
|
-
metaEntries.push(` description: ${JSON.stringify(metaTrait.description)},`);
|
|
2101
|
-
lines2.push("");
|
|
2102
|
-
lines2.push(`export const metadata = {`);
|
|
2103
|
-
lines2.push(metaEntries.join("\n"));
|
|
2104
|
-
lines2.push(`};`);
|
|
2105
|
-
}
|
|
2106
|
-
const routePath2 = route.replace(/^\//, "") || "index";
|
|
2107
|
-
return {
|
|
2108
|
-
path: `${routePath2}/page.tsx`,
|
|
2109
|
-
code: lines2.join("\n")
|
|
2110
|
-
};
|
|
2111
|
-
}
|
|
2112
|
-
const compilerOptions = {
|
|
2113
|
-
format: "react",
|
|
2114
|
-
useUIComponents: true,
|
|
2115
|
-
slots: slotMap
|
|
2116
|
-
};
|
|
2117
|
-
const elements = composition.ui?.elements || composition.objects || [];
|
|
2118
|
-
const componentCode = compiler.generateReactComponent(
|
|
2119
|
-
composition.name,
|
|
2120
|
-
elements,
|
|
2121
|
-
composition,
|
|
2122
|
-
compilerOptions
|
|
2123
|
-
);
|
|
2124
|
-
const pageSafeComponentCode = componentCode.replace(
|
|
2125
|
-
/export\s+function\s+([A-Za-z0-9_]+)\s*\(/,
|
|
2126
|
-
"function $1("
|
|
2127
|
-
);
|
|
2128
|
-
const lines = [];
|
|
2129
|
-
if (isClient) {
|
|
2130
|
-
lines.push("'use client';");
|
|
2131
|
-
lines.push("");
|
|
2132
|
-
}
|
|
2133
|
-
lines.push(pageSafeComponentCode);
|
|
2134
|
-
if (metaTrait && !isClient) {
|
|
2135
|
-
const metaEntries = [];
|
|
2136
|
-
if (metaTrait.title) metaEntries.push(` title: ${JSON.stringify(metaTrait.title)},`);
|
|
2137
|
-
if (metaTrait.description)
|
|
2138
|
-
metaEntries.push(` description: ${JSON.stringify(metaTrait.description)},`);
|
|
2139
|
-
lines.push("");
|
|
2140
|
-
lines.push(`export const metadata = {`);
|
|
2141
|
-
lines.push(metaEntries.join("\n"));
|
|
2142
|
-
lines.push(`};`);
|
|
2143
|
-
}
|
|
2144
|
-
const routePath = route.replace(/^\//, "") || "index";
|
|
2145
|
-
return {
|
|
2146
|
-
path: `${routePath}/page.tsx`,
|
|
2147
|
-
code: lines.join("\n")
|
|
2148
|
-
};
|
|
2149
|
-
}
|
|
2150
|
-
};
|
|
2151
|
-
|
|
2152
|
-
// src/compiler/index.ts
|
|
2153
|
-
init_NextJSAPICompiler();
|
|
2154
|
-
|
|
2155
|
-
// src/compiler/MCPConfigCompiler.ts
|
|
2156
|
-
chunkBF2235SI_cjs.init_CompilerBase();
|
|
2157
|
-
init_DialectRegistry();
|
|
2158
|
-
var MCPConfigCompiler = class extends chunkBF2235SI_cjs.CompilerBase {
|
|
2159
|
-
constructor(options = {}) {
|
|
2160
|
-
super();
|
|
2161
|
-
this.compilerName = "MCPConfigCompiler";
|
|
2162
|
-
this.servers = [];
|
|
2163
|
-
this.options = {
|
|
2164
|
-
target: options.target ?? "generic",
|
|
2165
|
-
envFile: options.envFile ?? "",
|
|
2166
|
-
envValues: options.envValues ?? {},
|
|
2167
|
-
cwd: options.cwd ?? ""
|
|
2168
|
-
};
|
|
2169
|
-
}
|
|
2170
|
-
compile(composition, agentToken, outputPath) {
|
|
2171
|
-
this.validateCompilerAccess(agentToken, outputPath);
|
|
2172
|
-
this.servers = [];
|
|
2173
|
-
if (composition.domainBlocks) {
|
|
2174
|
-
for (const block of composition.domainBlocks) {
|
|
2175
|
-
if (block.domain === "mcp_servers" || block.name === "mcp_servers") {
|
|
2176
|
-
this.extractServersFromBlock(block);
|
|
2177
|
-
}
|
|
2178
|
-
}
|
|
2179
|
-
}
|
|
2180
|
-
if (composition.objects) {
|
|
2181
|
-
for (const obj of composition.objects) {
|
|
2182
|
-
if (this.hasConnectorTrait(obj)) {
|
|
2183
|
-
this.servers.push(this.extractServerFromObject(obj));
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
|
-
const config = this.generateConfig();
|
|
2188
|
-
return JSON.stringify(config, null, 2);
|
|
2189
|
-
}
|
|
2190
|
-
// ── Extraction ────────────────────────────────────────────────────────────
|
|
2191
|
-
extractServersFromBlock(block) {
|
|
2192
|
-
if (!block.children) return;
|
|
2193
|
-
for (const child of block.children) {
|
|
2194
|
-
if ("type" in child && child.type === "ObjectDecl") {
|
|
2195
|
-
const obj = child;
|
|
2196
|
-
this.servers.push(this.extractServerFromObject(obj));
|
|
2197
|
-
}
|
|
2198
|
-
}
|
|
2199
|
-
}
|
|
2200
|
-
extractServerFromObject(obj) {
|
|
2201
|
-
const props = this.objectPropsToMap(obj.properties);
|
|
2202
|
-
const traits = obj.traits || [];
|
|
2203
|
-
let transport = "http";
|
|
2204
|
-
const connectorTrait = traits.find((t) => t.name === "connector");
|
|
2205
|
-
if (connectorTrait?.config) {
|
|
2206
|
-
const t = this.resolveString(connectorTrait.config["transport"] || connectorTrait.config["_arg1"]);
|
|
2207
|
-
if (t === "stdio" || t === "sse" || t === "http") transport = t;
|
|
2208
|
-
}
|
|
2209
|
-
const envVars = [];
|
|
2210
|
-
for (const trait of traits) {
|
|
2211
|
-
if (trait.name === "env") {
|
|
2212
|
-
const varName = this.resolveString(trait.config["_arg0"] || trait.config["name"] || "");
|
|
2213
|
-
const header = this.resolveString(trait.config["header"] || "");
|
|
2214
|
-
if (varName) {
|
|
2215
|
-
envVars.push({ name: varName, header: header || void 0 });
|
|
2216
|
-
}
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
return {
|
|
2220
|
-
name: obj.name,
|
|
2221
|
-
transport,
|
|
2222
|
-
url: this.resolveString(props.get("url")),
|
|
2223
|
-
command: this.resolveString(props.get("command")),
|
|
2224
|
-
args: this.resolveArray(props.get("args")),
|
|
2225
|
-
cwd: this.resolveString(props.get("cwd")),
|
|
2226
|
-
description: this.resolveString(props.get("description")),
|
|
2227
|
-
envVars
|
|
2228
|
-
};
|
|
2229
|
-
}
|
|
2230
|
-
hasConnectorTrait(obj) {
|
|
2231
|
-
return (obj.traits || []).some((t) => t.name === "connector");
|
|
2232
|
-
}
|
|
2233
|
-
// ── Config Generation ─────────────────────────────────────────────────────
|
|
2234
|
-
generateConfig() {
|
|
2235
|
-
const mcpServers = {};
|
|
2236
|
-
for (const server of this.servers) {
|
|
2237
|
-
mcpServers[server.name] = this.generateServerEntry(server);
|
|
2238
|
-
}
|
|
2239
|
-
const config = {
|
|
2240
|
-
_generated: "HoloScript MCPConfigCompiler",
|
|
2241
|
-
_target: this.options.target,
|
|
2242
|
-
_updated: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
|
|
2243
|
-
mcpServers
|
|
2244
|
-
};
|
|
2245
|
-
if (this.options.target === "claude") {
|
|
2246
|
-
config["$schema"] = "https://modelcontextprotocol.io/schemas/mcp-config.json";
|
|
2247
|
-
}
|
|
2248
|
-
return config;
|
|
2249
|
-
}
|
|
2250
|
-
generateServerEntry(server) {
|
|
2251
|
-
const entry = {};
|
|
2252
|
-
if (server.transport === "stdio") {
|
|
2253
|
-
entry.command = server.command || "node";
|
|
2254
|
-
if (server.args) entry.args = server.args;
|
|
2255
|
-
if (server.cwd || this.options.target === "antigravity") {
|
|
2256
|
-
entry.cwd = server.cwd || this.options.cwd || void 0;
|
|
2257
|
-
}
|
|
2258
|
-
const envBlock = {};
|
|
2259
|
-
for (const ev of server.envVars) {
|
|
2260
|
-
if (!ev.header) {
|
|
2261
|
-
envBlock[ev.name] = this.resolveEnvValue(ev.name);
|
|
2262
|
-
}
|
|
2263
|
-
}
|
|
2264
|
-
if (Object.keys(envBlock).length > 0) {
|
|
2265
|
-
entry.env = envBlock;
|
|
2266
|
-
}
|
|
2267
|
-
} else {
|
|
2268
|
-
if (this.options.target === "antigravity") {
|
|
2269
|
-
entry.serverURL = server.url;
|
|
2270
|
-
} else {
|
|
2271
|
-
entry.url = server.url;
|
|
2272
|
-
}
|
|
2273
|
-
if (this.options.target !== "antigravity" && server.transport === "sse") {
|
|
2274
|
-
entry.transport = "sse";
|
|
2275
|
-
}
|
|
2276
|
-
const headers = {};
|
|
2277
|
-
for (const ev of server.envVars) {
|
|
2278
|
-
if (ev.header) {
|
|
2279
|
-
const [headerName, ...prefix] = ev.header.split(":");
|
|
2280
|
-
const prefixStr = prefix.join(":").trim();
|
|
2281
|
-
const value = this.resolveEnvValue(ev.name);
|
|
2282
|
-
headers[headerName.trim()] = prefixStr ? `${prefixStr} ${value}` : value;
|
|
2283
|
-
} else {
|
|
2284
|
-
headers[ev.name] = this.resolveEnvValue(ev.name);
|
|
2285
|
-
}
|
|
2286
|
-
}
|
|
2287
|
-
if (Object.keys(headers).length > 0) {
|
|
2288
|
-
entry.headers = headers;
|
|
2289
|
-
}
|
|
2290
|
-
}
|
|
2291
|
-
if (server.description) {
|
|
2292
|
-
entry.description = server.description;
|
|
2293
|
-
}
|
|
2294
|
-
return entry;
|
|
2295
|
-
}
|
|
2296
|
-
// ── Env Value Resolution ──────────────────────────────────────────────────
|
|
2297
|
-
resolveEnvValue(varName) {
|
|
2298
|
-
switch (this.options.target) {
|
|
2299
|
-
case "antigravity":
|
|
2300
|
-
return this.options.envValues[varName] || this.readEnvFile(varName) || `MISSING_${varName}`;
|
|
2301
|
-
case "vscode":
|
|
2302
|
-
return `\${env:${varName}}`;
|
|
2303
|
-
case "claude":
|
|
2304
|
-
case "cursor":
|
|
2305
|
-
case "generic":
|
|
2306
|
-
default:
|
|
2307
|
-
return `\${${varName}}`;
|
|
2308
|
-
}
|
|
2309
|
-
}
|
|
2310
|
-
readEnvFile(varName) {
|
|
2311
|
-
if (!this.options.envFile) return void 0;
|
|
2312
|
-
try {
|
|
2313
|
-
return this.options.envValues[varName];
|
|
2314
|
-
} catch {
|
|
2315
|
-
return void 0;
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
// ── Helpers ───────────────────────────────────────────────────────────────
|
|
2319
|
-
objectPropsToMap(props) {
|
|
2320
|
-
const map = /* @__PURE__ */ new Map();
|
|
2321
|
-
if (!props) return map;
|
|
2322
|
-
for (const prop of props) {
|
|
2323
|
-
map.set(prop.key, prop.value);
|
|
2324
|
-
}
|
|
2325
|
-
return map;
|
|
2326
|
-
}
|
|
2327
|
-
resolveString(value) {
|
|
2328
|
-
if (!value) return void 0;
|
|
2329
|
-
if (typeof value === "string") return value;
|
|
2330
|
-
if (typeof value === "object" && "value" in value) {
|
|
2331
|
-
return String(value.value);
|
|
2332
|
-
}
|
|
2333
|
-
return String(value);
|
|
2334
|
-
}
|
|
2335
|
-
resolveArray(value) {
|
|
2336
|
-
if (!value) return void 0;
|
|
2337
|
-
if (Array.isArray(value)) {
|
|
2338
|
-
return value.map((v) => {
|
|
2339
|
-
if (typeof v === "string") return v;
|
|
2340
|
-
if (typeof v === "object" && v && "value" in v) return String(v.value);
|
|
2341
|
-
return String(v);
|
|
2342
|
-
});
|
|
2343
|
-
}
|
|
2344
|
-
return void 0;
|
|
2345
|
-
}
|
|
2346
|
-
};
|
|
2347
|
-
exports.DialectRegistry.register({
|
|
2348
|
-
name: "mcp-config",
|
|
2349
|
-
domain: "configuration",
|
|
2350
|
-
description: "Compiles .holo server definitions to IDE-specific MCP config JSON",
|
|
2351
|
-
supportedTraits: ["connector", "env"],
|
|
2352
|
-
factory: (options) => new MCPConfigCompiler(options),
|
|
2353
|
-
inputFormats: [".holo"],
|
|
2354
|
-
outputFormat: ".json"
|
|
2355
|
-
});
|
|
2356
|
-
|
|
2357
|
-
// src/compiler/index.ts
|
|
2358
|
-
init_Native2DCompiler();
|
|
2359
|
-
init_NodeServiceCompiler();
|
|
2360
|
-
init_DialectRegistry();
|
|
2361
|
-
init_registerBuiltinDialects();
|
|
2362
|
-
|
|
2363
|
-
Object.defineProperty(exports, "createReproducibilityContext", {
|
|
2364
|
-
enumerable: true,
|
|
2365
|
-
get: function () { return chunkVJ3L7CHT_cjs.createReproducibilityContext; }
|
|
2366
|
-
});
|
|
2367
|
-
Object.defineProperty(exports, "parseReproducibilityFlags", {
|
|
2368
|
-
enumerable: true,
|
|
2369
|
-
get: function () { return chunkVJ3L7CHT_cjs.parseReproducibilityFlags; }
|
|
2370
|
-
});
|
|
2371
|
-
Object.defineProperty(exports, "GLTF_PIPELINE_TOOLS", {
|
|
2372
|
-
enumerable: true,
|
|
2373
|
-
get: function () { return chunkKSGXLT74_cjs.GLTF_PIPELINE_TOOLS; }
|
|
2374
|
-
});
|
|
2375
|
-
Object.defineProperty(exports, "registerGLTFTools", {
|
|
2376
|
-
enumerable: true,
|
|
2377
|
-
get: function () { return chunkKSGXLT74_cjs.registerGLTFTools; }
|
|
2378
|
-
});
|
|
2379
|
-
Object.defineProperty(exports, "NodeToyMapper", {
|
|
2380
|
-
enumerable: true,
|
|
2381
|
-
get: function () { return chunk27LWW5FU_cjs.NodeToyMapper; }
|
|
2382
|
-
});
|
|
2383
|
-
Object.defineProperty(exports, "mapNodeToyToShader", {
|
|
2384
|
-
enumerable: true,
|
|
2385
|
-
get: function () { return chunk27LWW5FU_cjs.mapNodeToyToShader; }
|
|
2386
|
-
});
|
|
2387
|
-
Object.defineProperty(exports, "CompilerBridge", {
|
|
2388
|
-
enumerable: true,
|
|
2389
|
-
get: function () { return chunkF3HH56EB_cjs.CompilerBridge; }
|
|
2390
|
-
});
|
|
2391
|
-
Object.defineProperty(exports, "USDZPipeline", {
|
|
2392
|
-
enumerable: true,
|
|
2393
|
-
get: function () { return chunkF3HH56EB_cjs.USDZPipeline; }
|
|
2394
|
-
});
|
|
2395
|
-
Object.defineProperty(exports, "bestCategoryForTraits", {
|
|
2396
|
-
enumerable: true,
|
|
2397
|
-
get: function () { return chunkF3HH56EB_cjs.bestCategoryForTraits; }
|
|
2398
|
-
});
|
|
2399
|
-
Object.defineProperty(exports, "compilePipelineSource", {
|
|
2400
|
-
enumerable: true,
|
|
2401
|
-
get: function () { return chunkF3HH56EB_cjs.compilePipelineSource; }
|
|
2402
|
-
});
|
|
2403
|
-
Object.defineProperty(exports, "compilePipelineSourceToNode", {
|
|
2404
|
-
enumerable: true,
|
|
2405
|
-
get: function () { return chunkF3HH56EB_cjs.compilePipelineSourceToNode; }
|
|
2406
|
-
});
|
|
2407
|
-
Object.defineProperty(exports, "compilePipelineSourceToPython", {
|
|
2408
|
-
enumerable: true,
|
|
2409
|
-
get: function () { return chunkF3HH56EB_cjs.compilePipelineSourceToPython; }
|
|
2410
|
-
});
|
|
2411
|
-
Object.defineProperty(exports, "compilePipelineToNode", {
|
|
2412
|
-
enumerable: true,
|
|
2413
|
-
get: function () { return chunkF3HH56EB_cjs.compilePipelineToNode; }
|
|
2414
|
-
});
|
|
2415
|
-
Object.defineProperty(exports, "compilePipelineToPython", {
|
|
2416
|
-
enumerable: true,
|
|
2417
|
-
get: function () { return chunkF3HH56EB_cjs.compilePipelineToPython; }
|
|
2418
|
-
});
|
|
2419
|
-
Object.defineProperty(exports, "quickSafetyCheck", {
|
|
2420
|
-
enumerable: true,
|
|
2421
|
-
get: function () { return chunkF3HH56EB_cjs.quickSafetyCheck; }
|
|
2422
|
-
});
|
|
2423
|
-
Object.defineProperty(exports, "runSafetyPass", {
|
|
2424
|
-
enumerable: true,
|
|
2425
|
-
get: function () { return chunkF3HH56EB_cjs.runSafetyPass; }
|
|
2426
|
-
});
|
|
2427
|
-
Object.defineProperty(exports, "selectModality", {
|
|
2428
|
-
enumerable: true,
|
|
2429
|
-
get: function () { return chunkF3HH56EB_cjs.selectModality; }
|
|
2430
|
-
});
|
|
2431
|
-
Object.defineProperty(exports, "selectModalityForAll", {
|
|
2432
|
-
enumerable: true,
|
|
2433
|
-
get: function () { return chunkF3HH56EB_cjs.selectModalityForAll; }
|
|
2434
|
-
});
|
|
2435
|
-
Object.defineProperty(exports, "generateHullGeometry", {
|
|
2436
|
-
enumerable: true,
|
|
2437
|
-
get: function () { return chunkLK5IAVH6_cjs.generateHullGeometry; }
|
|
2438
|
-
});
|
|
2439
|
-
Object.defineProperty(exports, "generateMembraneGeometry", {
|
|
2440
|
-
enumerable: true,
|
|
2441
|
-
get: function () { return chunkLK5IAVH6_cjs.generateMembraneGeometry; }
|
|
2442
|
-
});
|
|
2443
|
-
Object.defineProperty(exports, "generateSplineGeometry", {
|
|
2444
|
-
enumerable: true,
|
|
2445
|
-
get: function () { return chunkLK5IAVH6_cjs.generateSplineGeometry; }
|
|
2446
|
-
});
|
|
2447
|
-
Object.defineProperty(exports, "RemotionBridge", {
|
|
2448
|
-
enumerable: true,
|
|
2449
|
-
get: function () { return chunkXUILI4KB_cjs.RemotionBridgeImpl; }
|
|
2450
|
-
});
|
|
2451
|
-
Object.defineProperty(exports, "SemanticSceneGraph", {
|
|
2452
|
-
enumerable: true,
|
|
2453
|
-
get: function () { return chunk5WUNN6ZN_cjs.SemanticSceneGraph; }
|
|
2454
|
-
});
|
|
2455
|
-
Object.defineProperty(exports, "COCOExporter", {
|
|
2456
|
-
enumerable: true,
|
|
2457
|
-
get: function () { return chunkI6XZ5DZF_cjs.COCOExporterImpl; }
|
|
2458
|
-
});
|
|
2459
|
-
Object.defineProperty(exports, "DTDLCompiler", {
|
|
2460
|
-
enumerable: true,
|
|
2461
|
-
get: function () { return chunkQLEAOI3Q_cjs.DTDLCompiler; }
|
|
2462
|
-
});
|
|
2463
|
-
Object.defineProperty(exports, "URDFCompiler", {
|
|
2464
|
-
enumerable: true,
|
|
2465
|
-
get: function () { return chunk6TZPZCOJ_cjs.URDFCompiler; }
|
|
2466
|
-
});
|
|
2467
|
-
Object.defineProperty(exports, "USDPhysicsCompiler", {
|
|
2468
|
-
enumerable: true,
|
|
2469
|
-
get: function () { return chunkEQV4R3EV_cjs.USDPhysicsCompiler; }
|
|
2470
|
-
});
|
|
2471
|
-
Object.defineProperty(exports, "SDFCompiler", {
|
|
2472
|
-
enumerable: true,
|
|
2473
|
-
get: function () { return chunk7AGYRWKW_cjs.SDFCompiler; }
|
|
2474
|
-
});
|
|
2475
|
-
Object.defineProperty(exports, "StateCompiler", {
|
|
2476
|
-
enumerable: true,
|
|
2477
|
-
get: function () { return chunkB5TCIAPQ_cjs.StateCompiler; }
|
|
2478
|
-
});
|
|
2479
|
-
Object.defineProperty(exports, "TraitCompositionCompiler", {
|
|
2480
|
-
enumerable: true,
|
|
2481
|
-
get: function () { return chunkXRKWN5PL_cjs.TraitCompositionCompiler; }
|
|
2482
|
-
});
|
|
2483
|
-
Object.defineProperty(exports, "IncrementalCompiler", {
|
|
2484
|
-
enumerable: true,
|
|
2485
|
-
get: function () { return chunkFSF7EQVA_cjs.IncrementalCompiler; }
|
|
2486
|
-
});
|
|
2487
|
-
Object.defineProperty(exports, "ENVIRONMENT_PRESETS", {
|
|
2488
|
-
enumerable: true,
|
|
2489
|
-
get: function () { return chunkQ5SJOGHQ_cjs.ENVIRONMENT_PRESETS; }
|
|
2490
|
-
});
|
|
2491
|
-
Object.defineProperty(exports, "R3FCompiler", {
|
|
2492
|
-
enumerable: true,
|
|
2493
|
-
get: function () { return chunkQ5SJOGHQ_cjs.R3FCompiler; }
|
|
2494
|
-
});
|
|
2495
|
-
Object.defineProperty(exports, "PlayCanvasCompiler", {
|
|
2496
|
-
enumerable: true,
|
|
2497
|
-
get: function () { return chunkXWPNTWDN_cjs.PlayCanvasCompiler; }
|
|
2498
|
-
});
|
|
2499
|
-
Object.defineProperty(exports, "AndroidCompiler", {
|
|
2500
|
-
enumerable: true,
|
|
2501
|
-
get: function () { return chunkNCUKG4SK_cjs.AndroidCompiler; }
|
|
2502
|
-
});
|
|
2503
|
-
Object.defineProperty(exports, "AndroidXRCompiler", {
|
|
2504
|
-
enumerable: true,
|
|
2505
|
-
get: function () { return chunk4XSNJCLC_cjs.AndroidXRCompiler; }
|
|
2506
|
-
});
|
|
2507
|
-
Object.defineProperty(exports, "IOSCompiler", {
|
|
2508
|
-
enumerable: true,
|
|
2509
|
-
get: function () { return chunkCBJSLA2E_cjs.IOSCompiler; }
|
|
2510
|
-
});
|
|
2511
|
-
Object.defineProperty(exports, "VisionOSCompiler", {
|
|
2512
|
-
enumerable: true,
|
|
2513
|
-
get: function () { return chunk5O6TQC6M_cjs.VisionOSCompiler; }
|
|
2514
|
-
});
|
|
2515
|
-
Object.defineProperty(exports, "WASMCompiler", {
|
|
2516
|
-
enumerable: true,
|
|
2517
|
-
get: function () { return chunk6UEHYZ7V_cjs.WASMCompiler; }
|
|
2518
|
-
});
|
|
2519
|
-
Object.defineProperty(exports, "WebGPUCompiler", {
|
|
2520
|
-
enumerable: true,
|
|
2521
|
-
get: function () { return chunkBND3ST2K_cjs.WebGPUCompiler; }
|
|
2522
|
-
});
|
|
2523
|
-
Object.defineProperty(exports, "MultiLayerCompiler", {
|
|
2524
|
-
enumerable: true,
|
|
2525
|
-
get: function () { return chunkZP4D3CSX_cjs.MultiLayerCompiler; }
|
|
2526
|
-
});
|
|
2527
|
-
Object.defineProperty(exports, "ARCompiler", {
|
|
2528
|
-
enumerable: true,
|
|
2529
|
-
get: function () { return chunkQ5JT3YML_cjs.ARCompiler; }
|
|
2530
|
-
});
|
|
2531
|
-
Object.defineProperty(exports, "OpenXRCompiler", {
|
|
2532
|
-
enumerable: true,
|
|
2533
|
-
get: function () { return chunkFFKU7BTK_cjs.OpenXRCompiler; }
|
|
2534
|
-
});
|
|
2535
|
-
Object.defineProperty(exports, "VRChatCompiler", {
|
|
2536
|
-
enumerable: true,
|
|
2537
|
-
get: function () { return chunkZ34RLXRA_cjs.VRChatCompiler; }
|
|
2538
|
-
});
|
|
2539
|
-
Object.defineProperty(exports, "BabylonCompiler", {
|
|
2540
|
-
enumerable: true,
|
|
2541
|
-
get: function () { return chunk33LSUQDD_cjs.BabylonCompiler; }
|
|
2542
|
-
});
|
|
2543
|
-
Object.defineProperty(exports, "UnityCompiler", {
|
|
2544
|
-
enumerable: true,
|
|
2545
|
-
get: function () { return chunkHE7ULERA_cjs.UnityCompiler; }
|
|
2546
|
-
});
|
|
2547
|
-
Object.defineProperty(exports, "GodotCompiler", {
|
|
2548
|
-
enumerable: true,
|
|
2549
|
-
get: function () { return chunkXXINBTZK_cjs.GodotCompiler; }
|
|
2550
|
-
});
|
|
2551
|
-
Object.defineProperty(exports, "CompilerBase", {
|
|
2552
|
-
enumerable: true,
|
|
2553
|
-
get: function () { return chunkBF2235SI_cjs.CompilerBase; }
|
|
2554
|
-
});
|
|
2555
|
-
Object.defineProperty(exports, "CompilerDocumentationGenerator", {
|
|
2556
|
-
enumerable: true,
|
|
2557
|
-
get: function () { return chunkBF2235SI_cjs.CompilerDocumentationGenerator; }
|
|
2558
|
-
});
|
|
2559
|
-
Object.defineProperty(exports, "UnauthorizedCompilerAccessError", {
|
|
2560
|
-
enumerable: true,
|
|
2561
|
-
get: function () { return chunkBF2235SI_cjs.UnauthorizedCompilerAccessError; }
|
|
2562
|
-
});
|
|
2563
|
-
Object.defineProperty(exports, "createTestCompilerToken", {
|
|
2564
|
-
enumerable: true,
|
|
2565
|
-
get: function () { return chunkBF2235SI_cjs.createTestCompilerToken; }
|
|
2566
|
-
});
|
|
2567
|
-
Object.defineProperty(exports, "isCapabilityTokenCredential", {
|
|
2568
|
-
enumerable: true,
|
|
2569
|
-
get: function () { return chunkBF2235SI_cjs.isCapabilityTokenCredential; }
|
|
2570
|
-
});
|
|
2571
|
-
exports.MCPConfigCompiler = MCPConfigCompiler;
|
|
2572
|
-
exports.NextJSCompiler = NextJSCompiler;
|
|
2573
|
-
exports.compileAllToNextJSAPI = compileAllToNextJSAPI;
|
|
2574
|
-
exports.compileToNextJSAPI = compileToNextJSAPI;
|
|
2575
|
-
exports.ensureDialectsBooted = ensureDialectsBooted;
|
|
2576
|
-
exports.registerBuiltinDialects = registerBuiltinDialects;
|
|
2577
|
-
//# sourceMappingURL=index.cjs.map
|
|
2578
|
-
//# sourceMappingURL=index.cjs.map
|