@purescraps/purehtml 0.7.0 → 0.7.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/examples/simple.js +29 -18
- package/dist/examples/simple.js.map +1 -1
- package/dist/src/index.d.ts +8 -4
- package/dist/src/index.js +29 -18
- package/dist/src/index.js.map +1 -1
- package/package.json +16 -14
package/dist/examples/simple.js
CHANGED
|
@@ -6461,7 +6461,7 @@ var PureHTMLCheerioNode = class _PureHTMLCheerioNode extends PureHTMLNode {
|
|
|
6461
6461
|
if (name) {
|
|
6462
6462
|
return this.#el.attr(name) ?? null;
|
|
6463
6463
|
}
|
|
6464
|
-
return this.#el.attr();
|
|
6464
|
+
return this.#el.attr() ?? {};
|
|
6465
6465
|
}
|
|
6466
6466
|
find(selector) {
|
|
6467
6467
|
return this.#el.find(selector).toArray().map((el) => new _PureHTMLCheerioNode(this.#$, this.#$(el)));
|
|
@@ -6513,6 +6513,9 @@ var ConfigWithSelector = class extends Config {
|
|
|
6513
6513
|
}
|
|
6514
6514
|
return matches;
|
|
6515
6515
|
}
|
|
6516
|
+
toString() {
|
|
6517
|
+
return `ConfigWithSelector(${this.selector})`;
|
|
6518
|
+
}
|
|
6516
6519
|
};
|
|
6517
6520
|
|
|
6518
6521
|
// src/config/types/primitive.ts
|
|
@@ -6578,6 +6581,7 @@ var ArrayConfig = class _ArrayConfig extends ConfigWithSelector {
|
|
|
6578
6581
|
alreadyMatched: params.elementAlreadyMatched ?? false,
|
|
6579
6582
|
includeRoot: false
|
|
6580
6583
|
});
|
|
6584
|
+
if (!$el) return null;
|
|
6581
6585
|
const matches = Array.isArray($el) ? $el : [$el];
|
|
6582
6586
|
const conf = this.items || PrimitiveValueConfig.generate(null, this.transform);
|
|
6583
6587
|
const extractOpts = { ...params };
|
|
@@ -6986,15 +6990,18 @@ var ObjectConfig = class _ObjectConfig extends ConfigWithSelector {
|
|
|
6986
6990
|
}
|
|
6987
6991
|
const props = this.properties;
|
|
6988
6992
|
const keys = Object.keys(props);
|
|
6989
|
-
return keys.reduce(
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6993
|
+
return keys.reduce(
|
|
6994
|
+
(acc, key) => {
|
|
6995
|
+
const config2 = props[key];
|
|
6996
|
+
acc[key] = config2.extract({
|
|
6997
|
+
...params,
|
|
6998
|
+
$el,
|
|
6999
|
+
property: this.makeProperty(params.property, key)
|
|
7000
|
+
});
|
|
7001
|
+
return acc;
|
|
7002
|
+
},
|
|
7003
|
+
{}
|
|
7004
|
+
);
|
|
6998
7005
|
}
|
|
6999
7006
|
makeProperty(property, prop) {
|
|
7000
7007
|
if (property === rootProp) {
|
|
@@ -7213,7 +7220,7 @@ var ConfigValidator = class {
|
|
|
7213
7220
|
var ConfigFactory = class _ConfigFactory {
|
|
7214
7221
|
static fromYAML(yaml) {
|
|
7215
7222
|
const plain = (0, import_yaml.parse)(yaml);
|
|
7216
|
-
return
|
|
7223
|
+
return _ConfigFactory.generate(plain);
|
|
7217
7224
|
}
|
|
7218
7225
|
static generate(plain) {
|
|
7219
7226
|
const validator = new ConfigValidator(plain);
|
|
@@ -7240,24 +7247,28 @@ var ConfigFactory = class _ConfigFactory {
|
|
|
7240
7247
|
case "constant":
|
|
7241
7248
|
return ConstantConfig.generate(constant, selector);
|
|
7242
7249
|
case "object": {
|
|
7243
|
-
let propConfigs
|
|
7250
|
+
let propConfigs;
|
|
7244
7251
|
if (properties) {
|
|
7245
|
-
propConfigs = Object.keys(properties).reduce(
|
|
7246
|
-
acc
|
|
7247
|
-
|
|
7248
|
-
|
|
7252
|
+
propConfigs = Object.keys(properties).reduce(
|
|
7253
|
+
(acc, key) => {
|
|
7254
|
+
acc[key] = _ConfigFactory.generate(properties[key]);
|
|
7255
|
+
return acc;
|
|
7256
|
+
},
|
|
7257
|
+
{}
|
|
7258
|
+
);
|
|
7249
7259
|
}
|
|
7250
7260
|
return ObjectConfig.generate(selector, propConfigs);
|
|
7251
7261
|
}
|
|
7252
7262
|
case "array":
|
|
7253
7263
|
return ArrayConfig.generate(
|
|
7254
7264
|
selector,
|
|
7255
|
-
items &&
|
|
7265
|
+
items && _ConfigFactory.generate(items),
|
|
7256
7266
|
transform
|
|
7257
7267
|
);
|
|
7258
7268
|
case "union":
|
|
7259
7269
|
return UnionConfig.generate(
|
|
7260
|
-
union.
|
|
7270
|
+
// biome-ignore lint/style/noNonNullAssertion: union will be present here. because our schema already validated the input
|
|
7271
|
+
union.map((cfg) => _ConfigFactory.generate(cfg))
|
|
7261
7272
|
);
|
|
7262
7273
|
default:
|
|
7263
7274
|
return PrimitiveValueConfig.generate(selector, transform);
|