@es-joy/jsoe 0.12.4 → 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 (37) hide show
  1. package/.nyc_output/out.json +11827 -11581
  2. package/CHANGES.md +4 -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 +795 -620
  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/src/formatAndTypeChoices.js +20 -5
  23. package/src/formats/indexedDBKey.js +1 -1
  24. package/src/formats/json.js +1 -1
  25. package/src/formats/schemaAndArbitrary.js +1 -1
  26. package/src/formats/schemaOnly.js +1 -1
  27. package/src/formats/structuredCloning.js +21 -14
  28. package/src/formats.js +87 -26
  29. package/src/fundamentalTypes/arrayReferenceType.js +2 -2
  30. package/src/fundamentalTypes/arrayType.js +43 -23
  31. package/src/fundamentalTypes/dateType.js +2 -3
  32. package/src/fundamentalTypes/errorType.js +5 -3
  33. package/src/fundamentalTypes/regexpType.js +2 -3
  34. package/src/index.js +1 -1
  35. package/src/superTypes/errorsSpecialType.js +12 -5
  36. package/src/typeChoices.js +21 -10
  37. package/src/types.js +579 -527
@@ -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
  );