json-as 0.9.8 → 0.9.9-a

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.
Files changed (63) hide show
  1. package/.github/workflows/nodejs.yml +9 -10
  2. package/CHANGELOG +13 -1
  3. package/README.md +56 -8
  4. package/asconfig.json +24 -3
  5. package/assembly/__tests__/test.spec.ts +564 -0
  6. package/assembly/__tests__/types.ts +82 -0
  7. package/assembly/{src/chars.ts → chars.ts} +36 -36
  8. package/assembly/deserialize/array/array.ts +4 -4
  9. package/assembly/deserialize/array/bool.ts +4 -4
  10. package/assembly/deserialize/array/float.ts +4 -4
  11. package/assembly/deserialize/array/integer.ts +4 -4
  12. package/assembly/deserialize/array/map.ts +4 -4
  13. package/assembly/deserialize/array/object.ts +4 -4
  14. package/assembly/deserialize/array/string.ts +4 -4
  15. package/assembly/deserialize/array.ts +5 -4
  16. package/assembly/deserialize/bool.ts +4 -4
  17. package/assembly/deserialize/date.ts +2 -2
  18. package/assembly/deserialize/float.ts +2 -2
  19. package/assembly/deserialize/integer.ts +3 -3
  20. package/assembly/deserialize/map.ts +6 -4
  21. package/assembly/deserialize/mpz.ts +12 -0
  22. package/assembly/deserialize/object.ts +4 -4
  23. package/assembly/deserialize/string.ts +5 -5
  24. package/assembly/index.ts +25 -23
  25. package/assembly/serialize/array.ts +6 -5
  26. package/assembly/serialize/bool.ts +2 -2
  27. package/assembly/serialize/date.ts +2 -2
  28. package/assembly/serialize/float.ts +2 -2
  29. package/assembly/serialize/integer.ts +2 -2
  30. package/assembly/serialize/map.ts +8 -7
  31. package/assembly/serialize/mpz.ts +6 -0
  32. package/assembly/serialize/object.ts +2 -2
  33. package/assembly/serialize/string.ts +5 -5
  34. package/assembly/serialize/unknown.ts +5 -5
  35. package/assembly/test.ts +70 -43
  36. package/assembly/types.ts +4 -0
  37. package/assembly/{src/util.ts → util.ts} +3 -3
  38. package/bench/benchmark.ts +1 -1
  39. package/build/test.spec.wasm +0 -0
  40. package/build/test.spec.wasm.map +1 -0
  41. package/build/test.spec.wat +112683 -0
  42. package/build/test.wasm +0 -0
  43. package/build/test.wasm.map +1 -0
  44. package/build/test.wat +30110 -0
  45. package/package.json +13 -13
  46. package/transform/lib/index.js +26 -0
  47. package/transform/lib/visitor.js +516 -0
  48. package/transform/package.json +1 -1
  49. package/transform/src/index.ts +24 -0
  50. package/transform/src/visitor.ts +543 -0
  51. package/transform/tsconfig.json +23 -63
  52. package/tsconfig.json +13 -13
  53. package/as-pect.asconfig.json +0 -24
  54. package/as-pect.config.js +0 -30
  55. package/assembly/__tests__/deserialize.spec.ts +0 -301
  56. package/assembly/__tests__/serialize.spec.ts +0 -398
  57. package/assembly/deserialize/box.ts +0 -17
  58. package/assembly/serialize/box.ts +0 -11
  59. package/develop/assembly/serialize/unknown.ts +0 -46
  60. package/transform/lib/index.old.js +0 -257
  61. package/transform/lib/types.js +0 -17
  62. package/transform/src/index.old.ts +0 -312
  63. /package/assembly/{src/sink.ts → sink.ts} +0 -0
