@vicin/sigil 3.4.0 → 4.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/CHANGELOG.md +4 -252
- package/CONTRIBUTING.md +24 -0
- package/LICENSE +3 -1
- package/README.md +134 -180
- package/dist/index.cjs +269 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.mts → index.d.cts} +67 -242
- package/dist/index.d.ts +67 -242
- package/dist/index.global.js +88 -208
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +87 -219
- package/dist/index.js.map +1 -1
- package/package.json +43 -59
- package/dist/index.mjs +0 -374
- package/dist/index.mjs.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -1,172 +1,99 @@
|
|
|
1
1
|
(function (exports) {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
// src/symbols.ts
|
|
5
|
+
var __SIGIL__ = /* @__PURE__ */ Symbol.for("@vicin/sigil.__SIGIL__");
|
|
6
|
+
var __SIGIL_LINEAGE__ = /* @__PURE__ */ Symbol.for("@vicin/sigil.__SIGIL_LINEAGE__");
|
|
7
|
+
var __LABEL__ = /* @__PURE__ */ Symbol.for("@vicin/sigil.__LABEL__");
|
|
8
|
+
var __DEPTH__ = /* @__PURE__ */ Symbol.for("@vicin/sigil.__DEPTH__");
|
|
9
|
+
|
|
10
|
+
// src/is.ts
|
|
11
|
+
function isSigilCtor(ctor) {
|
|
12
|
+
return typeof ctor === "function" && ctor.prototype && __SIGIL__ in ctor.prototype;
|
|
13
|
+
}
|
|
14
|
+
function isSigilInstance(inst) {
|
|
15
|
+
return !!inst && typeof inst === "object" && __SIGIL__ in inst;
|
|
16
|
+
}
|
|
17
|
+
|
|
4
18
|
// src/options.ts
|
|
5
19
|
var OPTIONS = {
|
|
6
|
-
labelValidation: null
|
|
7
|
-
autofillLabels: true,
|
|
8
|
-
skipLabelUniquenessCheck: false
|
|
20
|
+
labelValidation: null
|
|
9
21
|
};
|
|
10
|
-
var updateSigilOptions = (
|
|
11
|
-
|
|
12
|
-
if (typeof opts.autofillLabels !== "boolean")
|
|
13
|
-
throw new Error("'updateSigilOptions.autofillLabels' must be boolean");
|
|
14
|
-
OPTIONS.autofillLabels = opts.autofillLabels;
|
|
15
|
-
}
|
|
16
|
-
if ("labelValidation" in opts) {
|
|
17
|
-
const val = opts.labelValidation;
|
|
18
|
-
if (val !== null && typeof val !== "function" && !(val instanceof RegExp))
|
|
19
|
-
throw new Error("'updateSigilOptions.labelValidation' must be null, function or RegExp");
|
|
20
|
-
OPTIONS.labelValidation = val;
|
|
21
|
-
}
|
|
22
|
-
if ("skipLabelUniquenessCheck" in opts) {
|
|
23
|
-
if (typeof opts.skipLabelUniquenessCheck !== "boolean")
|
|
24
|
-
throw new Error("'updateSigilOptions.skipLabelUniquenessCheck' must be boolean");
|
|
25
|
-
OPTIONS.skipLabelUniquenessCheck = opts.skipLabelUniquenessCheck;
|
|
26
|
-
}
|
|
22
|
+
var updateSigilOptions = ({ labelValidation = null } = {}) => {
|
|
23
|
+
OPTIONS.labelValidation = labelValidation;
|
|
27
24
|
};
|
|
28
25
|
var RECOMMENDED_LABEL_REGEX = /^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;
|
|
29
|
-
var DEFAULT_LABEL_REGEX = RECOMMENDED_LABEL_REGEX;
|
|
30
|
-
|
|
31
|
-
// src/symbols.ts
|
|
32
|
-
var __SIGIL__ = /* @__PURE__ */ Symbol.for("@vicin/sigil.__SIGIL__");
|
|
33
|
-
var __LABEL__ = /* @__PURE__ */ Symbol.for("@vicin/sigil.__LABEL__");
|
|
34
|
-
var __EFFECTIVE_LABEL__ = /* @__PURE__ */ Symbol.for("@vicin/sigil.__EFFECTIVE_LABEL__");
|
|
35
|
-
var __DEPTH__ = /* @__PURE__ */ Symbol.for("@vicin/sigil.__DEPTH__");
|
|
36
26
|
|
|
37
|
-
// src/
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (handledCtorsExplicit.has(ctor))
|
|
27
|
+
// src/sigilify.ts
|
|
28
|
+
var resolved = /* @__PURE__ */ new WeakSet();
|
|
29
|
+
var hasOwnSigilRegistry = /* @__PURE__ */ new WeakSet();
|
|
30
|
+
function sigilify(ctor, label, opts) {
|
|
31
|
+
if (resolved.has(ctor))
|
|
43
32
|
throw new Error(
|
|
44
33
|
`[Sigil Error] Class '${ctor.name}' with label '${ctor.SigilLabel}' is already sigilified`
|
|
45
34
|
);
|
|
46
|
-
verifyLabel(
|
|
47
|
-
handleAncestors(ctor, opts);
|
|
48
|
-
sigilify(ctor, label, true);
|
|
49
|
-
}
|
|
50
|
-
function handleSigilLazy(ctor) {
|
|
51
|
-
if (handledCtors.has(ctor)) return;
|
|
52
|
-
if (!OPTIONS.autofillLabels)
|
|
53
|
-
throw new Error(
|
|
54
|
-
`[Sigil Error] Class '${ctor == null ? void 0 : ctor.name}' is not sigilified, Make sure to sigilify all Sigil classes or set 'autofillLabels' to 'true'`
|
|
55
|
-
);
|
|
35
|
+
verifyLabel(label, opts);
|
|
56
36
|
handleAncestors(ctor);
|
|
57
|
-
|
|
37
|
+
updateSigil(ctor, label);
|
|
38
|
+
resolved.add(ctor);
|
|
39
|
+
hasOwnSigilRegistry.add(ctor);
|
|
40
|
+
}
|
|
41
|
+
function hasOwnSigil(ctor) {
|
|
42
|
+
return hasOwnSigilRegistry.has(ctor);
|
|
58
43
|
}
|
|
59
|
-
function
|
|
44
|
+
function verifyLabel(label, opts) {
|
|
60
45
|
var _a;
|
|
61
|
-
const
|
|
46
|
+
const labelValidation = (_a = opts == null ? void 0 : opts.labelValidation) != null ? _a : OPTIONS.labelValidation;
|
|
47
|
+
if (labelValidation) {
|
|
48
|
+
let valid;
|
|
49
|
+
if (labelValidation instanceof RegExp) valid = labelValidation.test(label);
|
|
50
|
+
else valid = labelValidation(label);
|
|
51
|
+
if (!valid)
|
|
52
|
+
throw new Error(
|
|
53
|
+
`[Sigil Error] Invalid Sigil label '${label}'. Make sure that supplied label matches validation regex or function`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function handleAncestors(ctor) {
|
|
62
58
|
let a = Object.getPrototypeOf(ctor);
|
|
63
59
|
while (a && typeof a === "function" && a.prototype[__SIGIL__]) {
|
|
64
|
-
|
|
60
|
+
resolved.add(a);
|
|
65
61
|
a = Object.getPrototypeOf(a);
|
|
66
62
|
}
|
|
67
|
-
const labelOwner = /* @__PURE__ */ new Map();
|
|
68
|
-
const autofillLabels = (_a = opts == null ? void 0 : opts.autofillLabels) != null ? _a : OPTIONS.autofillLabels;
|
|
69
|
-
for (const a2 of ancestors) {
|
|
70
|
-
const l = a2.prototype[__LABEL__];
|
|
71
|
-
if (labelOwner.has(l)) {
|
|
72
|
-
if (!autofillLabels)
|
|
73
|
-
throw new Error(
|
|
74
|
-
`[Sigil Error] Class '${a2.name}' is not sigilified, Make sure to sigilify all Sigil classes or set 'autofillLabels' to 'true'`
|
|
75
|
-
);
|
|
76
|
-
sigilify(a2, generateRandomLabel(a2), false);
|
|
77
|
-
}
|
|
78
|
-
labelOwner.set(a2.prototype[__LABEL__], a2.name);
|
|
79
|
-
}
|
|
80
63
|
}
|
|
81
|
-
function
|
|
82
|
-
var _a;
|
|
64
|
+
function updateSigil(ctor, label) {
|
|
65
|
+
var _a, _b, _c;
|
|
83
66
|
const sym = Symbol.for(label);
|
|
84
67
|
Object.defineProperty(ctor.prototype, __SIGIL__, {
|
|
85
68
|
value: sym,
|
|
86
|
-
configurable:
|
|
69
|
+
configurable: false,
|
|
87
70
|
enumerable: false,
|
|
88
71
|
writable: false
|
|
89
72
|
});
|
|
90
73
|
Object.defineProperty(ctor.prototype, __LABEL__, {
|
|
91
74
|
value: label,
|
|
92
|
-
configurable:
|
|
75
|
+
configurable: false,
|
|
93
76
|
enumerable: false,
|
|
94
77
|
writable: false
|
|
95
78
|
});
|
|
96
|
-
|
|
97
|
-
Object.
|
|
98
|
-
value: label,
|
|
99
|
-
configurable: false,
|
|
100
|
-
enumerable: false,
|
|
101
|
-
writable: false
|
|
102
|
-
});
|
|
103
|
-
if (!handledCtors.has(ctor))
|
|
104
|
-
Object.defineProperty(ctor.prototype, __DEPTH__, {
|
|
105
|
-
value: ((_a = ctor.prototype[__DEPTH__]) != null ? _a : -1) + 1,
|
|
106
|
-
configurable: false,
|
|
107
|
-
enumerable: false,
|
|
108
|
-
writable: false
|
|
109
|
-
});
|
|
110
|
-
Object.defineProperty(ctor.prototype, sym, {
|
|
111
|
-
value: true,
|
|
79
|
+
Object.defineProperty(ctor.prototype, __SIGIL_LINEAGE__, {
|
|
80
|
+
value: [...(_b = (_a = Object.getPrototypeOf(ctor)) == null ? void 0 : _a.prototype[__SIGIL_LINEAGE__]) != null ? _b : [], sym],
|
|
112
81
|
configurable: false,
|
|
113
82
|
enumerable: false,
|
|
114
83
|
writable: false
|
|
115
84
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
function isSigilCtor(ctor) {
|
|
120
|
-
return typeof ctor === "function" && ctor.prototype && __SIGIL__ in ctor.prototype;
|
|
121
|
-
}
|
|
122
|
-
function isSigilInstance(inst) {
|
|
123
|
-
return !!inst && typeof inst === "object" && __SIGIL__ in inst;
|
|
124
|
-
}
|
|
125
|
-
function getSigilLabels() {
|
|
126
|
-
return getLabelRegistry().labels();
|
|
127
|
-
}
|
|
128
|
-
function getLabelRegistry() {
|
|
129
|
-
if ("__labelRegistry__" in globalThis) return globalThis.__labelRegistry__;
|
|
130
|
-
const labelSet = /* @__PURE__ */ new Set();
|
|
131
|
-
let count = 0;
|
|
132
|
-
const labelRegistry = {
|
|
133
|
-
has: (label) => labelSet.has(label),
|
|
134
|
-
add: (label) => labelSet.add(label),
|
|
135
|
-
labels: () => [...labelSet],
|
|
136
|
-
enc: () => ++count
|
|
137
|
-
};
|
|
138
|
-
Object.freeze(labelRegistry);
|
|
139
|
-
Object.defineProperty(globalThis, "__labelRegistry__", {
|
|
140
|
-
value: labelRegistry,
|
|
141
|
-
writable: false,
|
|
85
|
+
Object.defineProperty(ctor.prototype, __DEPTH__, {
|
|
86
|
+
value: ((_c = ctor.prototype[__DEPTH__]) != null ? _c : -1) + 1,
|
|
142
87
|
configurable: false,
|
|
143
|
-
enumerable: false
|
|
88
|
+
enumerable: false,
|
|
89
|
+
writable: false
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(ctor.prototype, sym, {
|
|
92
|
+
value: true,
|
|
93
|
+
configurable: false,
|
|
94
|
+
enumerable: false,
|
|
95
|
+
writable: false
|
|
144
96
|
});
|
|
145
|
-
return labelRegistry;
|
|
146
|
-
}
|
|
147
|
-
function verifyLabel(ctor, label, opts) {
|
|
148
|
-
var _a, _b;
|
|
149
|
-
const reg = getLabelRegistry();
|
|
150
|
-
if (label.startsWith(AUTO_LABEL_PREFEX))
|
|
151
|
-
throw new Error(`'${AUTO_LABEL_PREFEX}' is a prefex reserved by the library`);
|
|
152
|
-
if (!((_a = opts == null ? void 0 : opts.skipLabelUniquenessCheck) != null ? _a : OPTIONS.skipLabelUniquenessCheck) && reg.has(label))
|
|
153
|
-
throw new Error(
|
|
154
|
-
`[Sigil Error] Passed label '${label}' to class '${ctor == null ? void 0 : ctor.name}' is re-used, passed labels must be unique`
|
|
155
|
-
);
|
|
156
|
-
const labelValidation = (_b = opts == null ? void 0 : opts.labelValidation) != null ? _b : OPTIONS.labelValidation;
|
|
157
|
-
if (labelValidation) {
|
|
158
|
-
let valid;
|
|
159
|
-
if (labelValidation instanceof RegExp) valid = labelValidation.test(label);
|
|
160
|
-
else valid = labelValidation(label);
|
|
161
|
-
if (!valid)
|
|
162
|
-
throw new Error(
|
|
163
|
-
`[Sigil Error] Invalid Sigil label '${label}'. Make sure that supplied label matches validation regex or function`
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
reg.add(label);
|
|
167
|
-
}
|
|
168
|
-
function generateRandomLabel(ctor) {
|
|
169
|
-
return `${AUTO_LABEL_PREFEX}:${ctor == null ? void 0 : ctor.name}:${getLabelRegistry().enc()}:${Math.random().toString(36).slice(2, 10)}`;
|
|
170
97
|
}
|
|
171
98
|
|
|
172
99
|
// src/mixin.ts
|
|
@@ -176,47 +103,24 @@
|
|
|
176
103
|
* Class-level identity label constant for this sigil constructor.
|
|
177
104
|
*/
|
|
178
105
|
static get SigilLabel() {
|
|
179
|
-
handleSigilLazy(this);
|
|
180
106
|
return this.prototype[__LABEL__];
|
|
181
107
|
}
|
|
182
108
|
/**
|
|
183
|
-
*
|
|
184
|
-
*/
|
|
185
|
-
static get SigilEffectiveLabel() {
|
|
186
|
-
handleSigilLazy(this);
|
|
187
|
-
return this.prototype[__EFFECTIVE_LABEL__];
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Linearized sigil type label chain for the current constructor.
|
|
109
|
+
* Copy of the sigil label lineage for this instance's constructor.
|
|
191
110
|
*
|
|
192
|
-
* Useful for debugging and
|
|
111
|
+
* Useful for debugging and logging.
|
|
193
112
|
*
|
|
194
|
-
* @returns An array of labels representing parent → child
|
|
113
|
+
* @returns An array of sigil labels representing parent → child labels.
|
|
195
114
|
*/
|
|
196
115
|
static get SigilLabelLineage() {
|
|
197
|
-
|
|
198
|
-
const lineage = [];
|
|
199
|
-
let c = this;
|
|
200
|
-
while (c && typeof c === "function" && c.prototype[__SIGIL__]) {
|
|
201
|
-
lineage.unshift(c.SigilLabel);
|
|
202
|
-
c = Object.getPrototypeOf(c);
|
|
203
|
-
}
|
|
204
|
-
return lineage;
|
|
116
|
+
return this.prototype[__SIGIL_LINEAGE__].map((v) => v.description);
|
|
205
117
|
}
|
|
206
|
-
/**
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
*
|
|
210
|
-
* @deprecated To minize API and bundle size, internally this method is 'new Set(this.SigilLabelLineage)' only. will be removed in v4
|
|
211
|
-
* @returns A Readonly Set of labels that represent the type lineage.
|
|
212
|
-
*/
|
|
213
|
-
static get SigilLabelSet() {
|
|
214
|
-
return new Set(this.SigilLabelLineage);
|
|
118
|
+
/** Check if sigil label has been attached to this class */
|
|
119
|
+
static get hasOwnSigil() {
|
|
120
|
+
return hasOwnSigil(this);
|
|
215
121
|
}
|
|
216
122
|
constructor(...args) {
|
|
217
123
|
super(...args);
|
|
218
|
-
const ctor = new.target;
|
|
219
|
-
handleSigilLazy(ctor);
|
|
220
124
|
}
|
|
221
125
|
/**
|
|
222
126
|
* Check whether `other` is (or inherits from) the instance represented by the
|
|
@@ -230,8 +134,7 @@
|
|
|
230
134
|
* @param other - The object to test.
|
|
231
135
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
232
136
|
*/
|
|
233
|
-
static
|
|
234
|
-
handleSigilLazy(this);
|
|
137
|
+
static isInstance(other) {
|
|
235
138
|
if (other == null || typeof other !== "object") return false;
|
|
236
139
|
return other[this.prototype[__SIGIL__]] === true;
|
|
237
140
|
}
|
|
@@ -244,8 +147,7 @@
|
|
|
244
147
|
* @param other - The object to test.
|
|
245
148
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
246
149
|
*/
|
|
247
|
-
static
|
|
248
|
-
handleSigilLazy(this);
|
|
150
|
+
static isExactInstance(other) {
|
|
249
151
|
if (other == null || typeof other !== "object") return false;
|
|
250
152
|
if (this.prototype[__DEPTH__] !== other[__DEPTH__]) return false;
|
|
251
153
|
return other[this.prototype[__SIGIL__]] === true;
|
|
@@ -262,7 +164,7 @@
|
|
|
262
164
|
* @param other - The object to test.
|
|
263
165
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
264
166
|
*/
|
|
265
|
-
|
|
167
|
+
isInstance(other) {
|
|
266
168
|
if (other == null || typeof other !== "object") return false;
|
|
267
169
|
return other[this[__SIGIL__]] === true;
|
|
268
170
|
}
|
|
@@ -275,7 +177,7 @@
|
|
|
275
177
|
* @param other - The object to test.
|
|
276
178
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
277
179
|
*/
|
|
278
|
-
|
|
180
|
+
isExactInstance(other) {
|
|
279
181
|
if (other == null || typeof other !== "object") return false;
|
|
280
182
|
if (this[__DEPTH__] !== other[__DEPTH__]) return false;
|
|
281
183
|
return other[this[__SIGIL__]] === true;
|
|
@@ -285,42 +187,25 @@
|
|
|
285
187
|
*
|
|
286
188
|
* @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil-auto:ClassName:1:pnf11bgl').
|
|
287
189
|
*/
|
|
288
|
-
|
|
190
|
+
get SigilLabel() {
|
|
289
191
|
return this[__LABEL__];
|
|
290
192
|
}
|
|
291
193
|
/**
|
|
292
|
-
*
|
|
194
|
+
* Copy of the sigil label lineage for this instance's constructor.
|
|
293
195
|
*
|
|
294
|
-
*
|
|
295
|
-
*/
|
|
296
|
-
getSigilEffectiveLabel() {
|
|
297
|
-
return this[__EFFECTIVE_LABEL__];
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
196
|
+
* Useful for debugging and logging.
|
|
301
197
|
*
|
|
302
|
-
* @returns
|
|
198
|
+
* @returns An array of sigil labels representing parent → child labels.
|
|
303
199
|
*/
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
let proto = Object.getPrototypeOf(this);
|
|
307
|
-
while (proto && proto[__SIGIL__]) {
|
|
308
|
-
lineage.unshift(proto[__LABEL__]);
|
|
309
|
-
proto = Object.getPrototypeOf(proto);
|
|
310
|
-
}
|
|
311
|
-
return lineage;
|
|
200
|
+
get SigilLabelLineage() {
|
|
201
|
+
return this[__SIGIL_LINEAGE__].map((v) => v.description);
|
|
312
202
|
}
|
|
313
|
-
/**
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
* @deprecated To minize API and bundle size, internally this method is 'new Set(this.SigilLabelLineage)' only. will be removed in v4
|
|
317
|
-
* @returns readonly array of labels representing the type lineage.
|
|
318
|
-
*/
|
|
319
|
-
getSigilLabelSet() {
|
|
320
|
-
return new Set(this.getSigilLabelLineage());
|
|
203
|
+
/** Check if sigil label has been attached to this class */
|
|
204
|
+
get hasOwnSigil() {
|
|
205
|
+
return this.constructor.hasOwnSigil;
|
|
321
206
|
}
|
|
322
207
|
}
|
|
323
|
-
|
|
208
|
+
sigilify(Sigil2, "Sigil");
|
|
324
209
|
return Sigil2;
|
|
325
210
|
}
|
|
326
211
|
function Sigilify(Base, label, opts) {
|
|
@@ -331,7 +216,7 @@
|
|
|
331
216
|
const BaseSigil = BaseSigilify(Base);
|
|
332
217
|
class Sigilified extends BaseSigil {
|
|
333
218
|
}
|
|
334
|
-
|
|
219
|
+
sigilify(Sigilified, label, opts);
|
|
335
220
|
return Sigilified;
|
|
336
221
|
}
|
|
337
222
|
function SigilifyAbstract(Base, label, opts) {
|
|
@@ -342,7 +227,7 @@
|
|
|
342
227
|
const BaseSigil = BaseSigilify(Base);
|
|
343
228
|
class Sigilified extends BaseSigil {
|
|
344
229
|
}
|
|
345
|
-
|
|
230
|
+
sigilify(Sigilified, label, opts);
|
|
346
231
|
return Sigilified;
|
|
347
232
|
}
|
|
348
233
|
|
|
@@ -353,39 +238,34 @@
|
|
|
353
238
|
|
|
354
239
|
// src/attach.ts
|
|
355
240
|
function AttachSigil(label, opts) {
|
|
356
|
-
return function(
|
|
357
|
-
if (!isSigilCtor(
|
|
241
|
+
return function(target, ctx) {
|
|
242
|
+
if (!isSigilCtor(target))
|
|
358
243
|
throw new Error(
|
|
359
|
-
`[Sigil Error] 'AttachSigil' decorator accept only Sigil classes but used on class '${
|
|
244
|
+
`[Sigil Error] 'AttachSigil' decorator accept only Sigil classes but used on class '${target.name}'`
|
|
360
245
|
);
|
|
361
|
-
|
|
246
|
+
sigilify(target, label, opts);
|
|
362
247
|
};
|
|
363
248
|
}
|
|
364
|
-
var WithSigil = AttachSigil;
|
|
365
249
|
function attachSigil(Class, label, opts) {
|
|
366
250
|
if (!isSigilCtor(Class))
|
|
367
251
|
throw new Error(
|
|
368
252
|
`[Sigil Error] 'attachSigil' function accept only Sigil classes but used on class '${Class.name}'`
|
|
369
253
|
);
|
|
370
|
-
|
|
254
|
+
sigilify(Class, label, opts);
|
|
371
255
|
return Class;
|
|
372
256
|
}
|
|
373
|
-
var withSigil = attachSigil;
|
|
374
257
|
|
|
375
258
|
exports.AttachSigil = AttachSigil;
|
|
376
|
-
exports.DEFAULT_LABEL_REGEX = DEFAULT_LABEL_REGEX;
|
|
377
259
|
exports.RECOMMENDED_LABEL_REGEX = RECOMMENDED_LABEL_REGEX;
|
|
378
260
|
exports.Sigil = Sigil;
|
|
379
261
|
exports.SigilError = SigilError;
|
|
380
262
|
exports.Sigilify = Sigilify;
|
|
381
263
|
exports.SigilifyAbstract = SigilifyAbstract;
|
|
382
|
-
exports.WithSigil = WithSigil;
|
|
383
264
|
exports.attachSigil = attachSigil;
|
|
384
|
-
exports.
|
|
265
|
+
exports.hasOwnSigil = hasOwnSigil;
|
|
385
266
|
exports.isSigilCtor = isSigilCtor;
|
|
386
267
|
exports.isSigilInstance = isSigilInstance;
|
|
387
268
|
exports.updateSigilOptions = updateSigilOptions;
|
|
388
|
-
exports.withSigil = withSigil;
|
|
389
269
|
|
|
390
270
|
return exports;
|
|
391
271
|
|
package/dist/index.global.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/options.ts","../src/symbols.ts","../src/helpers.ts","../src/mixin.ts","../src/classes.ts","../src/attach.ts"],"names":["a","Sigil"],"mappings":";;;;EA6CO,IAAM,OAAA,GAAkC;EAAA,EAC7C,eAAA,EAAiB,IAAA;EAAA,EACjB,cAAA,EAAgB,IAAA;EAAA,EAChB,wBAAA,EAA0B;EAC5B,CAAA;AAYO,MAAM,kBAAA,GAAqB,CAAC,IAAA,KAA6B;EAC9D,EAAA,IAAI,oBAAoB,IAAA,EAAM;EAC5B,IAAA,IAAI,OAAO,KAAK,cAAA,KAAmB,SAAA;EACjC,MAAA,MAAM,IAAI,MAAM,qDAAqD,CAAA;EACvE,IAAA,OAAA,CA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K,CAAA;EACpB,MAAA,MAAM,IAAI,KAAA;EAAA,QACR,CAAA,mFAAA,EAAsF,MAAM,IAAI,CAAA,CAAA;EAAA,OAClG;EAEF,IAAA,mBAAA,CAAoB,KAAA,EAAO,OAAO,IAAI,CAAA;EAAA,EACxC,CAAA;EACF;AAKO,MAAM,SAAA,GAAY;EAYlB,SAAS,WAAA,CAAgC,KAAA,EAAU,KAAA,EAAe,IAAA,EAAwB;EAC/F,EAAA,IAAI,CAAC,YAAY,KAAK,CAAA;EACpB,IAAA,MAAM,IAAI,KAAA;EAAA,MACR,CAAA,kFAAA,EAAqF,MAAM,IAAI,CAAA,CAAA;EAAA,KACjG;EAEF,EAAA,mBAAA,CAAoB,KAAA,EAAO,OAAO,IAAI,CAAA;EACtC,EAAA,OAAO,KAAA;EACT;AAKO,MAAM,SAAA,GAAY","file":"index.global.js","sourcesContent":["/** -----------------------------------------\n * Types\n * ----------------------------------------- */\n\n/**\n * Configuration options for the Sigil library.\n *\n * These options control runtime validation, inheritance checks, label autofill behavior.\n */\nexport interface SigilOptions {\n /**\n * Validation rule applied to sigil labels before registration.\n *\n * - A function receives the label and must return `true` if valid.\n * - A `RegExp` must match the label.\n * - `null` disables validation entirely.\n *\n * Defaults to `null`.\n */\n labelValidation?: ((label: string) => boolean) | RegExp | null;\n\n /**\n * When enabled, non-decorated subclasses that would otherwise inherit an ancestor's label\n * will be assigned an autogenerated random label (so that explicit labels stay unique).\n */\n autofillLabels?: boolean;\n\n /**\n * Option for Hot module reload set-ups, reload of files can result in class redefinition which will throw\n * duplicate label error, setting this to 'true' will disabel this error.\n * However as it disables unique label check bugs can appear if the same label is passed to two different\n * classes so set this to 'true' only when needed and ensure uniqueness of passed labels.\n */\n skipLabelUniquenessCheck?: boolean;\n}\n\n/** -----------------------------------------\n * Internal options object\n * ----------------------------------------- */\n\n/**\n * Defined SigilOptions used in the library.\n *\n * @internal\n */\nexport const OPTIONS: Required<SigilOptions> = {\n labelValidation: null,\n autofillLabels: true,\n skipLabelUniquenessCheck: false,\n};\n\n/** -----------------------------------------\n * Update options\n * ----------------------------------------- */\n\n/**\n * Update runtime options for the Sigil library.\n * Call this early during application startup if you want non-default behavior.\n *\n * @param opts - Partial options to merge into the global `OPTIONS` object.\n */\nexport const updateSigilOptions = (opts: SigilOptions): void => {\n if ('autofillLabels' in opts) {\n if (typeof opts.autofillLabels !== 'boolean')\n throw new Error(\"'updateSigilOptions.autofillLabels' must be boolean\");\n OPTIONS.autofillLabels = opts.autofillLabels!;\n }\n\n if ('labelValidation' in opts) {\n const val = opts.labelValidation;\n if (val !== null && typeof val !== 'function' && !(val instanceof RegExp))\n throw new Error(\"'updateSigilOptions.labelValidation' must be null, function or RegExp\");\n OPTIONS.labelValidation = val;\n }\n\n if ('skipLabelUniquenessCheck' in opts) {\n if (typeof opts.skipLabelUniquenessCheck !== 'boolean')\n throw new Error(\"'updateSigilOptions.skipLabelUniquenessCheck' must be boolean\");\n OPTIONS.skipLabelUniquenessCheck = opts.skipLabelUniquenessCheck;\n }\n};\n\n/** -----------------------------------------\n * Label validation\n * ----------------------------------------- */\n\n/**\n * Label validation regex. Labels must follow the pattern\n * `@scope/package.ClassName` where `ClassName` begins with an uppercase\n * letter. This avoids collisions across packages and helps debugging.\n *\n * It's advised to use this regex in 'SigilOptions.labelValidation'.\n */\nexport const RECOMMENDED_LABEL_REGEX = /^@[\\w-]+(?:\\/[\\w-]+)*\\.[A-Z][A-Za-z0-9]*$/;\n\n/** @deprecated - Use 'RECOMMENDED_LABEL_REGEX' instead, will be removed in v4 */\nexport const DEFAULT_LABEL_REGEX = RECOMMENDED_LABEL_REGEX;\n","/**\n * Symbol to uniquely identify sigil classes.\n *\n * @constant {symbol}\n */\nexport const __SIGIL__ = Symbol.for('@vicin/sigil.__SIGIL__');\n\n/**\n * Symbol used to store the identity label for a sigil constructor.\n *\n * Stored on the constructor as a non-enumerable property.\n *\n * @constant {symbol}\n */\nexport const __LABEL__ = Symbol.for('@vicin/sigil.__LABEL__');\n\n/**\n * Symbol used to store the human-readable label for a sigil constructor, it can be inherited if no label is deined.\n *\n * Stored on the constructor as a non-enumerable property.\n *\n * @constant {symbol}\n */\nexport const __EFFECTIVE_LABEL__ = Symbol.for('@vicin/sigil.__EFFECTIVE_LABEL__');\n\n/**\n * Symbol used to store the depth inside Sigil chain. used in exact checks\n *\n * @constant {symbol}\n */\nexport const __DEPTH__ = Symbol.for('@vicin/sigil.__DEPTH__');\n","import { OPTIONS, type SigilOptions } from './options';\nimport { __LABEL__, __EFFECTIVE_LABEL__, __SIGIL__, __DEPTH__ } from './symbols';\nimport type { ISigil, ISigilInstance } from './types';\n\n/** -----------------------------------------\n * Constants\n * ----------------------------------------- */\n\n/** Prefex use by the lib to identify auto-generated classes */\nconst AUTO_LABEL_PREFEX = '@Sigil-auto';\n\n/** -----------------------------------------\n * Weak maps\n * ----------------------------------------- */\n\n/** Weak set to ensure that every ctor is handled only once. register both explicit and lazy handles */\nconst handledCtors = new WeakSet<Function>();\n\n/** Weak set to ensure that every ctor is handled only once. register explicit handles only */\nconst handledCtorsExplicit = new WeakSet<Function>();\n\n/** -----------------------------------------\n * Main helpers\n * ----------------------------------------- */\n\n/** Main function to handle 'Sigil' and attach its metadata to the class when label is passed */\nexport function handleSigilExplicit(ctor: Function, label: string, opts?: SigilOptions): void {\n // fast return if already defined\n if (handledCtorsExplicit.has(ctor))\n throw new Error(\n `[Sigil Error] Class '${ctor.name}' with label '${(ctor as any).SigilLabel}' is already sigilified`\n );\n // verify label\n verifyLabel(ctor, label, opts);\n // lazy evaluate ancestors\n handleAncestors(ctor, opts);\n // sigilify ctor\n sigilify(ctor, label, true);\n}\n\n/** Function to lazily evaluate 'Sigil' ( update with auto-generated metadata or throw ) */\nexport function handleSigilLazy(ctor: Function): void {\n // fast return if already handled\n if (handledCtors.has(ctor)) return;\n // if autofillLabels is set to false throw error\n if (!OPTIONS.autofillLabels)\n throw new Error(\n `[Sigil Error] Class '${ctor?.name}' is not sigilified, Make sure to sigilify all Sigil classes or set 'autofillLabels' to 'true'`\n );\n // lazy evaluate ancestors\n handleAncestors(ctor);\n // sigilify ctor\n sigilify(ctor, generateRandomLabel(ctor), false);\n}\n\n/** -----------------------------------------\n * Generic helpers\n * ----------------------------------------- */\n\nfunction handleAncestors(ctor: Function, opts?: Pick<SigilOptions, 'autofillLabels'>): void {\n // get line age of this class (ancestors only)\n const ancestors: Function[] = [];\n let a = Object.getPrototypeOf(ctor);\n while (a && typeof a === 'function' && a.prototype[__SIGIL__]) {\n ancestors.unshift(a);\n a = Object.getPrototypeOf(a);\n }\n\n /** Map<label, className> to record the owner of each label. */\n const labelOwner = new Map<string, string>();\n\n // loop lineage to insure that each label is unique in ancestors\n const autofillLabels = opts?.autofillLabels ?? OPTIONS.autofillLabels;\n for (const a of ancestors) {\n // get label\n const l = a.prototype[__LABEL__] as string;\n // if duplicate (no label is passed for this class) update class with new label\n if (labelOwner.has(l)) {\n if (!autofillLabels)\n throw new Error(\n `[Sigil Error] Class '${a.name}' is not sigilified, Make sure to sigilify all Sigil classes or set 'autofillLabels' to 'true'`\n );\n sigilify(a, generateRandomLabel(a), false);\n }\n // register current label with class name\n labelOwner.set(a.prototype[__LABEL__], a.name);\n }\n}\n\nfunction sigilify(ctor: Function, label: string, explicit: boolean) {\n // -------------------------\n // Get symbol from label\n // -------------------------\n\n const sym = Symbol.for(label);\n\n // -------------------------\n // Populate 'Sigil' symbols\n // -------------------------\n\n Object.defineProperty(ctor.prototype, __SIGIL__, {\n value: sym,\n configurable: !explicit,\n enumerable: false,\n writable: false,\n });\n Object.defineProperty(ctor.prototype, __LABEL__, {\n value: label,\n configurable: !explicit,\n enumerable: false,\n writable: false,\n });\n if (explicit)\n Object.defineProperty(ctor.prototype, __EFFECTIVE_LABEL__, {\n value: label,\n configurable: false,\n enumerable: false,\n writable: false,\n });\n if (!handledCtors.has(ctor))\n Object.defineProperty(ctor.prototype, __DEPTH__, {\n value: (ctor.prototype[__DEPTH__] ?? -1) + 1,\n configurable: false,\n enumerable: false,\n writable: false,\n });\n\n // -------------------------\n // Add { symbol: ture } pair\n // -------------------------\n\n Object.defineProperty(ctor.prototype, sym, {\n value: true,\n configurable: false,\n enumerable: false,\n writable: false,\n });\n\n // -------------------------\n // Mark as handled\n // -------------------------\n\n // mark as handled (explicit or lazy)\n handledCtors.add(ctor);\n // if explicit mark as handled explicit\n if (explicit) handledCtorsExplicit.add(ctor);\n}\n\n/** -----------------------------------------\n * Inspection helpers\n * ----------------------------------------- */\n\n/**\n * Runtime predicate that checks whether the provided value is a sigil constructor.\n *\n * @param ctor - Constructor to test.\n * @returns `true` if `value` is a sigil constructor, otherwise `false`.\n */\nexport function isSigilCtor(ctor: unknown): ctor is ISigil {\n return typeof ctor === 'function' && ctor.prototype && __SIGIL__ in ctor.prototype;\n}\n\n/**\n * Runtime predicate that checks whether the provided object is an instance\n * of a sigil class.\n *\n * @param inst - The instanca to test.\n * @returns `true` if `obj` is an instance produced by a sigil constructor.\n */\nexport function isSigilInstance(inst: unknown): inst is ISigilInstance {\n return !!inst && typeof inst === 'object' && __SIGIL__ in inst;\n}\n\n/**\n * Helper function to get labels registered by 'Sigil'\n * @returns Sigil labels registered\n */\nexport function getSigilLabels(): string[] {\n return getLabelRegistry().labels();\n}\n\n/** -----------------------------------------\n * Label helpers\n * ----------------------------------------- */\n\n/** Exposed methods of global label registry */\ninterface LabelRegistry {\n has: (label: string) => boolean;\n add: (label: string) => void;\n labels: () => string[];\n enc: () => number;\n}\n\n/** Internal helper to get (or init then get) global label registry */\nfunction getLabelRegistry(): LabelRegistry {\n if ('__labelRegistry__' in globalThis) return (globalThis as any).__labelRegistry__;\n\n const labelSet = new Set<string>();\n let count = 0;\n\n const labelRegistry: LabelRegistry = {\n has: (label: string) => labelSet.has(label),\n add: (label: string) => labelSet.add(label),\n labels: () => [...labelSet],\n enc: () => ++count,\n };\n\n Object.freeze(labelRegistry);\n\n Object.defineProperty(globalThis, '__labelRegistry__', {\n value: labelRegistry,\n writable: false,\n configurable: false,\n enumerable: false,\n });\n\n return labelRegistry;\n}\n\n/** Internal helper to validate passed label */\nfunction verifyLabel<L extends string>(ctor: Function, label: L, opts?: SigilOptions): void {\n // get label registry\n const reg = getLabelRegistry();\n\n // If label starts with '@Sigil-auto:' throw error\n if (label.startsWith(AUTO_LABEL_PREFEX))\n throw new Error(`'${AUTO_LABEL_PREFEX}' is a prefex reserved by the library`);\n\n // If label is duplicate throw error\n if (!(opts?.skipLabelUniquenessCheck ?? OPTIONS.skipLabelUniquenessCheck) && reg.has(label))\n throw new Error(\n `[Sigil Error] Passed label '${label}' to class '${ctor?.name}' is re-used, passed labels must be unique`\n );\n\n // If validation regex or function is defined validate\n const labelValidation = opts?.labelValidation ?? OPTIONS.labelValidation;\n if (labelValidation) {\n let valid: boolean;\n if (labelValidation instanceof RegExp) valid = labelValidation.test(label);\n else valid = labelValidation(label);\n\n if (!valid)\n throw new Error(\n `[Sigil Error] Invalid Sigil label '${label}'. Make sure that supplied label matches validation regex or function`\n );\n }\n\n // Add label to registry\n reg.add(label);\n}\n\n/** Internal helper to generate random label */\nfunction generateRandomLabel(ctor: Function): string {\n return `${AUTO_LABEL_PREFEX}:${ctor?.name}:${getLabelRegistry().enc()}:${Math.random().toString(36).slice(2, 10)}`;\n}\n","import { handleSigilExplicit, handleSigilLazy, isSigilCtor } from './helpers';\nimport type { SigilOptions } from './options';\nimport { __SIGIL__, __LABEL__, __EFFECTIVE_LABEL__, __DEPTH__ } from './symbols';\nimport type { Constructor, ConstructorAbstract, GetPrototype, sigil, ExtendSigil } from './types';\n\n/**\n * Helper function to extend Base class with Sigil Class that should be present at the start of each Sigil chain\n * @param Base - The base constructor to extend.\n * @returns Base Sigil class at the start of each Sigil chain\n */\nexport function BaseSigilify(Base: ConstructorAbstract) {\n class Sigil extends Base {\n /**\n * Class-level identity label constant for this sigil constructor.\n */\n static get SigilLabel(): string {\n handleSigilLazy(this);\n return (this as any).prototype[__LABEL__];\n }\n\n /**\n * Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.\n */\n static get SigilEffectiveLabel(): string {\n handleSigilLazy(this);\n return (this as any).prototype[__EFFECTIVE_LABEL__];\n }\n\n /**\n * Linearized sigil type label chain for the current constructor.\n *\n * Useful for debugging and performing strict lineage comparisons.\n *\n * @returns An array of labels representing parent → child type labels.\n */\n static get SigilLabelLineage(): readonly string[] {\n handleSigilLazy(this);\n const lineage = [];\n let c = this;\n while (c && typeof c === 'function' && (c.prototype as any)[__SIGIL__]) {\n lineage.unshift(c.SigilLabel);\n c = Object.getPrototypeOf(c);\n }\n return lineage;\n }\n\n /**\n * Sigil type label set for the current constructor.\n * Useful for debugging.\n *\n * @deprecated To minize API and bundle size, internally this method is 'new Set(this.SigilLabelLineage)' only. will be removed in v4\n * @returns A Readonly Set of labels that represent the type lineage.\n */\n static get SigilLabelSet(): Readonly<Set<string>> {\n return new Set(this.SigilLabelLineage);\n }\n\n /**\n * Compile-time nominal brand that encodes the class sigil labels object.\n */\n declare readonly [sigil]: {\n Sigil: true;\n };\n\n constructor(...args: any[]) {\n super(...args);\n const ctor = new.target;\n handleSigilLazy(ctor);\n }\n\n /**\n * Check whether `other` is (or inherits from) the instance represented by the\n * calling constructor.\n *\n * This replaces `instanceof` so that checks remain valid across bundles/realms\n * and when subclassing.\n *\n * @typeParam T - The specific sigil constructor (`this`).\n * @param this - The constructor performing the type check.\n * @param other - The object to test.\n * @returns A type guard asserting `other` is an instance of the constructor.\n */\n static isOfType<T>(this: T, other: unknown): other is GetPrototype<T> {\n handleSigilLazy(this as any);\n if (other == null || typeof other !== 'object') return false;\n return (other as any)[(this as any).prototype[__SIGIL__]] === true;\n }\n\n /**\n * Check whether `other` is exactly the same instance represented by the\n * calling constructor.\n *\n * @typeParam T - The specific sigil constructor (`this`).\n * @param this - The constructor performing the type check.\n * @param other - The object to test.\n * @returns A type guard asserting `other` is an instance of the constructor.\n */\n static isExactType<T>(this: T, other: unknown): other is GetPrototype<T> {\n handleSigilLazy(this as any);\n if (other == null || typeof other !== 'object') return false;\n if ((this as any).prototype[__DEPTH__] !== (other as any)[__DEPTH__]) return false;\n return (other as any)[(this as any).prototype[__SIGIL__]] === true;\n }\n\n /**\n * Check whether `other` is (or inherits from) the instance represented by the\n * calling constructor.\n *\n * This replaces `instanceof` so that checks remain valid across bundles/realms\n * and when subclassing.\n *\n * @typeParam T - The specific sigil constructor (`this`).\n * @param this - The constructor performing the type check.\n * @param other - The object to test.\n * @returns A type guard asserting `other` is an instance of the constructor.\n */\n isOfType<T>(this: T, other: unknown): other is T {\n if (other == null || typeof other !== 'object') return false;\n return (other as any)[(this as any)[__SIGIL__]] === true;\n }\n\n /**\n * Check whether `other` is exactly the same instance represented by the\n * calling constructor.\n *\n * @typeParam T - The specific sigil constructor (`this`).\n * @param this - The constructor performing the type check.\n * @param other - The object to test.\n * @returns A type guard asserting `other` is an instance of the constructor.\n */\n isExactType<T>(this: T, other: unknown): other is T {\n if (other == null || typeof other !== 'object') return false;\n if ((this as any)[__DEPTH__] !== (other as any)[__DEPTH__]) return false;\n return (other as any)[(this as any)[__SIGIL__]] === true;\n }\n\n /**\n * Returns the identity sigil label of this instance's constructor.\n *\n * @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil-auto:ClassName:1:pnf11bgl').\n */\n getSigilLabel(): string {\n return (this as any)[__LABEL__];\n }\n\n /**\n * Returns the human-readable sigil label of this instance's constructor.\n *\n * @returns The last passed label string (e.g. '@scope/pkg.ClassName').\n */\n getSigilEffectiveLabel(): string {\n return (this as any)[__EFFECTIVE_LABEL__];\n }\n\n /**\n * Returns a copy of the sigil type label lineage for this instance's constructor.\n *\n * @returns readonly array of labels representing the type lineage.\n */\n getSigilLabelLineage(): readonly string[] {\n const lineage: string[] = [];\n let proto = Object.getPrototypeOf(this);\n while (proto && proto[__SIGIL__]) {\n lineage.unshift(proto[__LABEL__]);\n proto = Object.getPrototypeOf(proto);\n }\n return lineage;\n }\n\n /**\n * Returns a copy of the sigil type label lineage set for this instance's constructor.\n *\n * @deprecated To minize API and bundle size, internally this method is 'new Set(this.SigilLabelLineage)' only. will be removed in v4\n * @returns readonly array of labels representing the type lineage.\n */\n getSigilLabelSet(): Readonly<Set<string>> {\n return new Set(this.getSigilLabelLineage());\n }\n }\n\n handleSigilExplicit(Sigil, 'Sigil', { skipLabelUniquenessCheck: true });\n return Sigil;\n}\n\n/**\n * Mixin factory that augments an existing class with Sigil runtime metadata and helpers.\n *\n * @param Base - The base constructor to extend.\n * @param label - Identity label to attach to the resulting class (e.g. '@scope/pkg.ClassName').\n * @param opts - Options object to override any global options if needed.\n * @returns A new constructor that extends `Base` and includes Sigil statics/instance methods.\n * @throws Error if `Base` is already sigilified.\n */\nexport function Sigilify<L extends string>(Base: Constructor, label: L, opts?: SigilOptions) {\n if (isSigilCtor(Base))\n throw new Error(\n `[Sigil Error] Class '${Base.name}' with label '${Base.SigilLabel}' is already sigilified`\n );\n\n const BaseSigil = BaseSigilify(Base);\n class Sigilified extends BaseSigil {\n declare [sigil]: ExtendSigil<L, InstanceType<typeof BaseSigil>>;\n }\n\n handleSigilExplicit(Sigilified, label, opts);\n return Sigilified;\n}\n\n/**\n * Mixin factory that augments an existing class with Sigil runtime metadata and helpers. Accept and return 'abstract' class.\n *\n * @param Base - The base constructor to extend.\n * @param label - Identity label to attach to the resulting class (e.g. '@scope/pkg.ClassName').\n * @param opts - Options object to override any global options if needed.\n * @returns A new abstract constructor that extends `Base` and includes Sigil statics/instance methods.\n * @throws Error if `Base` is already sigilified.\n */\nexport function SigilifyAbstract<L extends string>(\n Base: ConstructorAbstract,\n label: L,\n opts?: SigilOptions\n) {\n if (isSigilCtor(Base))\n throw new Error(\n `[Sigil Error] Class '${Base.name}' with label '${Base.SigilLabel}' is already sigilified`\n );\n\n const BaseSigil = BaseSigilify(Base);\n abstract class Sigilified extends BaseSigil {\n declare [sigil]: ExtendSigil<L, InstanceType<typeof BaseSigil>>;\n }\n\n handleSigilExplicit(Sigilified, label, opts);\n return Sigilified;\n}\n","import { Sigilify, BaseSigilify } from './mixin';\nimport type { sigil } from './types';\n\n/**\n * A minimal root Sigil class used by the library as a base identity.\n *\n * This is produced by `Sigilify` and can serve as a basic sentinel/base\n * class for other sigil classes or for debugging/inspection.\n */\nexport const Sigil = BaseSigilify(class {});\nexport type Sigil = InstanceType<typeof Sigil>;\n\n/**\n * A sigil variant of the built-in `Error` constructor used by the library\n * to represent Sigil-specific errors.\n *\n * Use `SigilError` when you want an Error type that is identifiable via sigil\n * runtime checks (e.g. `SigilError.isOfType(someError)`).\n */\nexport const SigilError = Sigilify(Error, 'SigilError');\nexport type SigilError = InstanceType<typeof SigilError>;\n","import { handleSigilExplicit, isSigilCtor } from './helpers';\nimport type { SigilOptions } from './options';\n\n/**\n * Class decorator factory that attaches sigil statics to a class constructor.\n *\n * @param label - Sigil label string to assign to the decorated class (e.g. `@scope/pkg.ClassName`).\n * @param opts - Options object to override any global options if needed.\n * @returns A class decorator compatible with the ECMAScript decorator context.\n */\nexport function AttachSigil(label: string, opts?: SigilOptions) {\n return function (value: Function, context: any) {\n if (!isSigilCtor(value))\n throw new Error(\n `[Sigil Error] 'AttachSigil' decorator accept only Sigil classes but used on class '${value.name}'`\n );\n\n handleSigilExplicit(value, label, opts);\n };\n}\n\n/**\n * @deprecated Use 'AttachSigil' instead, updated for clarity. will be removed in v4\n */\nexport const WithSigil = AttachSigil;\n\n/**\n * Function that attaches runtime sigil metadata to Sigil class.\n * Alternative to '@AttachSigil' if you prefer normal functions.\n *\n * @typeParam S - Constructor type (should be an instance of sigil class).\n * @param Class - The constructor (class) to enhance.\n * @param label - Sigil label string to assign to the decorated class (e.g. `@scope/pkg.ClassName`).\n * @param opts - Options object to override any global options if needed.\n * @returns The same constructor value, with runtime metadata ensured.\n */\nexport function attachSigil<S extends Function>(Class: S, label: string, opts?: SigilOptions): S {\n if (!isSigilCtor(Class))\n throw new Error(\n `[Sigil Error] 'attachSigil' function accept only Sigil classes but used on class '${Class.name}'`\n );\n\n handleSigilExplicit(Class, label, opts);\n return Class;\n}\n\n/**\n * @deprecated Use 'attachSigil' instead, updated for clarity. will be removed in v4\n */\nexport const withSigil = attachSigil;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/symbols.ts","../src/is.ts","../src/options.ts","../src/sigilify.ts","../src/mixin.ts","../src/classes.ts","../src/attach.ts"],"names":["Sigil"],"mappings":";;;;EAKO,IAAM,SAAA,mBAAY,MAAA,CAAO,GAAA,CAAI,wBAAwB,CAAA;EAOrD,IAAM,iBAAA,mBAAoB,MAAA,CAAO,GAAA,CAAI,gCAAgC,CAAA;EASrE,IAAM,SAAA,mBAAY,MAAA,CAAO,GAAA,CAAI,wBAAwB,CAAA;EAOrD,IAAM,SAAA,mBAAY,MAAA,CAAO,GAAA,CAAI,wBAAwB,CAAA;;;ECnBrD,SAAS,YAAY,IAAA,EAAqC;EAC/D,EAAA,OAAO,OAAO,IAAA,KAAS,UAAA,IAAc,IAAA,CAAK,SAAA,IAAa,aAAa,IAAA,CAAK,SAAA;EAC3E;EASO,SAAS,gBAAgB,IAAA,EAA8B;EAC5D,EAAA,OAAO,CAAC,CAAC,IAAA,IAAQ,OAAO,IAAA,KAAS,YAAY,SAAA,IAAa,IAAA;EAC5D;;;ECSO,IAAM,OAAA,GAAkC;EAAA,EAC7C,eAAA,EAAiB;EACnB,CAAA;AAYO,MAAM,qBAAqB,CAAC,EAAE,kBAAkB,IAAA,EAAK,GAAkB,EAAC,KAAY;EACzF,EAAA,OAAA,CAAQ,eAAA,GAAkB,eAAA;EAC5B;AAaO,MAAM,uBAAA,GAA0B;;;ECpDvC,IAAM,QAAA,uBAAe,OAAA,EAAkB;EAGvC,IAAM,mBAAA,uBAA0B,OAAA,EAAkB;EAO3C,SAAS,QAAA,CAAS,IAAA,EAAgB,KAAA,EAAe,IAAA,EAA2B;EAEjF,EAAA,IAAI,QAAA,CAAS,IAAI,IAAI,CAAA;EACnB,IAAA,MAAM,IAAI,KAAA;EAAA,MACR,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C9B,CAAA;EACF;EAYO,SAAS,WAAA,CAAgC,KAAA,EAAU,KAAA,EAAe,IAAA,EAAwB;EAC/F,EAAA,IAAI,CAAC,YAAY,KAAK,CAAA;EACpB,IAAA,MAAM,IAAI,KAAA;EAAA,MACR,CAAA,kFAAA,EAAqF,MAAM,IAAI,CAAA,CAAA;EAAA,KACjG;EAEF,EAAA,QAAA,CAAS,KAAA,EAAO,OAAO,IAAI,CAAA;EAC3B,EAAA,OAAO,KAAA;EACT","file":"index.global.js","sourcesContent":["/**\n * Symbol to uniquely identify sigil classes.\n *\n * @constant {symbol}\n */\nexport const __SIGIL__ = Symbol.for('@vicin/sigil.__SIGIL__');\n\n/**\n * Symbol to store sigil lineage of a class\n *\n * @constant {symbol}\n */\nexport const __SIGIL_LINEAGE__ = Symbol.for('@vicin/sigil.__SIGIL_LINEAGE__');\n\n/**\n * Symbol used to store the identity label for a sigil constructor.\n *\n * Stored on the constructor as a non-enumerable property.\n *\n * @constant {symbol}\n */\nexport const __LABEL__ = Symbol.for('@vicin/sigil.__LABEL__');\n\n/**\n * Symbol used to store the depth inside Sigil chain. used in exact checks\n *\n * @constant {symbol}\n */\nexport const __DEPTH__ = Symbol.for('@vicin/sigil.__DEPTH__');\n","import type { Sigil } from './classes';\nimport { __SIGIL__ } from './symbols';\n\n/**\n * Runtime predicate that checks whether the provided value is a sigil constructor.\n *\n * @param ctor - Constructor to test.\n * @returns `true` if `value` is a sigil constructor, otherwise `false`.\n */\nexport function isSigilCtor(ctor: unknown): ctor is typeof Sigil {\n return typeof ctor === 'function' && ctor.prototype && __SIGIL__ in ctor.prototype;\n}\n\n/**\n * Runtime predicate that checks whether the provided object is an instance\n * of a sigil class.\n *\n * @param inst - The instanca to test.\n * @returns `true` if `obj` is an instance produced by a sigil constructor.\n */\nexport function isSigilInstance(inst: unknown): inst is Sigil {\n return !!inst && typeof inst === 'object' && __SIGIL__ in inst;\n}\n","/** -----------------------------------------\n * Types\n * ----------------------------------------- */\n\n/**\n * Configuration options for the Sigil library.\n *\n * These options control runtime validation, inheritance checks, label autofill behavior.\n */\nexport interface SigilOptions {\n /**\n * Validation rule applied to sigil labels before registration.\n *\n * - A function receives the label and must return `true` if valid.\n * - A `RegExp` must match the label.\n * - `null` disables validation entirely.\n *\n * Defaults to `null`.\n */\n labelValidation?: ((label: string) => boolean) | RegExp | null;\n}\n\n/** -----------------------------------------\n * Internal options object\n * ----------------------------------------- */\n\n/**\n * Defined SigilOptions used in the library.\n *\n * @internal\n */\nexport const OPTIONS: Required<SigilOptions> = {\n labelValidation: null,\n};\n\n/** -----------------------------------------\n * Update options\n * ----------------------------------------- */\n\n/**\n * Update runtime options for the Sigil library.\n * Call this early during application startup if you want non-default behavior.\n *\n * @param opts - Partial options to merge into the global `OPTIONS` object.\n */\nexport const updateSigilOptions = ({ labelValidation = null }: SigilOptions = {}): void => {\n OPTIONS.labelValidation = labelValidation;\n};\n\n/** -----------------------------------------\n * Label validation\n * ----------------------------------------- */\n\n/**\n * Label validation regex. Labels must follow the pattern\n * `@scope/package.ClassName` where `ClassName` begins with an uppercase\n * letter. This avoids collisions across packages and helps debugging.\n *\n * It's advised to use this regex in 'SigilOptions.labelValidation'.\n */\nexport const RECOMMENDED_LABEL_REGEX = /^@[\\w-]+(?:\\/[\\w-]+)*\\.[A-Z][A-Za-z0-9]*$/;\n","import { OPTIONS, type SigilOptions } from './options';\nimport { __LABEL__, __SIGIL__, __SIGIL_LINEAGE__, __DEPTH__ } from './symbols';\n\n/** -----------------------------------------\n * Maps\n * ----------------------------------------- */\n\n/** Weak set to ensure that every ctor is handled only once */\nconst resolved = new WeakSet<Function>();\n\n/** Weak set to store ctors that called sigilify function */\nconst hasOwnSigilRegistry = new WeakSet<Function>();\n\n/** -----------------------------------------\n * Main helpers\n * ----------------------------------------- */\n\n/** Main function to handle 'Sigil' and attach its metadata to the class when label is passed */\nexport function sigilify(ctor: Function, label: string, opts?: SigilOptions): void {\n // throw if already seen\n if (resolved.has(ctor))\n throw new Error(\n `[Sigil Error] Class '${ctor.name}' with label '${(ctor as any).SigilLabel}' is already sigilified`\n );\n // verify label\n verifyLabel(label, opts);\n // handle ancestors (add them to seen)\n handleAncestors(ctor);\n // sigilify ctor\n updateSigil(ctor, label);\n // mark as seen and register in hasOwnSigil set\n resolved.add(ctor);\n hasOwnSigilRegistry.add(ctor);\n}\n\nexport function hasOwnSigil(ctor: Function) {\n return hasOwnSigilRegistry.has(ctor);\n}\n\n/** -----------------------------------------\n * Generic helpers\n * ----------------------------------------- */\n\n/** Helper function to validate passed label */\nexport function verifyLabel<L extends string>(label: L, opts?: SigilOptions): void {\n // If validation regex or function is defined validate\n const labelValidation = opts?.labelValidation ?? OPTIONS.labelValidation;\n if (labelValidation) {\n let valid: boolean;\n if (labelValidation instanceof RegExp) valid = labelValidation.test(label);\n else valid = labelValidation(label);\n\n if (!valid)\n throw new Error(\n `[Sigil Error] Invalid Sigil label '${label}'. Make sure that supplied label matches validation regex or function`\n );\n }\n}\n\nfunction handleAncestors(ctor: Function) {\n let a = Object.getPrototypeOf(ctor);\n while (a && typeof a === 'function' && a.prototype[__SIGIL__]) {\n resolved.add(a);\n a = Object.getPrototypeOf(a);\n }\n}\n\nfunction updateSigil(ctor: Function, label: string) {\n // -------------------------\n // Get symbol from label\n // -------------------------\n\n const sym = Symbol.for(label);\n\n // -------------------------\n // Populate 'Sigil' symbols\n // -------------------------\n\n Object.defineProperty(ctor.prototype, __SIGIL__, {\n value: sym,\n configurable: false,\n enumerable: false,\n writable: false,\n });\n Object.defineProperty(ctor.prototype, __LABEL__, {\n value: label,\n configurable: false,\n enumerable: false,\n writable: false,\n });\n Object.defineProperty(ctor.prototype, __SIGIL_LINEAGE__, {\n value: [...(Object.getPrototypeOf(ctor)?.prototype[__SIGIL_LINEAGE__] ?? []), sym],\n configurable: false,\n enumerable: false,\n writable: false,\n });\n Object.defineProperty(ctor.prototype, __DEPTH__, {\n value: (ctor.prototype[__DEPTH__] ?? -1) + 1,\n configurable: false,\n enumerable: false,\n writable: false,\n });\n\n // -------------------------\n // Add { symbol: ture } pair\n // -------------------------\n\n Object.defineProperty(ctor.prototype, sym, {\n value: true,\n configurable: false,\n enumerable: false,\n writable: false,\n });\n}\n","import { isSigilCtor } from './is';\nimport { sigilify, hasOwnSigil } from './sigilify';\nimport type { SigilOptions } from './options';\nimport { __LABEL__, __SIGIL__, __SIGIL_LINEAGE__, __DEPTH__ } from './symbols';\nimport type { Constructor, ConstructorAbstract, GetPrototype, sigil, ExtendSigil } from './types';\n\n/**\n * Helper function to extend Base class with Sigil Class that should be present at the start of each Sigil chain\n * @param Base - The base constructor to extend.\n * @returns Base Sigil class at the start of each Sigil chain\n */\nexport function BaseSigilify(Base: ConstructorAbstract) {\n class Sigil extends Base {\n /**\n * Class-level identity label constant for this sigil constructor.\n */\n static get SigilLabel(): string {\n return (this as any).prototype[__LABEL__];\n }\n\n /**\n * Copy of the sigil label lineage for this instance's constructor.\n *\n * Useful for debugging and logging.\n *\n * @returns An array of sigil labels representing parent → child labels.\n */\n static get SigilLabelLineage(): readonly string[] {\n return (this as any).prototype[__SIGIL_LINEAGE__].map((v: symbol) => v.description);\n }\n\n /** Check if sigil label has been attached to this class */\n static get hasOwnSigil(): boolean {\n return hasOwnSigil(this);\n }\n\n /**\n * Compile-time nominal brand that encodes the class sigil labels object.\n */\n declare readonly [sigil]: {\n Sigil: true;\n };\n\n constructor(...args: any[]) {\n super(...args);\n }\n\n /**\n * Check whether `other` is (or inherits from) the instance represented by the\n * calling constructor.\n *\n * This replaces `instanceof` so that checks remain valid across bundles/realms\n * and when subclassing.\n *\n * @typeParam T - The specific sigil constructor (`this`).\n * @param this - The constructor performing the type check.\n * @param other - The object to test.\n * @returns A type guard asserting `other` is an instance of the constructor.\n */\n static isInstance<T>(this: T, other: any): other is GetPrototype<T> {\n if (other == null || typeof other !== 'object') return false;\n return other[(this as any).prototype[__SIGIL__]] === true;\n }\n\n /**\n * Check whether `other` is exactly the same instance represented by the\n * calling constructor.\n *\n * @typeParam T - The specific sigil constructor (`this`).\n * @param this - The constructor performing the type check.\n * @param other - The object to test.\n * @returns A type guard asserting `other` is an instance of the constructor.\n */\n static isExactInstance<T>(this: T, other: any): other is GetPrototype<T> {\n if (other == null || typeof other !== 'object') return false;\n if ((this as any).prototype[__DEPTH__] !== other[__DEPTH__]) return false;\n return other[(this as any).prototype[__SIGIL__]] === true;\n }\n\n /**\n * Check whether `other` is (or inherits from) the instance represented by the\n * calling constructor.\n *\n * This replaces `instanceof` so that checks remain valid across bundles/realms\n * and when subclassing.\n *\n * @typeParam T - The specific sigil constructor (`this`).\n * @param this - The constructor performing the type check.\n * @param other - The object to test.\n * @returns A type guard asserting `other` is an instance of the constructor.\n */\n isInstance<T>(this: T, other: any): other is T {\n if (other == null || typeof other !== 'object') return false;\n return other[(this as any)[__SIGIL__]] === true;\n }\n\n /**\n * Check whether `other` is exactly the same instance represented by the\n * calling constructor.\n *\n * @typeParam T - The specific sigil constructor (`this`).\n * @param this - The constructor performing the type check.\n * @param other - The object to test.\n * @returns A type guard asserting `other` is an instance of the constructor.\n */\n isExactInstance<T>(this: T, other: any): other is T {\n if (other == null || typeof other !== 'object') return false;\n if ((this as any)[__DEPTH__] !== (other as any)[__DEPTH__]) return false;\n return other[(this as any)[__SIGIL__]] === true;\n }\n\n /**\n * Returns the identity sigil label of this instance's constructor.\n *\n * @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil-auto:ClassName:1:pnf11bgl').\n */\n get SigilLabel(): string {\n return (this as any)[__LABEL__];\n }\n\n /**\n * Copy of the sigil label lineage for this instance's constructor.\n *\n * Useful for debugging and logging.\n *\n * @returns An array of sigil labels representing parent → child labels.\n */\n get SigilLabelLineage(): readonly string[] {\n return (this as any)[__SIGIL_LINEAGE__].map((v: symbol) => v.description);\n }\n\n /** Check if sigil label has been attached to this class */\n get hasOwnSigil(): boolean {\n return (this.constructor as unknown as Sigil).hasOwnSigil;\n }\n }\n\n sigilify(Sigil, 'Sigil');\n return Sigil;\n}\n\n/**\n * Mixin factory that augments an existing class with Sigil runtime metadata and helpers.\n *\n * @param Base - The base constructor to extend.\n * @param label - Identity label to attach to the resulting class (e.g. '@scope/pkg.ClassName').\n * @param opts - Options object to override any global options if needed.\n * @returns A new constructor that extends `Base` and includes Sigil statics/instance methods.\n * @throws Error if `Base` is already sigilified.\n */\nexport function Sigilify<L extends string>(Base: Constructor, label: L, opts?: SigilOptions) {\n if (isSigilCtor(Base))\n throw new Error(\n `[Sigil Error] Class '${Base.name}' with label '${Base.SigilLabel}' is already sigilified`\n );\n\n const BaseSigil = BaseSigilify(Base);\n class Sigilified extends BaseSigil {\n declare [sigil]: ExtendSigil<L, InstanceType<typeof BaseSigil>>;\n }\n\n sigilify(Sigilified, label, opts);\n return Sigilified;\n}\n\n/**\n * Mixin factory that augments an existing class with Sigil runtime metadata and helpers. Accept and return 'abstract' class.\n *\n * @param Base - The base constructor to extend.\n * @param label - Identity label to attach to the resulting class (e.g. '@scope/pkg.ClassName').\n * @param opts - Options object to override any global options if needed.\n * @returns A new abstract constructor that extends `Base` and includes Sigil statics/instance methods.\n * @throws Error if `Base` is already sigilified.\n */\nexport function SigilifyAbstract<L extends string>(\n Base: ConstructorAbstract,\n label: L,\n opts?: SigilOptions\n) {\n if (isSigilCtor(Base))\n throw new Error(\n `[Sigil Error] Class '${Base.name}' with label '${Base.SigilLabel}' is already sigilified`\n );\n\n const BaseSigil = BaseSigilify(Base);\n abstract class Sigilified extends BaseSigil {\n declare [sigil]: ExtendSigil<L, InstanceType<typeof BaseSigil>>;\n }\n\n sigilify(Sigilified, label, opts);\n return Sigilified;\n}\n","import { Sigilify, BaseSigilify } from './mixin';\nimport type { sigil } from './types';\n\n/**\n * A minimal root Sigil class used by the library as a base identity.\n *\n * This is produced by `Sigilify` and can serve as a basic sentinel/base\n * class for other sigil classes or for debugging/inspection.\n */\nexport const Sigil = BaseSigilify(class {});\nexport type Sigil = InstanceType<typeof Sigil>;\n\n/**\n * A sigil variant of the built-in `Error` constructor used by the library\n * to represent Sigil-specific errors.\n *\n * Use `SigilError` when you want an Error type that is identifiable via sigil\n * runtime checks (e.g. `SigilError.isInstance(someError)`).\n */\nexport const SigilError = Sigilify(Error, 'SigilError');\nexport type SigilError = InstanceType<typeof SigilError>;\n","import { isSigilCtor } from './is';\nimport { sigilify } from './sigilify';\nimport type { SigilOptions } from './options';\n\n/**\n * Class decorator factory that attaches sigil statics to a class constructor.\n *\n * @param label - Sigil label string to assign to the decorated class (e.g. `@scope/pkg.ClassName`).\n * @param opts - Options object to override any global options if needed.\n * @returns A class decorator compatible with the ECMAScript decorator context.\n */\nexport function AttachSigil(label: string, opts?: SigilOptions) {\n return function (target: Function, ctx: any) {\n if (!isSigilCtor(target))\n throw new Error(\n `[Sigil Error] 'AttachSigil' decorator accept only Sigil classes but used on class '${target.name}'`\n );\n\n sigilify(target, label, opts);\n };\n}\n\n/**\n * Function that attaches runtime sigil metadata to Sigil class.\n * Alternative to '@AttachSigil' if you prefer normal functions.\n *\n * @typeParam S - Constructor type (should be an instance of sigil class).\n * @param Class - The constructor (class) to enhance.\n * @param label - Sigil label string to assign to the decorated class (e.g. `@scope/pkg.ClassName`).\n * @param opts - Options object to override any global options if needed.\n * @returns The same constructor value, with runtime metadata ensured.\n */\nexport function attachSigil<S extends Function>(Class: S, label: string, opts?: SigilOptions): S {\n if (!isSigilCtor(Class))\n throw new Error(\n `[Sigil Error] 'attachSigil' function accept only Sigil classes but used on class '${Class.name}'`\n );\n\n sigilify(Class, label, opts);\n return Class;\n}\n"]}
|