@es-joy/jsoe 0.12.3 → 0.13.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.
Files changed (38) hide show
  1. package/.nyc_output/out.json +11827 -11581
  2. package/CHANGES.md +8 -0
  3. package/demo/index.js +38 -29
  4. package/dist/formatAndTypeChoices.d.ts +11 -2
  5. package/dist/formatAndTypeChoices.d.ts.map +1 -1
  6. package/dist/formats/structuredCloning.d.ts.map +1 -1
  7. package/dist/formats.d.ts +52 -10
  8. package/dist/formats.d.ts.map +1 -1
  9. package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
  10. package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
  11. package/dist/fundamentalTypes/errorType.d.ts.map +1 -1
  12. package/dist/fundamentalTypes/regexpType.d.ts.map +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +12201 -0
  16. package/dist/superTypes/errorsSpecialType.d.ts.map +1 -1
  17. package/dist/typeChoices.d.ts +4 -0
  18. package/dist/typeChoices.d.ts.map +1 -1
  19. package/dist/types.d.ts +308 -74
  20. package/dist/types.d.ts.map +1 -1
  21. package/package.json +1 -1
  22. package/rollup.config.js +10 -0
  23. package/src/formatAndTypeChoices.js +20 -5
  24. package/src/formats/indexedDBKey.js +1 -1
  25. package/src/formats/json.js +1 -1
  26. package/src/formats/schemaAndArbitrary.js +1 -1
  27. package/src/formats/schemaOnly.js +1 -1
  28. package/src/formats/structuredCloning.js +21 -14
  29. package/src/formats.js +87 -26
  30. package/src/fundamentalTypes/arrayReferenceType.js +2 -2
  31. package/src/fundamentalTypes/arrayType.js +43 -23
  32. package/src/fundamentalTypes/dateType.js +2 -3
  33. package/src/fundamentalTypes/errorType.js +5 -3
  34. package/src/fundamentalTypes/regexpType.js +2 -3
  35. package/src/index.js +1 -1
  36. package/src/superTypes/errorsSpecialType.js +12 -5
  37. package/src/typeChoices.js +21 -10
  38. package/src/types.js +579 -527
@@ -169,7 +169,7 @@ const errorsSpecialType = {
169
169
  }
170
170
  });
171
171
  },
