assign-gingerly 0.0.49 → 0.0.50
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/defineWithFeatures.js +5 -1
- package/defineWithFeatures.ts +15 -1
- package/package.json +1 -1
package/defineWithFeatures.js
CHANGED
|
@@ -52,7 +52,7 @@ const resolvedSpawnCache = new WeakMap();
|
|
|
52
52
|
* @param registry - Optional custom element registry (defaults to global `customElements`)
|
|
53
53
|
* @returns The newly created and defined custom element class
|
|
54
54
|
*/
|
|
55
|
-
export async function defineWithFeatures(tagName, baseTagName, config, registry) {
|
|
55
|
+
export async function defineWithFeatures(tagName, baseTagName, config, registry, options) {
|
|
56
56
|
const reg = registry || customElements;
|
|
57
57
|
// 1. Resolve base class — wait for it if not yet defined
|
|
58
58
|
let BaseClass = reg.get(baseTagName);
|
|
@@ -99,6 +99,10 @@ export async function defineWithFeatures(tagName, baseTagName, config, registry)
|
|
|
99
99
|
// 3. Create subclass
|
|
100
100
|
const NewClass = class extends BaseClass {
|
|
101
101
|
};
|
|
102
|
+
// 3b. Call onSubclassCreated callback (before define, before features if needed)
|
|
103
|
+
if (options?.onSubclassCreated) {
|
|
104
|
+
options.onSubclassCreated(NewClass);
|
|
105
|
+
}
|
|
102
106
|
// 4. Build FeatureConfigsMap: resolved spawns + JSON config
|
|
103
107
|
const featuresMap = {};
|
|
104
108
|
for (const [key, jsonConfig] of Object.entries(config.assignFeatures)) {
|
package/defineWithFeatures.ts
CHANGED
|
@@ -33,6 +33,14 @@ export interface DefineWithFeaturesConfig {
|
|
|
33
33
|
}>;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Options for defineWithFeatures.
|
|
38
|
+
*/
|
|
39
|
+
export interface DefineWithFeaturesOptions {
|
|
40
|
+
/** Called after the subclass is created but before registry.define(). */
|
|
41
|
+
onSubclassCreated?: (NewCtr: Function) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
/**
|
|
37
45
|
* Determines if a function is an async spawner (same heuristic as assignFeatures).
|
|
38
46
|
*/
|
|
@@ -68,7 +76,8 @@ export async function defineWithFeatures(
|
|
|
68
76
|
tagName: string,
|
|
69
77
|
baseTagName: string,
|
|
70
78
|
config: DefineWithFeaturesConfig,
|
|
71
|
-
registry?: CustomElementRegistry
|
|
79
|
+
registry?: CustomElementRegistry,
|
|
80
|
+
options?: DefineWithFeaturesOptions
|
|
72
81
|
): Promise<Function> {
|
|
73
82
|
const reg = registry || customElements;
|
|
74
83
|
|
|
@@ -129,6 +138,11 @@ export async function defineWithFeatures(
|
|
|
129
138
|
// 3. Create subclass
|
|
130
139
|
const NewClass = class extends (BaseClass as any) {};
|
|
131
140
|
|
|
141
|
+
// 3b. Call onSubclassCreated callback (before define, before features if needed)
|
|
142
|
+
if (options?.onSubclassCreated) {
|
|
143
|
+
options.onSubclassCreated(NewClass);
|
|
144
|
+
}
|
|
145
|
+
|
|
132
146
|
// 4. Build FeatureConfigsMap: resolved spawns + JSON config
|
|
133
147
|
const featuresMap: FeatureConfigsMap = {};
|
|
134
148
|
for (const [key, jsonConfig] of Object.entries(config.assignFeatures)) {
|
package/package.json
CHANGED