@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/chunk-IWI6J7FX.js
DELETED
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
import { init_CompilerBase, CompilerBase } from './chunk-6XSERL6L.js';
|
|
2
|
-
import { __export, __esm } from './chunk-2CWOLHTE.js';
|
|
3
|
-
import { ANSCapabilityPath } from '@holoscript/platform';
|
|
4
|
-
|
|
5
|
-
// src/compiler/DTDLCompiler.ts
|
|
6
|
-
var DTDLCompiler_exports = {};
|
|
7
|
-
__export(DTDLCompiler_exports, {
|
|
8
|
-
DTDLCompiler: () => DTDLCompiler,
|
|
9
|
-
DTDL_TRAIT_COMPONENTS: () => DTDL_TRAIT_COMPONENTS,
|
|
10
|
-
default: () => DTDLCompiler_default
|
|
11
|
-
});
|
|
12
|
-
var DTDLCompiler, DTDL_TRAIT_COMPONENTS, DTDLCompiler_default;
|
|
13
|
-
var init_DTDLCompiler = __esm({
|
|
14
|
-
"src/compiler/DTDLCompiler.ts"() {
|
|
15
|
-
init_CompilerBase();
|
|
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-IWI6J7FX.js.map
|
|
421
|
-
//# sourceMappingURL=chunk-IWI6J7FX.js.map
|
package/dist/chunk-K3JDKWGI.cjs
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunk3SAK5KFL_cjs = require('./chunk-3SAK5KFL.cjs');
|
|
4
|
-
|
|
5
|
-
// src/compiler/traits/Semiring.ts
|
|
6
|
-
function minPlusMul(a, b) {
|
|
7
|
-
return !Number.isFinite(a) || !Number.isFinite(b) ? Number.POSITIVE_INFINITY : a + b;
|
|
8
|
-
}
|
|
9
|
-
function maxPlusMul(a, b) {
|
|
10
|
-
return !Number.isFinite(a) || !Number.isFinite(b) ? Number.NEGATIVE_INFINITY : a + b;
|
|
11
|
-
}
|
|
12
|
-
function strategyToSemiring(strategy) {
|
|
13
|
-
switch (strategy) {
|
|
14
|
-
case "sum":
|
|
15
|
-
case "multiply":
|
|
16
|
-
return exports.SumProductSemiring;
|
|
17
|
-
case "tropical-min-plus":
|
|
18
|
-
return exports.MinPlusSemiring;
|
|
19
|
-
case "tropical-max-plus":
|
|
20
|
-
return exports.MaxPlusSemiring;
|
|
21
|
-
default:
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.MinPlusSemiring = void 0; exports.MaxPlusSemiring = void 0; exports.SumProductSemiring = void 0;
|
|
26
|
-
var init_Semiring = chunk3SAK5KFL_cjs.__esm({
|
|
27
|
-
"src/compiler/traits/Semiring.ts"() {
|
|
28
|
-
exports.MinPlusSemiring = {
|
|
29
|
-
zero: Number.POSITIVE_INFINITY,
|
|
30
|
-
one: 0,
|
|
31
|
-
add: (a, b) => Math.min(a, b),
|
|
32
|
-
mul: minPlusMul
|
|
33
|
-
};
|
|
34
|
-
exports.MaxPlusSemiring = {
|
|
35
|
-
zero: Number.NEGATIVE_INFINITY,
|
|
36
|
-
one: 0,
|
|
37
|
-
add: (a, b) => Math.max(a, b),
|
|
38
|
-
mul: maxPlusMul
|
|
39
|
-
};
|
|
40
|
-
exports.SumProductSemiring = {
|
|
41
|
-
zero: 0,
|
|
42
|
-
one: 1,
|
|
43
|
-
add: (a, b) => a + b,
|
|
44
|
-
mul: (a, b) => a * b
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// src/compiler/traits/ProvenanceSemiring.ts
|
|
50
|
-
function isDeadElement(value) {
|
|
51
|
-
return value === exports.TRAIT_ZERO;
|
|
52
|
-
}
|
|
53
|
-
function createDeadElement(subsystem, elementId, reason, originalValue) {
|
|
54
|
-
return {
|
|
55
|
-
subsystem,
|
|
56
|
-
reason,
|
|
57
|
-
determinedAt: Date.now(),
|
|
58
|
-
elementId,
|
|
59
|
-
originalValue
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function authorityWeight(level, reputationScore) {
|
|
63
|
-
const clamped = Math.max(0, Math.min(100, level));
|
|
64
|
-
let baseWeight = 0.5 + clamped / 100 * 1.5;
|
|
65
|
-
if (reputationScore !== void 0 && reputationScore > 0) {
|
|
66
|
-
if (reputationScore >= 100)
|
|
67
|
-
baseWeight *= 3;
|
|
68
|
-
else if (reputationScore >= 30)
|
|
69
|
-
baseWeight *= 2;
|
|
70
|
-
else if (reputationScore >= 5) baseWeight *= 1.5;
|
|
71
|
-
}
|
|
72
|
-
return baseWeight;
|
|
73
|
-
}
|
|
74
|
-
exports.TRAIT_ZERO = void 0; exports.AuthorityTier = void 0; exports.ProvenanceSemiring = void 0;
|
|
75
|
-
var init_ProvenanceSemiring = chunk3SAK5KFL_cjs.__esm({
|
|
76
|
-
"src/compiler/traits/ProvenanceSemiring.ts"() {
|
|
77
|
-
init_Semiring();
|
|
78
|
-
exports.TRAIT_ZERO = /* @__PURE__ */ Symbol.for("HoloScript::TraitZero");
|
|
79
|
-
exports.AuthorityTier = /* @__PURE__ */ ((AuthorityTier2) => {
|
|
80
|
-
AuthorityTier2[AuthorityTier2["GUEST"] = 0] = "GUEST";
|
|
81
|
-
AuthorityTier2[AuthorityTier2["AGENT"] = 25] = "AGENT";
|
|
82
|
-
AuthorityTier2[AuthorityTier2["MEMBER"] = 50] = "MEMBER";
|
|
83
|
-
AuthorityTier2[AuthorityTier2["ADMIN"] = 75] = "ADMIN";
|
|
84
|
-
AuthorityTier2[AuthorityTier2["FOUNDER"] = 100] = "FOUNDER";
|
|
85
|
-
return AuthorityTier2;
|
|
86
|
-
})(exports.AuthorityTier || {});
|
|
87
|
-
exports.ProvenanceSemiring = class {
|
|
88
|
-
constructor(rules) {
|
|
89
|
-
this.rules = /* @__PURE__ */ new Map();
|
|
90
|
-
if (rules) {
|
|
91
|
-
for (const rule of rules) {
|
|
92
|
-
this.rules.set(rule.property, rule);
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
this.loadDefaultRules();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
loadDefaultRules() {
|
|
99
|
-
this.rules.set("type", {
|
|
100
|
-
property: "type",
|
|
101
|
-
strategy: "domain-override",
|
|
102
|
-
precedence: ["kinematic", "physics", "collidable", "static"]
|
|
103
|
-
});
|
|
104
|
-
this.rules.set("mass", { property: "mass", strategy: "authority-weighted" });
|
|
105
|
-
this.rules.set("friction", { property: "friction", strategy: "max" });
|
|
106
|
-
this.rules.set("restitution", { property: "restitution", strategy: "min" });
|
|
107
|
-
this.rules.set("color", {
|
|
108
|
-
property: "color",
|
|
109
|
-
strategy: "domain-override",
|
|
110
|
-
precedence: ["material", "color", "hoverable", "glowing"]
|
|
111
|
-
});
|
|
112
|
-
this.rules.set("opacity", { property: "opacity", strategy: "min" });
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Commutative addition (⊕)
|
|
116
|
-
* Merges multiple traits into a unified provenanced configuration map.
|
|
117
|
-
*/
|
|
118
|
-
add(traits) {
|
|
119
|
-
const acc = {};
|
|
120
|
-
const conflicts = [];
|
|
121
|
-
const errors = [];
|
|
122
|
-
const deadElements = [];
|
|
123
|
-
for (const trait of traits) {
|
|
124
|
-
for (const [key, value] of Object.entries(trait.config)) {
|
|
125
|
-
if (value === exports.TRAIT_ZERO) {
|
|
126
|
-
deadElements.push(
|
|
127
|
-
createDeadElement(
|
|
128
|
-
"semiring",
|
|
129
|
-
`${trait.name}.${key}`,
|
|
130
|
-
`TRAIT_ZERO encountered during addition: property '${key}' from @${trait.name}`
|
|
131
|
-
)
|
|
132
|
-
);
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
if (!(key in acc)) {
|
|
136
|
-
acc[key] = { value, source: trait.name, context: trait.context };
|
|
137
|
-
} else {
|
|
138
|
-
const existing = acc[key];
|
|
139
|
-
try {
|
|
140
|
-
acc[key] = this.multiply(
|
|
141
|
-
existing,
|
|
142
|
-
{ value, source: trait.name, context: trait.context },
|
|
143
|
-
key
|
|
144
|
-
);
|
|
145
|
-
conflicts.push(
|
|
146
|
-
`Resolved conflict on property '${key}' between @${existing.source} and @${trait.name}`
|
|
147
|
-
);
|
|
148
|
-
} catch (err) {
|
|
149
|
-
errors.push(err instanceof Error ? err.message : String(err));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
const finalConfig = {};
|
|
155
|
-
for (const [k, v] of Object.entries(acc)) {
|
|
156
|
-
finalConfig[k] = v.value;
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
config: finalConfig,
|
|
160
|
-
provenance: acc,
|
|
161
|
-
conflicts,
|
|
162
|
-
errors,
|
|
163
|
-
deadElements
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Semiring multiplication (⊗)
|
|
168
|
-
* Resolves conflicts based on loaded domain rules, enforcing commutativity.
|
|
169
|
-
*
|
|
170
|
-
* C1 FIX: Authority no longer bypasses rules. Instead, authority modulates
|
|
171
|
-
* the weight within rule resolution. Higher authority = higher weight in
|
|
172
|
-
* numeric strategies, tiebreaker in domain-override. This ensures the
|
|
173
|
-
* algebraic structure is preserved — crossing an authority threshold
|
|
174
|
-
* changes the WEIGHT of a resolution, not the MECHANISM.
|
|
175
|
-
*/
|
|
176
|
-
multiply(a, b, property) {
|
|
177
|
-
if (a.value === exports.TRAIT_ZERO) return a;
|
|
178
|
-
if (b.value === exports.TRAIT_ZERO) return b;
|
|
179
|
-
if (a.value === b.value) return a;
|
|
180
|
-
const rule = this.rules.get(property);
|
|
181
|
-
if (!rule) {
|
|
182
|
-
const authA = a.context?.authorityLevel ?? 0;
|
|
183
|
-
const authB = b.context?.authorityLevel ?? 0;
|
|
184
|
-
if (authA !== authB) {
|
|
185
|
-
return authA > authB ? a : b;
|
|
186
|
-
}
|
|
187
|
-
throw new Error(
|
|
188
|
-
`Unresolved conflict on '${property}': @${a.source} (${a.value}) vs @${b.source} (${b.value})`
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
const weightA = authorityWeight(a.context?.authorityLevel ?? 0, a.context?.reputationScore);
|
|
192
|
-
const weightB = authorityWeight(b.context?.authorityLevel ?? 0, b.context?.reputationScore);
|
|
193
|
-
if (rule && (rule.strategy === "tropical-min-plus" || rule.strategy === "tropical-max-plus")) {
|
|
194
|
-
const semiring = strategyToSemiring(rule.strategy);
|
|
195
|
-
if (!semiring) {
|
|
196
|
-
throw new Error(`No semiring adapter available for strategy '${rule.strategy}'`);
|
|
197
|
-
}
|
|
198
|
-
return {
|
|
199
|
-
value: semiring.mul(a.value, b.value),
|
|
200
|
-
source: `${a.source}\u2297${b.source}`,
|
|
201
|
-
context: weightA >= weightB ? a.context : b.context
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
switch (rule.strategy) {
|
|
205
|
-
case "max":
|
|
206
|
-
return {
|
|
207
|
-
value: Math.max(a.value, b.value),
|
|
208
|
-
source: a.value > b.value ? a.source : b.source
|
|
209
|
-
};
|
|
210
|
-
case "min":
|
|
211
|
-
return {
|
|
212
|
-
value: Math.min(a.value, b.value),
|
|
213
|
-
source: a.value < b.value ? a.source : b.source
|
|
214
|
-
};
|
|
215
|
-
case "sum":
|
|
216
|
-
return {
|
|
217
|
-
value: a.value + b.value,
|
|
218
|
-
source: `${a.source}+${b.source}`
|
|
219
|
-
};
|
|
220
|
-
case "multiply":
|
|
221
|
-
return {
|
|
222
|
-
value: a.value * b.value,
|
|
223
|
-
source: `${a.source}*${b.source}`
|
|
224
|
-
};
|
|
225
|
-
case "authority-weighted": {
|
|
226
|
-
const scaledA = a.value * weightA;
|
|
227
|
-
const scaledB = b.value * weightB;
|
|
228
|
-
return scaledA >= scaledB ? { value: a.value, source: a.source, context: a.context } : { value: b.value, source: b.source, context: b.context };
|
|
229
|
-
}
|
|
230
|
-
case "domain-override": {
|
|
231
|
-
const precedence = rule.precedence || [];
|
|
232
|
-
const aIndex = precedence.indexOf(a.source);
|
|
233
|
-
const bIndex = precedence.indexOf(b.source);
|
|
234
|
-
if (aIndex !== -1 && bIndex !== -1) {
|
|
235
|
-
if (aIndex === bIndex) {
|
|
236
|
-
return weightA >= weightB ? a : b;
|
|
237
|
-
}
|
|
238
|
-
return aIndex < bIndex ? a : b;
|
|
239
|
-
} else if (aIndex !== -1) {
|
|
240
|
-
return a;
|
|
241
|
-
} else if (bIndex !== -1) {
|
|
242
|
-
return b;
|
|
243
|
-
} else {
|
|
244
|
-
if (weightA !== weightB) {
|
|
245
|
-
return weightA > weightB ? a : b;
|
|
246
|
-
}
|
|
247
|
-
throw new Error(
|
|
248
|
-
`Unresolved domain override on '${property}': @${a.source} vs @${b.source}`
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
case "strict-error":
|
|
253
|
-
default:
|
|
254
|
-
throw new Error(
|
|
255
|
-
`Composition conflict: @${a.source} and @${b.source} both supply '${property}' = ${a.value} vs ${b.value}`
|
|
256
|
-
);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
exports.authorityWeight = authorityWeight;
|
|
264
|
-
exports.createDeadElement = createDeadElement;
|
|
265
|
-
exports.init_ProvenanceSemiring = init_ProvenanceSemiring;
|
|
266
|
-
exports.init_Semiring = init_Semiring;
|
|
267
|
-
exports.isDeadElement = isDeadElement;
|
|
268
|
-
exports.strategyToSemiring = strategyToSemiring;
|
|
269
|
-
//# sourceMappingURL=chunk-K3JDKWGI.cjs.map
|
|
270
|
-
//# sourceMappingURL=chunk-K3JDKWGI.cjs.map
|