pacc 9.2.12 → 9.2.14
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/README.md +3 -0
- package/package.json +3 -3
- package/src/expand.mjs +1 -2
- package/src/types.mjs +16 -25
- package/types/types.d.mts +3 -0
package/README.md
CHANGED
|
@@ -831,6 +831,9 @@ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
|
|
|
831
831
|
|
|
832
832
|
* `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
|
|
833
833
|
* `primitive` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** 
|
|
834
|
+
* `extends` **[Type](#type)?** 
|
|
835
|
+
* `members` **[Set](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Set)<[Type](#type)>?** 
|
|
836
|
+
* `clazz` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
834
837
|
* `toInternal` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
835
838
|
* `toExternal` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 
|
|
836
839
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pacc",
|
|
3
|
-
"version": "9.2.
|
|
3
|
+
"version": "9.2.14",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@mitata/counters": "^0.0.8",
|
|
46
|
-
"aggregated-map": "^1.0.
|
|
46
|
+
"aggregated-map": "^1.0.4",
|
|
47
47
|
"ava": "^8.0.1",
|
|
48
48
|
"browser-ava": "^2.3.61",
|
|
49
49
|
"c8": "^11.0.0",
|
|
50
50
|
"documentation": "^14.0.3",
|
|
51
51
|
"mitata": "^1.0.34",
|
|
52
|
-
"semantic-release": "^25.0.
|
|
52
|
+
"semantic-release": "^25.0.5",
|
|
53
53
|
"typescript": "^6.0.3"
|
|
54
54
|
},
|
|
55
55
|
"overrides": {
|
package/src/expand.mjs
CHANGED
|
@@ -159,7 +159,7 @@ export function expand(object, context) {
|
|
|
159
159
|
return object;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
if
|
|
162
|
+
if(Object.prototype.toString.call(object) !== '[object Object]') {
|
|
163
163
|
return object;
|
|
164
164
|
}
|
|
165
165
|
|
|
@@ -185,7 +185,6 @@ export function expand(object, context) {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
console.log(newObject);
|
|
189
188
|
return newObject;
|
|
190
189
|
}
|
|
191
190
|
|
package/src/types.mjs
CHANGED
|
@@ -6,6 +6,9 @@ import { parseBytes } from "./bytes.mjs";
|
|
|
6
6
|
* @typedef {Object} Type
|
|
7
7
|
* @property {string} name
|
|
8
8
|
* @property {boolean} [primitive]
|
|
9
|
+
* @property {Type} [extends]
|
|
10
|
+
* @property {Set<Type>} [members]
|
|
11
|
+
* @property {Function} [clazz]
|
|
9
12
|
* @property {Function} [toInternal]
|
|
10
13
|
* @property {Function} [toExternal]
|
|
11
14
|
*/
|
|
@@ -121,28 +124,11 @@ function raiseOnUnknownType(type, origin) {
|
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
export function addType(type) {
|
|
124
|
-
if (type.typeDefinition) {
|
|
125
|
-
const clazz = type;
|
|
126
|
-
type = type.typeDefinition;
|
|
127
|
-
type.clazz = clazz;
|
|
128
|
-
} else {
|
|
129
|
-
if (!!type?.constructor.name) {
|
|
130
|
-
const clazz = type;
|
|
131
|
-
type.clazz = clazz;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (type.specializationOf) {
|
|
136
|
-
type.specializationOf.specializations[type.name] = type;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
type.owners ||= [];
|
|
140
|
-
|
|
141
127
|
switch (typeof type.extends) {
|
|
142
128
|
case "undefined":
|
|
143
|
-
const ex = Object.getPrototypeOf(type.clazz);
|
|
129
|
+
const ex = Object.getPrototypeOf(type.clazz || type);
|
|
144
130
|
if (ex?.name) {
|
|
145
|
-
type.extends = ex
|
|
131
|
+
type.extends = ex;
|
|
146
132
|
}
|
|
147
133
|
break;
|
|
148
134
|
|
|
@@ -151,14 +137,19 @@ export function addType(type) {
|
|
|
151
137
|
break;
|
|
152
138
|
}
|
|
153
139
|
|
|
154
|
-
if (
|
|
155
|
-
|
|
140
|
+
if (type.specializationOf) {
|
|
141
|
+
type.specializationOf.specializations[type.name] = type;
|
|
156
142
|
}
|
|
157
143
|
|
|
158
|
-
|
|
159
|
-
return Object.assign(types[type.name], type);
|
|
160
|
-
}
|
|
144
|
+
type.owners ||= [];
|
|
161
145
|
|
|
146
|
+
if (!types[type.name]) {
|
|
147
|
+
types[type.name] = type;
|
|
148
|
+
} else {
|
|
149
|
+
if (types[type.name] !== type) {
|
|
150
|
+
return Object.assign(types[type.name], type);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
162
153
|
return type;
|
|
163
154
|
}
|
|
164
155
|
|
|
@@ -213,7 +204,7 @@ export function resolveTypeLinks() {
|
|
|
213
204
|
}
|
|
214
205
|
|
|
215
206
|
export function typeFactory(type, owner, data) {
|
|
216
|
-
const factory = type.factoryFor?.(owner, data) || type.clazz;
|
|
207
|
+
const factory = type.factoryFor?.(owner, data) || type.clazz || type;
|
|
217
208
|
const object = new factory(owner);
|
|
218
209
|
|
|
219
210
|
object.read(data);
|
package/types/types.d.mts
CHANGED
|
@@ -64,6 +64,9 @@ export const types: {
|
|
|
64
64
|
export type Type = {
|
|
65
65
|
name: string;
|
|
66
66
|
primitive?: boolean | undefined;
|
|
67
|
+
extends?: Type | undefined;
|
|
68
|
+
members?: Set<Type> | undefined;
|
|
69
|
+
clazz?: Function | undefined;
|
|
67
70
|
toInternal?: Function | undefined;
|
|
68
71
|
toExternal?: Function | undefined;
|
|
69
72
|
};
|