@holoscript/core 6.0.3 → 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/README.md +40 -40
- package/dist/codebase/index.d.ts +25 -0
- package/dist/compiler/index.d.ts +82 -0
- package/dist/constants.d.ts +4 -0
- package/dist/coordinators/index.d.ts +189 -0
- package/dist/entries/interop.d.ts +9 -0
- package/dist/entries/scripting.d.ts +7 -0
- package/dist/index.d.ts +520 -19
- package/dist/paper-0c-spike/index.d.ts +29 -0
- package/dist/reconstruction/index.d.ts +78 -0
- package/dist/self-improvement/index.d.ts +0 -48
- package/dist/storage/index.d.ts +24 -0
- package/dist/tools/index.d.ts +33 -0
- package/dist/traitDocs/traitDocs.d.ts +69 -0
- package/dist/traits/index.d.ts +61 -0
- package/package.json +102 -19
- package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
- package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
- package/dist/HoloScriptPlusParser-BZR5DELQ.js +0 -692
- package/dist/HoloScriptPlusParser-SBMYDNXO.cjs +0 -697
- package/dist/USDZExporter-MHEHXZB4.cjs +0 -709
- package/dist/USDZExporter-YA55ZS35.js +0 -707
- package/dist/chunk-26TLYBFD.js +0 -309
- package/dist/chunk-27LWW5FU.cjs +0 -410
- package/dist/chunk-2UX5LRAP.cjs +0 -833
- package/dist/chunk-32TWR3HE.js +0 -70
- package/dist/chunk-3FXV5S25.cjs +0 -633
- package/dist/chunk-3FYZOR7S.cjs +0 -69
- package/dist/chunk-3KEU5QYY.cjs +0 -175
- package/dist/chunk-4FCZDTD5.js +0 -610
- package/dist/chunk-4KJ2R7VP.cjs +0 -507
- package/dist/chunk-4SMUJFHL.js +0 -1213
- package/dist/chunk-54FHG2MX.js +0 -655
- package/dist/chunk-56IF4NTA.js +0 -56
- package/dist/chunk-5GLCTO44.js +0 -161
- package/dist/chunk-5TOFIR6L.js +0 -407
- package/dist/chunk-65RFOWZI.js +0 -765
- package/dist/chunk-6OQBLABR.js +0 -5240
- package/dist/chunk-6WNCRE6F.js +0 -126
- package/dist/chunk-74YCHHTE.js +0 -1872
- package/dist/chunk-7H5UNJZD.cjs +0 -1973
- package/dist/chunk-7KPI4EKH.cjs +0 -701
- package/dist/chunk-7LCYLPW2.cjs +0 -663
- package/dist/chunk-7N3JIJMT.js +0 -1395
- package/dist/chunk-7X2IEJIE.cjs +0 -2526
- package/dist/chunk-A6GO3DPZ.cjs +0 -1002
- package/dist/chunk-AC4BSHFV.js +0 -765
- package/dist/chunk-AIUXRS74.cjs +0 -3681
- package/dist/chunk-ARNKA274.cjs +0 -130
- package/dist/chunk-AW7WAELW.js +0 -975
- package/dist/chunk-BKIGPPVM.js +0 -629
- package/dist/chunk-BO2OKHIY.js +0 -6055
- package/dist/chunk-BU5ZAFMC.js +0 -115
- package/dist/chunk-BY3B7ZYV.cjs +0 -457
- package/dist/chunk-C2QHVHZF.js +0 -4066
- package/dist/chunk-C7BNX4XJ.js +0 -1043
- package/dist/chunk-CLYEIWA5.cjs +0 -408
- package/dist/chunk-CMYAWUX3.js +0 -4455
- package/dist/chunk-CN4NOESF.cjs +0 -416
- package/dist/chunk-CNVM7J3M.js +0 -883
- package/dist/chunk-CO2VM2DK.js +0 -1965
- package/dist/chunk-CQDOF3G7.cjs +0 -1404
- package/dist/chunk-DH5G2JUA.cjs +0 -614
- package/dist/chunk-DIEDKX5B.cjs +0 -660
- package/dist/chunk-DN7UFU63.cjs +0 -172
- package/dist/chunk-DXVCEFZB.js +0 -2027
- package/dist/chunk-EGIZHYJP.cjs +0 -85
- package/dist/chunk-EJA7G2C4.cjs +0 -428
- package/dist/chunk-ELLQPFAF.js +0 -830
- package/dist/chunk-EMO7HAKJ.cjs +0 -1875
- package/dist/chunk-ENV7K6XA.js +0 -282
- package/dist/chunk-EPWRXL6S.js +0 -2522
- package/dist/chunk-EUFLX2PI.js +0 -56956
- package/dist/chunk-F5LVGHNT.js +0 -449
- package/dist/chunk-FEFHPUEM.cjs +0 -6122
- package/dist/chunk-FF3Q7ADR.js +0 -380
- package/dist/chunk-GC3YU46J.js +0 -762
- package/dist/chunk-H6WMMLQK.cjs +0 -4492
- package/dist/chunk-H7XMORZI.js +0 -2731
- package/dist/chunk-HAN4V3PF.cjs +0 -2037
- package/dist/chunk-HBZYCASG.js +0 -4208
- package/dist/chunk-HF4OFY25.cjs +0 -4097
- package/dist/chunk-HHS6FMOU.cjs +0 -3813
- package/dist/chunk-HJJLD366.js +0 -1169
- package/dist/chunk-HKCVM6OK.cjs +0 -2237
- package/dist/chunk-HUFNKFA6.js +0 -698
- package/dist/chunk-I3XGTIHM.cjs +0 -1505
- package/dist/chunk-I6XZ5DZF.cjs +0 -488
- package/dist/chunk-IHOUYQIA.js +0 -406
- package/dist/chunk-ILRBGFVD.cjs +0 -72
- package/dist/chunk-KDB6BUMB.js +0 -3666
- package/dist/chunk-KUJRR4FJ.js +0 -657
- package/dist/chunk-KYM4XRFG.js +0 -421
- package/dist/chunk-L3Z2HIWJ.cjs +0 -793
- package/dist/chunk-LBPEZQAF.js +0 -2232
- package/dist/chunk-LER4WXW5.cjs +0 -286
- package/dist/chunk-LK5IAVH6.cjs +0 -1173
- package/dist/chunk-M6FU6S22.js +0 -2911
- package/dist/chunk-MWEFR6YQ.js +0 -1857
- package/dist/chunk-N5FTS757.cjs +0 -415
- package/dist/chunk-NCUHGRTZ.js +0 -752
- package/dist/chunk-NKRKT6V2.js +0 -69
- package/dist/chunk-NLPSZT4C.js +0 -630
- package/dist/chunk-NRUB55IT.cjs +0 -771
- package/dist/chunk-NTMZSDXM.cjs +0 -633
- package/dist/chunk-ODGMVILH.js +0 -9662
- package/dist/chunk-PBA6NXCT.cjs +0 -1216
- package/dist/chunk-PHENW4MQ.js +0 -65
- package/dist/chunk-PJMOXFPR.cjs +0 -1861
- package/dist/chunk-PLMYCCA4.js +0 -504
- package/dist/chunk-PPULB4GG.cjs +0 -9728
- package/dist/chunk-PQLGZKMC.cjs +0 -755
- package/dist/chunk-Q56TT7IL.js +0 -483
- package/dist/chunk-QHVVVN47.cjs +0 -2033
- package/dist/chunk-QWKUKVRE.js +0 -2026
- package/dist/chunk-RE3OKSYF.cjs +0 -424
- package/dist/chunk-RT7LJRSF.cjs +0 -57378
- package/dist/chunk-SPDELRRV.cjs +0 -319
- package/dist/chunk-SUCBB66F.js +0 -229
- package/dist/chunk-TSWTWZ42.cjs +0 -4214
- package/dist/chunk-UITWA6DV.cjs +0 -2829
- package/dist/chunk-UQW6SLM5.js +0 -172
- package/dist/chunk-V2ILLPHK.cjs +0 -237
- package/dist/chunk-V42NTCFH.js +0 -3645
- package/dist/chunk-VJ3L7CHT.cjs +0 -169
- package/dist/chunk-VJVCD5T5.cjs +0 -769
- package/dist/chunk-VK5AXKO3.js +0 -746
- package/dist/chunk-VSXOIUCF.cjs +0 -473
- package/dist/chunk-VZNKJZTT.cjs +0 -749
- package/dist/chunk-W76ETJTI.js +0 -678
- package/dist/chunk-WFJIDI2N.cjs +0 -424
- package/dist/chunk-WN3YF33G.cjs +0 -118
- package/dist/chunk-WUXIRGZP.cjs +0 -2915
- package/dist/chunk-WYH4GVZ5.js +0 -1488
- package/dist/chunk-X4YVN7H3.cjs +0 -888
- package/dist/chunk-X67XRI2T.js +0 -410
- package/dist/chunk-XDXZM3ZP.cjs +0 -1046
- package/dist/chunk-XH7SE4HH.cjs +0 -72
- package/dist/chunk-XNMEH2BI.js +0 -126
- package/dist/chunk-XSF76QRU.js +0 -468
- package/dist/chunk-XSUZMPVQ.cjs +0 -682
- package/dist/chunk-XUILI4KB.cjs +0 -430
- package/dist/chunk-Y5MUAYTO.js +0 -167
- package/dist/chunk-Y7VK5TH3.cjs +0 -129
- package/dist/chunk-YCMQQQ5U.cjs +0 -5244
- package/dist/chunk-YYXH45E2.js +0 -426
- package/dist/chunk-ZGTGVSTZ.js +0 -422
- package/dist/chunk-ZL6VJ6SN.js +0 -421
- package/dist/cli/holoscript-runner.cjs +0 -2258
- package/dist/cli/holoscript-runner.js +0 -2233
- package/dist/codebase/index.cjs +0 -336
- package/dist/codebase/index.js +0 -331
- package/dist/compiler/agent-inference.cjs +0 -29
- package/dist/compiler/agent-inference.js +0 -6
- package/dist/compiler/android-xr.cjs +0 -20
- package/dist/compiler/android-xr.js +0 -10
- package/dist/compiler/android.cjs +0 -21
- package/dist/compiler/android.js +0 -11
- package/dist/compiler/ar.cjs +0 -21
- package/dist/compiler/ar.js +0 -9
- package/dist/compiler/babylon.cjs +0 -18
- package/dist/compiler/babylon.js +0 -12
- package/dist/compiler/coco.cjs +0 -27
- package/dist/compiler/coco.js +0 -4
- package/dist/compiler/domain-block-utils.cjs +0 -595
- package/dist/compiler/domain-block-utils.js +0 -9
- package/dist/compiler/dtdl.cjs +0 -25
- package/dist/compiler/dtdl.js +0 -9
- package/dist/compiler/gltf-pipeline.cjs +0 -39
- package/dist/compiler/gltf-pipeline.js +0 -4
- package/dist/compiler/godot.cjs +0 -16
- package/dist/compiler/godot.js +0 -10
- package/dist/compiler/incremental.cjs +0 -30
- package/dist/compiler/incremental.js +0 -5
- package/dist/compiler/index.cjs +0 -1522
- package/dist/compiler/index.js +0 -1321
- package/dist/compiler/ios.cjs +0 -21
- package/dist/compiler/ios.js +0 -11
- package/dist/compiler/multi-layer.cjs +0 -27
- package/dist/compiler/multi-layer.js +0 -12
- package/dist/compiler/nodetoy.cjs +0 -23
- package/dist/compiler/nodetoy.js +0 -4
- package/dist/compiler/openxr.cjs +0 -16
- package/dist/compiler/openxr.js +0 -10
- package/dist/compiler/playcanvas.cjs +0 -17
- package/dist/compiler/playcanvas.js +0 -11
- package/dist/compiler/r3f.cjs +0 -35
- package/dist/compiler/r3f.js +0 -13
- 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 -22
- package/dist/compiler/sdf.js +0 -10
- package/dist/compiler/semantic-scene.cjs +0 -31
- package/dist/compiler/semantic-scene.js +0 -4
- package/dist/compiler/state.cjs +0 -18
- package/dist/compiler/state.js +0 -8
- package/dist/compiler/trait-composition.cjs +0 -27
- package/dist/compiler/trait-composition.js +0 -6
- package/dist/compiler/unity.cjs +0 -16
- package/dist/compiler/unity.js +0 -10
- package/dist/compiler/unreal.cjs +0 -20
- package/dist/compiler/unreal.js +0 -10
- package/dist/compiler/urdf.cjs +0 -46
- package/dist/compiler/urdf.js +0 -10
- package/dist/compiler/usd-physics.cjs +0 -24
- package/dist/compiler/usd-physics.js +0 -7
- package/dist/compiler/visionos.cjs +0 -16
- package/dist/compiler/visionos.js +0 -10
- package/dist/compiler/vrchat.cjs +0 -20
- package/dist/compiler/vrchat.js +0 -10
- package/dist/compiler/vrr.cjs +0 -22
- package/dist/compiler/vrr.js +0 -10
- package/dist/compiler/wasm.cjs +0 -34
- package/dist/compiler/wasm.js +0 -10
- package/dist/compiler/webgpu.cjs +0 -16
- package/dist/compiler/webgpu.js +0 -10
- 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 -67
- package/dist/entries/scripting.js +0 -10
- package/dist/index.cjs +0 -61703
- package/dist/index.js +0 -58652
- package/dist/math/vec3.cjs +0 -57
- package/dist/math/vec3.js +0 -4
- package/dist/parser.cjs +0 -26
- package/dist/parser.js +0 -9
- package/dist/playwright-7DTEQCBD.cjs +0 -98673
- package/dist/playwright-BIZXMLD2.js +0 -98660
- package/dist/post-quantum-JTTAAGO3.cjs +0 -6
- package/dist/post-quantum-RVPVDEPI.js +0 -4
- 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 -14331
- package/dist/traits/index.js +0 -12126
- package/dist/type-checker.cjs +0 -18
- package/dist/type-checker.js +0 -5
- package/dist/wot/index.cjs +0 -29
- package/dist/wot/index.js +0 -4
package/dist/chunk-ZL6VJ6SN.js
DELETED
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
import { init_CompilerBase, init_ANSNamespace, CompilerBase, ANSCapabilityPath } from './chunk-QWKUKVRE.js';
|
|
2
|
-
import { __export, __esm } from './chunk-32TWR3HE.js';
|
|
3
|
-
|
|
4
|
-
// src/compiler/DTDLCompiler.ts
|
|
5
|
-
var DTDLCompiler_exports = {};
|
|
6
|
-
__export(DTDLCompiler_exports, {
|
|
7
|
-
DTDLCompiler: () => DTDLCompiler,
|
|
8
|
-
DTDL_TRAIT_COMPONENTS: () => DTDL_TRAIT_COMPONENTS,
|
|
9
|
-
default: () => DTDLCompiler_default
|
|
10
|
-
});
|
|
11
|
-
var DTDLCompiler, DTDL_TRAIT_COMPONENTS, DTDLCompiler_default;
|
|
12
|
-
var init_DTDLCompiler = __esm({
|
|
13
|
-
"src/compiler/DTDLCompiler.ts"() {
|
|
14
|
-
init_CompilerBase();
|
|
15
|
-
init_ANSNamespace();
|
|
16
|
-
DTDLCompiler = class extends CompilerBase {
|
|
17
|
-
constructor(options = {}) {
|
|
18
|
-
super();
|
|
19
|
-
this.compilerName = "DTDLCompiler";
|
|
20
|
-
this.generatedInterfaces = [];
|
|
21
|
-
this.options = {
|
|
22
|
-
dtdlVersion: options.dtdlVersion ?? 3,
|
|
23
|
-
namespace: options.namespace || "dtmi:holoscript",
|
|
24
|
-
modelVersion: options.modelVersion ?? 1,
|
|
25
|
-
includeDescriptions: options.includeDescriptions ?? true,
|
|
26
|
-
includeTraitComponents: options.includeTraitComponents ?? true
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
getRequiredCapability() {
|
|
30
|
-
return ANSCapabilityPath.DTDL;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Get trait name from either string or { name: string } format
|
|
34
|
-
*/
|
|
35
|
-
getTraitName(trait) {
|
|
36
|
-
return typeof trait === "string" ? trait : trait.name;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Check if traits include a specific trait name
|
|
40
|
-
*/
|
|
41
|
-
hasTrait(traits, targetTrait) {
|
|
42
|
-
return traits?.some((t) => this.getTraitName(t) === targetTrait) ?? false;
|
|
43
|
-
}
|
|
44
|
-
compile(composition, agentToken, outputPath) {
|
|
45
|
-
this.validateCompilerAccess(agentToken, outputPath);
|
|
46
|
-
this.generatedInterfaces = [];
|
|
47
|
-
if (composition.templates) {
|
|
48
|
-
for (const template of composition.templates) {
|
|
49
|
-
this.generatedInterfaces.push(this.compileTemplate(template));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const mainInterface = this.compileComposition(composition);
|
|
53
|
-
this.generatedInterfaces.push(mainInterface);
|
|
54
|
-
if (composition.objects) {
|
|
55
|
-
for (const obj of composition.objects) {
|
|
56
|
-
if (this.objectNeedsInterface(obj)) {
|
|
57
|
-
this.generatedInterfaces.push(this.compileObject(obj));
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return JSON.stringify(this.generatedInterfaces, null, 2);
|
|
62
|
-
}
|
|
63
|
-
compileComposition(composition) {
|
|
64
|
-
const modelId = this.generateModelId(composition.name);
|
|
65
|
-
const contents = [];
|
|
66
|
-
if (composition.environment) {
|
|
67
|
-
contents.push(...this.compileEnvironmentProperties(composition.environment));
|
|
68
|
-
}
|
|
69
|
-
if (composition.state) {
|
|
70
|
-
contents.push(...this.compileStateProperties(composition.state));
|
|
71
|
-
}
|
|
72
|
-
if (composition.logic) {
|
|
73
|
-
contents.push(...this.compileLogicCommands(composition.logic));
|
|
74
|
-
}
|
|
75
|
-
if (composition.objects) {
|
|
76
|
-
for (const obj of composition.objects) {
|
|
77
|
-
contents.push(this.createObjectRelationship(obj));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (composition.spatialGroups) {
|
|
81
|
-
for (const group of composition.spatialGroups) {
|
|
82
|
-
contents.push({
|
|
83
|
-
"@type": "Relationship",
|
|
84
|
-
name: this.sanitizeName(group.name),
|
|
85
|
-
displayName: group.name,
|
|
86
|
-
description: `Spatial group containing ${group.objects?.length || 0} objects`
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const iface = {
|
|
91
|
-
"@context": this.getDtdlContext(),
|
|
92
|
-
"@type": "Interface",
|
|
93
|
-
"@id": modelId,
|
|
94
|
-
displayName: composition.name,
|
|
95
|
-
contents
|
|
96
|
-
};
|
|
97
|
-
if (this.options.includeDescriptions) {
|
|
98
|
-
iface.description = `Generated from HoloScript composition "${this.escapeStringValue(composition.name, "TypeScript")}"`;
|
|
99
|
-
}
|
|
100
|
-
return iface;
|
|
101
|
-
}
|
|
102
|
-
compileTemplate(template) {
|
|
103
|
-
const modelId = this.generateModelId(template.name);
|
|
104
|
-
const contents = [];
|
|
105
|
-
if (template.state) {
|
|
106
|
-
contents.push(...this.compileStateProperties(template.state));
|
|
107
|
-
}
|
|
108
|
-
if (template.actions) {
|
|
109
|
-
for (const action of template.actions) {
|
|
110
|
-
contents.push({
|
|
111
|
-
"@type": "Command",
|
|
112
|
-
name: action.name,
|
|
113
|
-
displayName: action.name,
|
|
114
|
-
description: `Action defined in template ${this.escapeStringValue(template.name, "TypeScript")}`
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (template.traits && this.options.includeTraitComponents) {
|
|
119
|
-
for (const trait of template.traits) {
|
|
120
|
-
const traitName = typeof trait === "string" ? trait : trait.name;
|
|
121
|
-
const component = this.traitToComponent(traitName);
|
|
122
|
-
if (component) {
|
|
123
|
-
contents.push(component);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
const iface = {
|
|
128
|
-
"@context": this.getDtdlContext(),
|
|
129
|
-
"@type": "Interface",
|
|
130
|
-
"@id": modelId,
|
|
131
|
-
displayName: template.name,
|
|
132
|
-
contents
|
|
133
|
-
};
|
|
134
|
-
const templateExt = template;
|
|
135
|
-
if (templateExt.extends) {
|
|
136
|
-
iface.extends = [this.generateModelId(templateExt.extends)];
|
|
137
|
-
}
|
|
138
|
-
return iface;
|
|
139
|
-
}
|
|
140
|
-
compileObject(obj) {
|
|
141
|
-
const modelId = this.generateModelId(obj.name);
|
|
142
|
-
const contents = [];
|
|
143
|
-
const posProp = obj.properties.find((p) => p.key === "position");
|
|
144
|
-
if (posProp) {
|
|
145
|
-
contents.push({
|
|
146
|
-
"@type": ["Property", "Location"],
|
|
147
|
-
name: "position",
|
|
148
|
-
schema: {
|
|
149
|
-
"@type": "Object",
|
|
150
|
-
fields: [
|
|
151
|
-
{ name: "x", schema: "double" },
|
|
152
|
-
{ name: "y", schema: "double" },
|
|
153
|
-
{ name: "z", schema: "double" }
|
|
154
|
-
]
|
|
155
|
-
},
|
|
156
|
-
writable: true
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
for (const prop of obj.properties) {
|
|
160
|
-
if (prop.key !== "position" && prop.key !== "geometry") {
|
|
161
|
-
contents.push(this.propertyToContent(prop.key, prop.value));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
if (this.hasTrait(obj.traits, "sensor") || this.hasTrait(obj.traits, "observable")) {
|
|
165
|
-
contents.push({
|
|
166
|
-
"@type": "Telemetry",
|
|
167
|
-
name: "sensorReading",
|
|
168
|
-
schema: "double",
|
|
169
|
-
description: "Sensor telemetry data"
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
if (obj.traits && this.options.includeTraitComponents) {
|
|
173
|
-
for (const trait of obj.traits) {
|
|
174
|
-
const traitName = this.getTraitName(trait);
|
|
175
|
-
const component = this.traitToComponent(traitName);
|
|
176
|
-
if (component) {
|
|
177
|
-
contents.push(component);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
const iface = {
|
|
182
|
-
"@context": this.getDtdlContext(),
|
|
183
|
-
"@type": "Interface",
|
|
184
|
-
"@id": modelId,
|
|
185
|
-
displayName: obj.name,
|
|
186
|
-
contents
|
|
187
|
-
};
|
|
188
|
-
if (obj.template) {
|
|
189
|
-
iface.extends = this.generateModelId(obj.template);
|
|
190
|
-
}
|
|
191
|
-
return iface;
|
|
192
|
-
}
|
|
193
|
-
compileEnvironmentProperties(env) {
|
|
194
|
-
const props = [];
|
|
195
|
-
const envExt = env;
|
|
196
|
-
if (Array.isArray(envExt.properties)) {
|
|
197
|
-
for (const prop of envExt.properties) {
|
|
198
|
-
this.addEnvironmentProperty(props, prop.key, prop.value);
|
|
199
|
-
}
|
|
200
|
-
} else {
|
|
201
|
-
for (const key of Object.keys(envExt)) {
|
|
202
|
-
if (key !== "type") {
|
|
203
|
-
this.addEnvironmentProperty(props, key, envExt[key]);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return props;
|
|
208
|
-
}
|
|
209
|
-
addEnvironmentProperty(props, key, _value) {
|
|
210
|
-
if (key === "skybox") {
|
|
211
|
-
props.push({
|
|
212
|
-
"@type": "Property",
|
|
213
|
-
name: "skybox",
|
|
214
|
-
schema: "string",
|
|
215
|
-
displayName: "Skybox",
|
|
216
|
-
description: "Environment skybox setting"
|
|
217
|
-
});
|
|
218
|
-
} else if (key === "ambient_light") {
|
|
219
|
-
props.push({
|
|
220
|
-
"@type": "Property",
|
|
221
|
-
name: "ambientLight",
|
|
222
|
-
schema: "double",
|
|
223
|
-
displayName: "Ambient Light",
|
|
224
|
-
description: "Ambient light level"
|
|
225
|
-
});
|
|
226
|
-
} else if (key === "fog") {
|
|
227
|
-
props.push({
|
|
228
|
-
"@type": "Property",
|
|
229
|
-
name: "fogEnabled",
|
|
230
|
-
schema: "boolean",
|
|
231
|
-
displayName: "Fog Enabled"
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
compileStateProperties(state) {
|
|
236
|
-
const props = [];
|
|
237
|
-
for (const prop of state.properties) {
|
|
238
|
-
props.push(this.propertyToContent(prop.key, prop.value));
|
|
239
|
-
}
|
|
240
|
-
return props;
|
|
241
|
-
}
|
|
242
|
-
compileLogicCommands(logic) {
|
|
243
|
-
const commands = [];
|
|
244
|
-
const logicExt = logic;
|
|
245
|
-
const items = logicExt.handlers || logicExt.rules || [];
|
|
246
|
-
for (const item of items) {
|
|
247
|
-
const event = item.event;
|
|
248
|
-
if (event?.startsWith("on_")) {
|
|
249
|
-
commands.push({
|
|
250
|
-
"@type": "Command",
|
|
251
|
-
name: event.replace("on_", ""),
|
|
252
|
-
displayName: this.formatEventName(event),
|
|
253
|
-
description: `Event handler for ${event}`
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return commands;
|
|
258
|
-
}
|
|
259
|
-
propertyToContent(key, value) {
|
|
260
|
-
return {
|
|
261
|
-
"@type": "Property",
|
|
262
|
-
name: this.sanitizeName(key),
|
|
263
|
-
schema: this.inferSchema(value),
|
|
264
|
-
displayName: this.formatDisplayName(key),
|
|
265
|
-
writable: true
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
createObjectRelationship(obj) {
|
|
269
|
-
return {
|
|
270
|
-
"@type": "Relationship",
|
|
271
|
-
name: `has${this.pascalCase(obj.name)}`,
|
|
272
|
-
displayName: obj.name,
|
|
273
|
-
target: this.objectNeedsInterface(obj) ? this.generateModelId(obj.name) : void 0,
|
|
274
|
-
maxMultiplicity: 1
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
traitToComponent(trait) {
|
|
278
|
-
const traitComponents = {
|
|
279
|
-
grabbable: {
|
|
280
|
-
schema: `${this.options.namespace}:component:Grabbable;${this.options.modelVersion}`,
|
|
281
|
-
description: "Allows object to be grabbed/manipulated"
|
|
282
|
-
},
|
|
283
|
-
networked: {
|
|
284
|
-
schema: `${this.options.namespace}:component:Networked;${this.options.modelVersion}`,
|
|
285
|
-
description: "Enables network synchronization"
|
|
286
|
-
},
|
|
287
|
-
physics: {
|
|
288
|
-
schema: `${this.options.namespace}:component:Physics;${this.options.modelVersion}`,
|
|
289
|
-
description: "Enables physics simulation"
|
|
290
|
-
},
|
|
291
|
-
collidable: {
|
|
292
|
-
schema: `${this.options.namespace}:component:Collidable;${this.options.modelVersion}`,
|
|
293
|
-
description: "Enables collision detection"
|
|
294
|
-
},
|
|
295
|
-
sensor: {
|
|
296
|
-
schema: `${this.options.namespace}:component:Sensor;${this.options.modelVersion}`,
|
|
297
|
-
description: "IoT sensor capabilities"
|
|
298
|
-
},
|
|
299
|
-
observable: {
|
|
300
|
-
schema: `${this.options.namespace}:component:Observable;${this.options.modelVersion}`,
|
|
301
|
-
description: "State observation capabilities"
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
const config = traitComponents[trait];
|
|
305
|
-
if (!config) return null;
|
|
306
|
-
return {
|
|
307
|
-
"@type": "Component",
|
|
308
|
-
name: trait,
|
|
309
|
-
schema: config.schema,
|
|
310
|
-
description: config.description
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
inferSchema(value) {
|
|
314
|
-
if (typeof value === "boolean") return "boolean";
|
|
315
|
-
if (typeof value === "number") {
|
|
316
|
-
return Number.isInteger(value) ? "integer" : "double";
|
|
317
|
-
}
|
|
318
|
-
if (typeof value === "string") return "string";
|
|
319
|
-
if (Array.isArray(value)) {
|
|
320
|
-
if (value.length > 0) {
|
|
321
|
-
return {
|
|
322
|
-
"@type": "Array",
|
|
323
|
-
elementSchema: this.inferSchema(value[0])
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
return { "@type": "Array", elementSchema: "double" };
|
|
327
|
-
}
|
|
328
|
-
if (typeof value === "object" && value !== null) {
|
|
329
|
-
const fields = Object.entries(value).map(([k, v]) => ({
|
|
330
|
-
name: k,
|
|
331
|
-
schema: this.inferSchema(v)
|
|
332
|
-
}));
|
|
333
|
-
return { "@type": "Object", fields };
|
|
334
|
-
}
|
|
335
|
-
return "string";
|
|
336
|
-
}
|
|
337
|
-
getDtdlContext() {
|
|
338
|
-
return this.options.dtdlVersion === 3 ? "dtmi:dtdl:context;3" : "dtmi:dtdl:context;2";
|
|
339
|
-
}
|
|
340
|
-
generateModelId(name) {
|
|
341
|
-
const sanitized = this.sanitizeName(name);
|
|
342
|
-
return `${this.options.namespace}:${sanitized};${this.options.modelVersion}`;
|
|
343
|
-
}
|
|
344
|
-
objectNeedsInterface(obj) {
|
|
345
|
-
const hasState = obj.properties.some((p) => p.key === "state" || typeof p.value === "object");
|
|
346
|
-
const complexTraitList = ["networked", "sensor", "observable", "state"];
|
|
347
|
-
const hasComplexTraits = obj.traits?.some(
|
|
348
|
-
(t) => complexTraitList.includes(this.getTraitName(t))
|
|
349
|
-
);
|
|
350
|
-
return hasState || hasComplexTraits || false;
|
|
351
|
-
}
|
|
352
|
-
sanitizeName(name) {
|
|
353
|
-
return name.replace(/[^a-zA-Z0-9_]/g, "_").replace(/^_+|_+$/g, "").replace(/_+/g, "_");
|
|
354
|
-
}
|
|
355
|
-
formatDisplayName(name) {
|
|
356
|
-
return name.replace(/_/g, " ").replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()).trim();
|
|
357
|
-
}
|
|
358
|
-
formatEventName(event) {
|
|
359
|
-
return event.replace(/^on_/, "").replace(/_/g, " ").replace(/^./, (s) => s.toUpperCase());
|
|
360
|
-
}
|
|
361
|
-
pascalCase(name) {
|
|
362
|
-
return name.replace(/[^a-zA-Z0-9]/g, " ").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join("");
|
|
363
|
-
}
|
|
364
|
-
};
|
|
365
|
-
DTDL_TRAIT_COMPONENTS = [
|
|
366
|
-
{
|
|
367
|
-
"@context": "dtmi:dtdl:context;3",
|
|
368
|
-
"@type": "Interface",
|
|
369
|
-
"@id": "dtmi:holoscript:component:Grabbable;1",
|
|
370
|
-
displayName: "Grabbable",
|
|
371
|
-
description: "Component for objects that can be grabbed in VR/AR",
|
|
372
|
-
contents: [
|
|
373
|
-
{ "@type": "Property", name: "isGrabbed", schema: "boolean", writable: false },
|
|
374
|
-
{ "@type": "Property", name: "grabDistance", schema: "double", writable: true }
|
|
375
|
-
]
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
"@context": "dtmi:dtdl:context;3",
|
|
379
|
-
"@type": "Interface",
|
|
380
|
-
"@id": "dtmi:holoscript:component:Networked;1",
|
|
381
|
-
displayName: "Networked",
|
|
382
|
-
description: "Component for network-synchronized objects",
|
|
383
|
-
contents: [
|
|
384
|
-
{ "@type": "Property", name: "networkId", schema: "string", writable: false },
|
|
385
|
-
{ "@type": "Property", name: "syncRate", schema: "integer", writable: true },
|
|
386
|
-
{ "@type": "Property", name: "ownerId", schema: "string", writable: false }
|
|
387
|
-
]
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
"@context": "dtmi:dtdl:context;3",
|
|
391
|
-
"@type": "Interface",
|
|
392
|
-
"@id": "dtmi:holoscript:component:Physics;1",
|
|
393
|
-
displayName: "Physics",
|
|
394
|
-
description: "Component for physics-enabled objects",
|
|
395
|
-
contents: [
|
|
396
|
-
{ "@type": "Property", name: "mass", schema: "double", writable: true },
|
|
397
|
-
{ "@type": "Property", name: "friction", schema: "double", writable: true },
|
|
398
|
-
{ "@type": "Property", name: "restitution", schema: "double", writable: true },
|
|
399
|
-
{ "@type": "Property", name: "isKinematic", schema: "boolean", writable: true }
|
|
400
|
-
]
|
|
401
|
-
},
|
|
402
|
-
{
|
|
403
|
-
"@context": "dtmi:dtdl:context;3",
|
|
404
|
-
"@type": "Interface",
|
|
405
|
-
"@id": "dtmi:holoscript:component:Sensor;1",
|
|
406
|
-
displayName: "Sensor",
|
|
407
|
-
description: "Component for IoT sensor capabilities",
|
|
408
|
-
contents: [
|
|
409
|
-
{ "@type": "Property", name: "sensorType", schema: "string", writable: false },
|
|
410
|
-
{ "@type": "Telemetry", name: "value", schema: "double" },
|
|
411
|
-
{ "@type": "Telemetry", name: "timestamp", schema: "dateTime" }
|
|
412
|
-
]
|
|
413
|
-
}
|
|
414
|
-
];
|
|
415
|
-
DTDLCompiler_default = DTDLCompiler;
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
export { DTDLCompiler, DTDLCompiler_default, DTDLCompiler_exports, DTDL_TRAIT_COMPONENTS, init_DTDLCompiler };
|
|
420
|
-
//# sourceMappingURL=chunk-ZL6VJ6SN.js.map
|
|
421
|
-
//# sourceMappingURL=chunk-ZL6VJ6SN.js.map
|