@matter/model 0.16.0-alpha.0-20251018-dd1ea6a8a → 0.16.0-alpha.0-20251020-3f6e46245
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/dist/cjs/common/Metatype.d.ts +1 -1
- package/dist/cjs/decoration/decorators/attribute.d.ts +11 -0
- package/dist/cjs/decoration/decorators/attribute.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/attribute.js +32 -0
- package/dist/cjs/decoration/decorators/attribute.js.map +6 -0
- package/dist/cjs/decoration/decorators/cluster.d.ts +11 -0
- package/dist/cjs/decoration/decorators/cluster.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/cluster.js +32 -0
- package/dist/cjs/decoration/decorators/cluster.js.map +6 -0
- package/dist/cjs/decoration/decorators/command.d.ts +12 -0
- package/dist/cjs/decoration/decorators/command.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/command.js +34 -0
- package/dist/cjs/decoration/decorators/command.js.map +6 -0
- package/dist/cjs/decoration/decorators/datatype.d.ts +11 -0
- package/dist/cjs/decoration/decorators/datatype.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/datatype.js +32 -0
- package/dist/cjs/decoration/decorators/datatype.js.map +6 -0
- package/dist/cjs/decoration/decorators/element.d.ts +40 -0
- package/dist/cjs/decoration/decorators/element.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/element.js +101 -0
- package/dist/cjs/decoration/decorators/element.js.map +6 -0
- package/dist/cjs/decoration/decorators/event.d.ts +14 -0
- package/dist/cjs/decoration/decorators/event.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/event.js +32 -0
- package/dist/cjs/decoration/decorators/event.js.map +6 -0
- package/dist/cjs/decoration/decorators/field.d.ts +14 -0
- package/dist/cjs/decoration/decorators/field.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/field.js +32 -0
- package/dist/cjs/decoration/decorators/field.js.map +6 -0
- package/dist/cjs/decoration/decorators/index.d.ts +16 -0
- package/dist/cjs/decoration/decorators/index.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/index.js +33 -0
- package/dist/cjs/decoration/decorators/index.js.map +6 -0
- package/dist/cjs/decoration/decorators/listOf.d.ts +12 -0
- package/dist/cjs/decoration/decorators/listOf.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/listOf.js +47 -0
- package/dist/cjs/decoration/decorators/listOf.js.map +6 -0
- package/dist/cjs/decoration/decorators/mandatory.d.ts +11 -0
- package/dist/cjs/decoration/decorators/mandatory.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/mandatory.js +41 -0
- package/dist/cjs/decoration/decorators/mandatory.js.map +6 -0
- package/dist/cjs/decoration/decorators/nonvolatile.d.ts +11 -0
- package/dist/cjs/decoration/decorators/nonvolatile.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/nonvolatile.js +41 -0
- package/dist/cjs/decoration/decorators/nonvolatile.js.map +6 -0
- package/dist/cjs/decoration/decorators/nullable.d.ts +11 -0
- package/dist/cjs/decoration/decorators/nullable.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/nullable.js +41 -0
- package/dist/cjs/decoration/decorators/nullable.js.map +6 -0
- package/dist/cjs/decoration/decorators/response.d.ts +12 -0
- package/dist/cjs/decoration/decorators/response.d.ts.map +1 -0
- package/dist/cjs/decoration/decorators/response.js +49 -0
- package/dist/cjs/decoration/decorators/response.js.map +6 -0
- package/dist/cjs/decoration/errors.d.ts +29 -0
- package/dist/cjs/decoration/errors.d.ts.map +1 -0
- package/dist/cjs/decoration/errors.js +44 -0
- package/dist/cjs/decoration/errors.js.map +6 -0
- package/dist/cjs/decoration/index.d.ts +9 -0
- package/dist/cjs/decoration/index.d.ts.map +1 -0
- package/dist/cjs/decoration/index.js +26 -0
- package/dist/cjs/decoration/index.js.map +6 -0
- package/dist/cjs/decoration/semantics/ClassSemantics.d.ts +84 -0
- package/dist/cjs/decoration/semantics/ClassSemantics.d.ts.map +1 -0
- package/dist/cjs/decoration/semantics/ClassSemantics.js +266 -0
- package/dist/cjs/decoration/semantics/ClassSemantics.js.map +6 -0
- package/dist/cjs/decoration/semantics/FieldSemantics.d.ts +21 -0
- package/dist/cjs/decoration/semantics/FieldSemantics.d.ts.map +1 -0
- package/dist/cjs/decoration/semantics/FieldSemantics.js +57 -0
- package/dist/cjs/decoration/semantics/FieldSemantics.js.map +6 -0
- package/dist/cjs/decoration/semantics/Semantics.d.ts +68 -0
- package/dist/cjs/decoration/semantics/Semantics.d.ts.map +1 -0
- package/dist/cjs/decoration/semantics/Semantics.js +156 -0
- package/dist/cjs/decoration/semantics/Semantics.js.map +6 -0
- package/dist/cjs/decoration/semantics/index.d.ts +9 -0
- package/dist/cjs/decoration/semantics/index.d.ts.map +1 -0
- package/dist/cjs/decoration/semantics/index.js +26 -0
- package/dist/cjs/decoration/semantics/index.js.map +6 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/models/AttributeModel.d.ts +1 -0
- package/dist/cjs/models/AttributeModel.d.ts.map +1 -1
- package/dist/cjs/models/AttributeModel.js +1 -0
- package/dist/cjs/models/AttributeModel.js.map +1 -1
- package/dist/cjs/models/Children.js +3 -3
- package/dist/cjs/models/Children.js.map +1 -1
- package/dist/cjs/models/CommandModel.d.ts +1 -0
- package/dist/cjs/models/CommandModel.d.ts.map +1 -1
- package/dist/cjs/models/CommandModel.js +1 -0
- package/dist/cjs/models/CommandModel.js.map +1 -1
- package/dist/cjs/models/EventModel.d.ts +1 -0
- package/dist/cjs/models/EventModel.d.ts.map +1 -1
- package/dist/cjs/models/EventModel.js +1 -0
- package/dist/cjs/models/EventModel.js.map +1 -1
- package/dist/cjs/models/Globals.d.ts +1 -1
- package/dist/cjs/models/Model.d.ts +12 -3
- package/dist/cjs/models/Model.d.ts.map +1 -1
- package/dist/cjs/models/Model.js +16 -10
- package/dist/cjs/models/Model.js.map +1 -1
- package/dist/cjs/models/Schema.d.ts +14 -0
- package/dist/cjs/models/Schema.d.ts.map +1 -1
- package/dist/cjs/models/Schema.js +29 -1
- package/dist/cjs/models/Schema.js.map +1 -1
- package/dist/cjs/models/ScopeModel.d.ts +1 -1
- package/dist/cjs/models/ScopeModel.d.ts.map +1 -1
- package/dist/cjs/models/ScopeModel.js +2 -2
- package/dist/cjs/models/ScopeModel.js.map +1 -1
- package/dist/cjs/standard/elements/definitions.d.ts +1 -1
- package/dist/cjs/standard/elements/definitions.js +1 -1
- package/dist/cjs/standard/elements/{interval.element.d.ts → duration.element.d.ts} +1 -1
- package/dist/cjs/standard/elements/duration.element.d.ts.map +1 -0
- package/dist/cjs/standard/elements/{interval.element.js → duration.element.js} +4 -4
- package/dist/cjs/standard/elements/{interval.element.js.map → duration.element.js.map} +1 -1
- package/dist/cjs/standard/elements/models.d.ts +1 -1
- package/dist/cjs/standard/elements/models.js +2 -2
- package/dist/esm/common/Metatype.d.ts +1 -1
- package/dist/esm/decoration/decorators/attribute.d.ts +11 -0
- package/dist/esm/decoration/decorators/attribute.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/attribute.js +12 -0
- package/dist/esm/decoration/decorators/attribute.js.map +6 -0
- package/dist/esm/decoration/decorators/cluster.d.ts +11 -0
- package/dist/esm/decoration/decorators/cluster.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/cluster.js +12 -0
- package/dist/esm/decoration/decorators/cluster.js.map +6 -0
- package/dist/esm/decoration/decorators/command.d.ts +12 -0
- package/dist/esm/decoration/decorators/command.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/command.js +14 -0
- package/dist/esm/decoration/decorators/command.js.map +6 -0
- package/dist/esm/decoration/decorators/datatype.d.ts +11 -0
- package/dist/esm/decoration/decorators/datatype.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/datatype.js +12 -0
- package/dist/esm/decoration/decorators/datatype.js.map +6 -0
- package/dist/esm/decoration/decorators/element.d.ts +40 -0
- package/dist/esm/decoration/decorators/element.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/element.js +81 -0
- package/dist/esm/decoration/decorators/element.js.map +6 -0
- package/dist/esm/decoration/decorators/event.d.ts +14 -0
- package/dist/esm/decoration/decorators/event.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/event.js +12 -0
- package/dist/esm/decoration/decorators/event.js.map +6 -0
- package/dist/esm/decoration/decorators/field.d.ts +14 -0
- package/dist/esm/decoration/decorators/field.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/field.js +12 -0
- package/dist/esm/decoration/decorators/field.js.map +6 -0
- package/dist/esm/decoration/decorators/index.d.ts +16 -0
- package/dist/esm/decoration/decorators/index.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/index.js +16 -0
- package/dist/esm/decoration/decorators/index.js.map +6 -0
- package/dist/esm/decoration/decorators/listOf.d.ts +12 -0
- package/dist/esm/decoration/decorators/listOf.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/listOf.js +27 -0
- package/dist/esm/decoration/decorators/listOf.js.map +6 -0
- package/dist/esm/decoration/decorators/mandatory.d.ts +11 -0
- package/dist/esm/decoration/decorators/mandatory.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/mandatory.js +21 -0
- package/dist/esm/decoration/decorators/mandatory.js.map +6 -0
- package/dist/esm/decoration/decorators/nonvolatile.d.ts +11 -0
- package/dist/esm/decoration/decorators/nonvolatile.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/nonvolatile.js +21 -0
- package/dist/esm/decoration/decorators/nonvolatile.js.map +6 -0
- package/dist/esm/decoration/decorators/nullable.d.ts +11 -0
- package/dist/esm/decoration/decorators/nullable.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/nullable.js +21 -0
- package/dist/esm/decoration/decorators/nullable.js.map +6 -0
- package/dist/esm/decoration/decorators/response.d.ts +12 -0
- package/dist/esm/decoration/decorators/response.d.ts.map +1 -0
- package/dist/esm/decoration/decorators/response.js +29 -0
- package/dist/esm/decoration/decorators/response.js.map +6 -0
- package/dist/esm/decoration/errors.d.ts +29 -0
- package/dist/esm/decoration/errors.d.ts.map +1 -0
- package/dist/esm/decoration/errors.js +24 -0
- package/dist/esm/decoration/errors.js.map +6 -0
- package/dist/esm/decoration/index.d.ts +9 -0
- package/dist/esm/decoration/index.d.ts.map +1 -0
- package/dist/esm/decoration/index.js +9 -0
- package/dist/esm/decoration/index.js.map +6 -0
- package/dist/esm/decoration/semantics/ClassSemantics.d.ts +84 -0
- package/dist/esm/decoration/semantics/ClassSemantics.d.ts.map +1 -0
- package/dist/esm/decoration/semantics/ClassSemantics.js +246 -0
- package/dist/esm/decoration/semantics/ClassSemantics.js.map +6 -0
- package/dist/esm/decoration/semantics/FieldSemantics.d.ts +21 -0
- package/dist/esm/decoration/semantics/FieldSemantics.d.ts.map +1 -0
- package/dist/esm/decoration/semantics/FieldSemantics.js +37 -0
- package/dist/esm/decoration/semantics/FieldSemantics.js.map +6 -0
- package/dist/esm/decoration/semantics/Semantics.d.ts +68 -0
- package/dist/esm/decoration/semantics/Semantics.d.ts.map +1 -0
- package/dist/esm/decoration/semantics/Semantics.js +126 -0
- package/dist/esm/decoration/semantics/Semantics.js.map +6 -0
- package/dist/esm/decoration/semantics/index.d.ts +9 -0
- package/dist/esm/decoration/semantics/index.d.ts.map +1 -0
- package/dist/esm/decoration/semantics/index.js +9 -0
- package/dist/esm/decoration/semantics/index.js.map +6 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/models/AttributeModel.d.ts +1 -0
- package/dist/esm/models/AttributeModel.d.ts.map +1 -1
- package/dist/esm/models/AttributeModel.js +1 -0
- package/dist/esm/models/AttributeModel.js.map +1 -1
- package/dist/esm/models/Children.js +3 -3
- package/dist/esm/models/Children.js.map +1 -1
- package/dist/esm/models/CommandModel.d.ts +1 -0
- package/dist/esm/models/CommandModel.d.ts.map +1 -1
- package/dist/esm/models/CommandModel.js +1 -0
- package/dist/esm/models/CommandModel.js.map +1 -1
- package/dist/esm/models/EventModel.d.ts +1 -0
- package/dist/esm/models/EventModel.d.ts.map +1 -1
- package/dist/esm/models/EventModel.js +1 -0
- package/dist/esm/models/EventModel.js.map +1 -1
- package/dist/esm/models/Globals.d.ts +1 -1
- package/dist/esm/models/Model.d.ts +12 -3
- package/dist/esm/models/Model.d.ts.map +1 -1
- package/dist/esm/models/Model.js +16 -10
- package/dist/esm/models/Model.js.map +1 -1
- package/dist/esm/models/Schema.d.ts +14 -0
- package/dist/esm/models/Schema.d.ts.map +1 -1
- package/dist/esm/models/Schema.js +29 -1
- package/dist/esm/models/Schema.js.map +1 -1
- package/dist/esm/models/ScopeModel.d.ts +1 -1
- package/dist/esm/models/ScopeModel.d.ts.map +1 -1
- package/dist/esm/models/ScopeModel.js +2 -2
- package/dist/esm/models/ScopeModel.js.map +1 -1
- package/dist/esm/standard/elements/definitions.d.ts +1 -1
- package/dist/esm/standard/elements/definitions.js +1 -1
- package/dist/esm/standard/elements/{interval.element.d.ts → duration.element.d.ts} +1 -1
- package/dist/esm/standard/elements/duration.element.d.ts.map +1 -0
- package/dist/esm/standard/elements/{interval.element.js → duration.element.js} +1 -1
- package/dist/esm/standard/elements/{interval.element.js.map → duration.element.js.map} +1 -1
- package/dist/esm/standard/elements/models.d.ts +1 -1
- package/dist/esm/standard/elements/models.js +2 -2
- package/package.json +4 -4
- package/src/decoration/decorators/attribute.ts +13 -0
- package/src/decoration/decorators/cluster.ts +13 -0
- package/src/decoration/decorators/command.ts +16 -0
- package/src/decoration/decorators/datatype.ts +13 -0
- package/src/decoration/decorators/element.ts +128 -0
- package/src/decoration/decorators/event.ts +16 -0
- package/src/decoration/decorators/field.ts +16 -0
- package/src/decoration/decorators/index.ts +16 -0
- package/src/decoration/decorators/listOf.ts +30 -0
- package/src/decoration/decorators/mandatory.ts +22 -0
- package/src/decoration/decorators/nonvolatile.ts +22 -0
- package/src/decoration/decorators/nullable.ts +22 -0
- package/src/decoration/decorators/response.ts +34 -0
- package/src/decoration/errors.ts +29 -0
- package/src/decoration/index.ts +9 -0
- package/src/decoration/semantics/ClassSemantics.ts +374 -0
- package/src/decoration/semantics/FieldSemantics.ts +49 -0
- package/src/decoration/semantics/Semantics.ts +170 -0
- package/src/decoration/semantics/index.ts +9 -0
- package/src/index.ts +1 -0
- package/src/models/AttributeModel.ts +1 -0
- package/src/models/Children.ts +3 -3
- package/src/models/CommandModel.ts +1 -0
- package/src/models/EventModel.ts +1 -0
- package/src/models/Model.ts +34 -12
- package/src/models/Schema.ts +51 -0
- package/src/models/ScopeModel.ts +2 -2
- package/src/standard/elements/definitions.ts +1 -1
- package/src/standard/elements/models.ts +1 -1
- package/dist/cjs/standard/elements/interval.element.d.ts.map +0 -1
- package/dist/esm/standard/elements/interval.element.d.ts.map +0 -1
- /package/src/standard/elements/{interval.element.ts → duration.element.ts} +0 -0
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ClassSemantics_exports = {};
|
|
20
|
+
__export(ClassSemantics_exports, {
|
|
21
|
+
ClassSemantics: () => ClassSemantics
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ClassSemantics_exports);
|
|
24
|
+
var import_models = require("#models/index.js");
|
|
25
|
+
var import_general = require("#general");
|
|
26
|
+
var import_Scope = require("#logic/Scope.js");
|
|
27
|
+
var import_models2 = require("#standard/elements/models.js");
|
|
28
|
+
var import_errors = require("../errors.js");
|
|
29
|
+
var import_FieldSemantics = require("./FieldSemantics.js");
|
|
30
|
+
var import_Semantics = require("./Semantics.js");
|
|
31
|
+
/**
|
|
32
|
+
* @license
|
|
33
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
34
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
35
|
+
*/
|
|
36
|
+
const matter = Symbol("matter");
|
|
37
|
+
class ClassSemantics extends import_Semantics.Semantics {
|
|
38
|
+
#new;
|
|
39
|
+
#definedFields;
|
|
40
|
+
/**
|
|
41
|
+
* The model that represents the semantics for this class.
|
|
42
|
+
*
|
|
43
|
+
* This may be {@link localModel} or {@link prototypeBaseModel}
|
|
44
|
+
*/
|
|
45
|
+
get semanticModel() {
|
|
46
|
+
if (this.localModel) {
|
|
47
|
+
return this.localModel;
|
|
48
|
+
}
|
|
49
|
+
if (this.#definedFields) {
|
|
50
|
+
return this.mutableModel;
|
|
51
|
+
}
|
|
52
|
+
return this.prototypeBaseModel;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the class constructor
|
|
56
|
+
*/
|
|
57
|
+
get new() {
|
|
58
|
+
return this.#new;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Assign the constructor for the class.
|
|
62
|
+
*/
|
|
63
|
+
set new(fn) {
|
|
64
|
+
if (this.#new === fn) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (this.isFinal) {
|
|
68
|
+
throw new import_errors.MetadataConflictError(
|
|
69
|
+
`Cannot install semantic constructor ${fn.name} because semantics are final`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
this.#new = fn;
|
|
73
|
+
if (this.localModel && !this.localModel.isFinal && this.localModel.name !== this.#new?.name) {
|
|
74
|
+
this.localModel.name = this.#new?.name;
|
|
75
|
+
}
|
|
76
|
+
if (this.localModel) {
|
|
77
|
+
this.#applyBaseSemantics();
|
|
78
|
+
} else {
|
|
79
|
+
const base = this.prototypeBaseModel;
|
|
80
|
+
if (base !== void 0) {
|
|
81
|
+
this.mutableModel = base;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The class {@link Model} inherited from {@link new}'s prototype chain, if any.
|
|
87
|
+
*/
|
|
88
|
+
get prototypeBaseModel() {
|
|
89
|
+
let current = this.#new?.prototype;
|
|
90
|
+
let base;
|
|
91
|
+
while (current) {
|
|
92
|
+
current = Object.getPrototypeOf(current);
|
|
93
|
+
if (typeof current !== "object" || current === null) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const constructor = current.constructor;
|
|
97
|
+
if (constructor === Object) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
base = ClassSemantics.maybeOf(constructor);
|
|
101
|
+
if (base?.localModel) {
|
|
102
|
+
base.finalize();
|
|
103
|
+
return base.localModel;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Obtain a {@link FieldSemantics} for the named field.
|
|
109
|
+
*/
|
|
110
|
+
fieldFor(name) {
|
|
111
|
+
if (typeof name !== "string") {
|
|
112
|
+
throw new import_errors.InvalidMetadataError(`Cannot decorate symbolic function ${String(name)}`);
|
|
113
|
+
}
|
|
114
|
+
if (this.#definedFields === void 0) {
|
|
115
|
+
this.#definedFields = /* @__PURE__ */ new Map();
|
|
116
|
+
}
|
|
117
|
+
let field = this.#definedFields.get(name);
|
|
118
|
+
if (field === void 0) {
|
|
119
|
+
if (this.isFinal) {
|
|
120
|
+
throw new import_errors.MetadataConflictError(`Cannot install field ${name} because semantics are final`);
|
|
121
|
+
}
|
|
122
|
+
this.#definedFields.set(name, field = new import_FieldSemantics.FieldSemantics(this, name));
|
|
123
|
+
}
|
|
124
|
+
return field;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Add logical fields for unrecognized members of an object.
|
|
128
|
+
*
|
|
129
|
+
* This extends the model with untyped fields for properties that are not otherwise typed.
|
|
130
|
+
*/
|
|
131
|
+
defineUnknownMembers(instance) {
|
|
132
|
+
if (instance === void 0 || instance === null) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const known = this.semanticModel ? new Set(
|
|
136
|
+
(0, import_Scope.Scope)(this.semanticModel).membersOf(this.semanticModel).map((model) => (0, import_general.camelize)(model.name))
|
|
137
|
+
) : /* @__PURE__ */ new Set();
|
|
138
|
+
const descriptors = Object.getOwnPropertyDescriptors(instance);
|
|
139
|
+
for (const name in descriptors) {
|
|
140
|
+
if (known.has((0, import_general.camelize)(name))) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (typeof name !== "string") {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const descriptor = descriptors[name];
|
|
147
|
+
if (descriptor.set && !descriptor.get) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
if (typeof instance[name] === "function") {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
} catch (e) {
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const model = this.fieldFor(name).mutableModel;
|
|
158
|
+
model.operationalBase = import_models2.any;
|
|
159
|
+
if (!descriptor.writable && !descriptor.set) {
|
|
160
|
+
model.quality = { ...model.quality, fixed: true };
|
|
161
|
+
}
|
|
162
|
+
this.fieldFor(name).mutableModel.operationalBase = import_models2.any;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Obtain the {@link ClassSemantics} for {@link source}.
|
|
167
|
+
*/
|
|
168
|
+
static of(source) {
|
|
169
|
+
if (source instanceof ClassSemantics) {
|
|
170
|
+
return source;
|
|
171
|
+
}
|
|
172
|
+
if (typeof source !== "function") {
|
|
173
|
+
const metadata2 = source.metadata;
|
|
174
|
+
if (Object.hasOwn(metadata2, matter)) {
|
|
175
|
+
return metadata2[matter];
|
|
176
|
+
}
|
|
177
|
+
return metadata2[matter] = new ClassSemantics();
|
|
178
|
+
}
|
|
179
|
+
let metadata;
|
|
180
|
+
if (!Object.hasOwn(source, Symbol.metadata)) {
|
|
181
|
+
metadata = source[Symbol.metadata] = {};
|
|
182
|
+
} else {
|
|
183
|
+
metadata = source[Symbol.metadata];
|
|
184
|
+
}
|
|
185
|
+
let semantics;
|
|
186
|
+
if (!Object.hasOwn(metadata, matter)) {
|
|
187
|
+
semantics = metadata[matter] = new ClassSemantics();
|
|
188
|
+
} else {
|
|
189
|
+
semantics = metadata[matter];
|
|
190
|
+
}
|
|
191
|
+
if (!semantics.new) {
|
|
192
|
+
semantics.new = source;
|
|
193
|
+
}
|
|
194
|
+
return semantics;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Determine {@link new} has semantic decoration.
|
|
198
|
+
*/
|
|
199
|
+
static hasOwnSemantics(source) {
|
|
200
|
+
return Object.hasOwn(source, Symbol.metadata) && Object.hasOwn(source[Symbol.metadata], matter);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Access the {@link ClassSemantics} of {@link new} if it is defined.
|
|
204
|
+
*/
|
|
205
|
+
static maybeOf(source) {
|
|
206
|
+
if (this.hasOwnSemantics(source)) {
|
|
207
|
+
return ClassSemantics.of(source);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
static {
|
|
211
|
+
import_Semantics.Semantics.classOf = this.of;
|
|
212
|
+
}
|
|
213
|
+
finalize() {
|
|
214
|
+
if (this.isFinal) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
this.#new?.[ClassSemantics.extend]?.(this);
|
|
218
|
+
super.finalize();
|
|
219
|
+
if (this.#definedFields) {
|
|
220
|
+
for (const field of this.#definedFields.values()) {
|
|
221
|
+
field.finalize();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
#applyBaseSemantics() {
|
|
226
|
+
const base = this.prototypeBaseModel;
|
|
227
|
+
if (base === void 0) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const { type, base: currentBase } = this.mutableModel;
|
|
231
|
+
if (type === void 0 && (currentBase === void 0 || currentBase === import_models2.struct)) {
|
|
232
|
+
const operationalBase = this.prototypeBaseModel;
|
|
233
|
+
if (operationalBase) {
|
|
234
|
+
this.mutableModel.operationalBase = operationalBase;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (base && base.tag !== "datatype" && this.mutableModel.tag !== base.tag) {
|
|
238
|
+
this.modelType = base.constructor;
|
|
239
|
+
}
|
|
240
|
+
if (this.mutableModel.id === void 0 && base.id !== void 0) {
|
|
241
|
+
this.mutableModel.id = base.id;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
integrateModel(model) {
|
|
245
|
+
if (this.localModel === void 0 || this.localModel.isFinal) {
|
|
246
|
+
return model;
|
|
247
|
+
}
|
|
248
|
+
if (model.isFinal) {
|
|
249
|
+
this.localModel.operationalBase = model;
|
|
250
|
+
return this.localModel;
|
|
251
|
+
}
|
|
252
|
+
model.children.push(...this.localModel.children);
|
|
253
|
+
return model;
|
|
254
|
+
}
|
|
255
|
+
createModel(type = import_models.DatatypeModel) {
|
|
256
|
+
let name = this.#new?.name;
|
|
257
|
+
if (name === void 0 || name === "") {
|
|
258
|
+
name = "Unnamed";
|
|
259
|
+
}
|
|
260
|
+
return new type({ name, operationalBase: import_models2.struct });
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
((ClassSemantics2) => {
|
|
264
|
+
ClassSemantics2.extend = Symbol("extend");
|
|
265
|
+
})(ClassSemantics || (ClassSemantics = {}));
|
|
266
|
+
//# sourceMappingURL=ClassSemantics.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/decoration/semantics/ClassSemantics.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,oBAAiD;AAEjD,qBAAyB;AACzB,mBAAsB;AACtB,IAAAA,iBAA4B;AAC5B,oBAA4D;AAC5D,4BAA+B;AAC/B,uBAA0B;AAd1B;AAAA;AAAA;AAAA;AAAA;AAqBA,MAAM,SAAS,OAAO,QAAQ;AAyBvB,MAAM,uBAAuB,2BAAU;AAAA,EAC1C;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,gBAAgB;AAChB,QAAI,KAAK,YAAY;AAEjB,aAAO,KAAK;AAAA,IAChB;AAEA,QAAI,KAAK,gBAAgB;AAErB,aAAO,KAAK;AAAA,IAChB;AAGA,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,MAA8C;AAC9C,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,IAAI,IAAgC;AACpC,QAAI,KAAK,SAAS,IAAI;AAClB;AAAA,IACJ;AAEA,QAAI,KAAK,SAAS;AACd,YAAM,IAAI;AAAA,QACN,uCAAuC,GAAG,IAAI;AAAA,MAClD;AAAA,IACJ;AAEA,SAAK,OAAO;AAGZ,QAAI,KAAK,cAAc,CAAC,KAAK,WAAW,WAAW,KAAK,WAAW,SAAS,KAAK,MAAM,MAAM;AACzF,WAAK,WAAW,OAAO,KAAK,MAAM;AAAA,IACtC;AAGA,QAAI,KAAK,YAAY;AAEjB,WAAK,oBAAoB;AAAA,IAC7B,OAAO;AAEH,YAAM,OAA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,EACJ;AAAA,EAEmB,eAAe,OAAc;AAE5C,QAAI,KAAK,eAAe,UAAa,KAAK,WAAW,SAAS;AAC1D,aAAO;AAAA,IACX;AAIA,QAAI,MAAM,SAAS;AACf,WAAK,WAAW,kBAAkB;AAClC,aAAO,KAAK;AAAA,IAChB;AAIA,UAAM,SAAS,KAAK,GAAG,KAAK,WAAW,QAAQ;AAE/C,WAAO;AAAA,EACX;AAAA,EAEmB,YAAY,OAA2B,6BAAe;AACrE,QAAI,OAAO,KAAK,MAAM;AACtB,QAAI,SAAS,UAAa,SAAS,IAAI;AACnC,aAAO;AAAA,IACX;AACA,WAAO,IAAI,KAAK,EAAE,MAAM,iBAAiB,sBAAO,CAAC;AAAA,EACrD;AACJ;AAAA,CAEO,CAAUC,oBAAV;AAgBI,EAAMA,gBAAA,SAAS,OAAO,QAAQ;AAAA,GAhBxB;",
|
|
5
|
+
"names": ["import_models", "metadata", "ClassSemantics"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Model } from "#models/Model.js";
|
|
7
|
+
import type { ClassSemantics } from "./ClassSemantics.js";
|
|
8
|
+
import { Semantics } from "./Semantics.js";
|
|
9
|
+
/**
|
|
10
|
+
* Decorator metadata associated with a specific class field.
|
|
11
|
+
*/
|
|
12
|
+
export declare class FieldSemantics extends Semantics {
|
|
13
|
+
constructor(owner: ClassSemantics, name: string);
|
|
14
|
+
protected createModel(): Model;
|
|
15
|
+
protected integrateModel(model: Model): Model;
|
|
16
|
+
static of(source: FieldSemantics.Source): FieldSemantics;
|
|
17
|
+
}
|
|
18
|
+
export declare namespace FieldSemantics {
|
|
19
|
+
type Source = DecoratorContext;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=FieldSemantics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldSemantics.d.ts","sourceRoot":"","sources":["../../../../src/decoration/semantics/FieldSemantics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,qBAAa,cAAe,SAAQ,SAAS;gBAC7B,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM;cAM5B,WAAW,IAAI,KAAK;cAKpB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;WAQtC,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,MAAM;CAQnD;AAED,yBAAiB,cAAc,CAAC;IAC5B,KAAY,MAAM,GAAG,gBAAgB,CAAC;CACzC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var FieldSemantics_exports = {};
|
|
20
|
+
__export(FieldSemantics_exports, {
|
|
21
|
+
FieldSemantics: () => FieldSemantics
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(FieldSemantics_exports);
|
|
24
|
+
var import_errors = require("#decoration/errors.js");
|
|
25
|
+
var import_general = require("#general");
|
|
26
|
+
var import_FieldModel = require("#models/FieldModel.js");
|
|
27
|
+
var import_Semantics = require("./Semantics.js");
|
|
28
|
+
/**
|
|
29
|
+
* @license
|
|
30
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
31
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
32
|
+
*/
|
|
33
|
+
class FieldSemantics extends import_Semantics.Semantics {
|
|
34
|
+
constructor(owner, name) {
|
|
35
|
+
super();
|
|
36
|
+
this.mutableModel = new import_FieldModel.FieldModel({ name, parent: owner.mutableModel });
|
|
37
|
+
}
|
|
38
|
+
createModel() {
|
|
39
|
+
throw new import_general.InternalError("Unexpected FieldSemantics.createModel");
|
|
40
|
+
}
|
|
41
|
+
integrateModel(model) {
|
|
42
|
+
if (this.localModel === void 0) {
|
|
43
|
+
return model;
|
|
44
|
+
}
|
|
45
|
+
this.mutableModel.operationalBase = model;
|
|
46
|
+
return this.mutableModel;
|
|
47
|
+
}
|
|
48
|
+
static of(source) {
|
|
49
|
+
if (source.kind === "class") {
|
|
50
|
+
throw new import_errors.InvalidMetadataError(
|
|
51
|
+
`Cannot retrieve field semantics for class decorator ${source.name ?? "of anonymous class"}`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return import_Semantics.Semantics.classOf(source).fieldFor(source.name);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=FieldSemantics.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/decoration/semantics/FieldSemantics.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAAqC;AACrC,qBAA8B;AAC9B,wBAA2B;AAG3B,uBAA0B;AAX1B;AAAA;AAAA;AAAA;AAAA;AAgBO,MAAM,uBAAuB,2BAAU;AAAA,EAC1C,YAAY,OAAuB,MAAc;AAC7C,UAAM;AAEN,SAAK,eAAe,IAAI,6BAAW,EAAE,MAAM,QAAQ,MAAM,aAAa,CAAC;AAAA,EAC3E;AAAA,EAEmB,cAAqB;AAEpC,UAAM,IAAI,6BAAc,uCAAuC;AAAA,EACnE;AAAA,EAEmB,eAAe,OAAqB;AACnD,QAAI,KAAK,eAAe,QAAW;AAC/B,aAAO;AAAA,IACX;AACA,SAAK,aAAa,kBAAkB;AACpC,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,OAAgB,GAAG,QAA+B;AAC9C,QAAI,OAAO,SAAS,SAAS;AACzB,YAAM,IAAI;AAAA,QACN,uDAAuD,OAAO,QAAQ,oBAAoB;AAAA,MAC9F;AAAA,IACJ;AACA,WAAO,2BAAU,QAAQ,MAAM,EAAE,SAAS,OAAO,IAAI;AAAA,EACzD;AACJ;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Model } from "#models/Model.js";
|
|
7
|
+
import type { ClassSemantics } from "./ClassSemantics.js";
|
|
8
|
+
/**
|
|
9
|
+
* Base class for Matter semantics associated with JavaScript classes and properties.
|
|
10
|
+
*
|
|
11
|
+
* We model semantics using {@link Model}. The model may be built declaratively with decorators or programmatically
|
|
12
|
+
* using this interface directly.
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class Semantics {
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* Determine whether these semantics are final.
|
|
18
|
+
*
|
|
19
|
+
* Once final no further mutation is allowed.
|
|
20
|
+
*/
|
|
21
|
+
get isFinal(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Finalize the model.
|
|
24
|
+
*/
|
|
25
|
+
finalize(): void;
|
|
26
|
+
/**
|
|
27
|
+
* The {@link Model} defined by local decoration, if any.
|
|
28
|
+
*/
|
|
29
|
+
get localModel(): Model<import("../../index.js").BaseElement, Model<import("../../index.js").BaseElement, any>> | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Set the model.
|
|
32
|
+
*
|
|
33
|
+
* When "setting" the model we need to merge semantics coming from decorators, the prototype hierarchy, and models
|
|
34
|
+
* provided programmatically.
|
|
35
|
+
*
|
|
36
|
+
* This may set the local model, change it or set its operational base. We use local state and the finalization
|
|
37
|
+
* status of the model to determine how to integrate.
|
|
38
|
+
*/
|
|
39
|
+
set mutableModel(model: Model);
|
|
40
|
+
/**
|
|
41
|
+
* Replace the "base" of {@link localModel} and return an updated model.
|
|
42
|
+
*/
|
|
43
|
+
protected abstract integrateModel(model: Model): Model;
|
|
44
|
+
/**
|
|
45
|
+
* Obtain a model unconditionally for mutation purposes.
|
|
46
|
+
*/
|
|
47
|
+
get mutableModel(): Model;
|
|
48
|
+
/**
|
|
49
|
+
* The model's {@link Model.Type}.
|
|
50
|
+
*
|
|
51
|
+
* Field decorators operate prior to class decorators, so we may need to transition the model to a new type when the
|
|
52
|
+
* class is decorated. This is slightly lossy so type-specific decoration should always occur after assigning kind.
|
|
53
|
+
*/
|
|
54
|
+
get modelType(): Model.Type | undefined;
|
|
55
|
+
set modelType(type: Model.ConcreteType);
|
|
56
|
+
protected abstract createModel(type?: Model.ConcreteType): Model;
|
|
57
|
+
}
|
|
58
|
+
export declare namespace Semantics {
|
|
59
|
+
/**
|
|
60
|
+
* Access the {@link Semantics} of a {@link DecoratorContext}.
|
|
61
|
+
*/
|
|
62
|
+
function of(context: DecoratorContext): import("./FieldSemantics.js").FieldSemantics | ClassSemantics;
|
|
63
|
+
/**
|
|
64
|
+
* Access the {@link ClassSemantics} of a constructor or decorator context.
|
|
65
|
+
*/
|
|
66
|
+
let classOf: (_source: ClassSemantics.Source) => ClassSemantics;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=Semantics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Semantics.d.ts","sourceRoot":"","sources":["../../../../src/decoration/semantics/Semantics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAI1D;;;;;GAKG;AACH,8BAAsB,SAAS;;IAI3B;;;;OAIG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,QAAQ;IAUR;;OAEG;IACH,IAAI,UAAU,8GAEb;IAED;;;;;;;;OAQG;IACH,IAAI,YAAY,CAAC,KAAK,EAAE,KAAK,EAgB5B;IAED;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;IAEtD;;OAEG;IACH,IAAI,YAAY,IA1BQ,KAAK,CAqC5B;IAED;;;;;OAKG;IACH,IAAI,SAAS,IAAI,KAAK,CAAC,IAAI,GAAG,SAAS,CAKtC;IAED,IAAI,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,EA8BrC;IAED,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK;CACnE;AAED,yBAAiB,SAAS,CAAC;IACvB;;OAEG;IACH,SAAgB,EAAE,CAAC,OAAO,EAAE,gBAAgB,iEAM3C;IAED;;OAEG;IAEI,IAAI,OAAO,GAAI,SAAS,cAAc,CAAC,MAAM,KAAG,cAGtD,CAAC;CACL"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Semantics_exports = {};
|
|
30
|
+
__export(Semantics_exports, {
|
|
31
|
+
Semantics: () => Semantics
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(Semantics_exports);
|
|
34
|
+
var import_errors = require("#decoration/errors.js");
|
|
35
|
+
var import_general = require("#general");
|
|
36
|
+
var models = __toESM(require("#standard/elements/models.js"), 1);
|
|
37
|
+
/**
|
|
38
|
+
* @license
|
|
39
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
40
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
41
|
+
*/
|
|
42
|
+
const standardModels = new Set(Object.values(models));
|
|
43
|
+
class Semantics {
|
|
44
|
+
#localModel;
|
|
45
|
+
#isFinal = false;
|
|
46
|
+
/**
|
|
47
|
+
* Determine whether these semantics are final.
|
|
48
|
+
*
|
|
49
|
+
* Once final no further mutation is allowed.
|
|
50
|
+
*/
|
|
51
|
+
get isFinal() {
|
|
52
|
+
return this.#isFinal;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Finalize the model.
|
|
56
|
+
*/
|
|
57
|
+
finalize() {
|
|
58
|
+
if (this.#isFinal) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.#isFinal = true;
|
|
62
|
+
Object.freeze(this);
|
|
63
|
+
this.#localModel?.finalize();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The {@link Model} defined by local decoration, if any.
|
|
67
|
+
*/
|
|
68
|
+
get localModel() {
|
|
69
|
+
return this.#localModel;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Set the model.
|
|
73
|
+
*
|
|
74
|
+
* When "setting" the model we need to merge semantics coming from decorators, the prototype hierarchy, and models
|
|
75
|
+
* provided programmatically.
|
|
76
|
+
*
|
|
77
|
+
* This may set the local model, change it or set its operational base. We use local state and the finalization
|
|
78
|
+
* status of the model to determine how to integrate.
|
|
79
|
+
*/
|
|
80
|
+
set mutableModel(model) {
|
|
81
|
+
if (this.#isFinal) {
|
|
82
|
+
throw new import_errors.MetadataConflictError(`Cannot modify final semantics of ${this.#localModel?.name ?? "(none)"}`);
|
|
83
|
+
}
|
|
84
|
+
if (this.#localModel === model) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (standardModels.has(model)) {
|
|
88
|
+
model.finalize();
|
|
89
|
+
}
|
|
90
|
+
this.#localModel = this.integrateModel(model);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Obtain a model unconditionally for mutation purposes.
|
|
94
|
+
*/
|
|
95
|
+
get mutableModel() {
|
|
96
|
+
if (this.#isFinal) {
|
|
97
|
+
throw new import_errors.MetadataConflictError(`Cannot modify final semantics of ${this.#localModel?.name ?? "(none)"}`);
|
|
98
|
+
}
|
|
99
|
+
if (this.#localModel === void 0) {
|
|
100
|
+
this.#localModel = this.createModel();
|
|
101
|
+
} else if (this.#localModel.isFinal) {
|
|
102
|
+
this.#localModel = this.#localModel.extend();
|
|
103
|
+
}
|
|
104
|
+
return this.#localModel;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The model's {@link Model.Type}.
|
|
108
|
+
*
|
|
109
|
+
* Field decorators operate prior to class decorators, so we may need to transition the model to a new type when the
|
|
110
|
+
* class is decorated. This is slightly lossy so type-specific decoration should always occur after assigning kind.
|
|
111
|
+
*/
|
|
112
|
+
get modelType() {
|
|
113
|
+
if (this.#localModel === void 0) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
return this.mutableModel.constructor;
|
|
117
|
+
}
|
|
118
|
+
set modelType(type) {
|
|
119
|
+
if (this.#localModel === void 0) {
|
|
120
|
+
this.#localModel = this.createModel(type);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (this.#localModel instanceof type) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const original = this.#localModel;
|
|
127
|
+
const { parent } = original;
|
|
128
|
+
original.parent = void 0;
|
|
129
|
+
const replacement = new type({
|
|
130
|
+
name: original.name,
|
|
131
|
+
id: original.id,
|
|
132
|
+
type: original.type,
|
|
133
|
+
parent,
|
|
134
|
+
operationalBase: original.operationalBase,
|
|
135
|
+
children: original.children
|
|
136
|
+
});
|
|
137
|
+
if ("quality" in original && "quality" in replacement) {
|
|
138
|
+
replacement.quality = original.quality;
|
|
139
|
+
}
|
|
140
|
+
this.#localModel = replacement;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
((Semantics2) => {
|
|
144
|
+
function of(context) {
|
|
145
|
+
const classSemantics = (0, Semantics2.classOf)(context);
|
|
146
|
+
if (context.kind === "class") {
|
|
147
|
+
return classSemantics;
|
|
148
|
+
}
|
|
149
|
+
return classSemantics.fieldFor(context.name);
|
|
150
|
+
}
|
|
151
|
+
Semantics2.of = of;
|
|
152
|
+
Semantics2.classOf = (_source) => {
|
|
153
|
+
throw new import_general.InternalError(`Class decoration lookup not installed`);
|
|
154
|
+
};
|
|
155
|
+
})(Semantics || (Semantics = {}));
|
|
156
|
+
//# sourceMappingURL=Semantics.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/decoration/semantics/Semantics.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,oBAAsC;AACtC,qBAA8B;AAE9B,aAAwB;AATxB;AAAA;AAAA;AAAA;AAAA;AAYA,MAAM,iBAAiB,IAAI,IAAI,OAAO,OAAO,MAAM,CAAY;AAQxD,MAAe,UAAU;AAAA,EAC5B;AAAA,EACA,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOX,IAAI,UAAmB;AACnB,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW;AACP,QAAI,KAAK,UAAU;AACf;AAAA,IACJ;AAEA,SAAK,WAAW;AAChB,WAAO,OAAO,IAAI;AAClB,SAAK,aAAa,SAAS;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,aAAa;AACb,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,IAAI,aAAa,OAAc;AA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AAEA,SAAK,cAAc;AAAA,EACvB;AAGJ;AAAA,CAEO,CAAUA,eAAV;AAII,WAAS,GAAG,SAA2B;AAC1C,UAAM,qBAAiBA,WAAA,SAAQ,OAAO;AACtC,QAAI,QAAQ,SAAS,SAAS;AAC1B,aAAO;AAAA,IACX;AACA,WAAO,eAAe,SAAS,QAAQ,IAAI;AAAA,EAC/C;AANO,EAAAA,WAAS;AAYT,EAAIA,WAAA,UAAU,CAAC,YAAmD;AAErE,UAAM,IAAI,6BAAc,uCAAuC;AAAA,EACnE;AAAA,GAnBa;",
|
|
5
|
+
"names": ["Semantics"]
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/decoration/semantics/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var semantics_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(semantics_exports);
|
|
18
|
+
__reExport(semantics_exports, require("./ClassSemantics.js"), module.exports);
|
|
19
|
+
__reExport(semantics_exports, require("./FieldSemantics.js"), module.exports);
|
|
20
|
+
__reExport(semantics_exports, require("./Semantics.js"), module.exports);
|
|
21
|
+
/**
|
|
22
|
+
* @license
|
|
23
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
24
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
25
|
+
*/
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC"}
|