pmcf 4.6.1 → 4.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "4.6.1",
3
+ "version": "4.7.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -60,7 +60,7 @@
60
60
  "package-directory": "^8.1.0"
61
61
  },
62
62
  "devDependencies": {
63
- "@types/node": "^25.0.8",
63
+ "@types/node": "^25.0.9",
64
64
  "ava": "^6.4.1",
65
65
  "c8": "^10.1.3",
66
66
  "documentation": "^14.0.3",
package/src/base.mjs CHANGED
@@ -310,29 +310,35 @@ export class Base {
310
310
  return this.owner.addObject(object);
311
311
  }
312
312
 
313
- *_allExtends(all) {
314
- for (const e of this.extends) {
315
- if (!all.has(e)) {
316
- all.add(e);
317
- yield e;
318
- yield* e._allExtends(all);
319
- }
320
- }
313
+ *walkDirections(directions = ["this", "extends", "owner"]) {
314
+ yield* this._walkDirections(
315
+ directions,
316
+ directions.indexOf("this") >= 0,
317
+ new Set()
318
+ );
321
319
  }
322
320
 
323
- *allExtends() {
324
- yield* this._allExtends(new Set());
325
- }
321
+ *_walkDirections(directions, withThis, seen) {
322
+ if (!seen.has(this)) {
323
+ seen.add(this);
326
324
 
327
- *owners() {
328
- if (this.owner) {
329
- yield* this.owner.thisAndOwners();
330
- }
331
- }
325
+ if (withThis) {
326
+ yield this;
327
+ }
328
+ for (const direction of directions) {
329
+ const value = this[direction];
332
330
 
333
- *thisAndOwners() {
334
- yield this;
335
- yield* this.owners();
331
+ if (value) {
332
+ if (value[Symbol.iterator]) {
333
+ for (const node of value) {
334
+ yield* node._walkDirections(directions, true, seen);
335
+ }
336
+ } else {
337
+ yield* value._walkDirections(directions, true, seen);
338
+ }
339
+ }
340
+ }
341
+ }
336
342
  }
337
343
 
338
344
  forOwner(owner) {
@@ -369,12 +375,13 @@ export class Base {
369
375
  if (value !== undefined) {
370
376
  yield value;
371
377
  } else {
372
- if (this._properties?.[propertyName] !== undefined) {
373
- yield this._properties?.[propertyName];
378
+ const value = this._properties?.[propertyName];
379
+ if (value !== undefined) {
380
+ yield value;
374
381
  }
375
382
  }
376
383
 
377
- for (const e of this.allExtends()) {
384
+ for (const e of this.walkDirections(["extends"])) {
378
385
  yield* e._extendedPropertyIterator(propertyName, seen);
379
386
  }
380
387
  }
@@ -383,7 +390,7 @@ export class Base {
383
390
  _extendedProperty(propertyName, seen) {
384
391
  if (!seen.has(this)) {
385
392
  seen.add(this);
386
- for (const e of this.allExtends()) {
393
+ for (const e of this.walkDirections(["extends"])) {
387
394
  const value =
388
395
  getAttribute(e, propertyName) ??
389
396
  e._extendedProperty(propertyName, seen);
@@ -580,15 +587,16 @@ export class Base {
580
587
  )
581
588
  ];
582
589
 
583
- return [...this.allExtends(), this].map(e => {
584
- const dir = join(e.directory, "content") + "/";
585
- console.log("DIR", dir);
586
-
587
- return transform(
588
- new FileContentProvider(dir, entryProperties, directoryProperties),
590
+ return [...this.walkDirections(["this", "extends"])].map(e =>
591
+ transform(
592
+ new FileContentProvider(
593
+ { dir: join(e.directory, "content"), pattern: "**/*" },
594
+ entryProperties,
595
+ directoryProperties
596
+ ),
589
597
  transformers
590
- );
591
- });
598
+ )
599
+ );
592
600
  }
593
601
 
594
602
  get tags() {
@@ -615,14 +623,14 @@ export class Base {
615
623
  return this._properties;
616
624
  }
617
625
 
626
+ /**
627
+ *
628
+ * @param {string} name
629
+ * @returns {any}
630
+ */
618
631
  property(name) {
619
- let value = this._properties?.[name];
620
- if (value !== undefined) {
621
- return value;
622
- }
623
-
624
- for (const o of this.owners()) {
625
- const value = o.property(name);
632
+ for (const node of this.walkDirections(["this", "extends", "owner"])) {
633
+ const value = node._properties?.[name];
626
634
  if (value !== undefined) {
627
635
  return value;
628
636
  }
package/types/base.d.mts CHANGED
@@ -60,10 +60,8 @@ export class Base {
60
60
  named(name: any): void;
61
61
  typeNamed(typeName: any, name: any): any;
62
62
  addObject(object: any): any;
63
- _allExtends(all: any): Generator<any, void, any>;
64
- allExtends(): Generator<any, void, any>;
65
- owners(): any;
66
- thisAndOwners(): any;
63
+ walkDirections(directions?: string[]): Generator<any, void, any>;
64
+ _walkDirections(directions: any, withThis: any, seen: any): Generator<any, void, any>;
67
65
  forOwner(owner: any): any;
68
66
  isNamed(name: any): boolean;
69
67
  relativeName(name: any): any;
@@ -129,7 +127,12 @@ export class Base {
129
127
  get isTemplate(): any;
130
128
  getGlobal(a: any): any;
131
129
  get properties(): any;
132
- property(name: any): any;
130
+ /**
131
+ *
132
+ * @param {string} name
133
+ * @returns {any}
134
+ */
135
+ property(name: string): any;
133
136
  /**
134
137
  *
135
138
  * @param {any} object