@@ -1,257 +0,0 @@
1
- import { Parser, Source, Tokenizer, } from "assemblyscript/dist/assemblyscript.js";
2
- import { toString, isStdlib } from "visitor-as/dist/utils.js";
3
- import { BaseVisitor, SimpleParser } from "visitor-as/dist/index.js";
4
- import { Transform } from "assemblyscript/dist/transform.js";
5
- class SchemaData {
6
- constructor() {
7
- this.keys = [];
8
- this.values = [];
9
- this.types = [];
10
- this.name = "";
11
- this.parent = "";
12
- this.encodeStmts = [];
13
- this.setDataStmts = [];
14
- this.initializeStmts = [];
15
- }
16
- }
17
- class AsJSONTransform extends BaseVisitor {
18
- constructor() {
19
- super(...arguments);
20
- this.schemasList = [];
21
- this.sources = new Set();
22
- }
23
- visitMethodDeclaration() { }
24
- visitClassDeclaration(node) {
25
- const className = node.name.text;
26
- if (!node.decorators?.length)
27
- return;
28
- let foundDecorator = false;
29
- for (const decorator of node.decorators) {
30
- if (
31
- // @ts-ignore
32
- decorator.name.text.toLowerCase() == "json" ||
33
- // @ts-ignore
34
- decorator.name.text.toLowerCase() == "serializable")
35
- foundDecorator = true;
36
- }
37
- if (!foundDecorator)
38
- return;
39
- // Prevent from being triggered twice.
40
- for (const member of node.members) {
41
- if (member.name.text == "__SERIALIZE")
42
- return;
43
- }
44
- this.currentClass = {
45
- name: className,
46
- keys: [],
47
- values: [],
48
- types: [],
49
- parent: node.extendsType ? toString(node.extendsType) : "",
50
- node: node,
51
- encodeStmts: [],
52
- setDataStmts: [],
53
- initializeStmts: []
54
- };
55
- if (this.currentClass.parent.length) {
56
- const parentSchema = this.schemasList.find((v) => v.name == this.currentClass.parent);
57
- if (parentSchema?.encodeStmts) {
58
- parentSchema?.encodeStmts.push(parentSchema?.encodeStmts.pop() + ",");
59
- for (let i = 0; i < parentSchema.keys.length; i++) {
60
- const key = parentSchema.keys[i];
61
- if (node.members.filter(v => v.name.text == key) == undefined)
62
- this.currentClass.encodeStmts.unshift(parentSchema.encodeStmts[i]);
63
- }
64
- }
65
- }
66
- const parentSchema = this.schemasList.find((v) => v.name == this.currentClass.parent);
67
- const members = [
68
- ...node.members
69
- ];
70
- if (parentSchema) {
71
- for (const mem of parentSchema.node.members) {
72
- if (members.find(v => v.name === mem.name) == undefined)
73
- members.unshift(mem);
74
- }
75
- }
76
- for (const mem of members) {
77
- // @ts-ignore
78
- if (mem.type && mem.type.name && mem.type.name.identifier.text) {
79
- const member = mem;
80
- const lineText = toString(member);
81
- //console.log("Member: " + lineText)
82
- if (!lineText.startsWith("private ") && !lineText.startsWith("static ")) {
83
- // @ts-ignore
84
- let type = toString(member.type);
85
- const name = member.name.text;
86
- let aliasName = name;
87
- // @ts-ignore
88
- if (member.decorators && member.decorators[0]?.name.text === "alias") {
89
- if (member.decorators[0] && member.decorators[0].args[0]) {
90
- // @ts-ignore
91
- aliasName = member.decorators[0].args[0].value;
92
- }
93
- }
94
- this.currentClass.keys.push(name);
95
- // @ts-ignore
96
- this.currentClass.types.push(type);
97
- // @ts-ignore
98
- if ([
99
- "u8",
100
- "i8",
101
- "u16",
102
- "i16",
103
- "u32",
104
- "i32",
105
- "u64",
106
- "i64",
107
- ].includes(type.toLowerCase())) {
108
- this.currentClass.encodeStmts.push(`${encodeKey(aliasName)}:\${this.${name}},`);
109
- // @ts-ignore
110
- this.currentClass.setDataStmts.push(`if (key.equals(${JSON.stringify(aliasName)})) {
111
- this.${name} = __atoi_fast<${type}>(data, val_start << 1, val_end << 1);
112
- return;
113
- }`);
114
- if (member.initializer) {
115
- this.currentClass.initializeStmts.push(`this.${name} = ${toString(member.initializer)}`);
116
- }
117
- }
118
- else // @ts-ignore
119
- if ([
120
- "f32",
121
- "f64",
122
- ].includes(type.toLowerCase())) {
123
- this.currentClass.encodeStmts.push(`${encodeKey(aliasName)}:\${this.${name}},`);
124
- // @ts-ignore
125
- this.currentClass.setDataStmts.push(`if (key.equals(${JSON.stringify(aliasName)})) {
126
- this.${name} = __parseObjectValue<${type}>(data.slice(val_start, val_end), initializeDefaultValues);
127
- return;
128
- }`);
129
- if (member.initializer) {
130
- this.currentClass.initializeStmts.push(`this.${name} = ${toString(member.initializer)}`);
131
- }
132
- }
133
- else {
134
- this.currentClass.encodeStmts.push(`${encodeKey(aliasName)}:\${__JSON_Stringify<${type}>(this.${name})},`);
135
- // @ts-ignore
136
- this.currentClass.setDataStmts.push(`if (key.equals(${JSON.stringify(aliasName)})) {
137
- this.${name} = __parseObjectValue<${type}>(val_start ? data.slice(val_start, val_end) : data, initializeDefaultValues);
138
- return;
139
- }`);
140
- if (member.initializer) {
141
- this.currentClass.initializeStmts.push(`this.${name} = ${toString(member.initializer)}`);
142
- }
143
- }
144
- }
145
- }
146
- }
147
- let serializeFunc = "";
148
- if (this.currentClass.encodeStmts.length > 0) {
149
- const stmt = this.currentClass.encodeStmts[this.currentClass.encodeStmts.length - 1];
150
- this.currentClass.encodeStmts[this.currentClass.encodeStmts.length - 1] =
151
- stmt.slice(0, stmt.length - 1);
152
- serializeFunc = `
153
- __SERIALIZE(): string {
154
- return \`{${this.currentClass.encodeStmts.join("")}}\`;
155
- }`;
156
- }
157
- else {
158
- serializeFunc = `
159
- __SERIALIZE(): string {
160
- return "{}";
161
- }`;
162
- }
163
- const setKeyFunc = `
164
- __JSON_Set_Key(key: __Virtual<string>, data: string, val_start: i32, val_end: i32, initializeDefaultValues: boolean): void {
165
- ${this.currentClass.setDataStmts.join("\n ")}
166
- }
167
- `;
168
- let initializeFunc = "";
169
- if (this.currentClass.initializeStmts.length > 0) {
170
- initializeFunc = `
171
- __JSON_Initialize(): void {
172
- ${this.currentClass.initializeStmts.join(";\n")};
173
- }
174
- `;
175
- }
176
- else {
177
- initializeFunc = `
178
- __JSON_Initialize(): void {}
179
- `;
180
- }
181
- const serializeMethod = SimpleParser.parseClassMember(serializeFunc, node);
182
- node.members.push(serializeMethod);
183
- const setDataMethod = SimpleParser.parseClassMember(setKeyFunc, node);
184
- node.members.push(setDataMethod);
185
- const initializeMethod = SimpleParser.parseClassMember(initializeFunc, node);
186
- node.members.push(initializeMethod);
187
- this.schemasList.push(this.currentClass);
188
- this.sources.add(node.name.range.source);
189
- // Uncomment to see the generated code for debugging.
190
- //console.log(serializeFunc);
191
- //console.log(setKeyFunc);
192
- //console.log(initializeFunc);
193
- }
194
- visitSource(node) {
195
- super.visitSource(node);
196
- // Only add the import statement to sources that have JSON decorated classes.
197
- if (!this.sources.has(node)) {
198
- return;
199
- }
200
- // Note, the following one liner would be easier, but it fails with an assertion error
201
- // because as-virtual's SimpleParser doesn't set the parser.currentSource correctly.
202
- //
203
- // const stmt = SimpleParser.parseTopLevelStatement('import { Virtual as __Virtual } from "as-virtual/assembly";');
204
- // ... So we have to do it the long way:
205
- const txt = 'import { Virtual as __Virtual } from "as-virtual/assembly";';
206
- const tokenizer = new Tokenizer(new Source(0 /* SourceKind.User */, node.normalizedPath, txt));
207
- const parser = new Parser();
208
- parser.currentSource = tokenizer.source;
209
- const stmt = parser.parseTopLevelStatement(tokenizer);
210
- // Add the import statement to the top of the source.
211
- node.statements.unshift(stmt);
212
- }
213
- }
214
- function encodeKey(aliasName) {
215
- return JSON.stringify(aliasName)
216
- .replace(/\\/g, "\\\\")
217
- .replace(/\`/g, '\\`');
218
- }
219
- export default class Transformer extends Transform {
220
- // Trigger the transform after parse.
221
- afterParse(parser) {
222
- // Create new transform
223
- const transformer = new AsJSONTransform();
224
- // Sort the sources so that user scripts are visited last
225
- const sources = parser.sources
226
- .filter((source) => !isStdlib(source))
227
- .sort((_a, _b) => {
228
- const a = _a.internalPath;
229
- const b = _b.internalPath;
230
- if (a[0] === "~" && b[0] !== "~") {
231
- return -1;
232
- }
233
- else if (a[0] !== "~" && b[0] === "~") {
234
- return 1;
235
- }
236
- else {
237
- return 0;
238
- }
239
- });
240
- // Loop over every source
241
- for (const source of sources) {
242
- // Ignore all lib and std. Visit everything else.
243
- if (!isStdlib(source)) {
244
- transformer.visit(source);
245
- }
246
- }
247
- // Check that every parent and child class is hooked up correctly
248
- const schemas = transformer.schemasList;
249
- for (const schema of schemas) {
250
- if (schema.parent) {
251
- const parent = schemas.find((v) => v.name === schema.parent);
252
- if (!parent)
253
- throw new Error(`Class ${schema.name} extends its parent class ${schema.parent}, but ${schema.parent} does not include a @json or @serializable decorator! Add the decorator and rebuild.`);
254
- }
255
- }
256
- }
257
- }
@@ -1,17 +0,0 @@
1
- export class SchemaMember {
2
- constructor() {
3
- this.key = "";
4
- this.type = "";
5
- this.value = null;
6
- this.serialize = null;
7
- this.deserialize = null;
8
- this.initialize = null;
9
- }
10
- }
11
- export class SchemaData {
12
- constructor() {
13
- this.name = "";
14
- this.members = [];
15
- this.parent = null;
16
- }
17
- }
@@ -1,312 +0,0 @@
1
- import {
2
- ClassDeclaration,
3
- FieldDeclaration,
4
- Parser,
5
- Source,
6
- SourceKind,
7
- Tokenizer,
8
- } from "assemblyscript/dist/assemblyscript.js";
9
-
10
- import { toString, isStdlib } from "visitor-as/dist/utils.js";
11
- import { BaseVisitor, SimpleParser } from "visitor-as/dist/index.js";
12
- import { Transform } from "assemblyscript/dist/transform.js";
13
-
14
- class SchemaData {
15
- public keys: string[] = [];
16
- public values: string[] = [];
17
- public types: string[] = [];
18
- public name: string = "";
19
- public parent: string = "";
20
- public node!: ClassDeclaration;
21
- public encodeStmts: string[] = [];
22
- public setDataStmts: string[] = [];
23
- public initializeStmts: string[] = [];
24
- }
25
-
26
- class AsJSONTransform extends BaseVisitor {
27
- public schemasList: SchemaData[] = [];
28
- public currentClass!: SchemaData;
29
- public sources = new Set<Source>();
30
-
31
- visitMethodDeclaration(): void { }
32
- visitClassDeclaration(node: ClassDeclaration): void {
33
- const className = node.name.text;
34
- if (!node.decorators?.length) return;
35
- let foundDecorator = false;
36
- for (const decorator of node.decorators!) {
37
- if (
38
- // @ts-ignore
39
- decorator.name.text.toLowerCase() == "json" ||
40
- // @ts-ignore
41
- decorator.name.text.toLowerCase() == "serializable"
42
- )
43
- foundDecorator = true;
44
- }
45
- if (!foundDecorator) return;
46
-
47
- // Prevent from being triggered twice.
48
- for (const member of node.members) {
49
- if (member.name.text == "__SERIALIZE") return;
50
- }
51
-
52
- this.currentClass = {
53
- name: className,
54
- keys: [],
55
- values: [],
56
- types: [],
57
- parent: node.extendsType ? toString(node.extendsType) : "",
58
- node: node,
59
- encodeStmts: [],
60
- setDataStmts: [],
61
- initializeStmts: []
62
- };
63
-
64
- if (this.currentClass.parent.length) {
65
- const parentSchema = this.schemasList.find(
66
- (v) => v.name == this.currentClass.parent
67
- );
68
- if (parentSchema?.encodeStmts) {
69
- parentSchema?.encodeStmts.push(parentSchema?.encodeStmts.pop() + ",");
70
- for (let i = 0; i < parentSchema.keys.length; i++) {
71
- const key = parentSchema.keys[i];
72
- if (node.members.filter(v => v.name.text == key) == undefined) this.currentClass.encodeStmts.unshift(parentSchema.encodeStmts[i]!);
73
- }
74
- }
75
- }
76
-
77
- const parentSchema = this.schemasList.find(
78
- (v) => v.name == this.currentClass.parent
79
- );
80
-
81
- const members = [
82
- ...node.members
83
- ];
84
-
85
- if (parentSchema) {
86
- for (const mem of parentSchema.node.members) {
87
- if (members.find(v => v.name === mem.name) == undefined) members.unshift(mem);
88
- }
89
- }
90
-
91
- for (const mem of members) {
92
- // @ts-ignore
93
- if (mem.type && mem.type.name && mem.type.name.identifier.text) {
94
- const member = mem as FieldDeclaration;
95
- const lineText = toString(member);
96
- //console.log("Member: " + lineText)
97
-
98
- if (!lineText.startsWith("private ") && !lineText.startsWith("static ")) {
99
-
100
- // @ts-ignore
101
- let type = toString(member.type);
102
-
103
- const name = member.name.text;
104
- let aliasName = name;
105
-
106
- // @ts-ignore
107
- if (member.decorators && member.decorators[0]?.name.text === "alias") {
108
- if (member.decorators[0] && member.decorators[0].args![0]) {
109
- // @ts-ignore
110
- aliasName = member.decorators[0].args![0].value;
111
- }
112
- }
113
- this.currentClass.keys.push(name);
114
- // @ts-ignore
115
- this.currentClass.types.push(type);
116
- // @ts-ignore
117
- if (
118
- [
119
- "u8",
120
- "i8",
121
- "u16",
122
- "i16",
123
- "u32",
124
- "i32",
125
- "u64",
126
- "i64",
127
- ].includes(type.toLowerCase())
128
- ) {
129
- this.currentClass.encodeStmts.push(
130
- `${encodeKey(aliasName)}:\${this.${name}},`
131
- );
132
- // @ts-ignore
133
- this.currentClass.setDataStmts.push(
134
- `if (key.equals(${JSON.stringify(aliasName)})) {
135
- this.${name} = __atoi_fast<${type}>(data, val_start << 1, val_end << 1);
136
- return;
137
- }`
138
- );
139
- if (member.initializer) {
140
- this.currentClass.initializeStmts.push(
141
- `this.${name} = ${toString(member.initializer)}`
142
- );
143
- }
144
- } else // @ts-ignore
145
- if (
146
- [
147
- "f32",
148
- "f64",
149
- ].includes(type.toLowerCase())
150
- ) {
151
- this.currentClass.encodeStmts.push(
152
- `${encodeKey(aliasName)}:\${this.${name}},`
153
- );
154
- // @ts-ignore
155
- this.currentClass.setDataStmts.push(
156
- `if (key.equals(${JSON.stringify(aliasName)})) {
157
- this.${name} = __parseObjectValue<${type}>(data.slice(val_start, val_end), initializeDefaultValues);
158
- return;
159
- }`
160
- );
161
- if (member.initializer) {
162
- this.currentClass.initializeStmts.push(
163
- `this.${name} = ${toString(member.initializer)}`
164
- );
165
- }
166
- } else {
167
- this.currentClass.encodeStmts.push(
168
- `${encodeKey(aliasName)}:\${__JSON_Stringify<${type}>(this.${name})},`
169
- );
170
- // @ts-ignore
171
- this.currentClass.setDataStmts.push(
172
- `if (key.equals(${JSON.stringify(aliasName)})) {
173
- this.${name} = __parseObjectValue<${type}>(val_start ? data.slice(val_start, val_end) : data, initializeDefaultValues);
174
- return;
175
- }`
176
- );
177
- if (member.initializer) {
178
- this.currentClass.initializeStmts.push(
179
- `this.${name} = ${toString(member.initializer)}`
180
- );
181
- }
182
- }
183
- }
184
- }
185
- }
186
-
187
- let serializeFunc = "";
188
-
189
- if (this.currentClass.encodeStmts.length > 0) {
190
- const stmt =
191
- this.currentClass.encodeStmts[
192
- this.currentClass.encodeStmts.length - 1
193
- ]!;
194
- this.currentClass.encodeStmts[this.currentClass.encodeStmts.length - 1] =
195
- stmt!.slice(0, stmt.length - 1);
196
- serializeFunc = `
197
- __SERIALIZE(): string {
198
- return \`{${this.currentClass.encodeStmts.join("")}}\`;
199
- }`;
200
- } else {
201
- serializeFunc = `
202
- __SERIALIZE(): string {
203
- return "{}";
204
- }`;
205
- }
206
-
207
- const setKeyFunc = `
208
- __JSON_Set_Key(key: __Virtual<string>, data: string, val_start: i32, val_end: i32, initializeDefaultValues: boolean): void {
209
- ${this.currentClass.setDataStmts.join("\n ")}
210
- }
211
- `;
212
-
213
- let initializeFunc = "";
214
-
215
- if (this.currentClass.initializeStmts.length > 0) {
216
- initializeFunc = `
217
- __JSON_Initialize(): void {
218
- ${this.currentClass.initializeStmts.join(";\n")};
219
- }
220
- `;
221
- } else {
222
- initializeFunc = `
223
- __JSON_Initialize(): void {}
224
- `;
225
- }
226
- const serializeMethod = SimpleParser.parseClassMember(serializeFunc, node);
227
- node.members.push(serializeMethod);
228
-
229
- const setDataMethod = SimpleParser.parseClassMember(setKeyFunc, node);
230
- node.members.push(setDataMethod);
231
-
232
- const initializeMethod = SimpleParser.parseClassMember(initializeFunc, node);
233
- node.members.push(initializeMethod);
234
-
235
- this.schemasList.push(this.currentClass);
236
- this.sources.add(node.name.range.source);
237
-
238
- // Uncomment to see the generated code for debugging.
239
- //console.log(serializeFunc);
240
- //console.log(setKeyFunc);
241
- //console.log(initializeFunc);
242
- }
243
-
244
- visitSource(node: Source): void {
245
- super.visitSource(node);
246
-
247
- // Only add the import statement to sources that have JSON decorated classes.
248
- if (!this.sources.has(node)) {
249
- return;
250
- }
251
-
252
- // Note, the following one liner would be easier, but it fails with an assertion error
253
- // because as-virtual's SimpleParser doesn't set the parser.currentSource correctly.
254
- //
255
- // const stmt = SimpleParser.parseTopLevelStatement('import { Virtual as __Virtual } from "as-virtual/assembly";');
256
-
257
- // ... So we have to do it the long way:
258
- const txt = 'import { Virtual as __Virtual } from "as-virtual/assembly";'
259
- const tokenizer = new Tokenizer(new Source(SourceKind.User, node.normalizedPath, txt));
260
- const parser = new Parser();
261
- parser.currentSource = tokenizer.source;
262
- const stmt = parser.parseTopLevelStatement(tokenizer)!;
263
-
264
- // Add the import statement to the top of the source.
265
- node.statements.unshift(stmt);
266
- }
267
- }
268
-
269
- function encodeKey(aliasName: string): string {
270
- return JSON.stringify(aliasName)
271
- .replace(/\\/g, "\\\\")
272
- .replace(/\`/g, '\\`');
273
- }
274
-
275
- export default class Transformer extends Transform {
276
- // Trigger the transform after parse.
277
- afterParse(parser: Parser): void {
278
- // Create new transform
279
- const transformer = new AsJSONTransform();
280
-
281
- // Sort the sources so that user scripts are visited last
282
- const sources = parser.sources
283
- .filter((source) => !isStdlib(source))
284
- .sort((_a, _b) => {
285
- const a = _a.internalPath;
286
- const b = _b.internalPath;
287
- if (a[0] === "~" && b[0] !== "~") {
288
- return -1;
289
- } else if (a[0] !== "~" && b[0] === "~") {
290
- return 1;
291
- } else {
292
- return 0;
293
- }
294
- });
295
-
296
- // Loop over every source
297
- for (const source of sources) {
298
- // Ignore all lib and std. Visit everything else.
299
- if (!isStdlib(source)) {
300
- transformer.visit(source);
301
- }
302
- }
303
- // Check that every parent and child class is hooked up correctly
304
- const schemas = transformer.schemasList;
305
- for (const schema of schemas) {
306
- if (schema.parent) {
307
- const parent = schemas.find((v) => v.name === schema.parent);
308
- if (!parent) throw new Error(`Class ${schema.name} extends its parent class ${schema.parent}, but ${schema.parent} does not include a @json or @serializable decorator! Add the decorator and rebuild.`);
309
- }
310
- }
311
- }
312
- }
File without changes