json-as 0.5.21 → 0.5.23

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": "json-as",
3
- "version": "0.5.21",
3
+ "version": "0.5.23",
4
4
  "description": "JSON encoder/decoder for AssemblyScript",
5
5
  "types": "assembly/index.ts",
6
6
  "author": "Jairus Tanaka",
@@ -48,9 +48,9 @@ class AsJSONTransform extends BaseVisitor {
48
48
  //);
49
49
  }
50
50
  visitClassDeclaration(node) {
51
- var _a;
51
+ var _c;
52
52
  const className = node.name.text;
53
- if (!((_a = node.decorators) === null || _a === void 0 ? void 0 : _a.length))
53
+ if (!((_c = node.decorators) === null || _c === void 0 ? void 0 : _c.length))
54
54
  return;
55
55
  let foundDecorator = false;
56
56
  for (const decorator of node.decorators) {
@@ -127,8 +127,22 @@ export default class Transformer extends Transform {
127
127
  afterParse(parser) {
128
128
  // Create new transform
129
129
  const transformer = new AsJSONTransform();
130
+ // Sort the sources so that user scripts are visited last
131
+ const sources = parser.sources.filter(source => !isStdlib(source)).sort((_a, _b) => {
132
+ const a = _a.internalPath;
133
+ const b = _b.internalPath;
134
+ if (a[0] === "~" && b[0] !== "~") {
135
+ return -1;
136
+ }
137
+ else if (a[0] !== "~" && b[0] === "~") {
138
+ return 1;
139
+ }
140
+ else {
141
+ return 0;
142
+ }
143
+ });
130
144
  // Loop over every source
131
- for (const source of parser.sources) {
145
+ for (const source of sources) {
132
146
  // Ignore all lib and std. Visit everything else.
133
147
  if (!isStdlib(source)) {
134
148
  transformer.visit(source);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-as/transform",
3
- "version": "0.5.21",
3
+ "version": "0.5.23",
4
4
  "description": "JSON encoder/decoder for AssemblyScript",
5
5
  "main": "./lib/index.js",
6
6
  "author": "Jairus Tanaka",
@@ -149,8 +149,22 @@ export default class Transformer extends Transform {
149
149
  afterParse(parser: Parser): void {
150
150
  // Create new transform
151
151
  const transformer = new AsJSONTransform();
152
+
153
+ // Sort the sources so that user scripts are visited last
154
+ const sources = parser.sources.filter(source => !isStdlib(source)).sort((_a, _b) => {
155
+ const a = _a.internalPath
156
+ const b = _b.internalPath
157
+ if (a[0] === "~" && b[0] !== "~") {
158
+ return -1;
159
+ } else if (a[0] !== "~" && b[0] === "~") {
160
+ return 1;
161
+ } else {
162
+ return 0;
163
+ }
164
+ })
165
+
152
166
  // Loop over every source
153
- for (const source of parser.sources) {
167
+ for (const source of sources) {
154
168
  // Ignore all lib and std. Visit everything else.
155
169
  if (!isStdlib(source)) {
156
170
  transformer.visit(source);