@valbuild/react 0.18.0 → 0.20.0

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.
@@ -13,7 +13,7 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
13
13
  };
14
14
  var addValPathIfFound = function addValPathIfFound(type, props) {
15
15
  var valSources = [];
16
- if (isIntrinsicElement(type) && props && _typeof(props) === "object") {
16
+ if (props && _typeof(props) === "object") {
17
17
  for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
18
18
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
19
19
  key = _Object$entries$_i[0],
@@ -26,7 +26,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
26
26
  var valPath = encodedBits === null || encodedBits === void 0 ? void 0 : (_encodedBits$data = encodedBits.data) === null || _encodedBits$data === void 0 ? void 0 : _encodedBits$data.valPath;
27
27
  if (valPath) {
28
28
  valSources.push(valPath);
29
- props[key] = vercelStegaSplit(value).cleaned;
29
+ props[key] = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
30
30
  props["data-val-attr-".concat(key)] = valPath;
31
31
  }
32
32
  }
@@ -98,26 +98,33 @@ function _objectSpread2(target) {
98
98
  *
99
99
  */
100
100
 
101
- function transform(input, opts) {
102
- function rec(sourceOrSelector, path) {
101
+ function stegaEncode(input, opts) {
102
+ function rec(sourceOrSelector, recOpts) {
103
103
  if (_typeof(sourceOrSelector) === "object") {
104
- var selectorPath = Internal.getValPath(sourceOrSelector);
105
- if (selectorPath) {
106
- return rec(opts.getModule && opts.getModule(selectorPath) || Internal.getSource(sourceOrSelector), opts.disabled ? undefined : selectorPath);
107
- }
108
104
  if (!sourceOrSelector) {
109
105
  return null;
110
106
  }
107
+ var selectorPath = Internal.getValPath(sourceOrSelector);
108
+ if (selectorPath) {
109
+ var newSchema = Internal.getSchema(sourceOrSelector);
110
+ return rec(opts.getModule && opts.getModule(selectorPath) || Internal.getSource(sourceOrSelector), opts.disabled ? undefined : {
111
+ path: selectorPath,
112
+ schema: newSchema
113
+ });
114
+ }
111
115
  if (VAL_EXTENSION in sourceOrSelector) {
112
116
  if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
113
- return _objectSpread2(_objectSpread2({}, sourceOrSelector), {}, {
114
- valPath: path
115
- });
117
+ if (recOpts !== null && recOpts !== void 0 && recOpts.path) {
118
+ return _objectSpread2(_objectSpread2({}, Internal.convertRichTextSource(sourceOrSelector)), {}, {
119
+ valPath: recOpts.path
120
+ });
121
+ }
122
+ return Internal.convertRichTextSource(sourceOrSelector);
116
123
  }
117
124
  if (sourceOrSelector[VAL_EXTENSION] === "file" && typeof sourceOrSelector[FILE_REF_PROP] === "string") {
118
125
  var fileSelector = Internal.convertFileSource(sourceOrSelector);
119
126
  return _objectSpread2(_objectSpread2({}, fileSelector), {}, {
120
- url: rec(fileSelector.url, path)
127
+ url: rec(fileSelector.url, recOpts)
121
128
  });
122
129
  }
123
130
  console.error("Encountered unexpected extension: ".concat(sourceOrSelector[VAL_EXTENSION]));
@@ -125,7 +132,10 @@ function transform(input, opts) {
125
132
  }
126
133
  if (Array.isArray(sourceOrSelector)) {
127
134
  return sourceOrSelector.map(function (el, i) {
128
- return rec(el, path && Internal.createValPathOfItem(path, i));
135
+ return rec(el, recOpts && {
136
+ path: Internal.createValPathOfItem(recOpts.path, i),
137
+ schema: recOpts.schema.item
138
+ });
129
139
  });
130
140
  }
131
141
  if (!Array.isArray(sourceOrSelector)) {
@@ -134,18 +144,30 @@ function transform(input, opts) {
134
144
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
135
145
  _key = _Object$entries$_i[0],
136
146
  value = _Object$entries$_i[1];
137
- res[_key] = rec(value, path && Internal.createValPathOfItem(path, _key));
147
+ res[_key] = rec(value, recOpts && {
148
+ path: Internal.createValPathOfItem(recOpts.path, _key),
149
+ schema: recOpts.schema.item ||
150
+ // Record
151
+ recOpts.schema.items[_key] // Object
152
+ });
138
153
  }
154
+
139
155
  return res;
140
156
  }
141
157
  console.error("Could not transform source selector: ".concat(_typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
142
158
  return sourceOrSelector;
143
159
  }
144
160
  if (typeof sourceOrSelector === "string") {
161
+ if (!recOpts) {
162
+ return sourceOrSelector;
163
+ }
164
+ if (recOpts.schema.isRaw) {
165
+ return sourceOrSelector;
166
+ }
145
167
  return vercelStegaCombine(sourceOrSelector, {
146
168
  origin: "val.build",
147
169
  data: {
148
- valPath: path
170
+ valPath: recOpts.path
149
171
  }
150
172
  }, false // auto detection on urls and dates is disabled, isDate could be used but it is also disabled (users should use a date schema instead): isDate(sourceOrSelector) // skip = true if isDate
151
173
  );
@@ -163,14 +185,14 @@ function getModuleIds(input) {
163
185
  var modules = new Set();
164
186
  function rec(sourceOrSelector) {
165
187
  if (_typeof(sourceOrSelector) === "object") {
188
+ if (!sourceOrSelector) {
189
+ return;
190
+ }
166
191
  var selectorPath = Internal.getValPath(sourceOrSelector);
167
192
  if (selectorPath) {
168
193
  modules.add(selectorPath);
169
194
  return;
170
195
  }
171
- if (!sourceOrSelector) {
172
- return;
173
- }
174
196
  if (VAL_EXTENSION in sourceOrSelector) {
175
197
  if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
176
198
  return;
@@ -209,4 +231,4 @@ function getModuleIds(input) {
209
231
  return Array.from(modules);
210
232
  }
211
233
 
212
- export { autoTagJSX, getModuleIds, transform };
234
+ export { autoTagJSX, getModuleIds, stegaEncode };
@@ -23,7 +23,7 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
23
23
  };
24
24
  var addValPathIfFound = function addValPathIfFound(type, props) {
25
25
  var valSources = [];
26
- if (isIntrinsicElement(type) && props && _typeof._typeof(props) === "object") {
26
+ if (props && _typeof._typeof(props) === "object") {
27
27
  for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
28
28
  var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
29
29
  key = _Object$entries$_i[0],
@@ -36,7 +36,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
36
36
  var valPath = encodedBits === null || encodedBits === void 0 ? void 0 : (_encodedBits$data = encodedBits.data) === null || _encodedBits$data === void 0 ? void 0 : _encodedBits$data.valPath;
37
37
  if (valPath) {
38
38
  valSources.push(valPath);
39
- props[key] = stega.vercelStegaSplit(value).cleaned;
39
+ props[key] = isIntrinsicElement(type) ? stega.vercelStegaSplit(value).cleaned : value;
40
40
  props["data-val-attr-".concat(key)] = valPath;
41
41
  }
42
42
  }
@@ -108,26 +108,33 @@ function _objectSpread2(target) {
108
108
  *
109
109
  */
110
110
 
111
- function transform(input, opts) {
112
- function rec(sourceOrSelector, path) {
111
+ function stegaEncode(input, opts) {
112
+ function rec(sourceOrSelector, recOpts) {
113
113
  if (_typeof._typeof(sourceOrSelector) === "object") {
114
- var selectorPath = core.Internal.getValPath(sourceOrSelector);
115
- if (selectorPath) {
116
- return rec(opts.getModule && opts.getModule(selectorPath) || core.Internal.getSource(sourceOrSelector), opts.disabled ? undefined : selectorPath);
117
- }
118
114
  if (!sourceOrSelector) {
119
115
  return null;
120
116
  }
117
+ var selectorPath = core.Internal.getValPath(sourceOrSelector);
118
+ if (selectorPath) {
119
+ var newSchema = core.Internal.getSchema(sourceOrSelector);
120
+ return rec(opts.getModule && opts.getModule(selectorPath) || core.Internal.getSource(sourceOrSelector), opts.disabled ? undefined : {
121
+ path: selectorPath,
122
+ schema: newSchema
123
+ });
124
+ }
121
125
  if (core.VAL_EXTENSION in sourceOrSelector) {
122
126
  if (sourceOrSelector[core.VAL_EXTENSION] === "richtext") {
123
- return _objectSpread2(_objectSpread2({}, sourceOrSelector), {}, {
124
- valPath: path
125
- });
127
+ if (recOpts !== null && recOpts !== void 0 && recOpts.path) {
128
+ return _objectSpread2(_objectSpread2({}, core.Internal.convertRichTextSource(sourceOrSelector)), {}, {
129
+ valPath: recOpts.path
130
+ });
131
+ }
132
+ return core.Internal.convertRichTextSource(sourceOrSelector);
126
133
  }
127
134
  if (sourceOrSelector[core.VAL_EXTENSION] === "file" && typeof sourceOrSelector[core.FILE_REF_PROP] === "string") {
128
135
  var fileSelector = core.Internal.convertFileSource(sourceOrSelector);
129
136
  return _objectSpread2(_objectSpread2({}, fileSelector), {}, {
130
- url: rec(fileSelector.url, path)
137
+ url: rec(fileSelector.url, recOpts)
131
138
  });
132
139
  }
133
140
  console.error("Encountered unexpected extension: ".concat(sourceOrSelector[core.VAL_EXTENSION]));
@@ -135,7 +142,10 @@ function transform(input, opts) {
135
142
  }
136
143
  if (Array.isArray(sourceOrSelector)) {
137
144
  return sourceOrSelector.map(function (el, i) {
138
- return rec(el, path && core.Internal.createValPathOfItem(path, i));
145
+ return rec(el, recOpts && {
146
+ path: core.Internal.createValPathOfItem(recOpts.path, i),
147
+ schema: recOpts.schema.item
148
+ });
139
149
  });
140
150
  }
141
151
  if (!Array.isArray(sourceOrSelector)) {
@@ -144,18 +154,30 @@ function transform(input, opts) {
144
154
  var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
145
155
  _key = _Object$entries$_i[0],
146
156
  value = _Object$entries$_i[1];
147
- res[_key] = rec(value, path && core.Internal.createValPathOfItem(path, _key));
157
+ res[_key] = rec(value, recOpts && {
158
+ path: core.Internal.createValPathOfItem(recOpts.path, _key),
159
+ schema: recOpts.schema.item ||
160
+ // Record
161
+ recOpts.schema.items[_key] // Object
162
+ });
148
163
  }
164
+
149
165
  return res;
150
166
  }
151
167
  console.error("Could not transform source selector: ".concat(_typeof._typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
152
168
  return sourceOrSelector;
153
169
  }
154
170
  if (typeof sourceOrSelector === "string") {
171
+ if (!recOpts) {
172
+ return sourceOrSelector;
173
+ }
174
+ if (recOpts.schema.isRaw) {
175
+ return sourceOrSelector;
176
+ }
155
177
  return stega.vercelStegaCombine(sourceOrSelector, {
156
178
  origin: "val.build",
157
179
  data: {
158
- valPath: path
180
+ valPath: recOpts.path
159
181
  }
160
182
  }, false // auto detection on urls and dates is disabled, isDate could be used but it is also disabled (users should use a date schema instead): isDate(sourceOrSelector) // skip = true if isDate
161
183
  );
@@ -173,14 +195,14 @@ function getModuleIds(input) {
173
195
  var modules = new Set();
174
196
  function rec(sourceOrSelector) {
175
197
  if (_typeof._typeof(sourceOrSelector) === "object") {
198
+ if (!sourceOrSelector) {
199
+ return;
200
+ }
176
201
  var selectorPath = core.Internal.getValPath(sourceOrSelector);
177
202
  if (selectorPath) {
178
203
  modules.add(selectorPath);
179
204
  return;
180
205
  }
181
- if (!sourceOrSelector) {
182
- return;
183
- }
184
206
  if (core.VAL_EXTENSION in sourceOrSelector) {
185
207
  if (sourceOrSelector[core.VAL_EXTENSION] === "richtext") {
186
208
  return;
@@ -221,4 +243,4 @@ function getModuleIds(input) {
221
243
 
222
244
  exports.autoTagJSX = autoTagJSX;
223
245
  exports.getModuleIds = getModuleIds;
224
- exports.transform = transform;
246
+ exports.stegaEncode = stegaEncode;
@@ -23,7 +23,7 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
23
23
  };
24
24
  var addValPathIfFound = function addValPathIfFound(type, props) {
25
25
  var valSources = [];
26
- if (isIntrinsicElement(type) && props && _typeof._typeof(props) === "object") {
26
+ if (props && _typeof._typeof(props) === "object") {
27
27
  for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
28
28
  var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
29
29
  key = _Object$entries$_i[0],
@@ -36,7 +36,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
36
36
  var valPath = encodedBits === null || encodedBits === void 0 ? void 0 : (_encodedBits$data = encodedBits.data) === null || _encodedBits$data === void 0 ? void 0 : _encodedBits$data.valPath;
37
37
  if (valPath) {
38
38
  valSources.push(valPath);
39
- props[key] = stega.vercelStegaSplit(value).cleaned;
39
+ props[key] = isIntrinsicElement(type) ? stega.vercelStegaSplit(value).cleaned : value;
40
40
  props["data-val-attr-".concat(key)] = valPath;
41
41
  }
42
42
  }
@@ -108,26 +108,33 @@ function _objectSpread2(target) {
108
108
  *
109
109
  */
110
110
 
111
- function transform(input, opts) {
112
- function rec(sourceOrSelector, path) {
111
+ function stegaEncode(input, opts) {
112
+ function rec(sourceOrSelector, recOpts) {
113
113
  if (_typeof._typeof(sourceOrSelector) === "object") {
114
- var selectorPath = core.Internal.getValPath(sourceOrSelector);
115
- if (selectorPath) {
116
- return rec(opts.getModule && opts.getModule(selectorPath) || core.Internal.getSource(sourceOrSelector), opts.disabled ? undefined : selectorPath);
117
- }
118
114
  if (!sourceOrSelector) {
119
115
  return null;
120
116
  }
117
+ var selectorPath = core.Internal.getValPath(sourceOrSelector);
118
+ if (selectorPath) {
119
+ var newSchema = core.Internal.getSchema(sourceOrSelector);
120
+ return rec(opts.getModule && opts.getModule(selectorPath) || core.Internal.getSource(sourceOrSelector), opts.disabled ? undefined : {
121
+ path: selectorPath,
122
+ schema: newSchema
123
+ });
124
+ }
121
125
  if (core.VAL_EXTENSION in sourceOrSelector) {
122
126
  if (sourceOrSelector[core.VAL_EXTENSION] === "richtext") {
123
- return _objectSpread2(_objectSpread2({}, sourceOrSelector), {}, {
124
- valPath: path
125
- });
127
+ if (recOpts !== null && recOpts !== void 0 && recOpts.path) {
128
+ return _objectSpread2(_objectSpread2({}, core.Internal.convertRichTextSource(sourceOrSelector)), {}, {
129
+ valPath: recOpts.path
130
+ });
131
+ }
132
+ return core.Internal.convertRichTextSource(sourceOrSelector);
126
133
  }
127
134
  if (sourceOrSelector[core.VAL_EXTENSION] === "file" && typeof sourceOrSelector[core.FILE_REF_PROP] === "string") {
128
135
  var fileSelector = core.Internal.convertFileSource(sourceOrSelector);
129
136
  return _objectSpread2(_objectSpread2({}, fileSelector), {}, {
130
- url: rec(fileSelector.url, path)
137
+ url: rec(fileSelector.url, recOpts)
131
138
  });
132
139
  }
133
140
  console.error("Encountered unexpected extension: ".concat(sourceOrSelector[core.VAL_EXTENSION]));
@@ -135,7 +142,10 @@ function transform(input, opts) {
135
142
  }
136
143
  if (Array.isArray(sourceOrSelector)) {
137
144
  return sourceOrSelector.map(function (el, i) {
138
- return rec(el, path && core.Internal.createValPathOfItem(path, i));
145
+ return rec(el, recOpts && {
146
+ path: core.Internal.createValPathOfItem(recOpts.path, i),
147
+ schema: recOpts.schema.item
148
+ });
139
149
  });
140
150
  }
141
151
  if (!Array.isArray(sourceOrSelector)) {
@@ -144,18 +154,30 @@ function transform(input, opts) {
144
154
  var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
145
155
  _key = _Object$entries$_i[0],
146
156
  value = _Object$entries$_i[1];
147
- res[_key] = rec(value, path && core.Internal.createValPathOfItem(path, _key));
157
+ res[_key] = rec(value, recOpts && {
158
+ path: core.Internal.createValPathOfItem(recOpts.path, _key),
159
+ schema: recOpts.schema.item ||
160
+ // Record
161
+ recOpts.schema.items[_key] // Object
162
+ });
148
163
  }
164
+
149
165
  return res;
150
166
  }
151
167
  console.error("Could not transform source selector: ".concat(_typeof._typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
152
168
  return sourceOrSelector;
153
169
  }
154
170
  if (typeof sourceOrSelector === "string") {
171
+ if (!recOpts) {
172
+ return sourceOrSelector;
173
+ }
174
+ if (recOpts.schema.isRaw) {
175
+ return sourceOrSelector;
176
+ }
155
177
  return stega.vercelStegaCombine(sourceOrSelector, {
156
178
  origin: "val.build",
157
179
  data: {
158
- valPath: path
180
+ valPath: recOpts.path
159
181
  }
160
182
  }, false // auto detection on urls and dates is disabled, isDate could be used but it is also disabled (users should use a date schema instead): isDate(sourceOrSelector) // skip = true if isDate
161
183
  );
@@ -173,14 +195,14 @@ function getModuleIds(input) {
173
195
  var modules = new Set();
174
196
  function rec(sourceOrSelector) {
175
197
  if (_typeof._typeof(sourceOrSelector) === "object") {
198
+ if (!sourceOrSelector) {
199
+ return;
200
+ }
176
201
  var selectorPath = core.Internal.getValPath(sourceOrSelector);
177
202
  if (selectorPath) {
178
203
  modules.add(selectorPath);
179
204
  return;
180
205
  }
181
- if (!sourceOrSelector) {
182
- return;
183
- }
184
206
  if (core.VAL_EXTENSION in sourceOrSelector) {
185
207
  if (sourceOrSelector[core.VAL_EXTENSION] === "richtext") {
186
208
  return;
@@ -221,4 +243,4 @@ function getModuleIds(input) {
221
243
 
222
244
  exports.autoTagJSX = autoTagJSX;
223
245
  exports.getModuleIds = getModuleIds;
224
- exports.transform = transform;
246
+ exports.stegaEncode = stegaEncode;
@@ -13,7 +13,7 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
13
13
  };
14
14
  var addValPathIfFound = function addValPathIfFound(type, props) {
15
15
  var valSources = [];
16
- if (isIntrinsicElement(type) && props && _typeof(props) === "object") {
16
+ if (props && _typeof(props) === "object") {
17
17
  for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
18
18
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
19
19
  key = _Object$entries$_i[0],
@@ -26,7 +26,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
26
26
  var valPath = encodedBits === null || encodedBits === void 0 ? void 0 : (_encodedBits$data = encodedBits.data) === null || _encodedBits$data === void 0 ? void 0 : _encodedBits$data.valPath;
27
27
  if (valPath) {
28
28
  valSources.push(valPath);
29
- props[key] = vercelStegaSplit(value).cleaned;
29
+ props[key] = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
30
30
  props["data-val-attr-".concat(key)] = valPath;
31
31
  }
32
32
  }
@@ -98,26 +98,33 @@ function _objectSpread2(target) {
98
98
  *
99
99
  */
100
100
 
101
- function transform(input, opts) {
102
- function rec(sourceOrSelector, path) {
101
+ function stegaEncode(input, opts) {
102
+ function rec(sourceOrSelector, recOpts) {
103
103
  if (_typeof(sourceOrSelector) === "object") {
104
- var selectorPath = Internal.getValPath(sourceOrSelector);
105
- if (selectorPath) {
106
- return rec(opts.getModule && opts.getModule(selectorPath) || Internal.getSource(sourceOrSelector), opts.disabled ? undefined : selectorPath);
107
- }
108
104
  if (!sourceOrSelector) {
109
105
  return null;
110
106
  }
107
+ var selectorPath = Internal.getValPath(sourceOrSelector);
108
+ if (selectorPath) {
109
+ var newSchema = Internal.getSchema(sourceOrSelector);
110
+ return rec(opts.getModule && opts.getModule(selectorPath) || Internal.getSource(sourceOrSelector), opts.disabled ? undefined : {
111
+ path: selectorPath,
112
+ schema: newSchema
113
+ });
114
+ }
111
115
  if (VAL_EXTENSION in sourceOrSelector) {
112
116
  if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
113
- return _objectSpread2(_objectSpread2({}, sourceOrSelector), {}, {
114
- valPath: path
115
- });
117
+ if (recOpts !== null && recOpts !== void 0 && recOpts.path) {
118
+ return _objectSpread2(_objectSpread2({}, Internal.convertRichTextSource(sourceOrSelector)), {}, {
119
+ valPath: recOpts.path
120
+ });
121
+ }
122
+ return Internal.convertRichTextSource(sourceOrSelector);
116
123
  }
117
124
  if (sourceOrSelector[VAL_EXTENSION] === "file" && typeof sourceOrSelector[FILE_REF_PROP] === "string") {
118
125
  var fileSelector = Internal.convertFileSource(sourceOrSelector);
119
126
  return _objectSpread2(_objectSpread2({}, fileSelector), {}, {
120
- url: rec(fileSelector.url, path)
127
+ url: rec(fileSelector.url, recOpts)
121
128
  });
122
129
  }
123
130
  console.error("Encountered unexpected extension: ".concat(sourceOrSelector[VAL_EXTENSION]));
@@ -125,7 +132,10 @@ function transform(input, opts) {
125
132
  }
126
133
  if (Array.isArray(sourceOrSelector)) {
127
134
  return sourceOrSelector.map(function (el, i) {
128
- return rec(el, path && Internal.createValPathOfItem(path, i));
135
+ return rec(el, recOpts && {
136
+ path: Internal.createValPathOfItem(recOpts.path, i),
137
+ schema: recOpts.schema.item
138
+ });
129
139
  });
130
140
  }
131
141
  if (!Array.isArray(sourceOrSelector)) {
@@ -134,18 +144,30 @@ function transform(input, opts) {
134
144
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
135
145
  _key = _Object$entries$_i[0],
136
146
  value = _Object$entries$_i[1];
137
- res[_key] = rec(value, path && Internal.createValPathOfItem(path, _key));
147
+ res[_key] = rec(value, recOpts && {
148
+ path: Internal.createValPathOfItem(recOpts.path, _key),
149
+ schema: recOpts.schema.item ||
150
+ // Record
151
+ recOpts.schema.items[_key] // Object
152
+ });
138
153
  }
154
+
139
155
  return res;
140
156
  }
141
157
  console.error("Could not transform source selector: ".concat(_typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
142
158
  return sourceOrSelector;
143
159
  }
144
160
  if (typeof sourceOrSelector === "string") {
161
+ if (!recOpts) {
162
+ return sourceOrSelector;
163
+ }
164
+ if (recOpts.schema.isRaw) {
165
+ return sourceOrSelector;
166
+ }
145
167
  return vercelStegaCombine(sourceOrSelector, {
146
168
  origin: "val.build",
147
169
  data: {
148
- valPath: path
170
+ valPath: recOpts.path
149
171
  }
150
172
  }, false // auto detection on urls and dates is disabled, isDate could be used but it is also disabled (users should use a date schema instead): isDate(sourceOrSelector) // skip = true if isDate
151
173
  );
@@ -163,14 +185,14 @@ function getModuleIds(input) {
163
185
  var modules = new Set();
164
186
  function rec(sourceOrSelector) {
165
187
  if (_typeof(sourceOrSelector) === "object") {
188
+ if (!sourceOrSelector) {
189
+ return;
190
+ }
166
191
  var selectorPath = Internal.getValPath(sourceOrSelector);
167
192
  if (selectorPath) {
168
193
  modules.add(selectorPath);
169
194
  return;
170
195
  }
171
- if (!sourceOrSelector) {
172
- return;
173
- }
174
196
  if (VAL_EXTENSION in sourceOrSelector) {
175
197
  if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
176
198
  return;
@@ -209,4 +231,4 @@ function getModuleIds(input) {
209
231
  return Array.from(modules);
210
232
  }
211
233
 
212
- export { autoTagJSX, getModuleIds, transform };
234
+ export { autoTagJSX, getModuleIds, stegaEncode };
@@ -13,7 +13,7 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
13
13
  };
14
14
  var addValPathIfFound = function addValPathIfFound(type, props) {
15
15
  var valSources = [];
16
- if (isIntrinsicElement(type) && props && _typeof(props) === "object") {
16
+ if (props && _typeof(props) === "object") {
17
17
  for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
18
18
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
19
19
  key = _Object$entries$_i[0],
@@ -26,7 +26,7 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
26
26
  var valPath = encodedBits === null || encodedBits === void 0 ? void 0 : (_encodedBits$data = encodedBits.data) === null || _encodedBits$data === void 0 ? void 0 : _encodedBits$data.valPath;
27
27
  if (valPath) {
28
28
  valSources.push(valPath);
29
- props[key] = vercelStegaSplit(value).cleaned;
29
+ props[key] = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
30
30
  props["data-val-attr-".concat(key)] = valPath;
31
31
  }
32
32
  }
@@ -98,26 +98,33 @@ function _objectSpread2(target) {
98
98
  *
99
99
  */
100
100
 
101
- function transform(input, opts) {
102
- function rec(sourceOrSelector, path) {
101
+ function stegaEncode(input, opts) {
102
+ function rec(sourceOrSelector, recOpts) {
103
103
  if (_typeof(sourceOrSelector) === "object") {
104
- var selectorPath = Internal.getValPath(sourceOrSelector);
105
- if (selectorPath) {
106
- return rec(opts.getModule && opts.getModule(selectorPath) || Internal.getSource(sourceOrSelector), opts.disabled ? undefined : selectorPath);
107
- }
108
104
  if (!sourceOrSelector) {
109
105
  return null;
110
106
  }
107
+ var selectorPath = Internal.getValPath(sourceOrSelector);
108
+ if (selectorPath) {
109
+ var newSchema = Internal.getSchema(sourceOrSelector);
110
+ return rec(opts.getModule && opts.getModule(selectorPath) || Internal.getSource(sourceOrSelector), opts.disabled ? undefined : {
111
+ path: selectorPath,
112
+ schema: newSchema
113
+ });
114
+ }
111
115
  if (VAL_EXTENSION in sourceOrSelector) {
112
116
  if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
113
- return _objectSpread2(_objectSpread2({}, sourceOrSelector), {}, {
114
- valPath: path
115
- });
117
+ if (recOpts !== null && recOpts !== void 0 && recOpts.path) {
118
+ return _objectSpread2(_objectSpread2({}, Internal.convertRichTextSource(sourceOrSelector)), {}, {
119
+ valPath: recOpts.path
120
+ });
121
+ }
122
+ return Internal.convertRichTextSource(sourceOrSelector);
116
123
  }
117
124
  if (sourceOrSelector[VAL_EXTENSION] === "file" && typeof sourceOrSelector[FILE_REF_PROP] === "string") {
118
125
  var fileSelector = Internal.convertFileSource(sourceOrSelector);
119
126
  return _objectSpread2(_objectSpread2({}, fileSelector), {}, {
120
- url: rec(fileSelector.url, path)
127
+ url: rec(fileSelector.url, recOpts)
121
128
  });
122
129
  }
123
130
  console.error("Encountered unexpected extension: ".concat(sourceOrSelector[VAL_EXTENSION]));
@@ -125,7 +132,10 @@ function transform(input, opts) {
125
132
  }
126
133
  if (Array.isArray(sourceOrSelector)) {
127
134
  return sourceOrSelector.map(function (el, i) {
128
- return rec(el, path && Internal.createValPathOfItem(path, i));
135
+ return rec(el, recOpts && {
136
+ path: Internal.createValPathOfItem(recOpts.path, i),
137
+ schema: recOpts.schema.item
138
+ });
129
139
  });
130
140
  }
131
141
  if (!Array.isArray(sourceOrSelector)) {
@@ -134,18 +144,30 @@ function transform(input, opts) {
134
144
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
135
145
  _key = _Object$entries$_i[0],
136
146
  value = _Object$entries$_i[1];
137
- res[_key] = rec(value, path && Internal.createValPathOfItem(path, _key));
147
+ res[_key] = rec(value, recOpts && {
148
+ path: Internal.createValPathOfItem(recOpts.path, _key),
149
+ schema: recOpts.schema.item ||
150
+ // Record
151
+ recOpts.schema.items[_key] // Object
152
+ });
138
153
  }
154
+
139
155
  return res;
140
156
  }
141
157
  console.error("Could not transform source selector: ".concat(_typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
142
158
  return sourceOrSelector;
143
159
  }
144
160
  if (typeof sourceOrSelector === "string") {
161
+ if (!recOpts) {
162
+ return sourceOrSelector;
163
+ }
164
+ if (recOpts.schema.isRaw) {
165
+ return sourceOrSelector;
166
+ }
145
167
  return vercelStegaCombine(sourceOrSelector, {
146
168
  origin: "val.build",
147
169
  data: {
148
- valPath: path
170
+ valPath: recOpts.path
149
171
  }
150
172
  }, false // auto detection on urls and dates is disabled, isDate could be used but it is also disabled (users should use a date schema instead): isDate(sourceOrSelector) // skip = true if isDate
151
173
  );
@@ -163,14 +185,14 @@ function getModuleIds(input) {
163
185
  var modules = new Set();
164
186
  function rec(sourceOrSelector) {
165
187
  if (_typeof(sourceOrSelector) === "object") {
188
+ if (!sourceOrSelector) {
189
+ return;
190
+ }
166
191
  var selectorPath = Internal.getValPath(sourceOrSelector);
167
192
  if (selectorPath) {
168
193
  modules.add(selectorPath);
169
194
  return;
170
195
  }
171
- if (!sourceOrSelector) {
172
- return;
173
- }
174
196
  if (VAL_EXTENSION in sourceOrSelector) {
175
197
  if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
176
198
  return;
@@ -209,4 +231,4 @@ function getModuleIds(input) {
209
231
  return Array.from(modules);
210
232
  }
211
233
 
212
- export { autoTagJSX, getModuleIds, transform };
234
+ export { autoTagJSX, getModuleIds, stegaEncode };
package/tsconfig.json CHANGED
@@ -11,7 +11,8 @@
11
11
  "noEmit": true,
12
12
  "target": "ES5",
13
13
  "outDir": "dist",
14
- "rootDir": "src"
14
+ "rootDir": "src",
15
+ "skipLibCheck": true
15
16
  },
16
17
  "include": ["src/**/*"],
17
18
  "exclude": ["dist/**", "jsx-runtime/dist/**", "jsx-dev-runtime/dist/**"]