@vicin/sigil 2.1.0 → 2.2.1
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/CHANGELOG.md +11 -0
- package/README.md +56 -47
- package/dist/index.d.mts +40 -12
- package/dist/index.d.ts +40 -12
- package/dist/index.global.js +122 -70
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +122 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -9,25 +9,24 @@
|
|
|
9
9
|
var OPTIONS = {
|
|
10
10
|
labelValidation: null,
|
|
11
11
|
skipLabelInheritanceCheck: false,
|
|
12
|
-
autofillLabels:
|
|
12
|
+
autofillLabels: true
|
|
13
13
|
};
|
|
14
14
|
var updateSigilOptions = (opts) => {
|
|
15
|
-
if (opts
|
|
15
|
+
if ("autofillLabels" in opts) {
|
|
16
16
|
if (typeof opts.autofillLabels !== "boolean")
|
|
17
17
|
throw new Error("'updateSigilOptions.autofillLabels' must be boolean");
|
|
18
18
|
OPTIONS.autofillLabels = opts.autofillLabels;
|
|
19
19
|
}
|
|
20
|
-
if (opts
|
|
20
|
+
if ("skipLabelInheritanceCheck" in opts) {
|
|
21
21
|
if (typeof opts.skipLabelInheritanceCheck !== "boolean")
|
|
22
22
|
throw new Error("'updateSigilOptions.skipLabelInheritanceCheck' must be boolean");
|
|
23
23
|
OPTIONS.skipLabelInheritanceCheck = opts.skipLabelInheritanceCheck;
|
|
24
24
|
}
|
|
25
|
-
if (opts
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
OPTIONS.labelValidation = opts.labelValidation;
|
|
25
|
+
if ("labelValidation" in opts) {
|
|
26
|
+
const val = opts.labelValidation;
|
|
27
|
+
if (val !== null && typeof val !== "function" && !(val instanceof RegExp))
|
|
28
|
+
throw new Error("'updateSigilOptions.labelValidation' must be null, function or RegExp");
|
|
29
|
+
OPTIONS.labelValidation = val != null ? val : null;
|
|
31
30
|
}
|
|
32
31
|
};
|
|
33
32
|
var DEFAULT_LABEL_REGEX = /^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;
|
|
@@ -38,6 +37,7 @@
|
|
|
38
37
|
var __DECORATED__ = /* @__PURE__ */ Symbol.for("@Sigil.__DECORATED__");
|
|
39
38
|
var __INHERITANCE_CHECKED__ = /* @__PURE__ */ Symbol.for("@Sigil.__INHERITANCE_CHECKED__");
|
|
40
39
|
var __LABEL__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL__");
|
|
40
|
+
var __EFFECTIVE_LABEL__ = /* @__PURE__ */ Symbol.for("@Sigil.__EFFECTIVE_LABEL__");
|
|
41
41
|
var __LABEL_LINEAGE__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL_LINEAGE__");
|
|
42
42
|
var __LABEL_SET__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL_SET__");
|
|
43
43
|
|
|
@@ -1748,44 +1748,48 @@
|
|
|
1748
1748
|
};
|
|
1749
1749
|
}
|
|
1750
1750
|
|
|
1751
|
-
// src/core/constants.ts
|
|
1752
|
-
var __DEV__ = typeof process !== "undefined" && process.env.NODE_ENV === "development";
|
|
1753
|
-
|
|
1754
1751
|
// src/core/helpers.ts
|
|
1755
|
-
function decorateCtor(ctor, label,
|
|
1756
|
-
if (
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1752
|
+
function decorateCtor(ctor, label, runtime) {
|
|
1753
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1754
|
+
if (isDecorated(ctor))
|
|
1755
|
+
throw new Error(
|
|
1756
|
+
`Constructor ${ctor} is already decorated. if you are using 'withSigilTyped()' & '@WithSigil()' at the same time remove one of them.`
|
|
1757
|
+
);
|
|
1758
|
+
}
|
|
1760
1759
|
Object.defineProperty(ctor, __LABEL__, {
|
|
1761
1760
|
value: label,
|
|
1762
|
-
configurable:
|
|
1761
|
+
configurable: true,
|
|
1763
1762
|
enumerable: false,
|
|
1764
1763
|
writable: false
|
|
1765
1764
|
});
|
|
1765
|
+
if (!(runtime == null ? void 0 : runtime.isInheritanceCheck))
|
|
1766
|
+
Object.defineProperty(ctor, __EFFECTIVE_LABEL__, {
|
|
1767
|
+
value: label,
|
|
1768
|
+
configurable: true,
|
|
1769
|
+
enumerable: false,
|
|
1770
|
+
writable: false
|
|
1771
|
+
});
|
|
1766
1772
|
const parent = Object.getPrototypeOf(ctor);
|
|
1767
1773
|
const parentChain = parent && parent[__LABEL_LINEAGE__] ? parent[__LABEL_LINEAGE__] : [];
|
|
1768
|
-
const ctorChain = isMixin && label !== "Sigil" ? ["Sigil", ...parentChain, label] : [...parentChain, label];
|
|
1774
|
+
const ctorChain = (runtime == null ? void 0 : runtime.isMixin) && label !== "Sigil" ? ["Sigil", ...parentChain, label] : [...parentChain, label];
|
|
1769
1775
|
Object.defineProperty(ctor, __LABEL_LINEAGE__, {
|
|
1770
1776
|
value: ctorChain,
|
|
1771
|
-
configurable:
|
|
1777
|
+
configurable: true,
|
|
1772
1778
|
enumerable: false,
|
|
1773
1779
|
writable: false
|
|
1774
1780
|
});
|
|
1775
1781
|
Object.defineProperty(ctor, __LABEL_SET__, {
|
|
1776
1782
|
value: new Set(ctorChain),
|
|
1777
|
-
configurable:
|
|
1783
|
+
configurable: true,
|
|
1778
1784
|
enumerable: false,
|
|
1779
1785
|
writable: false
|
|
1780
1786
|
});
|
|
1781
|
-
markDecorated(ctor);
|
|
1787
|
+
if (!(runtime == null ? void 0 : runtime.isInheritanceCheck)) markDecorated(ctor);
|
|
1782
1788
|
}
|
|
1783
1789
|
function checkInheritance(ctor, opts) {
|
|
1784
1790
|
var _a, _b;
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
if (!isSigilCtor(ctor)) return;
|
|
1788
|
-
if (isInheritanceChecked(ctor) || skipLabelInheritanceCheck) return;
|
|
1791
|
+
if (isInheritanceChecked(ctor) || ((_a = opts == null ? void 0 : opts.skipLabelInheritanceCheck) != null ? _a : OPTIONS.skipLabelInheritanceCheck))
|
|
1792
|
+
return;
|
|
1789
1793
|
const ctors = [ctor];
|
|
1790
1794
|
let ancestor = Object.getPrototypeOf(ctor);
|
|
1791
1795
|
while (isSigilCtor(ancestor)) {
|
|
@@ -1796,16 +1800,16 @@
|
|
|
1796
1800
|
for (let i = ctors.length - 1; i >= 0; i--) {
|
|
1797
1801
|
const ctor2 = ctors[i];
|
|
1798
1802
|
if (!ctor2) continue;
|
|
1799
|
-
let label = ctor2
|
|
1803
|
+
let label = ctor2[__LABEL__];
|
|
1800
1804
|
if (labelOwner.has(label)) {
|
|
1801
|
-
if (
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1805
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1806
|
+
if (isDecorated(ctor2) || !((_b = opts == null ? void 0 : opts.autofillLabels) != null ? _b : OPTIONS.autofillLabels))
|
|
1807
|
+
throw new Error(
|
|
1808
|
+
`[Sigil Error] Class "${ctor2.name}" re-uses Sigil label "${label}" from ancestor "${labelOwner.get(label)}". Each Sigil subclass must use a unique label. Did you forget to use "WithSigil(newLabel)" on the subclass?`
|
|
1809
|
+
);
|
|
1806
1810
|
}
|
|
1807
1811
|
label = generateRandomLabel();
|
|
1808
|
-
decorateCtor(ctor2, label);
|
|
1812
|
+
decorateCtor(ctor2, label, { isInheritanceCheck: true });
|
|
1809
1813
|
}
|
|
1810
1814
|
labelOwner.set(label, ctor2.name);
|
|
1811
1815
|
}
|
|
@@ -1818,10 +1822,12 @@
|
|
|
1818
1822
|
let valid;
|
|
1819
1823
|
if (labelValidation instanceof RegExp) valid = labelValidation.test(label);
|
|
1820
1824
|
else valid = labelValidation(label);
|
|
1821
|
-
if (
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1826
|
+
if (!valid)
|
|
1827
|
+
throw new Error(
|
|
1828
|
+
`[Sigil] Invalid identity label "${label}". Make sure that supplied label matches validation regex or function.`
|
|
1829
|
+
);
|
|
1830
|
+
}
|
|
1825
1831
|
}
|
|
1826
1832
|
}
|
|
1827
1833
|
function generateRandomLabel() {
|
|
@@ -1890,7 +1896,7 @@
|
|
|
1890
1896
|
|
|
1891
1897
|
// src/core/mixin.ts
|
|
1892
1898
|
function Sigilify(Base, label, opts) {
|
|
1893
|
-
if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already
|
|
1899
|
+
if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already sigilified.`);
|
|
1894
1900
|
let l;
|
|
1895
1901
|
if (label) {
|
|
1896
1902
|
verifyLabel(label, opts);
|
|
@@ -1898,11 +1904,18 @@
|
|
|
1898
1904
|
} else l = generateRandomLabel();
|
|
1899
1905
|
class Sigilified extends Base {
|
|
1900
1906
|
/**
|
|
1901
|
-
* Class-level
|
|
1907
|
+
* Class-level identity label constant for this sigil constructor.
|
|
1902
1908
|
*/
|
|
1903
1909
|
static get SigilLabel() {
|
|
1910
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
1904
1911
|
return this[__LABEL__];
|
|
1905
1912
|
}
|
|
1913
|
+
/**
|
|
1914
|
+
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
1915
|
+
*/
|
|
1916
|
+
static get SigilEffectiveLabel() {
|
|
1917
|
+
return this[__EFFECTIVE_LABEL__];
|
|
1918
|
+
}
|
|
1906
1919
|
/**
|
|
1907
1920
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
1908
1921
|
*
|
|
@@ -1912,6 +1925,7 @@
|
|
|
1912
1925
|
*/
|
|
1913
1926
|
static get SigilLabelLineage() {
|
|
1914
1927
|
var _a;
|
|
1928
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
1915
1929
|
return [...(_a = this[__LABEL_LINEAGE__]) != null ? _a : []];
|
|
1916
1930
|
}
|
|
1917
1931
|
/**
|
|
@@ -1922,6 +1936,7 @@
|
|
|
1922
1936
|
* @returns A Readonly Set of labels that represent the type lineage.
|
|
1923
1937
|
*/
|
|
1924
1938
|
static get SigilLabelSet() {
|
|
1939
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
1925
1940
|
const set = /* @__PURE__ */ new Set();
|
|
1926
1941
|
for (const s of this[__LABEL_SET__]) set.add(s);
|
|
1927
1942
|
return set;
|
|
@@ -1932,11 +1947,11 @@
|
|
|
1932
1947
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
1933
1948
|
const ctor = getConstructor(this);
|
|
1934
1949
|
if (!ctor) {
|
|
1935
|
-
if (
|
|
1950
|
+
if (process.env.NODE_ENV !== "production")
|
|
1936
1951
|
throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
|
|
1937
1952
|
return;
|
|
1938
1953
|
}
|
|
1939
|
-
|
|
1954
|
+
checkInheritance(ctor);
|
|
1940
1955
|
}
|
|
1941
1956
|
/**
|
|
1942
1957
|
* Runtime predicate indicating whether `obj` is an instance produced by a sigil class.
|
|
@@ -2015,19 +2030,33 @@
|
|
|
2015
2030
|
return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
|
|
2016
2031
|
}
|
|
2017
2032
|
/**
|
|
2018
|
-
* Returns the
|
|
2033
|
+
* Returns the identity sigil label of this instance's constructor.
|
|
2019
2034
|
*
|
|
2020
|
-
* @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown'
|
|
2035
|
+
* @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil.auto-dq62ib6jnvmmlfbjhxh2937h') or '@Sigil.unknown' if constructor is missing.
|
|
2021
2036
|
*/
|
|
2022
2037
|
getSigilLabel() {
|
|
2023
2038
|
const ctor = getConstructor(this);
|
|
2024
2039
|
if (!ctor) {
|
|
2025
|
-
if (
|
|
2026
|
-
throw new Error(`[Sigil Error]
|
|
2040
|
+
if (process.env.NODE_ENV !== "production")
|
|
2041
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2027
2042
|
return "@Sigil.unknown";
|
|
2028
2043
|
}
|
|
2029
2044
|
return ctor.SigilLabel;
|
|
2030
2045
|
}
|
|
2046
|
+
/**
|
|
2047
|
+
* Returns the human-readable sigil label of this instance's constructor.
|
|
2048
|
+
*
|
|
2049
|
+
* @returns The last passed label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' if constructor is missing.
|
|
2050
|
+
*/
|
|
2051
|
+
getSigilEffectiveLabel() {
|
|
2052
|
+
const ctor = getConstructor(this);
|
|
2053
|
+
if (!ctor) {
|
|
2054
|
+
if (process.env.NODE_ENV !== "production")
|
|
2055
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2056
|
+
return "@Sigil.unknown";
|
|
2057
|
+
}
|
|
2058
|
+
return ctor.SigilEffectiveLabel;
|
|
2059
|
+
}
|
|
2031
2060
|
/**
|
|
2032
2061
|
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
2033
2062
|
*
|
|
@@ -2036,8 +2065,8 @@
|
|
|
2036
2065
|
getSigilLabelLineage() {
|
|
2037
2066
|
const ctor = getConstructor(this);
|
|
2038
2067
|
if (!ctor) {
|
|
2039
|
-
if (
|
|
2040
|
-
throw new Error(`[Sigil Error]
|
|
2068
|
+
if (process.env.NODE_ENV !== "production")
|
|
2069
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2041
2070
|
return ["@Sigil.unknown"];
|
|
2042
2071
|
}
|
|
2043
2072
|
return ctor.SigilLabelLineage;
|
|
@@ -2050,20 +2079,20 @@
|
|
|
2050
2079
|
getSigilLabelSet() {
|
|
2051
2080
|
const ctor = getConstructor(this);
|
|
2052
2081
|
if (!ctor) {
|
|
2053
|
-
if (
|
|
2054
|
-
throw new Error(`[Sigil Error]
|
|
2082
|
+
if (process.env.NODE_ENV !== "production")
|
|
2083
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2055
2084
|
return /* @__PURE__ */ new Set(["@Sigil.unknown"]);
|
|
2056
2085
|
}
|
|
2057
2086
|
return ctor.SigilLabelSet;
|
|
2058
2087
|
}
|
|
2059
2088
|
}
|
|
2060
|
-
decorateCtor(Sigilified, l, true);
|
|
2089
|
+
decorateCtor(Sigilified, l, { isMixin: true });
|
|
2061
2090
|
markSigil(Sigilified);
|
|
2062
2091
|
markSigilBase(Sigilified);
|
|
2063
2092
|
return Sigilified;
|
|
2064
2093
|
}
|
|
2065
2094
|
function SigilifyAbstract(Base, label, opts) {
|
|
2066
|
-
if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already
|
|
2095
|
+
if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already sigilified.`);
|
|
2067
2096
|
let l;
|
|
2068
2097
|
if (label) {
|
|
2069
2098
|
verifyLabel(label, opts);
|
|
@@ -2071,11 +2100,18 @@
|
|
|
2071
2100
|
} else l = generateRandomLabel();
|
|
2072
2101
|
class Sigilified extends Base {
|
|
2073
2102
|
/**
|
|
2074
|
-
* Class-level
|
|
2103
|
+
* Class-level identity label constant for this sigil constructor.
|
|
2075
2104
|
*/
|
|
2076
2105
|
static get SigilLabel() {
|
|
2106
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
2077
2107
|
return this[__LABEL__];
|
|
2078
2108
|
}
|
|
2109
|
+
/**
|
|
2110
|
+
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
2111
|
+
*/
|
|
2112
|
+
static get SigilEffectiveLabel() {
|
|
2113
|
+
return this[__EFFECTIVE_LABEL__];
|
|
2114
|
+
}
|
|
2079
2115
|
/**
|
|
2080
2116
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
2081
2117
|
*
|
|
@@ -2085,6 +2121,7 @@
|
|
|
2085
2121
|
*/
|
|
2086
2122
|
static get SigilLabelLineage() {
|
|
2087
2123
|
var _a;
|
|
2124
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
2088
2125
|
return [...(_a = this[__LABEL_LINEAGE__]) != null ? _a : []];
|
|
2089
2126
|
}
|
|
2090
2127
|
/**
|
|
@@ -2095,6 +2132,7 @@
|
|
|
2095
2132
|
* @returns A Readonly Set of labels that represent the type lineage.
|
|
2096
2133
|
*/
|
|
2097
2134
|
static get SigilLabelSet() {
|
|
2135
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
2098
2136
|
const set = /* @__PURE__ */ new Set();
|
|
2099
2137
|
for (const s of this[__LABEL_SET__]) set.add(s);
|
|
2100
2138
|
return set;
|
|
@@ -2105,11 +2143,11 @@
|
|
|
2105
2143
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
2106
2144
|
const ctor = getConstructor(this);
|
|
2107
2145
|
if (!ctor) {
|
|
2108
|
-
if (
|
|
2146
|
+
if (process.env.NODE_ENV !== "production")
|
|
2109
2147
|
throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
|
|
2110
2148
|
return;
|
|
2111
2149
|
}
|
|
2112
|
-
|
|
2150
|
+
checkInheritance(ctor);
|
|
2113
2151
|
}
|
|
2114
2152
|
/**
|
|
2115
2153
|
* Runtime predicate indicating whether `obj` is an instance produced by a sigil class.
|
|
@@ -2137,7 +2175,7 @@
|
|
|
2137
2175
|
*/
|
|
2138
2176
|
static isOfType(other) {
|
|
2139
2177
|
var _a;
|
|
2140
|
-
if (!isSigilInstance(other)
|
|
2178
|
+
if (!isSigilInstance(other)) return false;
|
|
2141
2179
|
const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
|
|
2142
2180
|
const thisType = this[__LABEL__];
|
|
2143
2181
|
return !!otherSet && otherSet.has(thisType);
|
|
@@ -2156,7 +2194,7 @@
|
|
|
2156
2194
|
*/
|
|
2157
2195
|
static isOfTypeStrict(other) {
|
|
2158
2196
|
var _a;
|
|
2159
|
-
if (!isSigilInstance(other)
|
|
2197
|
+
if (!isSigilInstance(other)) return false;
|
|
2160
2198
|
const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
|
|
2161
2199
|
const thisLineage = this[__LABEL_LINEAGE__];
|
|
2162
2200
|
return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
|
|
@@ -2173,7 +2211,7 @@
|
|
|
2173
2211
|
*/
|
|
2174
2212
|
isOfType(other) {
|
|
2175
2213
|
var _a;
|
|
2176
|
-
if (!isSigilInstance(other)
|
|
2214
|
+
if (!isSigilInstance(other)) return false;
|
|
2177
2215
|
const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
|
|
2178
2216
|
const thisType = getConstructor(this)[__LABEL__];
|
|
2179
2217
|
return !!otherSet && otherSet.has(thisType);
|
|
@@ -2190,25 +2228,39 @@
|
|
|
2190
2228
|
*/
|
|
2191
2229
|
isOfTypeStrict(other) {
|
|
2192
2230
|
var _a, _b;
|
|
2193
|
-
if (!isSigilInstance(other)
|
|
2231
|
+
if (!isSigilInstance(other)) return false;
|
|
2194
2232
|
const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
|
|
2195
2233
|
const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__LABEL_LINEAGE__];
|
|
2196
2234
|
return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
|
|
2197
2235
|
}
|
|
2198
2236
|
/**
|
|
2199
|
-
* Returns the
|
|
2237
|
+
* Returns the identity sigil label of this instance's constructor.
|
|
2200
2238
|
*
|
|
2201
|
-
* @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown'
|
|
2239
|
+
* @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil.auto-dq62ib6jnvmmlfbjhxh2937h') or '@Sigil.unknown' if constructor is missing.
|
|
2202
2240
|
*/
|
|
2203
2241
|
getSigilLabel() {
|
|
2204
2242
|
const ctor = getConstructor(this);
|
|
2205
2243
|
if (!ctor) {
|
|
2206
|
-
if (
|
|
2207
|
-
throw new Error(`[Sigil Error]
|
|
2244
|
+
if (process.env.NODE_ENV !== "production")
|
|
2245
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2208
2246
|
return "@Sigil.unknown";
|
|
2209
2247
|
}
|
|
2210
2248
|
return ctor.SigilLabel;
|
|
2211
2249
|
}
|
|
2250
|
+
/**
|
|
2251
|
+
* Returns the human-readable sigil label of this instance's constructor.
|
|
2252
|
+
*
|
|
2253
|
+
* @returns The last passed label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' if constructor is missing.
|
|
2254
|
+
*/
|
|
2255
|
+
getSigilEffectiveLabel() {
|
|
2256
|
+
const ctor = getConstructor(this);
|
|
2257
|
+
if (!ctor) {
|
|
2258
|
+
if (process.env.NODE_ENV !== "production")
|
|
2259
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2260
|
+
return "@Sigil.unknown";
|
|
2261
|
+
}
|
|
2262
|
+
return ctor.SigilEffectiveLabel;
|
|
2263
|
+
}
|
|
2212
2264
|
/**
|
|
2213
2265
|
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
2214
2266
|
*
|
|
@@ -2217,8 +2269,8 @@
|
|
|
2217
2269
|
getSigilLabelLineage() {
|
|
2218
2270
|
const ctor = getConstructor(this);
|
|
2219
2271
|
if (!ctor) {
|
|
2220
|
-
if (
|
|
2221
|
-
throw new Error(`[Sigil Error]
|
|
2272
|
+
if (process.env.NODE_ENV !== "production")
|
|
2273
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2222
2274
|
return ["@Sigil.unknown"];
|
|
2223
2275
|
}
|
|
2224
2276
|
return ctor.SigilLabelLineage;
|
|
@@ -2231,14 +2283,14 @@
|
|
|
2231
2283
|
getSigilLabelSet() {
|
|
2232
2284
|
const ctor = getConstructor(this);
|
|
2233
2285
|
if (!ctor) {
|
|
2234
|
-
if (
|
|
2235
|
-
throw new Error(`[Sigil Error]
|
|
2286
|
+
if (process.env.NODE_ENV !== "production")
|
|
2287
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2236
2288
|
return /* @__PURE__ */ new Set(["@Sigil.unknown"]);
|
|
2237
2289
|
}
|
|
2238
2290
|
return ctor.SigilLabelSet;
|
|
2239
2291
|
}
|
|
2240
2292
|
}
|
|
2241
|
-
decorateCtor(Sigilified, l, true);
|
|
2293
|
+
decorateCtor(Sigilified, l, { isMixin: true });
|
|
2242
2294
|
markSigil(Sigilified);
|
|
2243
2295
|
markSigilBase(Sigilified);
|
|
2244
2296
|
return Sigilified;
|
|
@@ -2263,7 +2315,7 @@
|
|
|
2263
2315
|
`[Sigil Error] 'WithSigil' decorator accept only Sigil classes but used on class ${value.name}`
|
|
2264
2316
|
);
|
|
2265
2317
|
decorateCtor(value, l);
|
|
2266
|
-
|
|
2318
|
+
checkInheritance(value, opts);
|
|
2267
2319
|
};
|
|
2268
2320
|
}
|
|
2269
2321
|
|
|
@@ -2281,7 +2333,7 @@
|
|
|
2281
2333
|
} else l = generateRandomLabel();
|
|
2282
2334
|
const ctor = Class;
|
|
2283
2335
|
decorateCtor(ctor, l);
|
|
2284
|
-
|
|
2336
|
+
checkInheritance(ctor, opts);
|
|
2285
2337
|
return Class;
|
|
2286
2338
|
}
|
|
2287
2339
|
function withSigilTyped(Class, label, opts) {
|
|
@@ -2297,7 +2349,7 @@
|
|
|
2297
2349
|
} else l = generateRandomLabel();
|
|
2298
2350
|
const ctor = Class;
|
|
2299
2351
|
decorateCtor(ctor, l);
|
|
2300
|
-
|
|
2352
|
+
checkInheritance(ctor, opts);
|
|
2301
2353
|
return Class;
|
|
2302
2354
|
}
|
|
2303
2355
|
/*! Bundled license information:
|