rescript-relay 0.0.0-test-rust-compiler-a2f32b9e → 0.0.0-windows-96019f80
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/CHANGELOG.md +157 -6
- package/README.md +6 -10
- package/cli/cli.js +29 -35
- package/package.json +20 -11
- package/postinstall.js +17 -5
- package/ppx-linux +0 -0
- package/ppx-macos-latest +0 -0
- package/ppx-windows-latest +0 -0
- package/relay-compiler-linux-musl/relay +0 -0
- package/relay-compiler-linux-x64/relay +0 -0
- package/relay-compiler-macos-arm64/relay +0 -0
- package/relay-compiler-macos-x64/relay +0 -0
- package/{ppx-darwin → relay-compiler-win-x64/relay.exe} +0 -0
- package/src/ReactDOMExperimental.bs.js +3 -3
- package/src/ReactDOMExperimental.res +2 -3
- package/src/ReactExperimental.bs.js +14 -1
- package/src/ReactExperimental.res +9 -4
- package/src/ReactExperimental.resi +18 -0
- package/src/RescriptRelay.bs.js +21 -8
- package/src/RescriptRelay.res +70 -15
- package/src/RescriptRelay.resi +57 -13
- package/src/RescriptRelay_Internal.bs.js +42 -13
- package/src/RescriptRelay_Internal.res +22 -18
- package/src/RescriptRelay_Internal.resi +1 -0
- package/src/experimental-router/RescriptRelayRouter.bs.js +2 -1
- package/src/utils.js +184 -163
- package/src/utils.mjs +381 -0
|
@@ -3,23 +3,51 @@
|
|
|
3
3
|
|
|
4
4
|
var Curry = require("rescript/lib/js/curry.js");
|
|
5
5
|
var React = require("react");
|
|
6
|
+
var Js_dict = require("rescript/lib/js/js_dict.js");
|
|
7
|
+
var Caml_obj = require("rescript/lib/js/caml_obj.js");
|
|
8
|
+
var Belt_Array = require("rescript/lib/js/belt_Array.js");
|
|
9
|
+
var Belt_Option = require("rescript/lib/js/belt_Option.js");
|
|
6
10
|
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var newObj = {};
|
|
12
|
+
function internal_keepMapFieldsRaw(record, f) {
|
|
13
|
+
return Belt_Option.map(record, (function (obj) {
|
|
14
|
+
return Js_dict.fromArray(Belt_Array.keepMap(Js_dict.entries(obj), f));
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
function internal_cleanObjectFromUndefinedRaw(record) {
|
|
19
|
+
return internal_keepMapFieldsRaw(record, (function (param) {
|
|
20
|
+
var value = param[1];
|
|
21
|
+
if (value !== undefined) {
|
|
22
|
+
return [
|
|
23
|
+
param[0],
|
|
24
|
+
Caml_option.valFromOption(value)
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
20
30
|
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
function internal_removeUndefinedAndConvertNullsRaw(record) {
|
|
32
|
+
return internal_keepMapFieldsRaw(record, (function (param) {
|
|
33
|
+
var value = param[1];
|
|
34
|
+
var key = param[0];
|
|
35
|
+
var match = Caml_obj.caml_equal(value, Caml_option.some(undefined));
|
|
36
|
+
if (value !== undefined) {
|
|
37
|
+
return [
|
|
38
|
+
key,
|
|
39
|
+
Caml_option.valFromOption(value)
|
|
40
|
+
];
|
|
41
|
+
} else if (match) {
|
|
42
|
+
return [
|
|
43
|
+
key,
|
|
44
|
+
null
|
|
45
|
+
];
|
|
46
|
+
} else {
|
|
47
|
+
return ;
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
23
51
|
|
|
24
52
|
function internal_useConvertedValue(convert, v) {
|
|
25
53
|
return React.useMemo((function () {
|
|
@@ -38,5 +66,6 @@ function internal_nullableToOptionalExnHandler(x) {
|
|
|
38
66
|
|
|
39
67
|
exports.internal_useConvertedValue = internal_useConvertedValue;
|
|
40
68
|
exports.internal_cleanObjectFromUndefinedRaw = internal_cleanObjectFromUndefinedRaw;
|
|
69
|
+
exports.internal_removeUndefinedAndConvertNullsRaw = internal_removeUndefinedAndConvertNullsRaw;
|
|
41
70
|
exports.internal_nullableToOptionalExnHandler = internal_nullableToOptionalExnHandler;
|
|
42
71
|
/* react Not a pure module */
|
|
@@ -1,23 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return obj;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
var newObj = {};
|
|
1
|
+
let internal_keepMapFieldsRaw = (record, f) =>
|
|
2
|
+
record
|
|
3
|
+
->Obj.magic
|
|
4
|
+
->Belt.Option.map(obj => obj->Js.Dict.entries->Belt.Array.keepMap(f)->Js.Dict.fromArray)
|
|
5
|
+
->Obj.magic
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
// we need to do this until we can use @obj on record types
|
|
8
|
+
// see https://github.com/rescript-lang/rescript-compiler/pull/5253
|
|
9
|
+
let internal_cleanObjectFromUndefinedRaw = record =>
|
|
10
|
+
internal_keepMapFieldsRaw(record, ((key, value)) => {
|
|
11
|
+
switch value {
|
|
12
|
+
| Some(value) => Some((key, value))
|
|
13
|
+
| None => None
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
17
|
+
let internal_removeUndefinedAndConvertNullsRaw = record =>
|
|
18
|
+
internal_keepMapFieldsRaw(record, ((key, value)) => {
|
|
19
|
+
switch (value, value == Some(None)) {
|
|
20
|
+
| (Some(value), _) => Some((key, Js.Nullable.return(value)))
|
|
21
|
+
| (_, true) => Some((key, Js.Nullable.null))
|
|
22
|
+
| (None, _) => None
|
|
23
|
+
}
|
|
24
|
+
})
|
|
21
25
|
|
|
22
26
|
let internal_useConvertedValue = (convert, v) => React.useMemo1(() => convert(v), [v])
|
|
23
27
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
let internal_useConvertedValue: ('a => 'a, 'a) => 'a
|
|
2
2
|
let internal_cleanObjectFromUndefinedRaw: 't => 't
|
|
3
|
+
let internal_removeUndefinedAndConvertNullsRaw: 't => 't
|
|
3
4
|
let internal_nullableToOptionalExnHandler: option<option<'b> => 'a> => option<
|
|
4
5
|
Js.Nullable.t<'b> => 'a,
|
|
5
6
|
>
|
|
@@ -9,6 +9,7 @@ var Belt_Array = require("rescript/lib/js/belt_Array.js");
|
|
|
9
9
|
var Belt_Option = require("rescript/lib/js/belt_Option.js");
|
|
10
10
|
var Caml_option = require("rescript/lib/js/caml_option.js");
|
|
11
11
|
var Caml_exceptions = require("rescript/lib/js/caml_exceptions.js");
|
|
12
|
+
var ReactExperimental = require("../ReactExperimental.bs.js");
|
|
12
13
|
var RescriptReactRouter = require("@rescript/react/src/RescriptReactRouter.bs.js");
|
|
13
14
|
|
|
14
15
|
function matchesUrl(t, url) {
|
|
@@ -242,7 +243,7 @@ function RescriptRelayRouter$RouteRenderer(Props) {
|
|
|
242
243
|
});
|
|
243
244
|
var initialized = match[0];
|
|
244
245
|
var router = React.useContext(context);
|
|
245
|
-
var match$1 =
|
|
246
|
+
var match$1 = ReactExperimental.useTransition(undefined);
|
|
246
247
|
var startTransition = match$1[1];
|
|
247
248
|
var match$2 = React.useState(function () {
|
|
248
249
|
return Curry._1(router.get, undefined);
|
package/src/utils.js
CHANGED
|
@@ -10,6 +10,19 @@ function makeNewPath(currentPath, newKeys) {
|
|
|
10
10
|
return [].concat(currentPath, newKeys);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
function getTypename(v) {
|
|
14
|
+
if (v != null && typeof v === "object") {
|
|
15
|
+
if (v.__typename) {
|
|
16
|
+
return v.__typename;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// `v.VAL` relies on internal implementation details in ReScript.
|
|
20
|
+
if (v.VAL != null && typeof v.VAL === "object") {
|
|
21
|
+
return v.VAL.__typename;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
/**
|
|
14
27
|
* Runs on each object in the tree and follows the provided instructions
|
|
15
28
|
* to apply transforms etc.
|
|
@@ -24,6 +37,10 @@ function traverse(
|
|
|
24
37
|
instructionPaths,
|
|
25
38
|
addFragmentOnRoot
|
|
26
39
|
) {
|
|
40
|
+
// We lazily set up a new object for each "level", as we don't want to mutate
|
|
41
|
+
// what comes back from the Relay store, and nor do we want to create new
|
|
42
|
+
// objects unless we need to. And we only need to when we need to change
|
|
43
|
+
// something.
|
|
27
44
|
var newObj;
|
|
28
45
|
|
|
29
46
|
if (addFragmentOnRoot) {
|
|
@@ -32,6 +49,8 @@ function traverse(
|
|
|
32
49
|
}
|
|
33
50
|
|
|
34
51
|
for (var key in currentObj) {
|
|
52
|
+
if (key === "VAL" || key === "NAME") continue;
|
|
53
|
+
|
|
35
54
|
var isUnion = false;
|
|
36
55
|
var originalValue = currentObj[key];
|
|
37
56
|
|
|
@@ -39,151 +58,73 @@ function traverse(
|
|
|
39
58
|
var thisPath = makeNewPath(currentPath, [key]);
|
|
40
59
|
var path = getPathName(thisPath);
|
|
41
60
|
|
|
42
|
-
var instructions = instructionMap[path];
|
|
43
|
-
|
|
44
|
-
var hasDeeperInstructions =
|
|
45
|
-
instructionPaths.filter(function (p) {
|
|
46
|
-
return p.indexOf(path) === 0 && p.length > path.length;
|
|
47
|
-
}).length > 0;
|
|
61
|
+
var instructions = instructionMap[path] || {};
|
|
48
62
|
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
} else {
|
|
56
|
-
var shouldConvertRootObj =
|
|
57
|
-
typeof instructions["r"] === "string" &&
|
|
58
|
-
fullInstructionMap[instructions["r"]];
|
|
63
|
+
if (currentObj[key] == null) {
|
|
64
|
+
newObj = getNewObj(newObj, currentObj);
|
|
65
|
+
newObj[key] = nullableValue;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
59
68
|
|
|
60
|
-
|
|
69
|
+
var shouldConvertRootObj =
|
|
70
|
+
typeof instructions["r"] === "string" &&
|
|
71
|
+
fullInstructionMap[instructions["r"]];
|
|
61
72
|
|
|
62
|
-
|
|
63
|
-
typeof instructions["e"] === "string" &&
|
|
64
|
-
!!converters[instructions["e"]];
|
|
73
|
+
var shouldAddFragmentFn = instructions["f"] === "";
|
|
65
74
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
!!converters[instructions["c"]];
|
|
75
|
+
var shouldConvertEnum =
|
|
76
|
+
typeof instructions["e"] === "string" && !!converters[instructions["e"]];
|
|
69
77
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
!!converters[instructions["u"]];
|
|
78
|
+
var shouldConvertCustomField =
|
|
79
|
+
typeof instructions["c"] === "string" && !!converters[instructions["c"]];
|
|
73
80
|
|
|
74
|
-
|
|
81
|
+
var shouldConvertUnion =
|
|
82
|
+
typeof instructions["u"] === "string" && !!converters[instructions["u"]];
|
|
75
83
|
|
|
76
|
-
|
|
77
|
-
* Handle arrays
|
|
78
|
-
*/
|
|
79
|
-
if (Array.isArray(currentObj[key])) {
|
|
80
|
-
newObj = getNewObj(newObj, currentObj);
|
|
81
|
-
newObj[key] = currentObj[key].map(function (v) {
|
|
82
|
-
if (v == null) {
|
|
83
|
-
return nullableValue;
|
|
84
|
-
}
|
|
84
|
+
var isTopLevelNodeField = typeof instructions["tnf"] === "string";
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Handle arrays
|
|
88
|
+
*/
|
|
89
|
+
if (Array.isArray(currentObj[key])) {
|
|
90
|
+
newObj = getNewObj(newObj, currentObj);
|
|
91
|
+
newObj[key] = currentObj[key].map(function (v) {
|
|
92
|
+
if (v == null) {
|
|
93
|
+
return nullableValue;
|
|
94
|
+
}
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
96
|
+
if (shouldConvertRootObj) {
|
|
97
|
+
return traverser(
|
|
98
|
+
v,
|
|
99
|
+
fullInstructionMap,
|
|
100
|
+
converters,
|
|
101
|
+
nullableValue,
|
|
102
|
+
instructions["r"]
|
|
103
|
+
);
|
|
104
|
+
}
|
|
99
105
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
if (shouldConvertEnum) {
|
|
107
|
+
return converters[instructions["e"]](v);
|
|
108
|
+
}
|
|
103
109
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
typeof v.__typename === "string"
|
|
108
|
-
) {
|
|
109
|
-
isUnion = true;
|
|
110
|
-
|
|
111
|
-
var newPath = makeNewPath(currentPath, [key, v.__typename]);
|
|
112
|
-
|
|
113
|
-
var unionRootHasFragment =
|
|
114
|
-
(instructionMap[getPathName(newPath)] || {}).f === "";
|
|
115
|
-
|
|
116
|
-
var traversedValue = traverse(
|
|
117
|
-
fullInstructionMap,
|
|
118
|
-
newPath,
|
|
119
|
-
v,
|
|
120
|
-
instructionMap,
|
|
121
|
-
converters,
|
|
122
|
-
nullableValue,
|
|
123
|
-
instructionPaths,
|
|
124
|
-
unionRootHasFragment
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
return converters[instructions["u"]](traversedValue);
|
|
128
|
-
}
|
|
110
|
+
if (shouldConvertCustomField) {
|
|
111
|
+
return converters[instructions["c"]](v);
|
|
112
|
+
}
|
|
129
113
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
objWithFragmentFn.fragmentRefs = Object.assign(
|
|
133
|
-
{},
|
|
134
|
-
objWithFragmentFn
|
|
135
|
-
);
|
|
136
|
-
return objWithFragmentFn;
|
|
137
|
-
}
|
|
114
|
+
if (shouldConvertUnion && v != null && typeof v === "object") {
|
|
115
|
+
var typename = getTypename(v);
|
|
138
116
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Handle normal values.
|
|
144
|
-
*/
|
|
145
|
-
var v = currentObj[key];
|
|
146
|
-
|
|
147
|
-
if (shouldConvertRootObj) {
|
|
148
|
-
newObj = getNewObj(newObj, currentObj);
|
|
149
|
-
newObj[key] = traverser(
|
|
150
|
-
v,
|
|
151
|
-
fullInstructionMap,
|
|
152
|
-
converters,
|
|
153
|
-
nullableValue,
|
|
154
|
-
instructions["r"]
|
|
155
|
-
);
|
|
156
|
-
}
|
|
117
|
+
if (typename != null) {
|
|
118
|
+
isUnion = true;
|
|
119
|
+
var unionObj = v;
|
|
157
120
|
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
v.__typename !== instructions["tnf"]
|
|
163
|
-
) {
|
|
164
|
-
newObj = getNewObj(newObj, currentObj);
|
|
165
|
-
newObj[key] = nullableValue;
|
|
121
|
+
// Means we're wrapping, and this will be a ReScript value.
|
|
122
|
+
if (nullableValue === null) {
|
|
123
|
+
// Convert it back to a flat JS value
|
|
124
|
+
unionObj = converters[instructions["u"]](v);
|
|
166
125
|
}
|
|
167
|
-
}
|
|
168
126
|
|
|
169
|
-
|
|
170
|
-
newObj = getNewObj(newObj, currentObj);
|
|
171
|
-
newObj[key] = converters[instructions["e"]](v);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (shouldConvertCustomField) {
|
|
175
|
-
newObj = getNewObj(newObj, currentObj);
|
|
176
|
-
newObj[key] = converters[instructions["c"]](v);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (
|
|
180
|
-
shouldConvertUnion &&
|
|
181
|
-
typeof v === "object" &&
|
|
182
|
-
typeof v.__typename === "string"
|
|
183
|
-
) {
|
|
184
|
-
isUnion = true;
|
|
185
|
-
|
|
186
|
-
var newPath = makeNewPath(currentPath, [key, v.__typename]);
|
|
127
|
+
var newPath = makeNewPath(currentPath, [key, typename]);
|
|
187
128
|
|
|
188
129
|
var unionRootHasFragment =
|
|
189
130
|
(instructionMap[getPathName(newPath)] || {}).f === "";
|
|
@@ -191,7 +132,7 @@ function traverse(
|
|
|
191
132
|
var traversedValue = traverse(
|
|
192
133
|
fullInstructionMap,
|
|
193
134
|
newPath,
|
|
194
|
-
|
|
135
|
+
unionObj,
|
|
195
136
|
instructionMap,
|
|
196
137
|
converters,
|
|
197
138
|
nullableValue,
|
|
@@ -199,27 +140,113 @@ function traverse(
|
|
|
199
140
|
unionRootHasFragment
|
|
200
141
|
);
|
|
201
142
|
|
|
202
|
-
|
|
203
|
-
|
|
143
|
+
// Undefined means we're going from JS to ReScript, in which case we
|
|
144
|
+
// need to run the conversion here rather than earlier.
|
|
145
|
+
return nullableValue === undefined
|
|
146
|
+
? converters[instructions["u"]](traversedValue)
|
|
147
|
+
: traversedValue;
|
|
204
148
|
}
|
|
149
|
+
}
|
|
205
150
|
|
|
206
|
-
|
|
207
|
-
|
|
151
|
+
if (shouldAddFragmentFn && typeof v === "object") {
|
|
152
|
+
var objWithFragmentFn = Object.assign({}, v);
|
|
153
|
+
objWithFragmentFn.fragmentRefs = Object.assign({}, objWithFragmentFn);
|
|
154
|
+
return objWithFragmentFn;
|
|
155
|
+
}
|
|
208
156
|
|
|
209
|
-
|
|
157
|
+
return v;
|
|
158
|
+
});
|
|
159
|
+
} else {
|
|
160
|
+
/**
|
|
161
|
+
* Handle normal values.
|
|
162
|
+
*/
|
|
163
|
+
var v = currentObj[key];
|
|
210
164
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
165
|
+
if (shouldConvertRootObj) {
|
|
166
|
+
newObj = getNewObj(newObj, currentObj);
|
|
167
|
+
newObj[key] = traverser(
|
|
168
|
+
v,
|
|
169
|
+
fullInstructionMap,
|
|
170
|
+
converters,
|
|
171
|
+
nullableValue,
|
|
172
|
+
instructions["r"]
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (isTopLevelNodeField) {
|
|
177
|
+
// If this is a top level node field we should try and convert, ensure
|
|
178
|
+
// it conforms to the desired shape (has the correct typename). If not,
|
|
179
|
+
// null it and return right away.
|
|
180
|
+
if (
|
|
181
|
+
v == null ||
|
|
182
|
+
!v.hasOwnProperty("__typename") ||
|
|
183
|
+
v.__typename !== instructions["tnf"]
|
|
184
|
+
) {
|
|
185
|
+
newObj = getNewObj(newObj, currentObj);
|
|
186
|
+
newObj[key] = nullableValue;
|
|
187
|
+
return newObj;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (shouldConvertEnum) {
|
|
192
|
+
newObj = getNewObj(newObj, currentObj);
|
|
193
|
+
newObj[key] = converters[instructions["e"]](v);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (shouldConvertCustomField) {
|
|
197
|
+
newObj = getNewObj(newObj, currentObj);
|
|
198
|
+
newObj[key] = converters[instructions["c"]](v);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (shouldConvertUnion && v != null && typeof v === "object") {
|
|
202
|
+
var typename = getTypename(v);
|
|
203
|
+
|
|
204
|
+
if (typename != null) {
|
|
205
|
+
isUnion = true;
|
|
206
|
+
var unionObj = v;
|
|
215
207
|
|
|
216
|
-
|
|
208
|
+
// Means we're wrapping, and this will be a ReScript value.
|
|
209
|
+
if (nullableValue === null) {
|
|
210
|
+
// Convert it back to a flat JS value
|
|
211
|
+
unionObj = converters[instructions["u"]](v);
|
|
217
212
|
}
|
|
213
|
+
|
|
214
|
+
var newPath = makeNewPath(currentPath, [key, typename]);
|
|
215
|
+
|
|
216
|
+
var unionRootHasFragment =
|
|
217
|
+
(instructionMap[getPathName(newPath)] || {}).f === "";
|
|
218
|
+
|
|
219
|
+
var traversedValue = traverse(
|
|
220
|
+
fullInstructionMap,
|
|
221
|
+
newPath,
|
|
222
|
+
unionObj,
|
|
223
|
+
instructionMap,
|
|
224
|
+
converters,
|
|
225
|
+
nullableValue,
|
|
226
|
+
instructionPaths,
|
|
227
|
+
unionRootHasFragment
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
newObj = getNewObj(newObj, currentObj);
|
|
231
|
+
|
|
232
|
+
newObj[key] =
|
|
233
|
+
// Undefined means we're going from JS to ReScript, in which case we
|
|
234
|
+
// need to run the conversion here rather than earlier.
|
|
235
|
+
nullableValue === undefined
|
|
236
|
+
? converters[instructions["u"]](traversedValue)
|
|
237
|
+
: traversedValue;
|
|
218
238
|
}
|
|
219
239
|
}
|
|
240
|
+
|
|
241
|
+
if (shouldAddFragmentFn && typeof v === "object") {
|
|
242
|
+
newObj = getNewObj(newObj, currentObj);
|
|
243
|
+
var objWithFragmentFn = Object.assign({}, v);
|
|
244
|
+
objWithFragmentFn.fragmentRefs = Object.assign({}, objWithFragmentFn);
|
|
245
|
+
newObj[key] = objWithFragmentFn;
|
|
246
|
+
}
|
|
220
247
|
}
|
|
221
248
|
|
|
222
|
-
if (
|
|
249
|
+
if (originalValue != null && !isUnion) {
|
|
223
250
|
var nextObj = (newObj && newObj[key]) || currentObj[key];
|
|
224
251
|
|
|
225
252
|
if (typeof nextObj === "object" && !Array.isArray(originalValue)) {
|
|
@@ -240,17 +267,21 @@ function traverse(
|
|
|
240
267
|
} else if (Array.isArray(originalValue)) {
|
|
241
268
|
newObj = getNewObj(newObj, currentObj);
|
|
242
269
|
newObj[key] = nextObj.map(function (o) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
270
|
+
if (typeof o === "object" && o != null) {
|
|
271
|
+
return traverse(
|
|
272
|
+
fullInstructionMap,
|
|
273
|
+
thisPath,
|
|
274
|
+
o,
|
|
275
|
+
instructionMap,
|
|
276
|
+
converters,
|
|
277
|
+
nullableValue,
|
|
278
|
+
instructionPaths
|
|
279
|
+
);
|
|
280
|
+
} else if (o == null) {
|
|
281
|
+
return nullableValue;
|
|
282
|
+
} else {
|
|
283
|
+
return o;
|
|
284
|
+
}
|
|
254
285
|
});
|
|
255
286
|
}
|
|
256
287
|
}
|
|
@@ -280,21 +311,11 @@ function traverser(
|
|
|
280
311
|
}
|
|
281
312
|
|
|
282
313
|
var instructionMaps = instructionMaps_ || {};
|
|
283
|
-
var instructionMap = instructionMaps[rootObjectKey || "__root"];
|
|
284
|
-
|
|
285
|
-
// No instructions
|
|
286
|
-
if (!instructionMap) {
|
|
287
|
-
return root;
|
|
288
|
-
}
|
|
314
|
+
var instructionMap = instructionMaps[rootObjectKey || "__root"] || {};
|
|
289
315
|
|
|
290
316
|
var converters = theConverters == null ? {} : theConverters;
|
|
291
317
|
var instructionPaths = Object.keys(instructionMap);
|
|
292
318
|
|
|
293
|
-
// Nothing to convert, bail early
|
|
294
|
-
if (instructionPaths.length === 0) {
|
|
295
|
-
return root;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
319
|
// We'll add the fragmentRefs reference to the root if needed here.
|
|
299
320
|
var fragmentsOnRoot = (instructionMap[""] || {}).f === "";
|
|
300
321
|
var unionRootConverter = converters[(instructionMap[""] || {}).u];
|