@vicin/sigil 2.0.3 → 2.2.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/CHANGELOG.md +21 -3
- package/README.md +61 -52
- package/dist/index.d.mts +45 -64
- package/dist/index.d.ts +45 -64
- package/dist/index.global.js +134 -72
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +134 -74
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +134 -74
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -9,17 +9,26 @@
|
|
|
9
9
|
var OPTIONS = {
|
|
10
10
|
labelValidation: null,
|
|
11
11
|
skipLabelInheritanceCheck: false,
|
|
12
|
-
autofillLabels:
|
|
12
|
+
autofillLabels: true
|
|
13
13
|
};
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
var updateSigilOptions = (opts) => {
|
|
15
|
+
if ("autofillLabels" in opts) {
|
|
16
|
+
if (typeof opts.autofillLabels !== "boolean")
|
|
17
|
+
throw new Error("'updateSigilOptions.autofillLabels' must be boolean");
|
|
18
|
+
OPTIONS.autofillLabels = opts.autofillLabels;
|
|
19
|
+
}
|
|
20
|
+
if ("skipLabelInheritanceCheck" in opts) {
|
|
21
|
+
if (typeof opts.skipLabelInheritanceCheck !== "boolean")
|
|
22
|
+
throw new Error("'updateSigilOptions.skipLabelInheritanceCheck' must be boolean");
|
|
23
|
+
OPTIONS.skipLabelInheritanceCheck = opts.skipLabelInheritanceCheck;
|
|
24
|
+
}
|
|
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;
|
|
30
|
+
}
|
|
21
31
|
};
|
|
22
|
-
updateOptions(DEFAULT_OPTIONS);
|
|
23
32
|
var DEFAULT_LABEL_REGEX = /^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;
|
|
24
33
|
|
|
25
34
|
// src/core/symbols.ts
|
|
@@ -28,6 +37,7 @@
|
|
|
28
37
|
var __DECORATED__ = /* @__PURE__ */ Symbol.for("@Sigil.__DECORATED__");
|
|
29
38
|
var __INHERITANCE_CHECKED__ = /* @__PURE__ */ Symbol.for("@Sigil.__INHERITANCE_CHECKED__");
|
|
30
39
|
var __LABEL__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL__");
|
|
40
|
+
var __EFFECTIVE_LABEL__ = /* @__PURE__ */ Symbol.for("@Sigil.__EFFECTIVE_LABEL__");
|
|
31
41
|
var __LABEL_LINEAGE__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL_LINEAGE__");
|
|
32
42
|
var __LABEL_SET__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL_SET__");
|
|
33
43
|
|
|
@@ -1738,44 +1748,48 @@
|
|
|
1738
1748
|
};
|
|
1739
1749
|
}
|
|
1740
1750
|
|
|
1741
|
-
// src/core/constants.ts
|
|
1742
|
-
var __DEV__ = typeof process !== "undefined" && process.env.NODE_ENV === "development";
|
|
1743
|
-
|
|
1744
1751
|
// src/core/helpers.ts
|
|
1745
|
-
function decorateCtor(ctor, label,
|
|
1746
|
-
if (
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
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
|
+
}
|
|
1750
1759
|
Object.defineProperty(ctor, __LABEL__, {
|
|
1751
1760
|
value: label,
|
|
1752
|
-
configurable:
|
|
1761
|
+
configurable: true,
|
|
1753
1762
|
enumerable: false,
|
|
1754
1763
|
writable: false
|
|
1755
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
|
+
});
|
|
1756
1772
|
const parent = Object.getPrototypeOf(ctor);
|
|
1757
1773
|
const parentChain = parent && parent[__LABEL_LINEAGE__] ? parent[__LABEL_LINEAGE__] : [];
|
|
1758
|
-
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];
|
|
1759
1775
|
Object.defineProperty(ctor, __LABEL_LINEAGE__, {
|
|
1760
1776
|
value: ctorChain,
|
|
1761
|
-
configurable:
|
|
1777
|
+
configurable: true,
|
|
1762
1778
|
enumerable: false,
|
|
1763
1779
|
writable: false
|
|
1764
1780
|
});
|
|
1765
1781
|
Object.defineProperty(ctor, __LABEL_SET__, {
|
|
1766
1782
|
value: new Set(ctorChain),
|
|
1767
|
-
configurable:
|
|
1783
|
+
configurable: true,
|
|
1768
1784
|
enumerable: false,
|
|
1769
1785
|
writable: false
|
|
1770
1786
|
});
|
|
1771
|
-
markDecorated(ctor);
|
|
1787
|
+
if (!(runtime == null ? void 0 : runtime.isInheritanceCheck)) markDecorated(ctor);
|
|
1772
1788
|
}
|
|
1773
1789
|
function checkInheritance(ctor, opts) {
|
|
1774
1790
|
var _a, _b;
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
if (!isSigilCtor(ctor)) return;
|
|
1778
|
-
if (isInheritanceChecked(ctor) || skipLabelInheritanceCheck) return;
|
|
1791
|
+
if (isInheritanceChecked(ctor) || ((_a = opts == null ? void 0 : opts.skipLabelInheritanceCheck) != null ? _a : OPTIONS.skipLabelInheritanceCheck))
|
|
1792
|
+
return;
|
|
1779
1793
|
const ctors = [ctor];
|
|
1780
1794
|
let ancestor = Object.getPrototypeOf(ctor);
|
|
1781
1795
|
while (isSigilCtor(ancestor)) {
|
|
@@ -1786,16 +1800,16 @@
|
|
|
1786
1800
|
for (let i = ctors.length - 1; i >= 0; i--) {
|
|
1787
1801
|
const ctor2 = ctors[i];
|
|
1788
1802
|
if (!ctor2) continue;
|
|
1789
|
-
let label = ctor2
|
|
1803
|
+
let label = ctor2[__LABEL__];
|
|
1790
1804
|
if (labelOwner.has(label)) {
|
|
1791
|
-
if (
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
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
|
+
);
|
|
1796
1810
|
}
|
|
1797
1811
|
label = generateRandomLabel();
|
|
1798
|
-
decorateCtor(ctor2, label);
|
|
1812
|
+
decorateCtor(ctor2, label, { isInheritanceCheck: true });
|
|
1799
1813
|
}
|
|
1800
1814
|
labelOwner.set(label, ctor2.name);
|
|
1801
1815
|
}
|
|
@@ -1808,10 +1822,12 @@
|
|
|
1808
1822
|
let valid;
|
|
1809
1823
|
if (labelValidation instanceof RegExp) valid = labelValidation.test(label);
|
|
1810
1824
|
else valid = labelValidation(label);
|
|
1811
|
-
if (
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
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
|
+
}
|
|
1815
1831
|
}
|
|
1816
1832
|
}
|
|
1817
1833
|
function generateRandomLabel() {
|
|
@@ -1880,7 +1896,7 @@
|
|
|
1880
1896
|
|
|
1881
1897
|
// src/core/mixin.ts
|
|
1882
1898
|
function Sigilify(Base, label, opts) {
|
|
1883
|
-
if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already
|
|
1899
|
+
if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already sigilified.`);
|
|
1884
1900
|
let l;
|
|
1885
1901
|
if (label) {
|
|
1886
1902
|
verifyLabel(label, opts);
|
|
@@ -1888,11 +1904,18 @@
|
|
|
1888
1904
|
} else l = generateRandomLabel();
|
|
1889
1905
|
class Sigilified extends Base {
|
|
1890
1906
|
/**
|
|
1891
|
-
* Class-level
|
|
1907
|
+
* Class-level identity label constant for this sigil constructor.
|
|
1892
1908
|
*/
|
|
1893
1909
|
static get SigilLabel() {
|
|
1910
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
1894
1911
|
return this[__LABEL__];
|
|
1895
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
|
+
}
|
|
1896
1919
|
/**
|
|
1897
1920
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
1898
1921
|
*
|
|
@@ -1902,6 +1925,7 @@
|
|
|
1902
1925
|
*/
|
|
1903
1926
|
static get SigilLabelLineage() {
|
|
1904
1927
|
var _a;
|
|
1928
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
1905
1929
|
return [...(_a = this[__LABEL_LINEAGE__]) != null ? _a : []];
|
|
1906
1930
|
}
|
|
1907
1931
|
/**
|
|
@@ -1912,6 +1936,7 @@
|
|
|
1912
1936
|
* @returns A Readonly Set of labels that represent the type lineage.
|
|
1913
1937
|
*/
|
|
1914
1938
|
static get SigilLabelSet() {
|
|
1939
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
1915
1940
|
const set = /* @__PURE__ */ new Set();
|
|
1916
1941
|
for (const s of this[__LABEL_SET__]) set.add(s);
|
|
1917
1942
|
return set;
|
|
@@ -1922,11 +1947,11 @@
|
|
|
1922
1947
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
1923
1948
|
const ctor = getConstructor(this);
|
|
1924
1949
|
if (!ctor) {
|
|
1925
|
-
if (
|
|
1950
|
+
if (process.env.NODE_ENV !== "production")
|
|
1926
1951
|
throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
|
|
1927
1952
|
return;
|
|
1928
1953
|
}
|
|
1929
|
-
|
|
1954
|
+
checkInheritance(ctor);
|
|
1930
1955
|
}
|
|
1931
1956
|
/**
|
|
1932
1957
|
* Runtime predicate indicating whether `obj` is an instance produced by a sigil class.
|
|
@@ -2005,19 +2030,33 @@
|
|
|
2005
2030
|
return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
|
|
2006
2031
|
}
|
|
2007
2032
|
/**
|
|
2008
|
-
* Returns the
|
|
2033
|
+
* Returns the identity sigil label of this instance's constructor.
|
|
2009
2034
|
*
|
|
2010
|
-
* @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.
|
|
2011
2036
|
*/
|
|
2012
2037
|
getSigilLabel() {
|
|
2013
2038
|
const ctor = getConstructor(this);
|
|
2014
2039
|
if (!ctor) {
|
|
2015
|
-
if (
|
|
2016
|
-
throw new Error(`[Sigil Error]
|
|
2040
|
+
if (process.env.NODE_ENV !== "production")
|
|
2041
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2017
2042
|
return "@Sigil.unknown";
|
|
2018
2043
|
}
|
|
2019
2044
|
return ctor.SigilLabel;
|
|
2020
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
|
+
}
|
|
2021
2060
|
/**
|
|
2022
2061
|
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
2023
2062
|
*
|
|
@@ -2026,8 +2065,8 @@
|
|
|
2026
2065
|
getSigilLabelLineage() {
|
|
2027
2066
|
const ctor = getConstructor(this);
|
|
2028
2067
|
if (!ctor) {
|
|
2029
|
-
if (
|
|
2030
|
-
throw new Error(`[Sigil Error]
|
|
2068
|
+
if (process.env.NODE_ENV !== "production")
|
|
2069
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2031
2070
|
return ["@Sigil.unknown"];
|
|
2032
2071
|
}
|
|
2033
2072
|
return ctor.SigilLabelLineage;
|
|
@@ -2040,20 +2079,20 @@
|
|
|
2040
2079
|
getSigilLabelSet() {
|
|
2041
2080
|
const ctor = getConstructor(this);
|
|
2042
2081
|
if (!ctor) {
|
|
2043
|
-
if (
|
|
2044
|
-
throw new Error(`[Sigil Error]
|
|
2082
|
+
if (process.env.NODE_ENV !== "production")
|
|
2083
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2045
2084
|
return /* @__PURE__ */ new Set(["@Sigil.unknown"]);
|
|
2046
2085
|
}
|
|
2047
2086
|
return ctor.SigilLabelSet;
|
|
2048
2087
|
}
|
|
2049
2088
|
}
|
|
2050
|
-
decorateCtor(Sigilified, l, true);
|
|
2089
|
+
decorateCtor(Sigilified, l, { isMixin: true });
|
|
2051
2090
|
markSigil(Sigilified);
|
|
2052
2091
|
markSigilBase(Sigilified);
|
|
2053
2092
|
return Sigilified;
|
|
2054
2093
|
}
|
|
2055
2094
|
function SigilifyAbstract(Base, label, opts) {
|
|
2056
|
-
if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already
|
|
2095
|
+
if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already sigilified.`);
|
|
2057
2096
|
let l;
|
|
2058
2097
|
if (label) {
|
|
2059
2098
|
verifyLabel(label, opts);
|
|
@@ -2061,11 +2100,18 @@
|
|
|
2061
2100
|
} else l = generateRandomLabel();
|
|
2062
2101
|
class Sigilified extends Base {
|
|
2063
2102
|
/**
|
|
2064
|
-
* Class-level
|
|
2103
|
+
* Class-level identity label constant for this sigil constructor.
|
|
2065
2104
|
*/
|
|
2066
2105
|
static get SigilLabel() {
|
|
2106
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
2067
2107
|
return this[__LABEL__];
|
|
2068
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
|
+
}
|
|
2069
2115
|
/**
|
|
2070
2116
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
2071
2117
|
*
|
|
@@ -2075,6 +2121,7 @@
|
|
|
2075
2121
|
*/
|
|
2076
2122
|
static get SigilLabelLineage() {
|
|
2077
2123
|
var _a;
|
|
2124
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
2078
2125
|
return [...(_a = this[__LABEL_LINEAGE__]) != null ? _a : []];
|
|
2079
2126
|
}
|
|
2080
2127
|
/**
|
|
@@ -2085,6 +2132,7 @@
|
|
|
2085
2132
|
* @returns A Readonly Set of labels that represent the type lineage.
|
|
2086
2133
|
*/
|
|
2087
2134
|
static get SigilLabelSet() {
|
|
2135
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
2088
2136
|
const set = /* @__PURE__ */ new Set();
|
|
2089
2137
|
for (const s of this[__LABEL_SET__]) set.add(s);
|
|
2090
2138
|
return set;
|
|
@@ -2095,11 +2143,11 @@
|
|
|
2095
2143
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
2096
2144
|
const ctor = getConstructor(this);
|
|
2097
2145
|
if (!ctor) {
|
|
2098
|
-
if (
|
|
2146
|
+
if (process.env.NODE_ENV !== "production")
|
|
2099
2147
|
throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
|
|
2100
2148
|
return;
|
|
2101
2149
|
}
|
|
2102
|
-
|
|
2150
|
+
checkInheritance(ctor);
|
|
2103
2151
|
}
|
|
2104
2152
|
/**
|
|
2105
2153
|
* Runtime predicate indicating whether `obj` is an instance produced by a sigil class.
|
|
@@ -2127,7 +2175,7 @@
|
|
|
2127
2175
|
*/
|
|
2128
2176
|
static isOfType(other) {
|
|
2129
2177
|
var _a;
|
|
2130
|
-
if (!isSigilInstance(other)
|
|
2178
|
+
if (!isSigilInstance(other)) return false;
|
|
2131
2179
|
const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
|
|
2132
2180
|
const thisType = this[__LABEL__];
|
|
2133
2181
|
return !!otherSet && otherSet.has(thisType);
|
|
@@ -2146,7 +2194,7 @@
|
|
|
2146
2194
|
*/
|
|
2147
2195
|
static isOfTypeStrict(other) {
|
|
2148
2196
|
var _a;
|
|
2149
|
-
if (!isSigilInstance(other)
|
|
2197
|
+
if (!isSigilInstance(other)) return false;
|
|
2150
2198
|
const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
|
|
2151
2199
|
const thisLineage = this[__LABEL_LINEAGE__];
|
|
2152
2200
|
return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
|
|
@@ -2163,7 +2211,7 @@
|
|
|
2163
2211
|
*/
|
|
2164
2212
|
isOfType(other) {
|
|
2165
2213
|
var _a;
|
|
2166
|
-
if (!isSigilInstance(other)
|
|
2214
|
+
if (!isSigilInstance(other)) return false;
|
|
2167
2215
|
const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
|
|
2168
2216
|
const thisType = getConstructor(this)[__LABEL__];
|
|
2169
2217
|
return !!otherSet && otherSet.has(thisType);
|
|
@@ -2180,25 +2228,39 @@
|
|
|
2180
2228
|
*/
|
|
2181
2229
|
isOfTypeStrict(other) {
|
|
2182
2230
|
var _a, _b;
|
|
2183
|
-
if (!isSigilInstance(other)
|
|
2231
|
+
if (!isSigilInstance(other)) return false;
|
|
2184
2232
|
const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
|
|
2185
2233
|
const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__LABEL_LINEAGE__];
|
|
2186
2234
|
return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
|
|
2187
2235
|
}
|
|
2188
2236
|
/**
|
|
2189
|
-
* Returns the
|
|
2237
|
+
* Returns the identity sigil label of this instance's constructor.
|
|
2190
2238
|
*
|
|
2191
|
-
* @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.
|
|
2192
2240
|
*/
|
|
2193
2241
|
getSigilLabel() {
|
|
2194
2242
|
const ctor = getConstructor(this);
|
|
2195
2243
|
if (!ctor) {
|
|
2196
|
-
if (
|
|
2197
|
-
throw new Error(`[Sigil Error]
|
|
2244
|
+
if (process.env.NODE_ENV !== "production")
|
|
2245
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2198
2246
|
return "@Sigil.unknown";
|
|
2199
2247
|
}
|
|
2200
2248
|
return ctor.SigilLabel;
|
|
2201
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
|
+
}
|
|
2202
2264
|
/**
|
|
2203
2265
|
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
2204
2266
|
*
|
|
@@ -2207,8 +2269,8 @@
|
|
|
2207
2269
|
getSigilLabelLineage() {
|
|
2208
2270
|
const ctor = getConstructor(this);
|
|
2209
2271
|
if (!ctor) {
|
|
2210
|
-
if (
|
|
2211
|
-
throw new Error(`[Sigil Error]
|
|
2272
|
+
if (process.env.NODE_ENV !== "production")
|
|
2273
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2212
2274
|
return ["@Sigil.unknown"];
|
|
2213
2275
|
}
|
|
2214
2276
|
return ctor.SigilLabelLineage;
|
|
@@ -2221,14 +2283,14 @@
|
|
|
2221
2283
|
getSigilLabelSet() {
|
|
2222
2284
|
const ctor = getConstructor(this);
|
|
2223
2285
|
if (!ctor) {
|
|
2224
|
-
if (
|
|
2225
|
-
throw new Error(`[Sigil Error]
|
|
2286
|
+
if (process.env.NODE_ENV !== "production")
|
|
2287
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
2226
2288
|
return /* @__PURE__ */ new Set(["@Sigil.unknown"]);
|
|
2227
2289
|
}
|
|
2228
2290
|
return ctor.SigilLabelSet;
|
|
2229
2291
|
}
|
|
2230
2292
|
}
|
|
2231
|
-
decorateCtor(Sigilified, l, true);
|
|
2293
|
+
decorateCtor(Sigilified, l, { isMixin: true });
|
|
2232
2294
|
markSigil(Sigilified);
|
|
2233
2295
|
markSigilBase(Sigilified);
|
|
2234
2296
|
return Sigilified;
|
|
@@ -2253,11 +2315,11 @@
|
|
|
2253
2315
|
`[Sigil Error] 'WithSigil' decorator accept only Sigil classes but used on class ${value.name}`
|
|
2254
2316
|
);
|
|
2255
2317
|
decorateCtor(value, l);
|
|
2256
|
-
|
|
2318
|
+
checkInheritance(value, opts);
|
|
2257
2319
|
};
|
|
2258
2320
|
}
|
|
2259
2321
|
|
|
2260
|
-
// src/core/
|
|
2322
|
+
// src/core/hof.ts
|
|
2261
2323
|
function withSigil(Class, label, opts) {
|
|
2262
2324
|
var _a;
|
|
2263
2325
|
if (!isSigilCtor(Class))
|
|
@@ -2271,7 +2333,7 @@
|
|
|
2271
2333
|
} else l = generateRandomLabel();
|
|
2272
2334
|
const ctor = Class;
|
|
2273
2335
|
decorateCtor(ctor, l);
|
|
2274
|
-
|
|
2336
|
+
checkInheritance(ctor, opts);
|
|
2275
2337
|
return Class;
|
|
2276
2338
|
}
|
|
2277
2339
|
function withSigilTyped(Class, label, opts) {
|
|
@@ -2287,7 +2349,7 @@
|
|
|
2287
2349
|
} else l = generateRandomLabel();
|
|
2288
2350
|
const ctor = Class;
|
|
2289
2351
|
decorateCtor(ctor, l);
|
|
2290
|
-
|
|
2352
|
+
checkInheritance(ctor, opts);
|
|
2291
2353
|
return Class;
|
|
2292
2354
|
}
|
|
2293
2355
|
/*! Bundled license information:
|
|
@@ -2308,7 +2370,7 @@
|
|
|
2308
2370
|
exports.isSigilBaseInstance = isSigilBaseInstance;
|
|
2309
2371
|
exports.isSigilCtor = isSigilCtor;
|
|
2310
2372
|
exports.isSigilInstance = isSigilInstance;
|
|
2311
|
-
exports.
|
|
2373
|
+
exports.updateSigilOptions = updateSigilOptions;
|
|
2312
2374
|
exports.withSigil = withSigil;
|
|
2313
2375
|
exports.withSigilTyped = withSigilTyped;
|
|
2314
2376
|
|