@vicin/sigil 1.3.0 → 2.0.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/dist/index.mjs CHANGED
@@ -1,248 +1,21 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
1
+ import { createId } from '@paralleldrive/cuid2';
4
2
 
5
3
  // src/core/options.ts
6
4
  var OPTIONS = {
7
5
  labelValidation: null,
8
6
  skipLabelInheritanceCheck: false,
9
- autofillLabels: false,
10
- devMarker: false,
11
- registry: null,
12
- useGlobalRegistry: false,
13
- storeConstructor: false
7
+ autofillLabels: false
14
8
  };
15
- var __SIGIL_REGISTRY__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL_REGISTRY__");
16
- var updateGlobalRegistry = (map) => {
17
- if (map === null) delete globalThis[__SIGIL_REGISTRY__];
18
- else globalThis[__SIGIL_REGISTRY__] = map;
19
- };
20
- var getGlobalRegistry = () => {
21
- const val = globalThis[__SIGIL_REGISTRY__];
22
- return val === void 0 ? null : val;
23
- };
24
- var SigilRegistry = class _SigilRegistry {
25
- /**
26
- * @param map - Map used to register 'Sigil' classes. if not passed it will be auto-generated internally.
27
- */
28
- constructor(map) {
29
- /** Internal private registry map. */
30
- __publicField(this, "_registry");
31
- this._registry = map != null ? map : /* @__PURE__ */ new Map();
32
- }
33
- /**
34
- * Return a readonly view (array) of the current registry entries.
35
- *
36
- * @returns An array containing all registered labels, or an empty array when registry is disabled.
37
- */
38
- listLabels() {
39
- return this._registry ? Array.from(this._registry.keys()) : [];
40
- }
41
- /**
42
- * Determine whether the registry currently contains `label`.
43
- *
44
- * @param label - The label to test.
45
- * @returns `true` if present; `false` otherwise.
46
- */
47
- has(label) {
48
- return !!this._registry && this._registry.has(label);
49
- }
50
- /**
51
- * Get class constructor using its label.
52
- *
53
- * @param label - Label appended to Sigil class.
54
- * @returns Reference to Sigil class constructor or null if stored with 'SigilOptions.storeConstructor = false'.
55
- */
56
- get(label) {
57
- var _a;
58
- return (_a = this._registry.get(label)) != null ? _a : null;
59
- }
60
- /**
61
- * Register a label and class constructor in the active registry.
62
- *
63
- * If the label already exists then:
64
- * - In DEV builds: prints a console warning (HMR friendly) and returns early.
65
- * - In non-DEV builds: throws an Error to prevent duplicate registration.
66
- *
67
- * @param label - Label string to register (e.g. '@scope/pkg.ClassName').
68
- * @param Class - Constructor of the class being registered.
69
- * @param opts - Optional per-call overrides.
70
- */
71
- register(label, Class, opts) {
72
- var _a, _b, _c, _d;
73
- if (!OPTIONS.registry) return;
74
- const storeCtor = (_a = opts == null ? void 0 : opts.storeConstructor) != null ? _a : OPTIONS.storeConstructor;
75
- const devMarker = (_b = opts == null ? void 0 : opts.devMarker) != null ? _b : OPTIONS.devMarker;
76
- if (this._registry.has(label)) {
77
- const existing = this._registry.get(label);
78
- const isLikelyHMR = (existing == null ? void 0 : existing.name) === (Class == null ? void 0 : Class.name);
79
- if (devMarker) {
80
- if (isLikelyHMR) {
81
- console.warn(
82
- `[Sigil] Duplicate label "${label}" may be due to HMR \u2014 ignore if you are sure that it's defined once.`
83
- );
84
- } else {
85
- throw new Error(
86
- `[Sigil Error] Duplicate label '${label}' (different classes: ${(_c = existing == null ? void 0 : existing.name) != null ? _c : "unknown"} vs ${(_d = Class == null ? void 0 : Class.name) != null ? _d : "unknown"}).`
87
- );
88
- }
89
- } else {
90
- throw new Error(
91
- `[Sigil Error] Duplicate label '${label}' detected. Labels must be unique.`
92
- );
93
- }
94
- } else {
95
- this._registry.set(label, storeCtor ? Class : null);
96
- }
97
- }
98
- /**
99
- * Alias for 'SigilRegistry.register'.
100
- *
101
- * @param label - Label string to register (e.g. '@scope/pkg.ClassName').
102
- * @param Class - Constructor of the class being registered.
103
- * @param opts - Optional per-call overrides.
104
- */
105
- set(label, Class, opts) {
106
- return this.register(label, Class, opts);
107
- }
108
- /**
109
- * Unregister a previously registered class.
110
- *
111
- * @param label - The label to remove from the registry.
112
- * @returns `true` if the label was present and removed; `false` otherwise (or when registry is disabled).
113
- */
114
- unregister(label) {
115
- return this._registry.delete(label);
116
- }
117
- /**
118
- * Alias for 'SigilRegistry.unregister'.
119
- *
120
- * @param label - The label to remove from the registry.
121
- * @returns `true` if the label was present and removed; `false` otherwise (or when registry is disabled).
122
- */
123
- delete(label) {
124
- return this.unregister(label);
125
- }
126
- /**
127
- * Replace active registry with new one. deprecated use 'updateOptions({ registry: newRegistry })' instead.
128
- *
129
- * @deprecated Will be removed in v2.0.0, check https://www.npmjs.com/package/@vicin/sigil?activeTab=readme#deprecated-api for more details.
130
- * @param newRegistry - New Set<string> instance to use as the active registry, or `null` to disable checks.
131
- */
132
- replaceRegistry(newRegistry) {
133
- if (newRegistry) updateOptions({ registry: new _SigilRegistry(newRegistry) });
134
- else updateOptions({ registry: newRegistry });
135
- }
136
- /**
137
- * Clear the registry completely.
138
- *
139
- * Useful for test teardown, or when explicitly resetting state during development.
140
- * No-op when the registry is disabled.
141
- */
142
- clear() {
143
- this._registry.clear();
144
- }
145
- /**
146
- * Merge another SigilRegistry into this one.
147
- *
148
- * Entries from `other` will be registered into this registry. Duplicate labels
149
- * are handled via this registry's `register` logic (i.e., will warn in DEV or
150
- * throw in production).
151
- *
152
- * @param other - Another `SigilRegistry` whose entries will be merged into this registry.
153
- */
154
- merge(other) {
155
- if (!OPTIONS.registry) return;
156
- for (const [label, ctor] of other) this.register(label, ctor);
157
- }
158
- /**
159
- * Return a Map-style iterator over entries: `[label, constructor]`.
160
- * Equivalent to calling `registry[Symbol.iterator]()`.
161
- *
162
- * @returns IterableIterator of `[label, ISigil]`.
163
- */
164
- entries() {
165
- return this._registry.entries();
166
- }
167
- /**
168
- * Return an iterator over registered constructors.
169
- *
170
- * @returns IterableIterator of `ISigil` constructors.
171
- */
172
- values() {
173
- return this._registry.values();
174
- }
175
- /**
176
- * Return an iterator over registered labels (keys).
177
- *
178
- * @returns IterableIterator of `string` labels.
179
- */
180
- keys() {
181
- return this._registry.keys();
182
- }
183
- /**
184
- * Execute a provided function once per registry entry.
185
- *
186
- * @param callback - Function invoked with `(ctor, label)` for each entry.
187
- * @param thisArg - Optional `this` context for the callback.
188
- */
189
- forEach(callback, thisArg) {
190
- this._registry.forEach((ctor, label) => callback.call(thisArg, ctor, label));
191
- }
192
- /**
193
- * Get the size (number of entries) of the active registry.
194
- *
195
- * @returns The number of registered labels, or 0 when registry is disabled.
196
- */
197
- get size() {
198
- return this._registry.size;
199
- }
200
- /**
201
- * Return an iterator over `[label, constructor]` pairs.
202
- *
203
- * This makes the registry compatible with `for..of` and other iterable helpers:
204
- * ```ts
205
- * for (const [label, ctor] of registry) { ... }
206
- * ```
207
- *
208
- * @returns An iterable iterator that yields `[label, ISigil]` tuples.
209
- */
210
- [Symbol.iterator]() {
211
- return this._registry[Symbol.iterator]();
212
- }
213
- };
214
- var getActiveRegistry = () => {
215
- const globalRegistry = getGlobalRegistry();
216
- if (globalRegistry) return globalRegistry;
217
- return OPTIONS.registry;
218
- };
219
- var REGISTRY = OPTIONS.registry;
220
- var DEFAULT_LABEL_REGEX = /^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;
221
- var updateOptions = (opts, mergeRegistries = true) => {
222
- applyBeforeSideEffects(OPTIONS, opts, mergeRegistries);
9
+ var updateOptions = (opts) => {
223
10
  for (const [k, v] of Object.entries(opts)) OPTIONS[k] = v;
224
- applyAfterSideEffects(OPTIONS);
225
11
  };
226
- function applyBeforeSideEffects(oldOpts, newOpts, mergeRegistries) {
227
- if (mergeRegistries && newOpts.registry && oldOpts.registry)
228
- newOpts.registry.merge(oldOpts.registry);
229
- }
230
- function applyAfterSideEffects(opts) {
231
- if (opts.useGlobalRegistry) updateGlobalRegistry(opts.registry);
232
- else updateGlobalRegistry(null);
233
- if (OPTIONS.registry) REGISTRY = OPTIONS.registry;
234
- else REGISTRY = new SigilRegistry();
235
- }
236
12
  var DEFAULT_OPTIONS = {
237
13
  labelValidation: null,
238
14
  skipLabelInheritanceCheck: false,
239
- autofillLabels: false,
240
- devMarker: process.env.NODE_ENV !== "production",
241
- registry: new SigilRegistry(),
242
- useGlobalRegistry: true,
243
- storeConstructor: true
15
+ autofillLabels: false
244
16
  };
245
17
  updateOptions(DEFAULT_OPTIONS);
18
+ var DEFAULT_LABEL_REGEX = /^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;
246
19
 
247
20
  // src/core/symbols.ts
248
21
  var __SIGIL__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL__");
@@ -250,41 +23,34 @@ var __SIGIL_BASE__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL_BASE__");
250
23
  var __DECORATED__ = /* @__PURE__ */ Symbol.for("@Sigil.__DECORATED__");
251
24
  var __INHERITANCE_CHECKED__ = /* @__PURE__ */ Symbol.for("@Sigil.__INHERITANCE_CHECKED__");
252
25
  var __LABEL__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL__");
253
- var __TYPE__ = /* @__PURE__ */ Symbol.for("@Sigil.__TYPE__");
254
- var __TYPE_LINEAGE__ = /* @__PURE__ */ Symbol.for("@Sigil.__TYPE_LINEAGE__");
255
- var __TYPE_SET__ = /* @__PURE__ */ Symbol.for("@Sigil.__TYPE_SET__");
26
+ var __LABEL_LINEAGE__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL_LINEAGE__");
27
+ var __LABEL_SET__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL_SET__");
28
+
29
+ // src/core/constants.ts
30
+ var __DEV__ = typeof process !== "undefined" && process.env.NODE_ENV === "development";
256
31
 
257
32
  // src/core/helpers.ts
258
- function decorateCtor(ctor, label, opts, isMixin = false) {
259
- var _a;
33
+ function decorateCtor(ctor, label, isMixin = false) {
260
34
  if (isDecorated(ctor))
261
35
  throw new Error(
262
36
  `Constructor ${ctor} is already decorated. if you are using 'withSigilTyped()' & '@WithSigil()' at the same time remove one of them.`
263
37
  );
264
- const symbol = Symbol.for(label);
265
- (_a = getActiveRegistry()) == null ? void 0 : _a.register(label, ctor, opts);
266
38
  Object.defineProperty(ctor, __LABEL__, {
267
39
  value: label,
268
40
  configurable: false,
269
41
  enumerable: false,
270
42
  writable: false
271
43
  });
272
- Object.defineProperty(ctor, __TYPE__, {
273
- value: symbol,
274
- configurable: false,
275
- enumerable: false,
276
- writable: false
277
- });
278
44
  const parent = Object.getPrototypeOf(ctor);
279
- const parentChain = parent && parent[__TYPE_LINEAGE__] ? parent[__TYPE_LINEAGE__] : [];
280
- const ctorChain = isMixin && label !== "Sigil" ? [/* @__PURE__ */ Symbol.for("Sigil"), ...parentChain, symbol] : [...parentChain, symbol];
281
- Object.defineProperty(ctor, __TYPE_LINEAGE__, {
45
+ const parentChain = parent && parent[__LABEL_LINEAGE__] ? parent[__LABEL_LINEAGE__] : [];
46
+ const ctorChain = isMixin && label !== "Sigil" ? ["Sigil", ...parentChain, label] : [...parentChain, label];
47
+ Object.defineProperty(ctor, __LABEL_LINEAGE__, {
282
48
  value: ctorChain,
283
49
  configurable: false,
284
50
  enumerable: false,
285
51
  writable: false
286
52
  });
287
- Object.defineProperty(ctor, __TYPE_SET__, {
53
+ Object.defineProperty(ctor, __LABEL_SET__, {
288
54
  value: new Set(ctorChain),
289
55
  configurable: false,
290
56
  enumerable: false,
@@ -293,11 +59,9 @@ function decorateCtor(ctor, label, opts, isMixin = false) {
293
59
  markDecorated(ctor);
294
60
  }
295
61
  function checkInheritance(ctor, opts) {
296
- var _a, _b, _c;
297
- const devMarker = (_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker;
298
- const skipLabelInheritanceCheck = (_b = opts == null ? void 0 : opts.skipLabelInheritanceCheck) != null ? _b : OPTIONS.skipLabelInheritanceCheck;
299
- const autofillLabels = (_c = opts == null ? void 0 : opts.autofillLabels) != null ? _c : OPTIONS.autofillLabels;
300
- if (!devMarker) return;
62
+ var _a, _b;
63
+ const skipLabelInheritanceCheck = (_a = opts == null ? void 0 : opts.skipLabelInheritanceCheck) != null ? _a : OPTIONS.skipLabelInheritanceCheck;
64
+ const autofillLabels = (_b = opts == null ? void 0 : opts.autofillLabels) != null ? _b : OPTIONS.autofillLabels;
301
65
  if (!isSigilCtor(ctor)) return;
302
66
  if (isInheritanceChecked(ctor) || skipLabelInheritanceCheck) return;
303
67
  const ctors = [ctor];
@@ -319,7 +83,7 @@ function checkInheritance(ctor, opts) {
319
83
  );
320
84
  }
321
85
  label = generateRandomLabel();
322
- decorateCtor(ctor2, label, opts);
86
+ decorateCtor(ctor2, label);
323
87
  }
324
88
  labelOwner.set(label, ctor2.name);
325
89
  }
@@ -338,10 +102,8 @@ function verifyLabel(label, opts) {
338
102
  );
339
103
  }
340
104
  }
341
- function generateRandomLabel(length = 16) {
342
- let label = generateRandomString(length);
343
- const registry = getActiveRegistry();
344
- if (registry) while (registry.has(label)) label = generateRandomLabel();
105
+ function generateRandomLabel() {
106
+ let label = createId();
345
107
  return `@Sigil.auto-${label}`;
346
108
  }
347
109
  function markSigil(ctor) {
@@ -403,14 +165,6 @@ function getConstructor(obj) {
403
165
  if (!obj || typeof obj !== "object") return null;
404
166
  return (_c = (_b = obj.constructor) != null ? _b : (_a = Object.getPrototypeOf(obj)) == null ? void 0 : _a.constructor) != null ? _c : null;
405
167
  }
406
- function generateRandomString(length = 16) {
407
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
408
- let result = "";
409
- for (let i = 0; i < length; i++) {
410
- result += chars.charAt(Math.floor(Math.random() * chars.length));
411
- }
412
- return result;
413
- }
414
168
 
415
169
  // src/core/mixin.ts
416
170
  function Sigilify(Base, label, opts) {
@@ -428,49 +182,39 @@ function Sigilify(Base, label, opts) {
428
182
  return this[__LABEL__];
429
183
  }
430
184
  /**
431
- * Class-level unique runtime symbol used as the type identifier.
432
- *
433
- * This symbol is created with `Symbol.for(label)` during decoration so it is
434
- * stable across realms that share the same global symbol registry.
435
- */
436
- static get SigilType() {
437
- return this[__TYPE__];
438
- }
439
- /**
440
- * Copy of the linearized sigil type symbol chain for the current constructor.
185
+ * Copy of the linearized sigil type label chain for the current constructor.
441
186
  *
442
187
  * Useful for debugging and performing strict lineage comparisons.
443
188
  *
444
- * @returns An array of symbols representing parent → child type symbols.
189
+ * @returns An array of labels representing parent → child type labels.
445
190
  */
446
- static get SigilTypeLineage() {
191
+ static get SigilLabelLineage() {
447
192
  var _a;
448
- return [...(_a = this[__TYPE_LINEAGE__]) != null ? _a : []];
193
+ return [...(_a = this[__LABEL_LINEAGE__]) != null ? _a : []];
449
194
  }
450
195
  /**
451
- * Copy of the sigil type symbol set for the current constructor.
196
+ * Copy of the sigil type label set for the current constructor.
452
197
  *
453
198
  * Useful for quick membership checks (O(1) lookups) and debugging.
454
199
  *
455
- * @returns A Readonly Set of symbols that represent the type lineage.
200
+ * @returns A Readonly Set of labels that represent the type lineage.
456
201
  */
457
- static get SigilTypeSet() {
202
+ static get SigilLabelSet() {
458
203
  const set = /* @__PURE__ */ new Set();
459
- for (const s of this[__TYPE_SET__]) set.add(s);
204
+ for (const s of this[__LABEL_SET__]) set.add(s);
460
205
  return set;
461
206
  }
462
207
  constructor(...args) {
463
- var _a;
464
208
  super(...args);
465
209
  if (Object.getPrototypeOf(this) !== new.target.prototype)
466
210
  Object.setPrototypeOf(this, new.target.prototype);
467
211
  const ctor = getConstructor(this);
468
212
  if (!ctor) {
469
- if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
213
+ if (__DEV__)
470
214
  throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
471
215
  return;
472
216
  }
473
- checkInheritance(ctor);
217
+ if (__DEV__) checkInheritance(ctor);
474
218
  }
475
219
  /**
476
220
  * Runtime predicate indicating whether `obj` is an instance produced by a sigil class.
@@ -495,12 +239,12 @@ function Sigilify(Base, label, opts) {
495
239
  static isOfType(other) {
496
240
  var _a;
497
241
  if (!isSigilInstance(other)) return false;
498
- const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_SET__];
499
- const thisType = this[__TYPE__];
242
+ const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
243
+ const thisType = this[__LABEL__];
500
244
  return !!otherSet && otherSet.has(thisType);
501
245
  }
502
246
  /**
503
- * Strict lineage check: compares the type symbol lineage arrays element-by-element.
247
+ * Strict lineage check: compares the type label lineage arrays element-by-element.
504
248
  *
505
249
  * @typeParam T - The calling constructor type.
506
250
  * @param this - The constructor performing the check.
@@ -510,8 +254,8 @@ function Sigilify(Base, label, opts) {
510
254
  static isOfTypeStrict(other) {
511
255
  var _a;
512
256
  if (!isSigilInstance(other)) return false;
513
- const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_LINEAGE__];
514
- const thisLineage = this[__TYPE_LINEAGE__];
257
+ const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
258
+ const thisLineage = this[__LABEL_LINEAGE__];
515
259
  return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
516
260
  }
517
261
  /**
@@ -527,12 +271,12 @@ function Sigilify(Base, label, opts) {
527
271
  isOfType(other) {
528
272
  var _a;
529
273
  if (!isSigilInstance(other)) return false;
530
- const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_SET__];
531
- const thisType = getConstructor(this)[__TYPE__];
274
+ const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
275
+ const thisType = getConstructor(this)[__LABEL__];
532
276
  return !!otherSet && otherSet.has(thisType);
533
277
  }
534
278
  /**
535
- * Strict lineage check: compares the type symbol lineage arrays element-by-element.
279
+ * Strict lineage check: compares the type label lineage arrays element-by-element.
536
280
  *
537
281
  * Allows 'instanceof' like checks but in instances.
538
282
  *
@@ -544,8 +288,8 @@ function Sigilify(Base, label, opts) {
544
288
  isOfTypeStrict(other) {
545
289
  var _a, _b;
546
290
  if (!isSigilInstance(other)) return false;
547
- const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_LINEAGE__];
548
- const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__TYPE_LINEAGE__];
291
+ const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
292
+ const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__LABEL_LINEAGE__];
549
293
  return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
550
294
  }
551
295
  /**
@@ -554,62 +298,44 @@ function Sigilify(Base, label, opts) {
554
298
  * @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' in DEV when constructor is missing.
555
299
  */
556
300
  getSigilLabel() {
557
- var _a;
558
301
  const ctor = getConstructor(this);
559
302
  if (!ctor) {
560
- if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
303
+ if (__DEV__)
561
304
  throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
562
305
  return "@Sigil.unknown";
563
306
  }
564
307
  return ctor.SigilLabel;
565
308
  }
566
309
  /**
567
- * Returns the runtime sigil type symbol of this instance's constructor.
310
+ * Returns a copy of the sigil type label lineage for this instance's constructor.
568
311
  *
569
- * @returns The symbol that identifies this type at runtime.
312
+ * @returns readonly array of labels representing the type lineage.
570
313
  */
571
- getSigilType() {
572
- var _a;
314
+ getSigilLabelLineage() {
573
315
  const ctor = getConstructor(this);
574
316
  if (!ctor) {
575
- if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
317
+ if (__DEV__)
576
318
  throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
577
- return /* @__PURE__ */ Symbol.for("@Sigil.unknown");
319
+ return ["@Sigil.unknown"];
578
320
  }
579
- return ctor.SigilType;
321
+ return ctor.SigilLabelLineage;
580
322
  }
581
323
  /**
582
- * Returns a copy of the sigil type symbol lineage for this instance's constructor.
324
+ * Returns a readonly copy of the sigil type label set for this instance's constructor.
583
325
  *
584
- * @returns readonly array of symbols representing the type lineage.
326
+ * @returns A Readonly Set of labels representing the type lineage for O(1) membership tests.
585
327
  */
586
- getSigilTypeLineage() {
587
- var _a;
328
+ getSigilLabelSet() {
588
329
  const ctor = getConstructor(this);
589
330
  if (!ctor) {
590
- if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
331
+ if (__DEV__)
591
332
  throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
592
- return [/* @__PURE__ */ Symbol.for("@Sigil.unknown")];
333
+ return /* @__PURE__ */ new Set(["@Sigil.unknown"]);
593
334
  }
594
- return ctor.SigilTypeLineage;
595
- }
596
- /**
597
- * Returns a readonly copy of the sigil type symbol set for this instance's constructor.
598
- *
599
- * @returns A Readonly Set of symbols representing the type lineage for O(1) membership tests.
600
- */
601
- getSigilTypeSet() {
602
- var _a;
603
- const ctor = getConstructor(this);
604
- if (!ctor) {
605
- if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
606
- throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
607
- return /* @__PURE__ */ new Set([/* @__PURE__ */ Symbol.for("@Sigil.unknown")]);
608
- }
609
- return ctor.SigilTypeSet;
335
+ return ctor.SigilLabelSet;
610
336
  }
611
337
  }
612
- decorateCtor(Sigilified, l, opts, true);
338
+ decorateCtor(Sigilified, l, true);
613
339
  markSigil(Sigilified);
614
340
  markSigilBase(Sigilified);
615
341
  return Sigilified;
@@ -629,49 +355,39 @@ function SigilifyAbstract(Base, label, opts) {
629
355
  return this[__LABEL__];
630
356
  }
631
357
  /**
632
- * Class-level unique runtime symbol used as the type identifier.
633
- *
634
- * This symbol is created with `Symbol.for(label)` during decoration so it is
635
- * stable across realms that share the same global symbol registry.
636
- */
637
- static get SigilType() {
638
- return this[__TYPE__];
639
- }
640
- /**
641
- * Copy of the linearized sigil type symbol chain for the current constructor.
358
+ * Copy of the linearized sigil type label chain for the current constructor.
642
359
  *
643
360
  * Useful for debugging and performing strict lineage comparisons.
644
361
  *
645
- * @returns An array of symbols representing parent → child type symbols.
362
+ * @returns An array of labels representing parent → child type labels.
646
363
  */
647
- static get SigilTypeLineage() {
364
+ static get SigilLabelLineage() {
648
365
  var _a;
649
- return [...(_a = this[__TYPE_LINEAGE__]) != null ? _a : []];
366
+ return [...(_a = this[__LABEL_LINEAGE__]) != null ? _a : []];
650
367
  }
651
368
  /**
652
- * Copy of the sigil type symbol set for the current constructor.
369
+ * Copy of the sigil type label set for the current constructor.
653
370
  *
654
371
  * Useful for quick membership checks (O(1) lookups) and debugging.
655
372
  *
656
- * @returns A Readonly Set of symbols that represent the type lineage.
373
+ * @returns A Readonly Set of labels that represent the type lineage.
657
374
  */
658
- static get SigilTypeSet() {
375
+ static get SigilLabelSet() {
659
376
  const set = /* @__PURE__ */ new Set();
660
- for (const s of this[__TYPE_SET__]) set.add(s);
377
+ for (const s of this[__LABEL_SET__]) set.add(s);
661
378
  return set;
662
379
  }
663
380
  constructor(...args) {
664
- var _a;
665
381
  super(...args);
666
382
  if (Object.getPrototypeOf(this) !== new.target.prototype)
667
383
  Object.setPrototypeOf(this, new.target.prototype);
668
384
  const ctor = getConstructor(this);
669
385
  if (!ctor) {
670
- if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
386
+ if (__DEV__)
671
387
  throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
672
388
  return;
673
389
  }
674
- checkInheritance(ctor);
390
+ if (__DEV__) checkInheritance(ctor);
675
391
  }
676
392
  /**
677
393
  * Runtime predicate indicating whether `obj` is an instance produced by a sigil class.
@@ -686,7 +402,7 @@ function SigilifyAbstract(Base, label, opts) {
686
402
  * Check whether `other` is (or inherits from) the type represented by the calling constructor.
687
403
  *
688
404
  * Implementation detail:
689
- * - Uses the other instance's `__TYPE_SET__` for O(1) membership test.
405
+ * - Uses the other instance's `__LABEL_SET__` for O(1) membership test.
690
406
  * - O(1) and reliable as long as `OPTIONS.skipLabelInheritanceCheck` is `false`.
691
407
  *
692
408
  * This replaces `instanceof` so that checks remain valid across bundles/realms
@@ -700,12 +416,12 @@ function SigilifyAbstract(Base, label, opts) {
700
416
  static isOfType(other) {
701
417
  var _a;
702
418
  if (!isSigilInstance(other) || !isSigilCtor(this)) return false;
703
- const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_SET__];
704
- const thisType = this[__TYPE__];
419
+ const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
420
+ const thisType = this[__LABEL__];
705
421
  return !!otherSet && otherSet.has(thisType);
706
422
  }
707
423
  /**
708
- * Strict lineage check: compares the type symbol lineage arrays element-by-element.
424
+ * Strict lineage check: compares the type label lineage arrays element-by-element.
709
425
  *
710
426
  * Implementation detail:
711
427
  * - Works in O(n) time where n is the depth of the lineage.
@@ -719,8 +435,8 @@ function SigilifyAbstract(Base, label, opts) {
719
435
  static isOfTypeStrict(other) {
720
436
  var _a;
721
437
  if (!isSigilInstance(other) || !isSigilCtor(this)) return false;
722
- const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_LINEAGE__];
723
- const thisLineage = this[__TYPE_LINEAGE__];
438
+ const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
439
+ const thisLineage = this[__LABEL_LINEAGE__];
724
440
  return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
725
441
  }
726
442
  /**
@@ -736,12 +452,12 @@ function SigilifyAbstract(Base, label, opts) {
736
452
  isOfType(other) {
737
453
  var _a;
738
454
  if (!isSigilInstance(other) || !isSigilInstance(this)) return false;
739
- const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_SET__];
740
- const thisType = getConstructor(this)[__TYPE__];
455
+ const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
456
+ const thisType = getConstructor(this)[__LABEL__];
741
457
  return !!otherSet && otherSet.has(thisType);
742
458
  }
743
459
  /**
744
- * Strict lineage check: compares the type symbol lineage arrays element-by-element.
460
+ * Strict lineage check: compares the type label lineage arrays element-by-element.
745
461
  *
746
462
  * Allows 'instanceof' like checks but in instances.
747
463
  *
@@ -753,8 +469,8 @@ function SigilifyAbstract(Base, label, opts) {
753
469
  isOfTypeStrict(other) {
754
470
  var _a, _b;
755
471
  if (!isSigilInstance(other) || !isSigilInstance(this)) return false;
756
- const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__TYPE_LINEAGE__];
757
- const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__TYPE_LINEAGE__];
472
+ const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
473
+ const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__LABEL_LINEAGE__];
758
474
  return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
759
475
  }
760
476
  /**
@@ -763,62 +479,44 @@ function SigilifyAbstract(Base, label, opts) {
763
479
  * @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' in DEV when constructor is missing.
764
480
  */
765
481
  getSigilLabel() {
766
- var _a;
767
482
  const ctor = getConstructor(this);
768
483
  if (!ctor) {
769
- if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
484
+ if (__DEV__)
770
485
  throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
771
486
  return "@Sigil.unknown";
772
487
  }
773
488
  return ctor.SigilLabel;
774
489
  }
775
490
  /**
776
- * Returns the runtime sigil type symbol of this instance's constructor.
491
+ * Returns a copy of the sigil type label lineage for this instance's constructor.
777
492
  *
778
- * @returns The symbol that identifies this type at runtime.
493
+ * @returns readonly array of labels representing the type lineage.
779
494
  */
780
- getSigilType() {
781
- var _a;
782
- const ctor = getConstructor(this);
783
- if (!ctor) {
784
- if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
785
- throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
786
- return /* @__PURE__ */ Symbol.for("@Sigil.unknown");
787
- }
788
- return ctor.SigilType;
789
- }
790
- /**
791
- * Returns a copy of the sigil type symbol lineage for this instance's constructor.
792
- *
793
- * @returns readonly array of symbols representing the type lineage.
794
- */
795
- getSigilTypeLineage() {
796
- var _a;
495
+ getSigilLabelLineage() {
797
496
  const ctor = getConstructor(this);
798
497
  if (!ctor) {
799
- if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
498
+ if (__DEV__)
800
499
  throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
801
- return [/* @__PURE__ */ Symbol.for("@Sigil.unknown")];
500
+ return ["@Sigil.unknown"];
802
501
  }
803
- return ctor.SigilTypeLineage;
502
+ return ctor.SigilLabelLineage;
804
503
  }
805
504
  /**
806
- * Returns a readonly copy of the sigil type symbol set for this instance's constructor.
505
+ * Returns a readonly copy of the sigil type label set for this instance's constructor.
807
506
  *
808
- * @returns A Readonly Set of symbols representing the type lineage for O(1) membership tests.
507
+ * @returns A Readonly Set of labels representing the type lineage for O(1) membership tests.
809
508
  */
810
- getSigilTypeSet() {
811
- var _a;
509
+ getSigilLabelSet() {
812
510
  const ctor = getConstructor(this);
813
511
  if (!ctor) {
814
- if ((_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker)
512
+ if (__DEV__)
815
513
  throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
816
- return /* @__PURE__ */ new Set([/* @__PURE__ */ Symbol.for("@Sigil.unknown")]);
514
+ return /* @__PURE__ */ new Set(["@Sigil.unknown"]);
817
515
  }
818
- return ctor.SigilTypeSet;
516
+ return ctor.SigilLabelSet;
819
517
  }
820
518
  }
821
- decorateCtor(Sigilified, l, opts, true);
519
+ decorateCtor(Sigilified, l, true);
822
520
  markSigil(Sigilified);
823
521
  markSigilBase(Sigilified);
824
522
  return Sigilified;
@@ -842,8 +540,8 @@ function WithSigil(label, opts) {
842
540
  throw new Error(
843
541
  `[Sigil Error] 'WithSigil' decorator accept only Sigil classes but used on class ${value.name}`
844
542
  );
845
- decorateCtor(value, l, opts);
846
- checkInheritance(value, opts);
543
+ decorateCtor(value, l);
544
+ if (__DEV__) checkInheritance(value, opts);
847
545
  };
848
546
  }
849
547
 
@@ -860,24 +558,8 @@ function withSigil(Class, label, opts) {
860
558
  l = label;
861
559
  } else l = generateRandomLabel();
862
560
  const ctor = Class;
863
- decorateCtor(ctor, l, opts);
864
- checkInheritance(ctor, opts);
865
- return Class;
866
- }
867
- function typed(Class, label, opts) {
868
- var _a, _b;
869
- const devMarker = (_a = opts == null ? void 0 : opts.devMarker) != null ? _a : OPTIONS.devMarker;
870
- if (!isSigilCtor(Class))
871
- throw new Error(
872
- `[Sigil Error] 'typed' HOF accept only Sigil classes but used on class ${(_b = Class == null ? void 0 : Class.name) != null ? _b : "unknown"}`
873
- );
874
- if (devMarker && label) {
875
- const runtimeLabel = Class.SigilLabel;
876
- if (runtimeLabel && runtimeLabel !== label)
877
- throw new Error(
878
- `[Sigil Error][typed] runtime label "${runtimeLabel}" does not match asserted label "${label}".`
879
- );
880
- }
561
+ decorateCtor(ctor, l);
562
+ if (__DEV__) checkInheritance(ctor, opts);
881
563
  return Class;
882
564
  }
883
565
  function withSigilTyped(Class, label, opts) {
@@ -892,11 +574,11 @@ function withSigilTyped(Class, label, opts) {
892
574
  l = label;
893
575
  } else l = generateRandomLabel();
894
576
  const ctor = Class;
895
- decorateCtor(ctor, l, opts);
896
- checkInheritance(ctor, opts);
577
+ decorateCtor(ctor, l);
578
+ if (__DEV__) checkInheritance(ctor, opts);
897
579
  return Class;
898
580
  }
899
581
 
900
- export { DEFAULT_LABEL_REGEX, REGISTRY, Sigil, SigilError, SigilRegistry, Sigilify, SigilifyAbstract, WithSigil, getActiveRegistry, isDecorated, isInheritanceChecked, isSigilBaseCtor, isSigilBaseInstance, isSigilCtor, isSigilInstance, typed, updateOptions, withSigil, withSigilTyped };
582
+ export { DEFAULT_LABEL_REGEX, Sigil, SigilError, Sigilify, SigilifyAbstract, WithSigil, isDecorated, isInheritanceChecked, isSigilBaseCtor, isSigilBaseInstance, isSigilCtor, isSigilInstance, updateOptions, withSigil, withSigilTyped };
901
583
  //# sourceMappingURL=index.mjs.map
902
584
  //# sourceMappingURL=index.mjs.map