pacc 4.41.0 → 4.41.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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "4.41.0",
3
+ "version": "4.41.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
7
7
  },
8
- "packageManager": "npm@11.6.0+sha512.77f3fb0dbbd881835d7bd1217deabdf7ed77fc4ec4f363df64fc3cb986404abf6c437661041080f5c5d225103508e7c9ea30cb2742b7e942675d05a10af2d7b9",
8
+ "packageManager": "npm@11.6.3+sha512.4085a763162e0e3acd19a4e9d23ad3aa0978e501ccf947dd7233c12a689ae0bb0190763c4ef12366990056b34eec438903ffed38fde4fbd722a17c2a7407ee92",
9
9
  "types": "./types/module.d.mts",
10
10
  "exports": {
11
11
  ".": {
@@ -42,11 +42,11 @@
42
42
  "browser-ava": "^2.3.44",
43
43
  "c8": "^10.1.3",
44
44
  "documentation": "^14.0.3",
45
- "semantic-release": "^25.0.1",
45
+ "semantic-release": "^25.0.2",
46
46
  "typescript": "^5.9.3"
47
47
  },
48
48
  "engines": {
49
- "node": ">=22.21.0"
49
+ "node": ">=24.11.1"
50
50
  },
51
51
  "repository": {
52
52
  "type": "git",
@@ -80,7 +80,7 @@ export function parse(input, context = { globals }) {
80
80
  }
81
81
  result = r;
82
82
  } else {
83
- if (result === undefined && context.globals?.[p]) {
83
+ if (result === undefined) {
84
84
  result = context.globals?.[p];
85
85
  } else {
86
86
  if (result instanceof Map) {
package/src/types.mjs CHANGED
@@ -29,7 +29,8 @@ export const types = {
29
29
  duration: {
30
30
  name: "duration",
31
31
  primitive: true,
32
- prepareValue: value => (typeof value === "string" ? parseFloat(value) : value)
32
+ prepareValue: value =>
33
+ typeof value === "string" ? parseFloat(value) : value
33
34
  },
34
35
  url: { name: "url", primitive: true },
35
36
  object: { name: "object" }
@@ -89,12 +90,6 @@ export function addType(type) {
89
90
  types[type.name] = type;
90
91
  }
91
92
 
92
- for (const [path, attribute] of attributeIterator(type.attributes)) {
93
- if (typeof attribute.type === "string") {
94
- attribute.type = oneOfType(attribute.type);
95
- }
96
- }
97
-
98
93
  if (types[type.name] !== type) {
99
94
  return Object.assign(types[type.name], type);
100
95
  }
@@ -143,5 +138,21 @@ export function resolveTypeLinks() {
143
138
  if (type.owners) {
144
139
  type.owners = type.owners.map(owner => raiseOnUnknownType(owner, type));
145
140
  }
141
+
142
+ for (const [path, attribute] of attributeIterator(type.attributes)) {
143
+ if (typeof attribute.type === "string") {
144
+ attribute.type = oneOfType(attribute.type);
145
+ }
146
+ }
146
147
  }
147
148
  }
149
+
150
+ export function typeFactory(type, owner, data) {
151
+ const factory = type.factoryFor?.(owner, data) || type.clazz;
152
+ //console.log(factory, type, owner, data);
153
+ const object = new factory(owner);
154
+
155
+ object.read(data);
156
+ owner.addObject(object);
157
+ return object;
158
+ }
package/types/types.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  export function addType(type: any): any;
2
2
  export function oneOfType(definition: any): any;
3
3
  export function resolveTypeLinks(): void;
4
+ export function typeFactory(type: any, owner: any, data: any): any;
4
5
  export const types: {
5
6
  string: {
6
7
  name: string;