thunderous 0.6.0 → 0.6.2
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.cjs +20 -3
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +20 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -1223,6 +1223,14 @@ var DEFAULT_RENDER_OPTIONS = {
|
|
1223
1223
|
mode: "closed"
|
1224
1224
|
}
|
1225
1225
|
};
|
1226
|
+
var TrackableCustomElementRegistry = class extends CustomElementRegistry {
|
1227
|
+
__tagNames = /* @__PURE__ */ new Set();
|
1228
|
+
define(tagName, constructor) {
|
1229
|
+
super.define(tagName, constructor);
|
1230
|
+
this.__tagNames.add(tagName);
|
1231
|
+
}
|
1232
|
+
};
|
1233
|
+
window.CustomElementRegistry = TrackableCustomElementRegistry;
|
1226
1234
|
var getPropName = (attrName) => attrName.replace(/^([A-Z]+)/, (_, letter) => letter.toLowerCase()).replace(/(-|_| )([a-zA-Z])/g, (_, letter) => letter.toUpperCase());
|
1227
1235
|
var customElement = (render, options) => {
|
1228
1236
|
const {
|
@@ -1234,7 +1242,6 @@ var customElement = (render, options) => {
|
|
1234
1242
|
} = { ...DEFAULT_RENDER_OPTIONS, ...options };
|
1235
1243
|
const shadowRootOptions = { ...DEFAULT_RENDER_OPTIONS.shadowRootOptions, ..._shadowRootOptions };
|
1236
1244
|
shadowRootOptions.registry = shadowRootOptions.customElements = shadowRootOptions.registry instanceof CustomElementRegistry ? shadowRootOptions.registry : shadowRootOptions.registry?.eject();
|
1237
|
-
console.log(shadowRootOptions);
|
1238
1245
|
const observedAttributesSet = new Set(_observedAttributes);
|
1239
1246
|
const attributesAsPropertiesMap = /* @__PURE__ */ new Map();
|
1240
1247
|
for (const [attrName, coerce] of attributesAsProperties) {
|
@@ -1373,8 +1380,19 @@ You must set an initial value before calling a property signal's getter.
|
|
1373
1380
|
}
|
1374
1381
|
});
|
1375
1382
|
fragment.host = this;
|
1383
|
+
const registry = shadowRootOptions.registry instanceof CustomElementRegistry ? shadowRootOptions.registry : shadowRootOptions.registry?.eject();
|
1384
|
+
const tempContainer = document.createElement("div");
|
1385
|
+
tempContainer.append(fragment.cloneNode(true));
|
1386
|
+
const fragmentContent = tempContainer.innerHTML;
|
1387
|
+
root.innerHTML = fragmentContent;
|
1388
|
+
if (registry !== void 0 && registry.__tagNames !== void 0) {
|
1389
|
+
for (const tagName of registry.__tagNames) {
|
1390
|
+
const upgradedElement = root.querySelector(tagName);
|
1391
|
+
const nonUpgradedElement = fragment.querySelector(tagName);
|
1392
|
+
nonUpgradedElement.replaceWith(upgradedElement);
|
1393
|
+
}
|
1394
|
+
}
|
1376
1395
|
setInnerHTML(root, fragment);
|
1377
|
-
root.innerHTML = root.innerHTML;
|
1378
1396
|
}
|
1379
1397
|
static get formAssociated() {
|
1380
1398
|
return formAssociated;
|
@@ -1482,7 +1500,6 @@ You must set an initial value before calling a property signal's getter.
|
|
1482
1500
|
const elementResult = {
|
1483
1501
|
define(tagName) {
|
1484
1502
|
const registry = _registry?.scoped ? _registry.eject() : customElements;
|
1485
|
-
console.log(tagName, registry);
|
1486
1503
|
if (registry.get(tagName) !== void 0) {
|
1487
1504
|
console.warn(`Custom element "${tagName}" was already defined. Skipping...`);
|
1488
1505
|
return this;
|
package/dist/index.d.cts
CHANGED
@@ -89,6 +89,11 @@ type RenderOptions = {
|
|
89
89
|
};
|
90
90
|
};
|
91
91
|
type RenderFunction<Props extends CustomElementProps> = (args: RenderArgs<Props>) => DocumentFragment;
|
92
|
+
declare global {
|
93
|
+
interface CustomElementRegistry {
|
94
|
+
__tagNames: Set<string>;
|
95
|
+
}
|
96
|
+
}
|
92
97
|
/**
|
93
98
|
* Create a custom element that can be defined for use in the DOM.
|
94
99
|
* @example
|
package/dist/index.d.ts
CHANGED
@@ -89,6 +89,11 @@ type RenderOptions = {
|
|
89
89
|
};
|
90
90
|
};
|
91
91
|
type RenderFunction<Props extends CustomElementProps> = (args: RenderArgs<Props>) => DocumentFragment;
|
92
|
+
declare global {
|
93
|
+
interface CustomElementRegistry {
|
94
|
+
__tagNames: Set<string>;
|
95
|
+
}
|
96
|
+
}
|
92
97
|
/**
|
93
98
|
* Create a custom element that can be defined for use in the DOM.
|
94
99
|
* @example
|
package/dist/index.js
CHANGED
@@ -1191,6 +1191,14 @@ var DEFAULT_RENDER_OPTIONS = {
|
|
1191
1191
|
mode: "closed"
|
1192
1192
|
}
|
1193
1193
|
};
|
1194
|
+
var TrackableCustomElementRegistry = class extends CustomElementRegistry {
|
1195
|
+
__tagNames = /* @__PURE__ */ new Set();
|
1196
|
+
define(tagName, constructor) {
|
1197
|
+
super.define(tagName, constructor);
|
1198
|
+
this.__tagNames.add(tagName);
|
1199
|
+
}
|
1200
|
+
};
|
1201
|
+
window.CustomElementRegistry = TrackableCustomElementRegistry;
|
1194
1202
|
var getPropName = (attrName) => attrName.replace(/^([A-Z]+)/, (_, letter) => letter.toLowerCase()).replace(/(-|_| )([a-zA-Z])/g, (_, letter) => letter.toUpperCase());
|
1195
1203
|
var customElement = (render, options) => {
|
1196
1204
|
const {
|
@@ -1202,7 +1210,6 @@ var customElement = (render, options) => {
|
|
1202
1210
|
} = { ...DEFAULT_RENDER_OPTIONS, ...options };
|
1203
1211
|
const shadowRootOptions = { ...DEFAULT_RENDER_OPTIONS.shadowRootOptions, ..._shadowRootOptions };
|
1204
1212
|
shadowRootOptions.registry = shadowRootOptions.customElements = shadowRootOptions.registry instanceof CustomElementRegistry ? shadowRootOptions.registry : shadowRootOptions.registry?.eject();
|
1205
|
-
console.log(shadowRootOptions);
|
1206
1213
|
const observedAttributesSet = new Set(_observedAttributes);
|
1207
1214
|
const attributesAsPropertiesMap = /* @__PURE__ */ new Map();
|
1208
1215
|
for (const [attrName, coerce] of attributesAsProperties) {
|
@@ -1341,8 +1348,19 @@ You must set an initial value before calling a property signal's getter.
|
|
1341
1348
|
}
|
1342
1349
|
});
|
1343
1350
|
fragment.host = this;
|
1351
|
+
const registry = shadowRootOptions.registry instanceof CustomElementRegistry ? shadowRootOptions.registry : shadowRootOptions.registry?.eject();
|
1352
|
+
const tempContainer = document.createElement("div");
|
1353
|
+
tempContainer.append(fragment.cloneNode(true));
|
1354
|
+
const fragmentContent = tempContainer.innerHTML;
|
1355
|
+
root.innerHTML = fragmentContent;
|
1356
|
+
if (registry !== void 0 && registry.__tagNames !== void 0) {
|
1357
|
+
for (const tagName of registry.__tagNames) {
|
1358
|
+
const upgradedElement = root.querySelector(tagName);
|
1359
|
+
const nonUpgradedElement = fragment.querySelector(tagName);
|
1360
|
+
nonUpgradedElement.replaceWith(upgradedElement);
|
1361
|
+
}
|
1362
|
+
}
|
1344
1363
|
setInnerHTML(root, fragment);
|
1345
|
-
root.innerHTML = root.innerHTML;
|
1346
1364
|
}
|
1347
1365
|
static get formAssociated() {
|
1348
1366
|
return formAssociated;
|
@@ -1450,7 +1468,6 @@ You must set an initial value before calling a property signal's getter.
|
|
1450
1468
|
const elementResult = {
|
1451
1469
|
define(tagName) {
|
1452
1470
|
const registry = _registry?.scoped ? _registry.eject() : customElements;
|
1453
|
-
console.log(tagName, registry);
|
1454
1471
|
if (registry.get(tagName) !== void 0) {
|
1455
1472
|
console.warn(`Custom element "${tagName}" was already defined. Skipping...`);
|
1456
1473
|
return this;
|