172
- getValue ({root}) {
172
+ getValue ({root, stateObj}) {
173
173
  const UserErrorType = specialErrorsMap.get(
174
174
  /** @type {HTMLSelectElement} */ (
175
175
  $e(root, '.errorType')
@@ -206,6 +206,7 @@ const errorsSpecialType = {
206
206
  )).firstElementChild;
207
207
 
208
208
  const errors = arrayType.getValue({
209
+ stateObj,
209
210
  root: /** @type {HTMLDivElement} */ (errorRoot)
210
211
  });
211
212
  errObj = new UET(errors, message);
@@ -221,6 +222,7 @@ const errorsSpecialType = {
221
222
  root, '.aggregateErrorsContents'
222
223
  )).firstElementChild;
223
224
  const errors = arrayType.getValue({
225
+ stateObj,
224
226
  root: /** @type {HTMLDivElement} */ (errorRoot)
225
227
  });
226
228
  errObj = new UET(errors);
@@ -278,6 +280,7 @@ const errorsSpecialType = {
278
280
  );
279
281
  if (causeContents.children.length) {
280
282
  errObj.cause = this.getValue({
283
+ stateObj,
281
284
  root: causeContents
282
285
  });
283
286
  }
@@ -285,7 +288,7 @@ const errorsSpecialType = {
285
288
  return errObj;
286
289
  },
287
290
  viewUI (
288
- {value: o, format, typeNamespace, resultType}
291
+ {value: o, types, format, typeNamespace, resultType}
289
292
  ) {
290
293
  const constructor = getConstructor(o.constructor);
291
294
  return /** @type {import('jamilih').JamilihArray} */ ([
@@ -327,7 +330,8 @@ const errorsSpecialType = {
327
330
  o.cause
328
331
  ? this.viewUI({
329
332
  format,
330
- value: o.cause
333
+ value: o.cause,
334
+ types
331
335
  })
332
336
  : ''
333
337
  ]]
@@ -354,7 +358,8 @@ const errorsSpecialType = {
354
358
  const [div] = arrayType.viewUI({
355
359
  typeNamespace, resultType, format,
356
360
  type: 'arrayNonindexKeys',
357
- value: []
361
+ value: [],
362
+ types
358
363
  });
359
364
 
360
365
  /** @type {Error[]} */
@@ -389,6 +394,7 @@ const errorsSpecialType = {
389
394
  },
390
395
  editUI ({
391
396
  typeNamespace,
397
+ types,
392
398
 
393
399
  // Pass these to `errors` array
394
400
  buildTypeChoices,
@@ -617,6 +623,7 @@ const errorsSpecialType = {
617
623
  if (!causeContents?.children.length) {
618
624
  const editui = component.editUI({
619
625
  typeNamespace,
626
+ types,
620
627
  value: value.cause
621
628
  });
622
629
  jml(...editui, causeContents);
@@ -683,7 +690,7 @@ const errorsSpecialType = {
683
690
  );
684
691
  if (!aggregateErrorsContents?.children.length) {
685
692
  const [editui] = arrayType.editUI({
686
- typeNamespace, buildTypeChoices, format,
693
+ typeNamespace, types, buildTypeChoices, format,
687
694
  type: 'array',
688
695
  topRoot, bringIntoFocus,
689
696
  arrayState: 'errorsArray',
@@ -1,5 +1,5 @@
1
1
  import {jml} from './vendor-imports.js';
2
- import Formats, {getControlsForFormatAndValue} from './formats.js';
2
+ import Formats from './formats.js';
3
3
  import Types from './types.js';
4
4
 
5
5
  import {$e, DOM} from './utils/templateUtils.js';
@@ -75,6 +75,8 @@ import dialogs from './utils/dialogs.js';
75
75
  * requireObject?: boolean,
76
76
  * objectHasValue?: boolean,
77
77
  * topRoot?: import('./types.js').RootElement,
78
+ * formats?: import('./formats.js').default
79
+ * types?: import('./types.js').default
78
80
  * schema?: string,
79
81
  * schemaContent?: object,
80
82
  * }} cfg
@@ -101,13 +103,15 @@ export const buildTypeChoices = ({
101
103
  requireObject,
102
104
  objectHasValue,
103
105
  topRoot,
106
+ formats = new Formats(),
107
+ types = new Types(),
104
108
  schema,
105
109
  schemaContent
106
110
  }) => {
107
111
  // console.log('format', format, 'state', state, 'path', typeNamespace);
108
112
  const typeOptions = requireObject
109
- ? [Types.getOptionForType('object')]
110
- : Types.getTypeOptionsForFormatAndState(format, state);
113
+ ? [types.getOptionForType('object')]
114
+ : types.getTypeOptionsForFormatAndState(format, state);
111
115
 
112
116
  let editUI;
113
117
 
@@ -116,11 +120,13 @@ export const buildTypeChoices = ({
116
120
  const root = /** @type {HTMLDivElement} */ (
117
121
  $e(typeContainer, 'div[data-type]')
118
122
  );
119
- return Types.getValueForRoot(
123
+ return types.getValueForRoot(
120
124
  root,
121
125
  /** @type {import('./types.js').StateObject} */ ({
122
126
  typeNamespace,
127
+ formats,
123
128
  format,
129
+ types,
124
130
  ...stateObj
125
131
  }),
126
132
  currentPath
@@ -183,7 +189,7 @@ export const buildTypeChoices = ({
183
189
  // (needed by arrayNonindexKeys for setting an array
184
190
  // length and avoiding errors); could set all
185
191
  // values through here?
186
- editUI = Types.getUIForModeAndType({
192
+ editUI = types.getUIForModeAndType({
187
193
  readonly: false,
188
194
  typeNamespace,
189
195
  type,
@@ -198,7 +204,7 @@ export const buildTypeChoices = ({
198
204
  this.$validate();
199
205
  topRoot = this.$getTopRoot(); // May be existing now
200
206
  // Needed; Array/object ref somewhere could now be valid or invalid
201
- Types.validateAllReferences({topRoot});
207
+ types.validateAllReferences({topRoot});
202
208
  },
203
209
 
204
210
  /** @type {AddTypeAndEditUI} */
@@ -230,7 +236,7 @@ export const buildTypeChoices = ({
230
236
  return false;
231
237
  }
232
238
  const editUI = container.firstElementChild;
233
- return Types.validate({
239
+ return types.validate({
234
240
  type, root: editUI, topRoot: this.$getTopRoot()
235
241
  });
236
242
  }
@@ -267,13 +273,17 @@ export const buildTypeChoices = ({
267
273
  value = {};
268
274
  }
269
275
  try {
270
- const rootEditUI = await Formats.availableFormats[format].iterate(
276
+ const rootEditUI = await formats.getControlsForFormatAndValue(
277
+ types,
278
+ format,
271
279
  value,
272
280
  {
273
281
  readonly: false,
274
282
  typeNamespace,
275
283
  schema,
276
- schemaContent
284
+ schemaContent,
285
+ formats,
286
+ types
277
287
  }
278
288
  );
279
289
  const type =
@@ -329,7 +339,8 @@ export const buildTypeChoices = ({
329
339
  /** @type {SetValue} */
330
340
  async setValue (value, stateObj) {
331
341
  const rootEditUI = /** @type {HTMLDivElement} */ (
332
- await getControlsForFormatAndValue(
342
+ await formats.getControlsForFormatAndValue(
343
+ types,
333
344
  format, value, stateObj
334
345
  )
335
346
  );