@es-joy/jsoe 0.24.2 → 0.25.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.
- package/.claude/settings.local.json +9 -0
- package/.ncurc.cjs +2 -2
- package/CHANGES.md +51 -0
- package/README.md +23 -13
- package/badges/coverage-badge.svg +1 -1
- package/dist/eslint.config.d.ts +3 -0
- package/dist/eslint.config.d.ts.map +1 -0
- package/dist/formatAndTypeChoices.d.ts +28 -30
- package/dist/formatAndTypeChoices.d.ts.map +1 -1
- package/dist/formats/indexedDBKey.d.ts.map +1 -1
- package/dist/formats/schema.d.ts +46 -3
- package/dist/formats/schema.d.ts.map +1 -1
- package/dist/formats/structuredCloning.d.ts +3 -0
- package/dist/formats/structuredCloning.d.ts.map +1 -1
- package/dist/formats.d.ts +24 -6
- package/dist/formats.d.ts.map +1 -1
- package/dist/fundamentalTypes/BooleanObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/NumberObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/StringObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayReferenceType.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayType.d.ts +7 -0
- package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
- package/dist/fundamentalTypes/bigintObjectType.d.ts.map +1 -1
- package/dist/fundamentalTypes/bigintType.d.ts +10 -0
- package/dist/fundamentalTypes/bigintType.d.ts.map +1 -1
- package/dist/fundamentalTypes/blobType.d.ts.map +1 -1
- package/dist/fundamentalTypes/booleanType.d.ts.map +1 -1
- package/dist/fundamentalTypes/catchType.d.ts +2 -2
- package/dist/fundamentalTypes/catchType.d.ts.map +1 -1
- package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
- package/dist/fundamentalTypes/domexceptionType.d.ts.map +1 -1
- package/dist/fundamentalTypes/enumType.d.ts +2 -2
- package/dist/fundamentalTypes/enumType.d.ts.map +1 -1
- package/dist/fundamentalTypes/errorType.d.ts.map +1 -1
- package/dist/fundamentalTypes/fileType.d.ts +6 -0
- package/dist/fundamentalTypes/fileType.d.ts.map +1 -1
- package/dist/fundamentalTypes/functionType.d.ts.map +1 -1
- package/dist/fundamentalTypes/literalType.d.ts +3 -2
- package/dist/fundamentalTypes/literalType.d.ts.map +1 -1
- package/dist/fundamentalTypes/looseRecordType.d.ts +6 -0
- package/dist/fundamentalTypes/looseRecordType.d.ts.map +1 -0
- package/dist/fundamentalTypes/nanType.d.ts.map +1 -1
- package/dist/fundamentalTypes/neverType.d.ts +2 -2
- package/dist/fundamentalTypes/neverType.d.ts.map +1 -1
- package/dist/fundamentalTypes/noneditableType.d.ts.map +1 -1
- package/dist/fundamentalTypes/nullType.d.ts.map +1 -1
- package/dist/fundamentalTypes/numberType.d.ts.map +1 -1
- package/dist/fundamentalTypes/promiseType.d.ts.map +1 -1
- package/dist/fundamentalTypes/regexpType.d.ts.map +1 -1
- package/dist/fundamentalTypes/stringType.d.ts.map +1 -1
- package/dist/fundamentalTypes/symbolType.d.ts.map +1 -1
- package/dist/fundamentalTypes/undefinedType.d.ts.map +1 -1
- package/dist/fundamentalTypes/voidType.d.ts +2 -2
- package/dist/fundamentalTypes/voidType.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/rollup.config.d.ts +30 -0
- package/dist/rollup.config.d.ts.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/src/formatAndTypeChoices.d.ts +108 -0
- package/dist/src/formatAndTypeChoices.d.ts.map +1 -0
- package/dist/src/formats/arbitraryJS.d.ts +4 -0
- package/dist/src/formats/arbitraryJS.d.ts.map +1 -0
- package/dist/src/formats/indexedDBKey.d.ts +4 -0
- package/dist/src/formats/indexedDBKey.d.ts.map +1 -0
- package/dist/src/formats/json.d.ts +4 -0
- package/dist/src/formats/json.d.ts.map +1 -0
- package/dist/src/formats/schema.d.ts +17 -0
- package/dist/src/formats/schema.d.ts.map +1 -0
- package/dist/src/formats/structuredCloning.d.ts +19 -0
- package/dist/src/formats/structuredCloning.d.ts.map +1 -0
- package/dist/src/formats.d.ts +135 -0
- package/dist/src/formats.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/BooleanObjectType.d.ts +8 -0
- package/dist/src/fundamentalTypes/BooleanObjectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/NumberObjectType.d.ts +6 -0
- package/dist/src/fundamentalTypes/NumberObjectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/StringObjectType.d.ts +6 -0
- package/dist/src/fundamentalTypes/StringObjectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/arrayReferenceType.d.ts +8 -0
- package/dist/src/fundamentalTypes/arrayReferenceType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/arrayType.d.ts +29 -0
- package/dist/src/fundamentalTypes/arrayType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/bigintObjectType.d.ts +6 -0
- package/dist/src/fundamentalTypes/bigintObjectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/bigintType.d.ts +6 -0
- package/dist/src/fundamentalTypes/bigintType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/blobType.d.ts +11 -0
- package/dist/src/fundamentalTypes/blobType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/booleanType.d.ts +8 -0
- package/dist/src/fundamentalTypes/booleanType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/catchType.d.ts +6 -0
- package/dist/src/fundamentalTypes/catchType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/dateType.d.ts +26 -0
- package/dist/src/fundamentalTypes/dateType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/domexceptionType.d.ts +6 -0
- package/dist/src/fundamentalTypes/domexceptionType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/enumType.d.ts +6 -0
- package/dist/src/fundamentalTypes/enumType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/errorType.d.ts +6 -0
- package/dist/src/fundamentalTypes/errorType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/fileType.d.ts +13 -0
- package/dist/src/fundamentalTypes/fileType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/filelistType.d.ts +6 -0
- package/dist/src/fundamentalTypes/filelistType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/functionType.d.ts +7 -0
- package/dist/src/fundamentalTypes/functionType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/literalType.d.ts +6 -0
- package/dist/src/fundamentalTypes/literalType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/mapType.d.ts +6 -0
- package/dist/src/fundamentalTypes/mapType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/nanType.d.ts +6 -0
- package/dist/src/fundamentalTypes/nanType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/neverType.d.ts +6 -0
- package/dist/src/fundamentalTypes/neverType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/noneditableType.d.ts +6 -0
- package/dist/src/fundamentalTypes/noneditableType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/nullType.d.ts +6 -0
- package/dist/src/fundamentalTypes/nullType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/numberType.d.ts +6 -0
- package/dist/src/fundamentalTypes/numberType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/objectReferenceType.d.ts +8 -0
- package/dist/src/fundamentalTypes/objectReferenceType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/objectType.d.ts +6 -0
- package/dist/src/fundamentalTypes/objectType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/promiseType.d.ts +6 -0
- package/dist/src/fundamentalTypes/promiseType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/recordType.d.ts +6 -0
- package/dist/src/fundamentalTypes/recordType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/regexpType.d.ts +8 -0
- package/dist/src/fundamentalTypes/regexpType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/setType.d.ts +6 -0
- package/dist/src/fundamentalTypes/setType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/sparseUndefinedType.d.ts +6 -0
- package/dist/src/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/stringType.d.ts +6 -0
- package/dist/src/fundamentalTypes/stringType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/symbolType.d.ts +8 -0
- package/dist/src/fundamentalTypes/symbolType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/tupleType.d.ts +6 -0
- package/dist/src/fundamentalTypes/tupleType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/undefinedType.d.ts +6 -0
- package/dist/src/fundamentalTypes/undefinedType.d.ts.map +1 -0
- package/dist/src/fundamentalTypes/voidType.d.ts +6 -0
- package/dist/src/fundamentalTypes/voidType.d.ts.map +1 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/subTypes/blobHTMLType.d.ts +20 -0
- package/dist/src/subTypes/blobHTMLType.d.ts.map +1 -0
- package/dist/src/subTypes/falseType.d.ts +8 -0
- package/dist/src/subTypes/falseType.d.ts.map +1 -0
- package/dist/src/subTypes/trueType.d.ts +8 -0
- package/dist/src/subTypes/trueType.d.ts.map +1 -0
- package/dist/src/superTypes/SpecialNumberType.d.ts +6 -0
- package/dist/src/superTypes/SpecialNumberType.d.ts.map +1 -0
- package/dist/src/superTypes/SpecialRealNumberType.d.ts +6 -0
- package/dist/src/superTypes/SpecialRealNumberType.d.ts.map +1 -0
- package/dist/src/superTypes/buffersourceType.d.ts +8 -0
- package/dist/src/superTypes/buffersourceType.d.ts.map +1 -0
- package/dist/src/superTypes/dommatrixType.d.ts +6 -0
- package/dist/src/superTypes/dommatrixType.d.ts.map +1 -0
- package/dist/src/superTypes/dompointType.d.ts +6 -0
- package/dist/src/superTypes/dompointType.d.ts.map +1 -0
- package/dist/src/superTypes/domrectType.d.ts +6 -0
- package/dist/src/superTypes/domrectType.d.ts.map +1 -0
- package/dist/src/superTypes/errorsSpecialType.d.ts +8 -0
- package/dist/src/superTypes/errorsSpecialType.d.ts.map +1 -0
- package/dist/src/typeChoices.d.ts +140 -0
- package/dist/src/typeChoices.d.ts.map +1 -0
- package/dist/src/types.d.ts +758 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/utils/FileList.d.ts +26 -0
- package/dist/src/utils/FileList.d.ts.map +1 -0
- package/dist/src/utils/dialogs.d.ts +111 -0
- package/dist/src/utils/dialogs.d.ts.map +1 -0
- package/dist/src/utils/jsonPointer.d.ts +46 -0
- package/dist/src/utils/jsonPointer.d.ts.map +1 -0
- package/dist/src/utils/media.d.ts +18 -0
- package/dist/src/utils/media.d.ts.map +1 -0
- package/dist/src/utils/objects.d.ts +16 -0
- package/dist/src/utils/objects.d.ts.map +1 -0
- package/dist/src/utils/templateUtils.d.ts +59 -0
- package/dist/src/utils/templateUtils.d.ts.map +1 -0
- package/dist/src/utils/types.d.ts +2 -0
- package/dist/src/utils/types.d.ts.map +1 -0
- package/dist/src/vendor-imports.d.ts +4 -0
- package/dist/src/vendor-imports.d.ts.map +1 -0
- package/dist/subTypes/blobHTMLType.d.ts.map +1 -1
- package/dist/superTypes/SpecialRealNumberType.d.ts.map +1 -1
- package/dist/superTypes/buffersourceType.d.ts.map +1 -1
- package/dist/superTypes/dommatrixType.d.ts.map +1 -1
- package/dist/superTypes/dompointType.d.ts.map +1 -1
- package/dist/superTypes/domrectType.d.ts.map +1 -1
- package/dist/superTypes/errorsSpecialType.d.ts.map +1 -1
- package/dist/typeChoices.d.ts +21 -87
- package/dist/typeChoices.d.ts.map +1 -1
- package/dist/types.d.ts +90 -64
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/FileList.d.ts +4 -3
- package/dist/utils/FileList.d.ts.map +1 -1
- package/dist/utils/dialogs.d.ts +4 -4
- package/dist/utils/dialogs.d.ts.map +1 -1
- package/dist/utils/media.d.ts.map +1 -1
- package/dist/utils/schemaMeta.d.ts +92 -0
- package/dist/utils/schemaMeta.d.ts.map +1 -0
- package/dist/utils/templateUtils.d.ts +3 -3
- package/dist/utils/templateUtils.d.ts.map +1 -1
- package/dist/utils/timing.d.ts +2 -0
- package/dist/utils/timing.d.ts.map +1 -0
- package/dist/utils/types.d.ts +1 -0
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/vendor-imports.d.ts +3 -1
- package/docs/proposals/schema-meta.md +233 -0
- package/eslint.config.js +51 -4
- package/licenseInfo.json +1 -1
- package/package.json +52 -42
- package/pnpm-workspace.yaml +57 -0
- package/rollup.config.js +20 -18
- package/server.js +3 -3
- package/src/deepEqual.js +77 -66
- package/src/deepEqual.js.map +1 -1
- package/src/formatAndTypeChoices.js +62 -58
- package/src/formats/indexedDBKey.js +3 -4
- package/src/formats/schema.js +824 -475
- package/src/formats/structuredCloning.js +189 -80
- package/src/formats.js +17 -5
- package/src/fundamentalTypes/BooleanObjectType.js +4 -5
- package/src/fundamentalTypes/NumberObjectType.js +4 -4
- package/src/fundamentalTypes/StringObjectType.js +3 -4
- package/src/fundamentalTypes/arrayReferenceType.js +0 -2
- package/src/fundamentalTypes/arrayType.js +624 -389
- package/src/fundamentalTypes/bigintObjectType.js +3 -2
- package/src/fundamentalTypes/bigintType.js +79 -17
- package/src/fundamentalTypes/blobType.js +35 -35
- package/src/fundamentalTypes/booleanType.js +16 -8
- package/src/fundamentalTypes/dateType.js +6 -8
- package/src/fundamentalTypes/domexceptionType.js +5 -4
- package/src/fundamentalTypes/errorType.js +39 -32
- package/src/fundamentalTypes/fileType.js +238 -52
- package/src/fundamentalTypes/functionType.js +61 -41
- package/src/fundamentalTypes/nanType.js +5 -4
- package/src/fundamentalTypes/noneditableType.js +4 -3
- package/src/fundamentalTypes/nullType.js +3 -2
- package/src/fundamentalTypes/numberType.js +72 -20
- package/src/fundamentalTypes/promiseType.js +16 -40
- package/src/fundamentalTypes/regexpType.js +7 -13
- package/src/fundamentalTypes/stringType.js +176 -110
- package/src/fundamentalTypes/symbolType.js +3 -2
- package/src/fundamentalTypes/undefinedType.js +3 -2
- package/src/index.js +6 -5
- package/src/jsoe.css +107 -8
- package/src/subTypes/blobHTMLType.js +23 -10
- package/src/superTypes/SpecialNumberType.js +6 -6
- package/src/superTypes/SpecialRealNumberType.js +10 -9
- package/src/superTypes/buffersourceType.js +86 -75
- package/src/superTypes/dommatrixType.js +6 -5
- package/src/superTypes/dompointType.js +6 -5
- package/src/superTypes/domrectType.js +6 -5
- package/src/superTypes/errorsSpecialType.js +54 -35
- package/src/typeChoices.js +373 -53
- package/src/types.js +157 -97
- package/src/utils/FileList.js +3 -3
- package/src/utils/dialogs.js +5 -7
- package/src/utils/jsonPointer.js +1 -1
- package/src/utils/media.js +1 -0
- package/src/utils/schemaMeta.js +257 -0
- package/src/utils/templateUtils.js +3 -3
- package/src/utils/timing.js +12 -0
- package/src/utils/types.js +19 -0
- package/src/vendor-imports.js +10 -2
- package/tsconfig.json +2 -0
- package/vendor/acorn/dist/acorn.d.mts +46 -5
- package/vendor/acorn/dist/acorn.d.ts +46 -5
- package/vendor/acorn/dist/acorn.js +394 -117
- package/vendor/acorn/dist/acorn.mjs +394 -117
- package/vendor/acorn/dist/bin.js +1 -1
- package/vendor/jamilih/dist/{jml-es.js → jml.mjs} +590 -312
- package/vendor/jamilih/package.json +1 -1
- package/vendor/mime/dist/types/other.js +719 -0
- package/vendor/mime/dist/types/standard.js +366 -0
- package/vendor/typeson-registry/dist/index.js +519 -99
- package/vendor/zod/classic/checks.d.ts +1 -0
- package/vendor/zod/classic/checks.js +1 -0
- package/vendor/zod/classic/coerce.d.ts +17 -0
- package/vendor/zod/classic/coerce.js +17 -0
- package/vendor/zod/classic/compat.d.ts +48 -0
- package/vendor/zod/classic/compat.js +31 -0
- package/vendor/zod/classic/deep-partial.d.ts +14 -0
- package/vendor/zod/classic/deep-partial.js +13 -0
- package/vendor/zod/classic/errors.d.ts +29 -0
- package/vendor/zod/classic/errors.js +57 -0
- package/vendor/zod/classic/external.d.ts +19 -0
- package/vendor/zod/classic/external.js +17 -0
- package/vendor/zod/classic/from-json-schema.d.ts +12 -0
- package/vendor/zod/classic/from-json-schema.js +660 -0
- package/vendor/zod/classic/in-out.d.ts +8 -0
- package/vendor/zod/classic/in-out.js +36 -0
- package/vendor/zod/classic/index.d.ts +3 -0
- package/vendor/zod/classic/index.js +4 -0
- package/vendor/zod/classic/iso.d.ts +7 -0
- package/vendor/zod/classic/iso.js +15 -0
- package/vendor/zod/classic/package.json +7 -0
- package/vendor/zod/classic/parse.d.ts +44 -0
- package/vendor/zod/classic/parse.js +16 -0
- package/vendor/zod/classic/schemas.d.ts +802 -0
- package/vendor/zod/classic/schemas.js +1491 -0
- package/vendor/zod/core/api.d.ts +329 -0
- package/vendor/zod/core/api.js +1104 -0
- package/vendor/zod/core/checks.d.ts +278 -0
- package/vendor/zod/core/checks.js +581 -0
- package/vendor/zod/core/compile.d.ts +51 -0
- package/vendor/zod/core/compile.js +1783 -0
- package/vendor/zod/core/core.d.ts +82 -0
- package/vendor/zod/core/core.js +141 -0
- package/vendor/zod/core/doc.d.ts +16 -0
- package/vendor/zod/core/doc.js +33 -0
- package/vendor/zod/core/errors.d.ts +225 -0
- package/vendor/zod/core/errors.js +270 -0
- package/vendor/zod/core/index.d.ts +19 -0
- package/vendor/zod/core/index.js +19 -0
- package/vendor/zod/core/json-schema-generator.d.ts +65 -0
- package/vendor/zod/core/json-schema-generator.js +99 -0
- package/vendor/zod/core/json-schema-processors.d.ts +49 -0
- package/vendor/zod/core/json-schema-processors.js +747 -0
- package/vendor/zod/core/json-schema.d.ts +89 -0
- package/vendor/zod/core/memoizer.d.ts +15 -0
- package/vendor/zod/core/memoizer.js +265 -0
- package/vendor/zod/core/package.json +7 -0
- package/vendor/zod/core/parse.d.ts +52 -0
- package/vendor/zod/core/parse.js +154 -0
- package/vendor/zod/core/regexes.d.ts +87 -0
- package/vendor/zod/core/regexes.js +150 -0
- package/vendor/zod/core/registries.d.ts +35 -0
- package/vendor/zod/core/registries.js +51 -0
- package/vendor/zod/core/schemas.d.ts +1253 -0
- package/vendor/zod/core/schemas.js +2440 -0
- package/vendor/zod/core/standard-schema.d.ts +126 -0
- package/vendor/zod/core/to-json-schema.d.ts +153 -0
- package/vendor/zod/core/to-json-schema.js +650 -0
- package/vendor/zod/core/util.d.ts +257 -0
- package/vendor/zod/core/util.js +846 -0
- package/vendor/zod/core/versions.d.ts +5 -0
- package/vendor/zod/core/versions.js +5 -0
- package/vendor/zod/core/visit.d.ts +30 -0
- package/vendor/zod/core/visit.js +169 -0
- package/vendor/zod/index.d.ts +3 -0
- package/vendor/zod/index.js +4 -0
- package/vendor/zod/locales/ar.d.ts +4 -0
- package/vendor/zod/locales/ar.js +109 -0
- package/vendor/zod/locales/az.d.ts +4 -0
- package/vendor/zod/locales/az.js +108 -0
- package/vendor/zod/locales/be.d.ts +4 -0
- package/vendor/zod/locales/be.js +166 -0
- package/vendor/zod/locales/bg.d.ts +4 -0
- package/vendor/zod/locales/bg.js +123 -0
- package/vendor/zod/locales/bn.d.ts +4 -0
- package/vendor/zod/locales/bn.js +111 -0
- package/vendor/zod/locales/ca.d.ts +4 -0
- package/vendor/zod/locales/ca.js +110 -0
- package/vendor/zod/locales/ckb.d.ts +4 -0
- package/vendor/zod/locales/ckb.js +131 -0
- package/vendor/zod/locales/cs.d.ts +4 -0
- package/vendor/zod/locales/cs.js +114 -0
- package/vendor/zod/locales/da.d.ts +4 -0
- package/vendor/zod/locales/da.js +118 -0
- package/vendor/zod/locales/de.d.ts +4 -0
- package/vendor/zod/locales/de.js +111 -0
- package/vendor/zod/locales/el.d.ts +4 -0
- package/vendor/zod/locales/el.js +110 -0
- package/vendor/zod/locales/en.d.ts +4 -0
- package/vendor/zod/locales/en.js +123 -0
- package/vendor/zod/locales/eo.d.ts +4 -0
- package/vendor/zod/locales/eo.js +112 -0
- package/vendor/zod/locales/es.d.ts +4 -0
- package/vendor/zod/locales/es.js +134 -0
- package/vendor/zod/locales/fa.d.ts +4 -0
- package/vendor/zod/locales/fa.js +117 -0
- package/vendor/zod/locales/fi.d.ts +4 -0
- package/vendor/zod/locales/fi.js +115 -0
- package/vendor/zod/locales/fr-CA.d.ts +4 -0
- package/vendor/zod/locales/fr-CA.js +110 -0
- package/vendor/zod/locales/fr.d.ts +4 -0
- package/vendor/zod/locales/fr.js +127 -0
- package/vendor/zod/locales/gu.d.ts +4 -0
- package/vendor/zod/locales/gu.js +111 -0
- package/vendor/zod/locales/he.d.ts +4 -0
- package/vendor/zod/locales/he.js +219 -0
- package/vendor/zod/locales/hi.d.ts +4 -0
- package/vendor/zod/locales/hi.js +109 -0
- package/vendor/zod/locales/hr.d.ts +4 -0
- package/vendor/zod/locales/hr.js +124 -0
- package/vendor/zod/locales/hu.d.ts +4 -0
- package/vendor/zod/locales/hu.js +111 -0
- package/vendor/zod/locales/hy.d.ts +4 -0
- package/vendor/zod/locales/hy.js +156 -0
- package/vendor/zod/locales/id.d.ts +4 -0
- package/vendor/zod/locales/id.js +109 -0
- package/vendor/zod/locales/index.d.ts +62 -0
- package/vendor/zod/locales/index.js +62 -0
- package/vendor/zod/locales/is.d.ts +4 -0
- package/vendor/zod/locales/is.js +112 -0
- package/vendor/zod/locales/it.d.ts +4 -0
- package/vendor/zod/locales/it.js +111 -0
- package/vendor/zod/locales/ja.d.ts +4 -0
- package/vendor/zod/locales/ja.js +110 -0
- package/vendor/zod/locales/ka.d.ts +4 -0
- package/vendor/zod/locales/ka.js +115 -0
- package/vendor/zod/locales/kh.d.ts +5 -0
- package/vendor/zod/locales/kh.js +5 -0
- package/vendor/zod/locales/km.d.ts +4 -0
- package/vendor/zod/locales/km.js +113 -0
- package/vendor/zod/locales/kn.d.ts +4 -0
- package/vendor/zod/locales/kn.js +114 -0
- package/vendor/zod/locales/ko.d.ts +4 -0
- package/vendor/zod/locales/ko.js +114 -0
- package/vendor/zod/locales/lt.d.ts +4 -0
- package/vendor/zod/locales/lt.js +205 -0
- package/vendor/zod/locales/mk.d.ts +4 -0
- package/vendor/zod/locales/mk.js +112 -0
- package/vendor/zod/locales/ms.d.ts +4 -0
- package/vendor/zod/locales/ms.js +110 -0
- package/vendor/zod/locales/ne.d.ts +4 -0
- package/vendor/zod/locales/ne.js +109 -0
- package/vendor/zod/locales/nl.d.ts +4 -0
- package/vendor/zod/locales/nl.js +113 -0
- package/vendor/zod/locales/nn.d.ts +4 -0
- package/vendor/zod/locales/nn.js +111 -0
- package/vendor/zod/locales/no.d.ts +4 -0
- package/vendor/zod/locales/no.js +111 -0
- package/vendor/zod/locales/ota.d.ts +4 -0
- package/vendor/zod/locales/ota.js +112 -0
- package/vendor/zod/locales/package.json +7 -0
- package/vendor/zod/locales/pl.d.ts +4 -0
- package/vendor/zod/locales/pl.js +112 -0
- package/vendor/zod/locales/ps.d.ts +4 -0
- package/vendor/zod/locales/ps.js +117 -0
- package/vendor/zod/locales/pt-BR.d.ts +4 -0
- package/vendor/zod/locales/pt-BR.js +141 -0
- package/vendor/zod/locales/pt.d.ts +4 -0
- package/vendor/zod/locales/pt.js +140 -0
- package/vendor/zod/locales/ro.d.ts +4 -0
- package/vendor/zod/locales/ro.js +120 -0
- package/vendor/zod/locales/ru.d.ts +4 -0
- package/vendor/zod/locales/ru.js +166 -0
- package/vendor/zod/locales/sk.d.ts +4 -0
- package/vendor/zod/locales/sk.js +114 -0
- package/vendor/zod/locales/sl.d.ts +4 -0
- package/vendor/zod/locales/sl.js +112 -0
- package/vendor/zod/locales/sv.d.ts +4 -0
- package/vendor/zod/locales/sv.js +113 -0
- package/vendor/zod/locales/ta.d.ts +4 -0
- package/vendor/zod/locales/ta.js +113 -0
- package/vendor/zod/locales/th.d.ts +4 -0
- package/vendor/zod/locales/th.js +113 -0
- package/vendor/zod/locales/tk.d.ts +4 -0
- package/vendor/zod/locales/tk.js +105 -0
- package/vendor/zod/locales/tr.d.ts +4 -0
- package/vendor/zod/locales/tr.js +108 -0
- package/vendor/zod/locales/ua.d.ts +5 -0
- package/vendor/zod/locales/ua.js +5 -0
- package/vendor/zod/locales/uk.d.ts +4 -0
- package/vendor/zod/locales/uk.js +111 -0
- package/vendor/zod/locales/ur.d.ts +4 -0
- package/vendor/zod/locales/ur.js +113 -0
- package/vendor/zod/locales/uz.d.ts +4 -0
- package/vendor/zod/locales/uz.js +111 -0
- package/vendor/zod/locales/vi.d.ts +4 -0
- package/vendor/zod/locales/vi.js +111 -0
- package/vendor/zod/locales/yo.d.ts +4 -0
- package/vendor/zod/locales/yo.js +110 -0
- package/vendor/zod/locales/zh-CN.d.ts +4 -0
- package/vendor/zod/locales/zh-CN.js +112 -0
- package/vendor/zod/locales/zh-TW.d.ts +4 -0
- package/vendor/zod/locales/zh-TW.js +110 -0
- package/vendor/zod/mini/checks.d.ts +1 -0
- package/vendor/zod/mini/checks.js +1 -0
- package/vendor/zod/mini/coerce.d.ts +7 -0
- package/vendor/zod/mini/coerce.js +22 -0
- package/vendor/zod/mini/deep-partial.d.ts +14 -0
- package/vendor/zod/mini/deep-partial.js +13 -0
- package/vendor/zod/mini/external.d.ts +16 -0
- package/vendor/zod/mini/external.js +16 -0
- package/vendor/zod/mini/in-out.d.ts +8 -0
- package/vendor/zod/mini/in-out.js +36 -0
- package/vendor/zod/mini/index.d.ts +3 -0
- package/vendor/zod/mini/index.js +3 -0
- package/vendor/zod/mini/iso.d.ts +22 -0
- package/vendor/zod/mini/iso.js +34 -0
- package/vendor/zod/mini/package.json +7 -0
- package/vendor/zod/mini/parse.d.ts +1 -0
- package/vendor/zod/mini/parse.js +1 -0
- package/vendor/zod/mini/schemas.d.ts +475 -0
- package/vendor/zod/mini/schemas.js +987 -0
- package/vendor/zod/package.json +7 -0
- package/vendor/zodexy/dist/esm/index.js +1274 -0
- package/vendor/zodexy/dist/index.js +1088 -0
- package/vendor/zodexy/dist/schema.zodexy.json +1036 -0
- package/dist/fundamentalTypes/nativeEnumType.d.ts +0 -6
- package/dist/fundamentalTypes/nativeEnumType.d.ts.map +0 -1
- package/src/fundamentalTypes/catchType.js +0 -140
- package/src/fundamentalTypes/enumType.js +0 -52
- package/src/fundamentalTypes/literalType.js +0 -81
- package/src/fundamentalTypes/nativeEnumType.js +0 -157
- package/src/fundamentalTypes/neverType.js +0 -49
- package/src/fundamentalTypes/recordType.js +0 -42
- package/src/fundamentalTypes/tupleType.js +0 -39
- package/src/fundamentalTypes/voidType.js +0 -48
- package/vendor/zod/lib/index.mjs +0 -4236
- package/vendor/zodex/dist/esm/dezerialize.d.ts +0 -26
- package/vendor/zodex/dist/esm/dezerialize.js +0 -393
- package/vendor/zodex/dist/esm/index.d.ts +0 -9
- package/vendor/zodex/dist/esm/index.js +0 -4
- package/vendor/zodex/dist/esm/infer.d.ts +0 -29
- package/vendor/zodex/dist/esm/package.json +0 -1
- package/vendor/zodex/dist/esm/types.d.ts +0 -201
- package/vendor/zodex/dist/esm/types.js +0 -13
- package/vendor/zodex/dist/esm/ui.d.ts +0 -23
- package/vendor/zodex/dist/esm/ui.js +0 -10
- package/vendor/zodex/dist/esm/zerialize.d.ts +0 -50
- package/vendor/zodex/dist/esm/zerialize.js +0 -417
- package/vendor/zodex/dist/esm/zod-types.d.ts +0 -11
- /package/vendor/{zodex/dist/esm/infer.js → zod/core/json-schema.js} +0 -0
- /package/vendor/{zodex/dist/esm/zod-types.js → zod/core/standard-schema.js} +0 -0
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t));}));}return e}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n);}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,r){return (t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _slicedToArray(e,t){return function _arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1;}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){u=!0,o=e;}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(e,t)||_unsupportedIterableToArray(e,t)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _toConsumableArray(e){return function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}(e)||function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||_unsupportedIterableToArray(e)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return "Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==typeof t?t:String(t)}var e=_createClass((function TypesonPromise(e){_classCallCheck(this,TypesonPromise),this.p=new Promise(e);}));e.__typeson__type__="TypesonPromise","undefined"!=typeof Symbol&&Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function get(){return "TypesonPromise"}}),e.prototype.then=function(t,r){var n=this;return new e((function(e,o){n.p.then((function(r){e(t?t(r):r);})).catch((function(e){return r?r(e):Promise.reject(e)})).then(e,o);}))},e.prototype.catch=function(e){return this.then((function(){}),e)},e.resolve=function(t){return new e((function(e){e(t);}))},e.reject=function(t){return new e((function(e,r){r(t);}))},e.all=function(t){return new e((function(e,r){Promise.all(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))},e.race=function(t){return new e((function(e,r){Promise.race(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))},e.allSettled=function(t){return new e((function(e,r){Promise.allSettled(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))};var t=Object.hasOwn,r=Object.getPrototypeOf;function isThenable(e,t){return isObject(e)&&"function"==typeof e.then&&(!t||"function"==typeof e.catch)}function toStringTag(e){return Object.prototype.toString.call(e).slice(8,-1)}function hasConstructorOf(e,n){if(!e||"object"!==_typeof(e))return !1;var o=r(e);if(!o)return null===n;var i=t(o,"constructor")&&o.constructor;return "function"!=typeof i?null===n:n===i||(null!==n&&Function.prototype.toString.call(i)===Function.prototype.toString.call(n)||"function"==typeof n&&"string"==typeof i.__typeson__type__&&i.__typeson__type__===n.__typeson__type__)}function isPlainObject(e){return !(!e||"Object"!==toStringTag(e))&&(!r(e)||hasConstructorOf(e,Object))}function isUserObject(e){if(!e||"Object"!==toStringTag(e))return !1;var t=r(e);return !t||(hasConstructorOf(e,Object)||isUserObject(t))}function isObject(e){return null!==e&&"object"===_typeof(e)}function escapeKeyPathComponent(e){return e.replaceAll("''","''''").replace(/^$/,"''").replaceAll("~","~0").replaceAll(".","~1")}function unescapeKeyPathComponent(e){return e.replaceAll("~1",".").replaceAll("~0","~").replace(/^''$/,"").replaceAll("''''","''")}function getByKeyPath(e,t){if(""===t)return e;if(null===e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");var r=t.indexOf(".");if(r>-1){var n=e[unescapeKeyPathComponent(t.slice(0,r))];return void 0===n?void 0:getByKeyPath(n,t.slice(r+1))}return e[unescapeKeyPathComponent(t)]}function setAtKeyPath(e,t,r){if(""===t)return r;if(!e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");var n=t.indexOf(".");return n>-1?setAtKeyPath(e[unescapeKeyPathComponent(t.slice(0,n))],t.slice(n+1),r):(e[unescapeKeyPathComponent(t)]=r,e)}function getJSONType(e){return null===e?"null":Array.isArray(e)?"array":_typeof(e)}function _await(e,t,r){return (e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}var n=Object.keys,o=Object.hasOwn,i$1=Array.isArray,a=["type","replaced","iterateIn","iterateUnsetNumeric","addLength"];function _async(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function nestedPathsFirst(e,t){var r,n;if(""===e.keypath)return -1;var o=null!==(r=e.keypath.match(/\./g))&&void 0!==r?r:0,i=null!==(n=t.keypath.match(/\./g))&&void 0!==n?n:0;return o&&(o=o.length),i&&(i=i.length),o>i?-1:o<i?1:e.keypath<t.keypath?-1:e.keypath>t.keypath?1:0}var c=function(){function Typeson(e){_classCallCheck(this,Typeson),this.options=e,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={};}return _createClass(Typeson,[{key:"stringify",value:function stringify(e,t,r,n){n=_objectSpread2(_objectSpread2(_objectSpread2({},this.options),n),{},{stringification:!0});var o=this.encapsulate(e,null,n);return i$1(o)?JSON.stringify(o[0],t,r):o.then((function(e){return JSON.stringify(e,t,r)}))}},{key:"stringifySync",value:function stringifySync(e,t,r,n){return this.stringify(e,t,r,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},n),{},{sync:!0}))}},{key:"stringifyAsync",value:function stringifyAsync(e,t,r,n){return this.stringify(e,t,r,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},n),{},{sync:!1}))}},{key:"parse",value:function parse(e,t,r){return r=_objectSpread2(_objectSpread2(_objectSpread2({},this.options),r),{},{parse:!0}),this.revive(JSON.parse(e,t),r)}},{key:"parseSync",value:function parseSync(e,t,r){return this.parse(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!0}))}},{key:"parseAsync",value:function parseAsync(e,t,r){return this.parse(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!1}))}},{key:"specialTypeNames",value:function specialTypeNames(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.returnTypeNames=!0,this.encapsulate(e,t,r)}},{key:"rootTypeName",value:function rootTypeName(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.iterateNone=!0,this.encapsulate(e,t,r)}},{key:"encapsulate",value:function encapsulate(t,r,c){var s=this,u=_objectSpread2(_objectSpread2({sync:!0},this.options),c),l=u.sync,y={},p=[],f=[],v=[],h=!("cyclic"in u)||u.cyclic,d=u.encapsulateObserver,b=function finish(e){var t=Object.values(y);if(u.iterateNone)return t.length?t[0]:getJSONType(e);if(t.length){if(u.returnTypeNames)return _toConsumableArray(new Set(t));e&&isPlainObject(e)&&!o(e,"$types")?e.$types=y:e={$:e,$types:{$:y}};}else isObject(e)&&o(e,"$types")&&(e={$:e,$types:!0});return !u.returnTypeNames&&e},_=_async((function(t,r){return _await(Promise.all(r.map((function(e){return e[1].p}))),(function(n){return _await(Promise.all(n.map(_async((function(n){var o=!1,i=[],a=_slicedToArray(r.splice(0,1),1),c=_slicedToArray(a[0],7),s=c[0],u=c[2],l=c[3],y=c[4],p=c[5],f=c[6],v=m(s,n,u,l,i,!0,f),h=hasConstructorOf(v,e);return function _invoke(e,t){var r=e();return r&&r.then?r.then(t):t(r)}((function(){if(s&&h)return _await(v.p,(function(e){y[p]=e;var r=_(t,i);return o=!0,r}))}),(function(e){return o?e:(s?y[p]=v:t=h?v.p:v,_(t,i))}))})))),(function(){return t}))}))})),O=function _adaptBuiltinStateObjectProperties(e,t,r){Object.assign(e,t);var n=a.map((function(t){var r=e[t];return delete e[t],r}));r(),a.forEach((function(t,r){e[t]=n[r];}));},m=function _encapsulate(t,r,a,c,l,v,h){var b,_={},m=_typeof(r),g=d?function(n){var o,i=null!==(o=null!=h?h:c.type)&&void 0!==o?o:getJSONType(r);d(Object.assign(null!=n?n:_,{keypath:t,value:r,cyclic:a,stateObj:c,promisesData:l,resolvingTypesonPromise:v,awaitingTypesonPromise:hasConstructorOf(r,e)},{type:i}));}:null;if(["string","boolean","number","undefined"].includes(m))return void 0===r||Number.isNaN(r)||r===Number.NEGATIVE_INFINITY||r===Number.POSITIVE_INFINITY||0===r?(b=c.replaced?r:j(t,r,c,l,!1,v,g))!==r&&(_={replaced:b}):b=r,g&&g(),b;if(null===r)return g&&g(),r;if(a&&!c.iterateIn&&!c.iterateUnsetNumeric&&r&&"object"===_typeof(r)){var S=p.indexOf(r);if(!(S<0))return y[t]="#",g&&g({cyclicKeypath:f[S]}),"#"+f[S];!0===a&&(p.push(r),f.push(t));}var P,T,w=isPlainObject(r),A=i$1(r),C=(w||A)&&(!s.plainObjectReplacers.length||c.replaced)||c.iterateIn?r:j(t,r,c,l,w||A,null,g);if(C!==r?(b=C,_={replaced:C}):""===t&&hasConstructorOf(r,e)?(l.push([t,r,a,c,void 0,void 0,c.type]),b=r):A&&"object"!==c.iterateIn||"array"===c.iterateIn?(P=new Array(r.length),_={clone:P}):(["function","symbol"].includes(_typeof(r))||"toJSON"in r||hasConstructorOf(r,e)||hasConstructorOf(r,Promise)||hasConstructorOf(r,ArrayBuffer))&&!w&&"object"!==c.iterateIn?b=r:(P={},c.addLength&&(P.length=r.length),_={clone:P}),g&&g(),u.iterateNone)return null!==(T=P)&&void 0!==T?T:b;if(!P)return b;if(c.iterateIn){var k=function _loop(n){var i={ownKeys:o(r,n)};O(c,i,(function(){var o=t+(t?".":"")+escapeKeyPathComponent(n),i=_encapsulate(o,r[n],Boolean(a),c,l,v);hasConstructorOf(i,e)?l.push([o,i,Boolean(a),c,P,n,c.type]):void 0!==i&&(P[n]=i);}));};for(var N in r)k(N);g&&g({endIterateIn:!0,end:!0});}else n(r).forEach((function(n){var o=t+(t?".":"")+escapeKeyPathComponent(n);O(c,{ownKeys:!0},(function(){var t=_encapsulate(o,r[n],Boolean(a),c,l,v);hasConstructorOf(t,e)?l.push([o,t,Boolean(a),c,P,n,c.type]):void 0!==t&&(P[n]=t);}));})),g&&g({endIterateOwn:!0,end:!0});if(c.iterateUnsetNumeric){for(var I=r.length,E=function _loop2(n){if(!(n in r)){var o="".concat(t).concat(t?".":"").concat(n);O(c,{ownKeys:!1},(function(){var t=_encapsulate(o,void 0,Boolean(a),c,l,v);hasConstructorOf(t,e)?l.push([o,t,Boolean(a),c,P,n,c.type]):void 0!==t&&(P[n]=t);}));}},K=0;K<I;K++)E(K);g&&g({endIterateUnsetNumeric:!0,end:!0});}return P},j=function replace(e,t,r,n,o,i,a){for(var c=o?s.plainObjectReplacers:s.nonplainObjectReplacers,u=c.length;u--;){var p=c[u];if(p.test(t,r)){var f=p.type;if(s.revivers[f]){var v=y[e];y[e]=v?[f].concat(v):f;}if(Object.assign(r,{type:f,replaced:!0}),(l||!p.replaceAsync)&&!p.replace)return a&&a({typeDetected:!0}),m(e,t,h&&"readonly",r,n,i,f);a&&a({replacing:!0});var d=void 0;if(l||!p.replaceAsync){if(void 0===p.replace)throw new TypeError("Missing replacer");d=p.replace(t,r);}else d=p.replaceAsync(t,r);return m(e,d,h&&"readonly",r,n,i,f)}}return t},g=m("",t,h,null!=r?r:{},v);if(v.length)return l&&u.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(_(g,v)).then(b);if(!l&&u.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return u.stringification&&l?[b(g)]:l?b(g):Promise.resolve(b(g))}},{key:"encapsulateSync",value:function encapsulateSync(e,t,r){return this.encapsulate(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!0}))}},{key:"encapsulateAsync",value:function encapsulateAsync(e,t,r){return this.encapsulate(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!1}))}},{key:"revive",value:function revive(t,r){var o=this,a=_objectSpread2(_objectSpread2({sync:!0},this.options),r),c=a.sync;function finishRevival(e){if(c)return e;if(a.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return Promise.resolve(e)}if(!t||"object"!==_typeof(t)||Array.isArray(t))return finishRevival(t);var u=t.$types;if(!0===u)return finishRevival(t.$);if(!u||"object"!==_typeof(u)||Array.isArray(u))return finishRevival(t);var l=[],y={},p=!0;u.$&&isPlainObject(u.$)&&(t=t.$,u=u.$,p=!1);var f=function executeReviver(e,t){var r,n=_slicedToArray(null!==(r=o.revivers[e])&&void 0!==r?r:[],1)[0];if(!n)throw new Error("Unregistered type: "+e);if(c&&!("revive"in n))return t;if(!c&&n.reviveAsync)return n.reviveAsync(t,y);if(n.revive)return n.revive(t,y);throw new Error("Missing reviver")},v=[];function checkUndefined(e){return hasConstructorOf(e,s)?void 0:e}var h,d=function revivePlainObjects(){var r=[];if(!u)throw new Error("Found bad `types`");if(Object.entries(u).forEach((function(e){var t=_slicedToArray(e,2),n=t[0],i=t[1];"#"!==i&&[].concat(i).forEach((function(e){var t;_slicedToArray(null!==(t=o.revivers[e])&&void 0!==t?t:[null,{}],2)[1].plain&&(r.push({keypath:n,type:e}),delete u[n]);}));})),r.length)return r.sort(nestedPathsFirst).reduce((function reducer(r,n){var o=n.keypath,i=n.type;if(isThenable(r))return r.then((function(e){return reducer(e,{keypath:o,type:i})}));var a=getByKeyPath(t,o);if(hasConstructorOf(a=f(i,a),e))return a.then((function(e){var r=setAtKeyPath(t,o,e);r===e&&(t=r);}));var c=setAtKeyPath(t,o,a);c===a&&(t=c);}),void 0)}();return hasConstructorOf(d,e)?h=d.then((function(){return t})):(h=function _revive(t,r,o,a,c){if(!p||"$types"!==t){var y=u[t],h=i$1(r);if(h||isPlainObject(r)){var d=h?new Array(r.length):{};for(n(r).forEach((function(n){var i=_revive(t+(t?".":"")+escapeKeyPathComponent(n),r[n],null!=o?o:d,d,n),a=function set(e){return hasConstructorOf(e,s)?d[n]=void 0:void 0!==e&&(d[n]=e),e};hasConstructorOf(i,e)?v.push(i.then((function(e){return a(e)}))):a(i);})),r=d;l.length;){var b=_slicedToArray(l[0],4),_=b[0],O=b[1],m=b[2],j=b[3],g=getByKeyPath(_,O);if(void 0===g)break;m[j]=g,l.splice(0,1);}}if(!y)return r;if("#"===y){var S=getByKeyPath(o,r.slice(1));return void 0===S&&l.push([o,r.slice(1),a,c]),S}return [].concat(y).reduce((function reducer(t,r){if(hasConstructorOf(t,e))return t.then((function(e){return reducer(e,r)}));if("string"!=typeof r)throw new TypeError("Bad type JSON");return f(r,t)}),r)}}("",t,null),v.length&&(h=e.resolve(h).then((function(t){return e.all([t].concat(v))})).then((function(e){return _slicedToArray(e,1)[0]})))),isThenable(h)?c&&a.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():hasConstructorOf(h,e)?h.p.then(checkUndefined):h:!c&&a.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():c?checkUndefined(h):Promise.resolve(checkUndefined(h))}},{key:"reviveSync",value:function reviveSync(e,t){return this.revive(e,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},t),{},{sync:!0}))}},{key:"reviveAsync",value:function reviveAsync(e,t){return this.revive(e,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},t),{},{sync:!1}))}},{key:"register",value:function register(e,t){var r=this,o=null!=t?t:{},a=function R(e){i$1(e)?e.forEach((function(e){return R(e)})):n(e).forEach((function(t){var n;if("#"===t)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(u.includes(t))throw new TypeError("Plain JSON object types are reserved as type names");var a=e[t],c=a&&"function"!=typeof a&&!Array.isArray(a)&&a.testPlainObjects?r.plainObjectReplacers:r.nonplainObjectReplacers,s=c.filter((function(e){return e.type===t}));if(s.length&&(c.splice(c.indexOf(s[0]),1),delete r.revivers[t],delete r.types[t]),"function"==typeof a){var l=a;a={test:function test(e){return e&&e.constructor===l},replace:function replace(e){return _objectSpread2({},e)},revive:function revive(e){return Object.assign(Object.create(l.prototype),e)}};}else if(i$1(a)){var y=_slicedToArray(a,3);a={test:y[0],replace:y[1],revive:y[2]};}if(null!==(n=a)&&void 0!==n&&n.test){var p={type:t,test:a.test.bind(a)};a.replace&&(p.replace=a.replace.bind(a)),a.replaceAsync&&(p.replaceAsync=a.replaceAsync.bind(a));var f="number"==typeof o.fallback?o.fallback:o.fallback?0:Number.POSITIVE_INFINITY;if(a.testPlainObjects?r.plainObjectReplacers.splice(f,0,p):r.nonplainObjectReplacers.splice(f,0,p),a.revive||a.reviveAsync){var v={};a.revive&&(v.revive=a.revive.bind(a)),a.reviveAsync&&(v.reviveAsync=a.reviveAsync.bind(a)),r.revivers[t]=[v,{plain:a.testPlainObjects}];}r.types[t]=a;}}));};return [].concat(e).forEach((function(e){return a(e)})),this}}]),Typeson}(),s=_createClass((function Undefined(){_classCallCheck(this,Undefined);}));s.__typeson__type__="TypesonUndefined";var u=["null","boolean","number","string","array","object"];
|
|
1
|
+
class TypesonPromise{constructor(e){this.p=new Promise(e);}}TypesonPromise.__typeson__type__="TypesonPromise","undefined"!=typeof Symbol&&Object.defineProperty(TypesonPromise.prototype,Symbol.toStringTag,{get:()=>"TypesonPromise"}),TypesonPromise.prototype.then=function(e,t){return new TypesonPromise((n,r)=>{this.p.then(function(t){n(e?e(t):t);}).catch(function(e){return t?t(e):Promise.reject(e)}).then(n,r);})},TypesonPromise.prototype.catch=function(e){return this.then(void 0,e)},TypesonPromise.resolve=function(e){return new TypesonPromise(t=>{t(e);})},TypesonPromise.reject=function(e){return new TypesonPromise((t,n)=>{n(e);})},TypesonPromise.all=function(e){return new TypesonPromise(function(t,n){Promise.all(e.map(e=>e?.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e)).then(t,n);})},TypesonPromise.race=function(e){return new TypesonPromise(function(t,n){Promise.race(e.map(e=>e?.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e)).then(t,n);})},TypesonPromise.allSettled=function(e){return new TypesonPromise(function(t,n){Promise.allSettled(e.map(e=>e?.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e)).then(t,n);})};const{hasOwn:e}=Object,t=Object.getPrototypeOf;function isThenable(e,t){return isObject(e)&&"function"==typeof e.then&&(!t||"function"==typeof e.catch)}function toStringTag(e){return Object.prototype.toString.call(e).slice(8,-1)}function hasConstructorOf(n,r){if(!n||"object"!=typeof n)return false;const o=t(n);if(!o)return null===r;const s=e(o,"constructor")&&o.constructor;return "function"!=typeof s?null===r:r===s||(null!==r&&Function.prototype.toString.call(s)===Function.prototype.toString.call(r)||"function"==typeof r&&"string"==typeof s.__typeson__type__&&s.__typeson__type__===r.__typeson__type__)}function isPlainObject(e){if(!e||"Object"!==toStringTag(e))return false;return !t(e)||hasConstructorOf(e,Object)}function isUserObject(e){if(!e||"Object"!==toStringTag(e))return false;const n=t(e);return !n||(hasConstructorOf(e,Object)||isUserObject(n))}function isObject(e){return null!==e&&"object"==typeof e}function escapeKeyPathComponent(e){return e.replaceAll("''","''''").replace(/^$/u,"''").replaceAll("~","~0").replaceAll(".","~1")}function unescapeKeyPathComponent(e){return e.replaceAll("~1",".").replaceAll("~0","~").replace(/^''$/u,"").replaceAll("''''","''")}function getByKeyPath(t,n,r){if(""===n)return t;if(null===t||"object"!=typeof t)throw new TypeError("Unexpected non-object type");const o=n.indexOf("."),s=unescapeKeyPathComponent(-1===o?n:n.slice(0,o));if(!r||e(t,s)){if(-1!==o){const e=t[s];return void 0===e?void 0:getByKeyPath(e,n.slice(o+1),r)}return t[s]}}function setAtKeyPath(t,n,r,o){if(""===n)return r;let s=t,i=n;for(;;){if(!s||"object"!=typeof s)throw new TypeError("Unexpected non-object type");const n=i.indexOf("."),c=unescapeKeyPathComponent(-1===n?i:i.slice(0,n));if("__proto__"===c)throw new TypeError("Invalid property");if(-1===n)return s[c]=r,t;if(o&&!e(s,c))throw new TypeError("Invalid property");s=s[c],i=i.slice(n+1);}}function getJSONType(e){return null===e?"null":Array.isArray(e)?"array":typeof e}
|
|
2
|
+
/**
|
|
3
|
+
* @file Typeson - JSON with types.
|
|
4
|
+
* @license The MIT License (MIT)
|
|
5
|
+
* @copyright (c) 2016-2018 David Fahlander, Brett Zamir
|
|
6
|
+
*/const{keys:n,hasOwn:r}=Object,{isArray:o}=Array,s=["type","replaced","iterateIn","iterateUnsetNumeric","iterateSymbols","addLength"];function setOwnEnumerable(e,t,n){Object.defineProperty(e,t,{configurable:true,enumerable:true,value:n,writable:true});}const i$1=["asyncIterator","hasInstance","isConcatSpreadable","iterator","match","matchAll","replace","search","species","split","toPrimitive","toStringTag","unscopables"];function nestedPathsFirst(e,t){if(""===e.keypath)return -1;let n=e.keypath.match(/\./gu)??0,r=t.keypath.match(/\./gu)??0;return n&&(n=n.length),r&&(r=r.length),n>r?-1:n<r?1:e.keypath<t.keypath?-1:e.keypath>t.keypath?1:0}class Typeson{constructor(e){this.options=e,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={},this.symbolsByName=Object.create(null),this.symbolsByValue=new Map;const t=e?.symbols;t&&Object.entries(t).forEach(([e,t])=>{if("symbol"!=typeof t)throw new TypeError("Non-symbol value supplied for `symbols` entry: "+e);this.symbolsByName[e]=t,this.symbolsByValue.set(t,e);});}stringify(e,t,n,r){r={...this.options,...r,stringification:true};const s=this.encapsulate(e,null,r);return o(s)?JSON.stringify(s[0],t,n):s.then(e=>JSON.stringify(e,t,n))}stringifySync(e,t,n,r){return this.stringify(e,t,n,{throwOnBadSyncType:true,...r,sync:true})}stringifyAsync(e,t,n,r){return this.stringify(e,t,n,{throwOnBadSyncType:true,...r,sync:false})}parse(e,t,n){return n={...this.options,...n,parse:true},this.revive(JSON.parse(e,t),n)}parseSync(e,t,n){return this.parse(e,t,{throwOnBadSyncType:true,...n,sync:true})}parseAsync(e,t,n){return this.parse(e,t,{throwOnBadSyncType:true,...n,sync:false})}specialTypeNames(e,t,n={}){return this.encapsulate(e,t,{...n,returnTypeNames:true})}rootTypeName(e,t,n={}){return this.encapsulate(e,t,{...n,iterateNone:true})}encapsulate(e,t,c){const a={sync:true,...this.options,...c},{sync:y}=a,l={},p={},u=[],h=[],f=[],b=!("cyclic"in a)||a.cyclic,{encapsulateObserver:d,encapsulateError:m}=a,finish=e=>{const t=Object.values(l);if(a.iterateNone)return t.length?t[0]:getJSONType(e);if(a.returnTypeNames)return !!t.length&&[...new Set(t)];const n=Object.keys(p).length>0,o=isObject(e)&&(r(e,"$types")||r(e,"$symbolKeys"));return n||t.length?(!o&&e&&isPlainObject(e)?t.length&&(e.$types=l):e={$:e,$types:{$:l}},n&&(e.$symbolKeys=p)):o&&(e={$:e,$types:true}),e},checkPromises=async(e,t)=>{const n=await Promise.all(t.map(e=>e[1].p));return await Promise.all(n.map(async function(n){const r=[],[o]=t.splice(0,1),[s,,i,c,a,y,l]=o,p=_encapsulate(s,n,i,c,r,true,l),u=hasConstructorOf(p,TypesonPromise);if(s&&u){return setOwnEnumerable(a,y,await p.p),checkPromises(e,r)}return s?setOwnEnumerable(a,y,p):e=u?p.p:p,checkPromises(e,r)})),e},_adaptBuiltinStateObjectProperties=(e,t,n)=>{Object.assign(e,t);const r=s.map(t=>{const n=e[t];return delete e[t],n});n(),s.forEach((t,n)=>{e[t]=r[n];});},_encapsulate=(e,t,s,c,y,f,b)=>{let v,O={};const w=d?function(n){const r=b??c.type??getJSONType(t);d(Object.assign(n??O,{keypath:e,value:t,cyclic:s,stateObj:c,promisesData:y,resolvingTypesonPromise:f,awaitingTypesonPromise:hasConstructorOf(t,TypesonPromise)},{type:r}));}:null,getEncapsulatedValue=(e,t,n)=>{try{return {value:_encapsulate(e,t[n],Boolean(s),c,y,f)}}catch(r){if(!m)throw r;const o=b??c.type??getJSONType(t),s=m({keypath:e,error:r,parent:t,key:n,stateObj:c,type:o});if(!s)throw r;if("substitute"in s)return {value:s.substitute,substitute:true};if(s.ignore)return;throw r}};if(["string","boolean","number","undefined"].includes(typeof t))return void 0===t||t===1/0||0===t||t===-1/0||Number.isNaN(t)?(v=c.replaced?t:replace(e,t,c,y,false,f,w),v!==t&&(O={replaced:v})):v=t,w&&w(),v;if(null===t)return w&&w(),t;if(s&&t&&"object"==typeof t&&!c.iterateIn&&!c.iterateUnsetNumeric){const n=u.indexOf(t);if(-1!==n)return l[e]="#",w&&w({cyclicKeypath:h[n]}),"#"+h[n];true===s&&(u.push(t),h.push(e));}const g=isPlainObject(t),T=o(t),P=(g||T)&&(!this.plainObjectReplacers.length||c.replaced)||c.iterateIn?t:replace(e,t,c,y,g||T,null,w);let j;if(P!==t?(v=P,O={replaced:P}):""===e&&hasConstructorOf(t,TypesonPromise)?(y.push([e,t,s,c,void 0,void 0,c.type]),v=t):T&&"object"!==c.iterateIn||"array"===c.iterateIn?(j=new Array(t.length),O={clone:j}):!g&&("object"!=typeof t||"toJSON"in t||hasConstructorOf(t,TypesonPromise)||hasConstructorOf(t,Promise)||hasConstructorOf(t,ArrayBuffer))&&"object"!==c.iterateIn?v=t:(j={},c.addLength&&(j.length=t.length),O={clone:j}),w&&w(),a.iterateNone)return j??v;if(!j)return v;if(c.iterateIn){for(const n in t){const o={ownKeys:r(t,n)};_adaptBuiltinStateObjectProperties(c,o,()=>{const r=e+(e?".":"")+escapeKeyPathComponent(n),o=getEncapsulatedValue(r,t,n),i=o&&o.value;hasConstructorOf(i,TypesonPromise)?y.push([r,i,Boolean(s),c,j,n,c.type]):o&&(void 0!==i||"substitute"in o)&&setOwnEnumerable(j,n,i);});}w&&w({endIterateIn:true,end:true});}else n(t).forEach(function(n){const r=e+(e?".":"")+escapeKeyPathComponent(n);_adaptBuiltinStateObjectProperties(c,{ownKeys:true},()=>{const e=getEncapsulatedValue(r,t,n),o=e&&e.value;hasConstructorOf(o,TypesonPromise)?y.push([r,o,Boolean(s),c,j,n,c.type]):e&&(void 0!==o||"substitute"in e)&&setOwnEnumerable(j,n,o);});}),w&&w({endIterateOwn:true,end:true}),(c.iterateSymbols||a.iterateSymbols)&&(Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e)).forEach(n=>{const r=function resolveSymbolIdentity(e,t){const n=Symbol.keyFor(e);if(void 0!==n)return {for:n};const r=i$1.find(t=>Symbol[t]===e);if(r)return {wellKnown:r};const o=t.get(e);return void 0!==o?{registered:o}:null}(n,this.symbolsByValue);if(!r){if(a.throwOnUnregisteredSymbol)throw new TypeError("Cannot serialize a Symbol-keyed property whose Symbol has no portable identity (not global, not well-known, and not in the `symbols` option): "+String(n));return}const o=p[e]??=[],l={key:r};o.push(l);const u=o.length-1,h=`$symbolKeys.${escapeKeyPathComponent(e)}.${String(u)}.value`,f={value:t[n]};_adaptBuiltinStateObjectProperties(c,{ownKeys:true},()=>{const e=getEncapsulatedValue(h,f,"value"),t=e&&e.value;hasConstructorOf(t,TypesonPromise)?y.push([h,t,Boolean(s),c,l,"value",c.type]):e&&(void 0!==t||"substitute"in e)&&setOwnEnumerable(l,"value",t);});}),w&&w({endIterateSymbols:true,end:true}));if(c.iterateUnsetNumeric){const n=t.length;for(let r=0;r<n;r++){if(r in t)continue;const n=`${e}${e?".":""}${String(r)}`;_adaptBuiltinStateObjectProperties(c,{ownKeys:false},()=>{const e=_encapsulate(n,void 0,Boolean(s),c,y,f);hasConstructorOf(e,TypesonPromise)?y.push([n,e,Boolean(s),c,j,r,c.type]):void 0!==e&&setOwnEnumerable(j,r,e);});}w&&w({endIterateUnsetNumeric:true,end:true});}return j},replace=(e,t,n,r,o,s,i)=>{const c=o?this.plainObjectReplacers:this.nonplainObjectReplacers;let a=c.length;for(;a--;){const o=c[a];if(o.test(t,n)){const{type:c}=o;if(Object.hasOwn(this.revivers,c)){const t=l[e];l[e]=t?[c].concat(t):c;}if(Object.assign(n,{type:c,replaced:true}),(y||!o.replaceAsync)&&!o.replace)return i&&i({typeDetected:true}),_encapsulate(e,t,b&&"readonly",n,r,s,c);let a;if(i&&i({replacing:true}),y||!o.replaceAsync){if(void 0===o.replace)throw new TypeError("Missing replacer");a=o.replace(t,n);}else a=o.replaceAsync(t,n);return _encapsulate(e,a,b&&"readonly",n,r,s,c)}}return t},v=_encapsulate("",e,b,t??{},f);if(f.length)return y&&a.throwOnBadSyncType?(()=>{throw new TypeError("Sync method requested but async result obtained")})():Promise.resolve(checkPromises(v,f)).then(finish);if(!y&&a.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return y&&a.stringification?[finish(v)]:y?finish(v):Promise.resolve(finish(v))}encapsulateSync(e,t,n){return this.encapsulate(e,t,{throwOnBadSyncType:true,...n,sync:true})}encapsulateAsync(e,t,n){return this.encapsulate(e,t,{throwOnBadSyncType:true,...n,sync:false})}revive(e,t){const s={sync:true,...this.options,...t},{sync:c}=s;function finishRevival(e){if(c)return e;if(s.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return Promise.resolve(e)}if(!e||"object"!=typeof e||Array.isArray(e))return finishRevival(e);let a=e.$types;if(true===a)return finishRevival(e.$);const y=e.$symbolKeys;let l=void 0!==y;if(!a||"object"!=typeof a||Array.isArray(a)){if(!y)return finishRevival(e);a={};}const p=[],u=Object.create(null),h={};let f=true;a.$&&isPlainObject(a.$)&&(e=e.$,a=a.$,f=false,l=false,void 0!==y&&isObject(e)&&!r(e,"$symbolKeys")&&(e.$symbolKeys=y,l=true));const executeReviver=(e,t)=>{const[n]=this.revivers[e]??[];if(!n)throw new Error("Unregistered type: "+e);if(c&&!("revive"in n))return t;if(!c&&n.reviveAsync)return n.reviveAsync(t,h);if(n.revive)return n.revive(t,h);throw new Error("Missing reviver")},b=[];function checkUndefined(e){return hasConstructorOf(e,Undefined)?void 0:e}const reHomeSymbolKeys=e=>{if(!isObject(e))return;const t=l?e.$symbolKeys:y;t&&(Object.entries(t).forEach(([t,n])=>{const o=getByKeyPath(e,t,true);isObject(o)&&n.forEach(e=>{if(!r(e,"value"))return;const t=function resolveSymbolFromIdentity(e,t){if("for"in e)return Symbol.for(e.for);if("wellKnown"in e){const t=i$1.find(t=>t===e.wellKnown);if(!t)throw new Error("Unknown well-known Symbol: "+e.wellKnown);return Symbol[t]}if(!r(t,e.registered))throw new Error("Unregistered symbol: "+e.registered);return t[e.registered]}(e.key,this.symbolsByName),n=checkUndefined(e.value);e.descriptor?Object.defineProperty(o,t,{configurable:true,enumerable:true,writable:true,...e.descriptor,value:n}):o[t]=n;});}),l&&delete e.$symbolKeys);},d=(()=>{if(!a)throw new Error("Found bad `types`");const t=[];if(Object.entries(a).forEach(([e,n])=>{"#"!==n&&[].concat(n).forEach(n=>{const[,{plain:r}]=this.revivers[n]??[null,{}];r&&(t.push({keypath:e,type:n}),delete a[e]);});}),t.length)return t.sort(nestedPathsFirst),t.reduce(function reducer(t,{keypath:n,type:r}){if(isThenable(t))return t.then(e=>reducer(e,{keypath:n,type:r}));let o=getByKeyPath(e,n,true);if(o=executeReviver(r,o),hasConstructorOf(o,TypesonPromise))return o.then(t=>{const r=setAtKeyPath(e,n,t,true);r===t&&(e=r);});const s=setAtKeyPath(e,n,o,true);s===o&&(e=s);},void 0)})();let m;return hasConstructorOf(d,TypesonPromise)?m=d.then(()=>e):(m=function _revive(e,t,s,i,y){if(f&&"$types"===e)return;const l=b.length,h=r(a,e)?a[e]:void 0,d=o(t);if(d||isPlainObject(t)){const o=d?new Array(t.length):{};for(n(t).forEach(n=>{const r=_revive(e+(e?".":"")+escapeKeyPathComponent(n),t[n],s??o,o,n),set=e=>(hasConstructorOf(e,Undefined)?setOwnEnumerable(o,n,void 0):void 0!==e&&setOwnEnumerable(o,n,e),e);hasConstructorOf(r,TypesonPromise)?b.push(r.then(e=>set(e))):set(r);}),t=o;p.length;){const[[e,t,n,o]]=p,s=r(u,t),i=s?u[t]:getByKeyPath(e,t,true);if(!s&&void 0===i)break;setOwnEnumerable(n,o,i),p.shift();}}if(!h)return u[e]=t,t;if("#"===h){const e=t.slice(1),n=r(u,e),o=n?u[e]:getByKeyPath(s,e,true);return n||void 0!==o||p.push([s,e,i,y]),o}const applyType=t=>{const n=[].concat(h).reduce(function reducer(e,t){if(hasConstructorOf(e,TypesonPromise))return e.then(e=>reducer(e,t));if("string"!=typeof t)throw new TypeError("Bad type JSON");return executeReviver(t,e)},t);return hasConstructorOf(n,TypesonPromise)?n.then(t=>(u[e]=t,t)):(u[e]=n,n)};return !c&&b.length>l?TypesonPromise.all(b.slice(l)).then(()=>applyType(t)):applyType(t)}("",e,null),b.length&&(m=TypesonPromise.resolve(m).then(e=>TypesonPromise.all([e,...b])).then(([e])=>e))),y&&(isThenable(m)?m=m.then(e=>(reHomeSymbolKeys(e),e)):reHomeSymbolKeys(m)),isThenable(m)?c&&s.throwOnBadSyncType?(()=>{throw new TypeError("Sync method requested but async result obtained")})():hasConstructorOf(m,TypesonPromise)?m.p.then(checkUndefined):m:!c&&s.throwOnBadSyncType?(()=>{throw new TypeError("Async method requested but sync result obtained")})():c?checkUndefined(m):Promise.resolve(checkUndefined(m))}reviveSync(e,t){return this.revive(e,{throwOnBadSyncType:true,...t,sync:true})}reviveAsync(e,t){return this.revive(e,{throwOnBadSyncType:true,...t,sync:false})}register(e,t){const r=t??{},reg=e=>{o(e)?e.forEach(e=>{reg(e);}):n(e).forEach(t=>{if("#"===t)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(c.includes(t))throw new TypeError("Plain JSON object types are reserved as type names");let n=e[t];if([this.plainObjectReplacers,this.nonplainObjectReplacers].forEach(e=>{const n=e.findIndex(e=>e.type===t);-1!==n&&e.splice(n,1);}),delete this.revivers[t],delete this.types[t],"function"==typeof n){const e=n;n={test:t=>t&&t.constructor===e,replace:e=>({...e}),revive:t=>Object.assign(Object.create(e.prototype),t)};}else if(o(n)){const[e,t,r]=n;n={test:e,replace:t,revive:r};}if(!n?.test)return;const s={type:t,test:n.test.bind(n)};n.replace&&(s.replace=n.replace.bind(n)),n.replaceAsync&&(s.replaceAsync=n.replaceAsync.bind(n));const i="number"==typeof r.fallback?r.fallback:r.fallback?0:1/0;if(n.testPlainObjects?this.plainObjectReplacers.splice(i,0,s):this.nonplainObjectReplacers.splice(i,0,s),n.revive||n.reviveAsync){const e={};n.revive&&(e.revive=n.revive.bind(n)),n.reviveAsync&&(e.reviveAsync=n.reviveAsync.bind(n)),this.revivers[t]=[e,{plain:n.testPlainObjects}];}this.types[t]=n;});};return [].concat(e).forEach(e=>{reg(e);}),this}}class Undefined{}Undefined.__typeson__type__="TypesonUndefined";const c=["null","boolean","number","string","array","object"];
|
|
2
7
|
|
|
3
8
|
/*
|
|
4
9
|
* base64-arraybuffer
|
|
@@ -107,13 +112,14 @@ const arraybuffer = {
|
|
|
107
112
|
stateObj.buffers = [];
|
|
108
113
|
}
|
|
109
114
|
const index = stateObj.buffers.indexOf(b);
|
|
110
|
-
if (index
|
|
115
|
+
if (index !== -1) {
|
|
111
116
|
return {index};
|
|
112
117
|
}
|
|
113
118
|
stateObj.buffers.push(b);
|
|
114
119
|
return {
|
|
115
120
|
s: encode(b),
|
|
116
|
-
maxByteLength: b.maxByteLength
|
|
121
|
+
maxByteLength: b.maxByteLength,
|
|
122
|
+
resizable: b.resizable
|
|
117
123
|
};
|
|
118
124
|
},
|
|
119
125
|
revive (
|
|
@@ -137,7 +143,9 @@ const arraybuffer = {
|
|
|
137
143
|
}
|
|
138
144
|
const buffer = decode(
|
|
139
145
|
/** @type {string} */ (b64.s),
|
|
140
|
-
|
|
146
|
+
b64.resizable
|
|
147
|
+
? {maxByteLength: b64.maxByteLength}
|
|
148
|
+
: undefined
|
|
141
149
|
);
|
|
142
150
|
stateObj.buffers.push(buffer);
|
|
143
151
|
return buffer;
|
|
@@ -147,6 +155,65 @@ const arraybuffer = {
|
|
|
147
155
|
|
|
148
156
|
// See also typed-arrays!
|
|
149
157
|
|
|
158
|
+
/* globals AudioData -- Polyfills */
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @type {import('typeson').TypeSpecSet}
|
|
162
|
+
*/
|
|
163
|
+
const audiodata = {
|
|
164
|
+
audiodata: {
|
|
165
|
+
test (x) {
|
|
166
|
+
return toStringTag(x) === 'AudioData';
|
|
167
|
+
},
|
|
168
|
+
replace (audioData) {
|
|
169
|
+
const {
|
|
170
|
+
format, sampleRate, numberOfFrames, numberOfChannels,
|
|
171
|
+
timestamp
|
|
172
|
+
} = audioData;
|
|
173
|
+
|
|
174
|
+
// 2. Determine plane layout based on audio format
|
|
175
|
+
const isPlanar = format.endsWith('-planar');
|
|
176
|
+
const numPlanes = isPlanar ? numberOfChannels : 1;
|
|
177
|
+
|
|
178
|
+
// 3. Per the AudioData API, planes are laid out back-to-back
|
|
179
|
+
// within a single buffer, so compute their sizes up front
|
|
180
|
+
const planeSizes = [];
|
|
181
|
+
let totalSize = 0;
|
|
182
|
+
for (let i = 0; i < numPlanes; i++) {
|
|
183
|
+
const size = audioData.allocationSize({planeIndex: i});
|
|
184
|
+
planeSizes.push(size);
|
|
185
|
+
totalSize += size;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// 4. Copy the raw binary data out of each plane into its slot
|
|
189
|
+
const data = new ArrayBuffer(totalSize);
|
|
190
|
+
let offset = 0;
|
|
191
|
+
for (let i = 0; i < numPlanes; i++) {
|
|
192
|
+
const planeView = new Uint8Array(data, offset, planeSizes[i]);
|
|
193
|
+
audioData.copyTo(planeView, {planeIndex: i});
|
|
194
|
+
offset += planeSizes[i];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// 5. Return a clean, serializable manifest
|
|
198
|
+
return {
|
|
199
|
+
format, sampleRate, numberOfFrames, numberOfChannels,
|
|
200
|
+
timestamp,
|
|
201
|
+
data
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
revive ({
|
|
205
|
+
format, sampleRate, numberOfFrames, numberOfChannels,
|
|
206
|
+
timestamp, data
|
|
207
|
+
}) {
|
|
208
|
+
return new AudioData({
|
|
209
|
+
format, sampleRate, numberOfFrames, numberOfChannels,
|
|
210
|
+
timestamp,
|
|
211
|
+
data: new Uint8Array(data)
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
150
217
|
/**
|
|
151
218
|
* @type {import('typeson').TypeSpecSet}
|
|
152
219
|
*/
|
|
@@ -282,7 +349,7 @@ const blob = {
|
|
|
282
349
|
return new Blob([string2arraybuffer(stringContents)], {type});
|
|
283
350
|
},
|
|
284
351
|
replaceAsync (b) {
|
|
285
|
-
return new
|
|
352
|
+
return new TypesonPromise((resolve, reject) => {
|
|
286
353
|
/*
|
|
287
354
|
if (b.isClosed) { // On MDN, but not in https://w3c.github.io/FileAPI/#dfn-Blob
|
|
288
355
|
reject(new Error('The Blob is closed'));
|
|
@@ -318,16 +385,16 @@ const blob = {
|
|
|
318
385
|
* it may be troublesome to bundle and not strongly needed)
|
|
319
386
|
* @returns {string}
|
|
320
387
|
*/
|
|
321
|
-
function generateUUID () { // Adapted from original: public domain/MIT:
|
|
388
|
+
function generateUUID () { // Adapted from original: public domain/MIT: https://stackoverflow.com/a/8809472/271577
|
|
322
389
|
/* c8 ignore next */
|
|
323
390
|
let d = Date.now();
|
|
324
391
|
|
|
325
392
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replaceAll(/[xy]/gu, function (c) {
|
|
326
|
-
/* eslint-disable no-bitwise -- Convenient */
|
|
393
|
+
/* eslint-disable no-bitwise, sonarjs/pseudo-random -- Convenient */
|
|
327
394
|
const r = Math.trunc((d + (Math.random() * 16)) % 16);
|
|
328
395
|
d = Math.floor(d / 16);
|
|
329
396
|
return (c === 'x' ? r : ((r & 0x3) | 0x8)).toString(16);
|
|
330
|
-
/* eslint-enable no-bitwise -- Convenient */
|
|
397
|
+
/* eslint-enable no-bitwise, sonarjs/pseudo-random -- Convenient */
|
|
331
398
|
});
|
|
332
399
|
}
|
|
333
400
|
|
|
@@ -375,7 +442,7 @@ const cryptokey = {
|
|
|
375
442
|
/** @type {CryptoKey} */
|
|
376
443
|
key
|
|
377
444
|
) {
|
|
378
|
-
return new
|
|
445
|
+
return new TypesonPromise(async (resolve, reject) => {
|
|
379
446
|
/** @type {JsonWebKey} */
|
|
380
447
|
let jwk;
|
|
381
448
|
try {
|
|
@@ -397,12 +464,12 @@ const cryptokey = {
|
|
|
397
464
|
const {
|
|
398
465
|
jwk, algorithm, usages
|
|
399
466
|
} = /**
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
467
|
+
* @type {{
|
|
468
|
+
* jwk: JsonWebKey,
|
|
469
|
+
* algorithm: KeyAlgorithm,
|
|
470
|
+
* usages: KeyUsage[]
|
|
471
|
+
* }}
|
|
472
|
+
*/ (obj);
|
|
406
473
|
|
|
407
474
|
return crypto.subtle.importKey(
|
|
408
475
|
'jwk', jwk, algorithm, true, usages
|
|
@@ -430,13 +497,14 @@ const dataview = {
|
|
|
430
497
|
stateObj.buffers = [];
|
|
431
498
|
}
|
|
432
499
|
const index = stateObj.buffers.indexOf(buffer);
|
|
433
|
-
if (index
|
|
500
|
+
if (index !== -1) {
|
|
434
501
|
return {index, byteOffset, byteLength};
|
|
435
502
|
}
|
|
436
503
|
stateObj.buffers.push(buffer);
|
|
437
504
|
return {
|
|
438
505
|
encoded: encode(buffer),
|
|
439
506
|
maxByteLength: buffer.maxByteLength,
|
|
507
|
+
resizable: buffer.resizable,
|
|
440
508
|
byteOffset,
|
|
441
509
|
byteLength
|
|
442
510
|
};
|
|
@@ -454,7 +522,8 @@ const dataview = {
|
|
|
454
522
|
stateObj.buffers = [];
|
|
455
523
|
}
|
|
456
524
|
const {
|
|
457
|
-
byteOffset, byteLength, encoded, index, maxByteLength
|
|
525
|
+
byteOffset, byteLength, encoded, index, maxByteLength,
|
|
526
|
+
resizable
|
|
458
527
|
} = b64Obj;
|
|
459
528
|
let buffer;
|
|
460
529
|
if ('index' in b64Obj) {
|
|
@@ -462,10 +531,9 @@ const dataview = {
|
|
|
462
531
|
} else {
|
|
463
532
|
buffer = decode(
|
|
464
533
|
encoded,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
: {maxByteLength}
|
|
534
|
+
resizable
|
|
535
|
+
? {maxByteLength}
|
|
536
|
+
: maxByteLength
|
|
469
537
|
);
|
|
470
538
|
stateObj.buffers.push(buffer);
|
|
471
539
|
}
|
|
@@ -489,7 +557,7 @@ const date = {
|
|
|
489
557
|
},
|
|
490
558
|
revive (time) {
|
|
491
559
|
if (time === 'NaN') {
|
|
492
|
-
return new Date(
|
|
560
|
+
return new Date(NaN);
|
|
493
561
|
}
|
|
494
562
|
return new Date(time);
|
|
495
563
|
}
|
|
@@ -679,6 +747,68 @@ function create$3 (Ctor) {
|
|
|
679
747
|
};
|
|
680
748
|
}
|
|
681
749
|
|
|
750
|
+
/* globals EncodedAudioChunk -- Polyfills */
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* @type {import('typeson').TypeSpecSet}
|
|
754
|
+
*/
|
|
755
|
+
const encodedaudiochunk = {
|
|
756
|
+
encodedaudiochunk: {
|
|
757
|
+
test (x) {
|
|
758
|
+
return toStringTag(x) === 'EncodedAudioChunk';
|
|
759
|
+
},
|
|
760
|
+
replace (chunk) {
|
|
761
|
+
const {type, timestamp, duration, byteLength} = chunk;
|
|
762
|
+
const data = new ArrayBuffer(byteLength);
|
|
763
|
+
chunk.copyTo(data);
|
|
764
|
+
return {type, timestamp, duration, data};
|
|
765
|
+
},
|
|
766
|
+
revive ({type, timestamp, duration, data}) {
|
|
767
|
+
// A browser's `EncodedAudioChunkInit` has no `duration`
|
|
768
|
+
// default and coerces an explicit `null`/`undefined` to `0`,
|
|
769
|
+
// so only pass it through when the source chunk actually
|
|
770
|
+
// had one (otherwise `duration` must round-trip as `null`).
|
|
771
|
+
/** @type {EncodedAudioChunkInit} */
|
|
772
|
+
const init = {type, timestamp, data: new Uint8Array(data)};
|
|
773
|
+
if (duration !== null && duration !== undefined) {
|
|
774
|
+
init.duration = duration;
|
|
775
|
+
}
|
|
776
|
+
return new EncodedAudioChunk(init);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
/* globals EncodedVideoChunk -- Polyfills */
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* @type {import('typeson').TypeSpecSet}
|
|
785
|
+
*/
|
|
786
|
+
const encodedvideochunk = {
|
|
787
|
+
encodedvideochunk: {
|
|
788
|
+
test (x) {
|
|
789
|
+
return toStringTag(x) === 'EncodedVideoChunk';
|
|
790
|
+
},
|
|
791
|
+
replace (chunk) {
|
|
792
|
+
const {type, timestamp, duration, byteLength} = chunk;
|
|
793
|
+
const data = new ArrayBuffer(byteLength);
|
|
794
|
+
chunk.copyTo(data);
|
|
795
|
+
return {type, timestamp, duration, data};
|
|
796
|
+
},
|
|
797
|
+
revive ({type, timestamp, duration, data}) {
|
|
798
|
+
// A browser's `EncodedVideoChunkInit` has no `duration`
|
|
799
|
+
// default and coerces an explicit `null`/`undefined` to `0`,
|
|
800
|
+
// so only pass it through when the source chunk actually
|
|
801
|
+
// had one (otherwise `duration` must round-trip as `null`).
|
|
802
|
+
/** @type {EncodedVideoChunkInit} */
|
|
803
|
+
const init = {type, timestamp, data: new Uint8Array(data)};
|
|
804
|
+
if (duration !== null && duration !== undefined) {
|
|
805
|
+
init.duration = duration;
|
|
806
|
+
}
|
|
807
|
+
return new EncodedVideoChunk(init);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
|
|
682
812
|
/**
|
|
683
813
|
* @type {import('typeson').TypeSpecSet}
|
|
684
814
|
*/
|
|
@@ -694,18 +824,20 @@ const error = {
|
|
|
694
824
|
},
|
|
695
825
|
revive (obj) {
|
|
696
826
|
const e = /**
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
827
|
+
* @type {{
|
|
828
|
+
* name: string,
|
|
829
|
+
* cause: Error,
|
|
830
|
+
* stack: string,
|
|
831
|
+
* fileName?: string,
|
|
832
|
+
* lineNumber?: import('typeson').Integer,
|
|
833
|
+
* columnNumber?: import('typeson').Integer
|
|
834
|
+
* }}
|
|
835
|
+
*/ (new Error(obj.message));
|
|
836
|
+
/* eslint-disable unicorn/no-error-property-assignment -- Ok */
|
|
706
837
|
e.name = obj.name;
|
|
707
838
|
e.cause = obj.cause;
|
|
708
839
|
e.stack = obj.stack;
|
|
840
|
+
/* eslint-enable unicorn/no-error-property-assignment -- Ok */
|
|
709
841
|
e.fileName = obj.fileName;
|
|
710
842
|
e.lineNumber = obj.lineNumber;
|
|
711
843
|
e.columnNumber = obj.columnNumber;
|
|
@@ -723,6 +855,7 @@ const error = {
|
|
|
723
855
|
const errors = {};
|
|
724
856
|
|
|
725
857
|
// JS standard
|
|
858
|
+
// eslint-disable-next-line unicorn/no-top-level-side-effects -- Too cumbersome
|
|
726
859
|
[
|
|
727
860
|
TypeError, RangeError, SyntaxError, ReferenceError,
|
|
728
861
|
EvalError, URIError
|
|
@@ -740,7 +873,6 @@ if (typeof InternalError === 'function') {
|
|
|
740
873
|
create$2(InternalError);
|
|
741
874
|
}
|
|
742
875
|
|
|
743
|
-
/* eslint-disable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/131 */
|
|
744
876
|
/**
|
|
745
877
|
* Non-standard.
|
|
746
878
|
* @typedef {{
|
|
@@ -748,14 +880,13 @@ if (typeof InternalError === 'function') {
|
|
|
748
880
|
* (message?: string, options?: ErrorOptions): EvalError;
|
|
749
881
|
* }} InternalErrorConstructor
|
|
750
882
|
*/
|
|
751
|
-
/* eslint-enable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/131 */
|
|
752
883
|
|
|
753
884
|
/**
|
|
754
885
|
* Comprises all built-in errors.
|
|
755
|
-
* @param {TypeErrorConstructor|RangeErrorConstructor
|
|
756
|
-
* SyntaxErrorConstructor|ReferenceErrorConstructor
|
|
757
|
-
* EvalErrorConstructor|URIErrorConstructor
|
|
758
|
-
* AggregateErrorConstructor|InternalErrorConstructor
|
|
886
|
+
* @param {TypeErrorConstructor|RangeErrorConstructor
|
|
887
|
+
* |SyntaxErrorConstructor|ReferenceErrorConstructor
|
|
888
|
+
* |EvalErrorConstructor|URIErrorConstructor
|
|
889
|
+
* |AggregateErrorConstructor|InternalErrorConstructor
|
|
759
890
|
* } Ctor
|
|
760
891
|
* @returns {void}
|
|
761
892
|
*/
|
|
@@ -775,24 +906,24 @@ function create$2 (Ctor) {
|
|
|
775
906
|
const isAggregateError = typeof AggregateError !== 'undefined' &&
|
|
776
907
|
Ctor === AggregateError;
|
|
777
908
|
const e = /**
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
909
|
+
* @type {{
|
|
910
|
+
* name: string,
|
|
911
|
+
* cause: Error,
|
|
912
|
+
* stack: string,
|
|
913
|
+
* fileName?: string,
|
|
914
|
+
* lineNumber?: import('typeson').Integer,
|
|
915
|
+
* columnNumber?: import('typeson').Integer
|
|
916
|
+
* }}
|
|
917
|
+
*/ (isAggregateError
|
|
787
918
|
? new /** @type {AggregateErrorConstructor} */ (
|
|
788
919
|
Ctor
|
|
789
920
|
)(obj.errors, obj.message)
|
|
790
921
|
: new /**
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
922
|
+
* @type {TypeErrorConstructor|RangeErrorConstructor|
|
|
923
|
+
* SyntaxErrorConstructor|ReferenceErrorConstructor|
|
|
924
|
+
* EvalErrorConstructor|URIErrorConstructor|
|
|
925
|
+
* InternalErrorConstructor}
|
|
926
|
+
*/ (Ctor)(obj.message));
|
|
796
927
|
|
|
797
928
|
e.name = obj.name;
|
|
798
929
|
e.cause = obj.cause;
|
|
@@ -839,7 +970,7 @@ const file = {
|
|
|
839
970
|
});
|
|
840
971
|
},
|
|
841
972
|
replaceAsync (f) {
|
|
842
|
-
return new
|
|
973
|
+
return new TypesonPromise(function (resolve, reject) {
|
|
843
974
|
/*
|
|
844
975
|
if (f.isClosed) { // On MDN, but not in https://w3c.github.io/FileAPI/#dfn-Blob
|
|
845
976
|
reject(new Error('The File is closed'));
|
|
@@ -913,6 +1044,8 @@ const filelist = {
|
|
|
913
1044
|
return 'FileList';
|
|
914
1045
|
}
|
|
915
1046
|
}
|
|
1047
|
+
|
|
1048
|
+
// @ts-ignore Override API
|
|
916
1049
|
return new FileList(o);
|
|
917
1050
|
}
|
|
918
1051
|
}
|
|
@@ -962,7 +1095,7 @@ const imagebitmap = {
|
|
|
962
1095
|
canvas.getContext('2d')
|
|
963
1096
|
);
|
|
964
1097
|
const img = document.createElement('img');
|
|
965
|
-
// The onload is needed by some browsers per
|
|
1098
|
+
// The onload is needed by some browsers per https://stackoverflow.com/a/4776378/271577
|
|
966
1099
|
img.addEventListener('load', function () {
|
|
967
1100
|
ctx.drawImage(img, 0, 0);
|
|
968
1101
|
});
|
|
@@ -982,13 +1115,13 @@ const imagebitmap = {
|
|
|
982
1115
|
canvas.getContext('2d')
|
|
983
1116
|
);
|
|
984
1117
|
const img = document.createElement('img');
|
|
985
|
-
// The onload is needed by some browsers per
|
|
1118
|
+
// The onload is needed by some browsers per https://stackoverflow.com/a/4776378/271577
|
|
986
1119
|
img.addEventListener('load', function () {
|
|
987
1120
|
ctx.drawImage(img, 0, 0);
|
|
988
1121
|
});
|
|
989
1122
|
img.src = o.dataURL;
|
|
990
1123
|
|
|
991
|
-
return new
|
|
1124
|
+
return new TypesonPromise(async (resolve, reject) => {
|
|
992
1125
|
try {
|
|
993
1126
|
const resp = await createImageBitmap(canvas);
|
|
994
1127
|
resolve(resp);
|
|
@@ -1013,16 +1146,39 @@ const imagedata = {
|
|
|
1013
1146
|
imagedata: {
|
|
1014
1147
|
test (x) { return toStringTag(x) === 'ImageData'; },
|
|
1015
1148
|
replace (d) {
|
|
1149
|
+
const pixelFormat = toStringTag(d.data) === 'Float16Array'
|
|
1150
|
+
/* c8 ignore next -- Not yet supported in `canvas` */
|
|
1151
|
+
? 'rgba-float16'
|
|
1152
|
+
: 'rgba-unorm8';
|
|
1016
1153
|
return {
|
|
1017
1154
|
// Ensure `length` gets preserved for revival
|
|
1018
1155
|
array: [...d.data],
|
|
1019
1156
|
width: d.width,
|
|
1020
|
-
height: d.height
|
|
1157
|
+
height: d.height,
|
|
1158
|
+
pixelFormat,
|
|
1159
|
+
colorSpace: d.colorSpace
|
|
1021
1160
|
};
|
|
1022
1161
|
},
|
|
1023
1162
|
revive (o) {
|
|
1163
|
+
const {array, width, height, colorSpace, pixelFormat} = o;
|
|
1164
|
+
/* c8 ignore next 12 -- Not yet supported in `canvas` */
|
|
1165
|
+
if (pixelFormat === 'rgba-float16') {
|
|
1166
|
+
return new ImageData(
|
|
1167
|
+
// @ts-expect-error -- Ok
|
|
1168
|
+
new Float16Array(array),
|
|
1169
|
+
width,
|
|
1170
|
+
height,
|
|
1171
|
+
{
|
|
1172
|
+
colorSpace,
|
|
1173
|
+
pixelFormat
|
|
1174
|
+
}
|
|
1175
|
+
);
|
|
1176
|
+
}
|
|
1024
1177
|
return new ImageData(
|
|
1025
|
-
new Uint8ClampedArray(
|
|
1178
|
+
new Uint8ClampedArray(array), width, height, {
|
|
1179
|
+
colorSpace,
|
|
1180
|
+
pixelFormat
|
|
1181
|
+
}
|
|
1026
1182
|
);
|
|
1027
1183
|
}
|
|
1028
1184
|
}
|
|
@@ -1033,9 +1189,9 @@ const imagedata = {
|
|
|
1033
1189
|
*/
|
|
1034
1190
|
const infinity = {
|
|
1035
1191
|
infinity: {
|
|
1036
|
-
test (x) { return x ===
|
|
1192
|
+
test (x) { return x === Infinity; },
|
|
1037
1193
|
replace (/* n */) { return 'Infinity'; },
|
|
1038
|
-
revive (/* s */) { return
|
|
1194
|
+
revive (/* s */) { return Infinity; }
|
|
1039
1195
|
}
|
|
1040
1196
|
};
|
|
1041
1197
|
|
|
@@ -1080,7 +1236,7 @@ const intlTypes = {
|
|
|
1080
1236
|
const map = {
|
|
1081
1237
|
map: {
|
|
1082
1238
|
test (x) { return toStringTag(x) === 'Map'; },
|
|
1083
|
-
replace (mp) { return
|
|
1239
|
+
replace (mp) { return mp.entries().toArray(); },
|
|
1084
1240
|
revive (entries) { return new Map(entries); }
|
|
1085
1241
|
}
|
|
1086
1242
|
};
|
|
@@ -1092,7 +1248,7 @@ const nan = {
|
|
|
1092
1248
|
nan: {
|
|
1093
1249
|
test (x) { return Number.isNaN(x); },
|
|
1094
1250
|
replace (/* n */) { return 'NaN'; },
|
|
1095
|
-
revive (/* s */) { return
|
|
1251
|
+
revive (/* s */) { return NaN; }
|
|
1096
1252
|
}
|
|
1097
1253
|
};
|
|
1098
1254
|
|
|
@@ -1101,9 +1257,9 @@ const nan = {
|
|
|
1101
1257
|
*/
|
|
1102
1258
|
const negativeInfinity = {
|
|
1103
1259
|
negativeInfinity: {
|
|
1104
|
-
test (x) { return x ===
|
|
1260
|
+
test (x) { return x === -Infinity; },
|
|
1105
1261
|
replace (/* n */) { return '-Infinity'; },
|
|
1106
|
-
revive (/* s */) { return
|
|
1262
|
+
revive (/* s */) { return -Infinity; }
|
|
1107
1263
|
}
|
|
1108
1264
|
};
|
|
1109
1265
|
|
|
@@ -1193,8 +1349,51 @@ const primitiveObjects = {
|
|
|
1193
1349
|
test (x) {
|
|
1194
1350
|
return toStringTag(x) === 'Number' && typeof x === 'object';
|
|
1195
1351
|
},
|
|
1196
|
-
|
|
1197
|
-
|
|
1352
|
+
// `_encapsulate`'s nested-replace guard (`_stateObj.replaced`)
|
|
1353
|
+
// means a bare `NaN`/`Infinity`/`-Infinity`/`-0` returned here
|
|
1354
|
+
// would skip the sentinel treatment the bare `nan`/`infinity`/
|
|
1355
|
+
// `negativeZero` type specs normally give those values (since
|
|
1356
|
+
// we're already inside this spec's own `replace()`) -- JSON
|
|
1357
|
+
// can't represent them, so they'd otherwise silently become
|
|
1358
|
+
// `null` (or lose their sign, for `-0`). Encode them the same
|
|
1359
|
+
// way those specs do, directly, rather than relying on that
|
|
1360
|
+
// nested pass.
|
|
1361
|
+
replace (o) {
|
|
1362
|
+
const n = o.valueOf();
|
|
1363
|
+
if (Number.isNaN(n)) {
|
|
1364
|
+
return 'NaN';
|
|
1365
|
+
}
|
|
1366
|
+
if (n === Infinity) {
|
|
1367
|
+
return 'Infinity';
|
|
1368
|
+
}
|
|
1369
|
+
if (n === -Infinity) {
|
|
1370
|
+
return '-Infinity';
|
|
1371
|
+
}
|
|
1372
|
+
if (Object.is(n, -0)) {
|
|
1373
|
+
// A plain `0` here would be indistinguishable from a
|
|
1374
|
+
// genuine positive `0` once round-tripped through JSON
|
|
1375
|
+
// (which can't represent the sign), so this needs its
|
|
1376
|
+
// own sentinel too, same as the others above.
|
|
1377
|
+
return '-0';
|
|
1378
|
+
}
|
|
1379
|
+
return n;
|
|
1380
|
+
},
|
|
1381
|
+
// Revive to an objectified number
|
|
1382
|
+
revive (n) {
|
|
1383
|
+
if (n === 'NaN') {
|
|
1384
|
+
return new Number(NaN);
|
|
1385
|
+
}
|
|
1386
|
+
if (n === 'Infinity') {
|
|
1387
|
+
return new Number(Infinity);
|
|
1388
|
+
}
|
|
1389
|
+
if (n === '-Infinity') {
|
|
1390
|
+
return new Number(-Infinity);
|
|
1391
|
+
}
|
|
1392
|
+
if (n === '-0') {
|
|
1393
|
+
return new Number(-0);
|
|
1394
|
+
}
|
|
1395
|
+
return new Number(n);
|
|
1396
|
+
}
|
|
1198
1397
|
}
|
|
1199
1398
|
};
|
|
1200
1399
|
|
|
@@ -1207,7 +1406,7 @@ const promise = {
|
|
|
1207
1406
|
return toStringTag(x) === 'Promise';
|
|
1208
1407
|
},
|
|
1209
1408
|
replaceAsync (prom) {
|
|
1210
|
-
return new
|
|
1409
|
+
return new TypesonPromise(async (resolve) => {
|
|
1211
1410
|
try {
|
|
1212
1411
|
resolve({
|
|
1213
1412
|
value: await prom
|
|
@@ -1227,6 +1426,29 @@ const promise = {
|
|
|
1227
1426
|
}
|
|
1228
1427
|
};
|
|
1229
1428
|
|
|
1429
|
+
/**
|
|
1430
|
+
* @type {import('typeson').TypeSpecSet}
|
|
1431
|
+
*/
|
|
1432
|
+
const quotaexceedederror = {
|
|
1433
|
+
quotaexceedederror: {
|
|
1434
|
+
test (x) { return toStringTag(x) === 'QuotaExceededError'; },
|
|
1435
|
+
replace ({message, quota, requested}) {
|
|
1436
|
+
return {message, quota, requested};
|
|
1437
|
+
},
|
|
1438
|
+
revive ({message, quota, requested}) {
|
|
1439
|
+
/** @type {{quota?: number, requested?: number}} */
|
|
1440
|
+
const options = {};
|
|
1441
|
+
if (quota !== null && quota !== undefined) {
|
|
1442
|
+
options.quota = quota;
|
|
1443
|
+
}
|
|
1444
|
+
if (requested !== null && requested !== undefined) {
|
|
1445
|
+
options.requested = requested;
|
|
1446
|
+
}
|
|
1447
|
+
return new QuotaExceededError(message, options);
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
|
|
1230
1452
|
/**
|
|
1231
1453
|
* @type {import('typeson').TypeSpecSet}
|
|
1232
1454
|
*/
|
|
@@ -1240,7 +1462,10 @@ const regexp = {
|
|
|
1240
1462
|
(rexp.ignoreCase ? 'i' : '') +
|
|
1241
1463
|
(rexp.multiline ? 'm' : '') +
|
|
1242
1464
|
(rexp.sticky ? 'y' : '') +
|
|
1243
|
-
(rexp.unicode ? 'u' : '')
|
|
1465
|
+
(rexp.unicode ? 'u' : '') +
|
|
1466
|
+
(rexp.unicodeSets ? 'v' : '') +
|
|
1467
|
+
(rexp.hasIndices ? 'd' : '') +
|
|
1468
|
+
(rexp.dotAll ? 's' : '')
|
|
1244
1469
|
};
|
|
1245
1470
|
},
|
|
1246
1471
|
revive ({source, flags}) { return new RegExp(source, flags); }
|
|
@@ -1286,7 +1511,7 @@ const set = {
|
|
|
1286
1511
|
set: {
|
|
1287
1512
|
test (x) { return toStringTag(x) === 'Set'; },
|
|
1288
1513
|
replace (st) {
|
|
1289
|
-
return
|
|
1514
|
+
return st.values().toArray();
|
|
1290
1515
|
},
|
|
1291
1516
|
revive (values) {
|
|
1292
1517
|
return new Set(values);
|
|
@@ -1322,12 +1547,12 @@ const symbol = {
|
|
|
1322
1547
|
const typedArraysSocketIO = {};
|
|
1323
1548
|
|
|
1324
1549
|
/**
|
|
1325
|
-
* @param {Int8ArrayConstructor|Uint8ArrayConstructor
|
|
1326
|
-
* Uint8ClampedArrayConstructor|Int16ArrayConstructor
|
|
1327
|
-
* Uint16ArrayConstructor|Int32ArrayConstructor
|
|
1328
|
-
* Uint32ArrayConstructor|Float32ArrayConstructor
|
|
1329
|
-
* Float64ArrayConstructor|
|
|
1330
|
-
* BigInt64ArrayConstructor|BigUint64ArrayConstructor
|
|
1550
|
+
* @param {Int8ArrayConstructor|Uint8ArrayConstructor
|
|
1551
|
+
* |Uint8ClampedArrayConstructor|Int16ArrayConstructor
|
|
1552
|
+
* |Uint16ArrayConstructor|Int32ArrayConstructor
|
|
1553
|
+
* |Uint32ArrayConstructor|Float32ArrayConstructor
|
|
1554
|
+
* |Float64ArrayConstructor|Float16ArrayConstructor
|
|
1555
|
+
* |BigInt64ArrayConstructor|BigUint64ArrayConstructor
|
|
1331
1556
|
* } TypedArray
|
|
1332
1557
|
* @returns {void}
|
|
1333
1558
|
*/
|
|
@@ -1376,6 +1601,10 @@ if (typeof Int8Array === 'function') {
|
|
|
1376
1601
|
...(typeof BigInt64Array === 'function'
|
|
1377
1602
|
? [BigInt64Array, BigUint64Array]
|
|
1378
1603
|
/* c8 ignore next */
|
|
1604
|
+
: []),
|
|
1605
|
+
...(typeof Float16Array === 'function'
|
|
1606
|
+
? [Float16Array]
|
|
1607
|
+
/* c8 ignore next */
|
|
1379
1608
|
: [])
|
|
1380
1609
|
].forEach((TypedArray) => create$1(TypedArray));
|
|
1381
1610
|
}
|
|
@@ -1386,13 +1615,14 @@ if (typeof Int8Array === 'function') {
|
|
|
1386
1615
|
const typedArrays = {};
|
|
1387
1616
|
|
|
1388
1617
|
/**
|
|
1389
|
-
* @typedef {Int8ArrayConstructor|Uint8ArrayConstructor
|
|
1390
|
-
* Uint8ClampedArrayConstructor
|
|
1391
|
-
* Int16ArrayConstructor|Uint16ArrayConstructor
|
|
1392
|
-
* Int32ArrayConstructor|Uint32ArrayConstructor
|
|
1393
|
-
* Float32ArrayConstructor
|
|
1394
|
-
* Float64ArrayConstructor
|
|
1395
|
-
* BigInt64ArrayConstructor|BigUint64ArrayConstructor
|
|
1618
|
+
* @typedef {Int8ArrayConstructor|Uint8ArrayConstructor
|
|
1619
|
+
* |Uint8ClampedArrayConstructor
|
|
1620
|
+
* |Int16ArrayConstructor|Uint16ArrayConstructor
|
|
1621
|
+
* |Int32ArrayConstructor|Uint32ArrayConstructor
|
|
1622
|
+
* |Float32ArrayConstructor
|
|
1623
|
+
* |Float64ArrayConstructor
|
|
1624
|
+
* |BigInt64ArrayConstructor|BigUint64ArrayConstructor
|
|
1625
|
+
* |Float16ArrayConstructor} TypedArrayConstructor
|
|
1396
1626
|
*/
|
|
1397
1627
|
|
|
1398
1628
|
/**
|
|
@@ -1417,12 +1647,13 @@ function create (TypedArray) {
|
|
|
1417
1647
|
stateObj.buffers = [];
|
|
1418
1648
|
}
|
|
1419
1649
|
const index = stateObj.buffers.indexOf(buffer);
|
|
1420
|
-
if (index
|
|
1650
|
+
if (index !== -1) {
|
|
1421
1651
|
return {index, byteOffset, length: l};
|
|
1422
1652
|
}
|
|
1423
1653
|
stateObj.buffers.push(buffer);
|
|
1424
1654
|
return {
|
|
1425
1655
|
maxByteLength: buffer.maxByteLength,
|
|
1656
|
+
resizable: buffer.resizable,
|
|
1426
1657
|
encoded: encode(buffer),
|
|
1427
1658
|
byteOffset,
|
|
1428
1659
|
length: l
|
|
@@ -1441,7 +1672,8 @@ function create (TypedArray) {
|
|
|
1441
1672
|
stateObj.buffers = [];
|
|
1442
1673
|
}
|
|
1443
1674
|
const {
|
|
1444
|
-
byteOffset, length: len, encoded, index, maxByteLength
|
|
1675
|
+
byteOffset, length: len, encoded, index, maxByteLength,
|
|
1676
|
+
resizable
|
|
1445
1677
|
} = b64Obj;
|
|
1446
1678
|
let buffer;
|
|
1447
1679
|
if ('index' in b64Obj) {
|
|
@@ -1449,13 +1681,13 @@ function create (TypedArray) {
|
|
|
1449
1681
|
} else {
|
|
1450
1682
|
buffer = decode(
|
|
1451
1683
|
encoded,
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
: {maxByteLength}
|
|
1684
|
+
resizable
|
|
1685
|
+
? {maxByteLength}
|
|
1686
|
+
: undefined
|
|
1456
1687
|
);
|
|
1457
1688
|
stateObj.buffers.push(buffer);
|
|
1458
1689
|
}
|
|
1690
|
+
|
|
1459
1691
|
return new TypedArray(buffer, byteOffset, len);
|
|
1460
1692
|
}
|
|
1461
1693
|
};
|
|
@@ -1477,6 +1709,10 @@ if (typeof Int8Array === 'function') {
|
|
|
1477
1709
|
...(typeof BigInt64Array === 'function'
|
|
1478
1710
|
? [BigInt64Array, BigUint64Array]
|
|
1479
1711
|
/* c8 ignore next */
|
|
1712
|
+
: []),
|
|
1713
|
+
...(typeof Float16Array === 'function'
|
|
1714
|
+
? [Float16Array]
|
|
1715
|
+
/* c8 ignore next */
|
|
1480
1716
|
: [])
|
|
1481
1717
|
].forEach((TypedArray) => create(TypedArray));
|
|
1482
1718
|
}
|
|
@@ -1497,7 +1733,7 @@ const undef$1 = {
|
|
|
1497
1733
|
revive (/* s */) {
|
|
1498
1734
|
// Will add `undefined` (returning `undefined` would instead
|
|
1499
1735
|
// avoid explicitly setting)
|
|
1500
|
-
return new
|
|
1736
|
+
return new Undefined();
|
|
1501
1737
|
}
|
|
1502
1738
|
}
|
|
1503
1739
|
};
|
|
@@ -1513,6 +1749,94 @@ const userObject = {
|
|
|
1513
1749
|
}
|
|
1514
1750
|
};
|
|
1515
1751
|
|
|
1752
|
+
/* globals VideoFrame -- Polyfills */
|
|
1753
|
+
|
|
1754
|
+
/**
|
|
1755
|
+
* @type {import('typeson').TypeSpecSet}
|
|
1756
|
+
*/
|
|
1757
|
+
const videoframe = {
|
|
1758
|
+
videoframe: {
|
|
1759
|
+
test (x) {
|
|
1760
|
+
return toStringTag(x) === 'VideoFrame';
|
|
1761
|
+
},
|
|
1762
|
+
replaceAsync (frame) {
|
|
1763
|
+
return new TypesonPromise(async (resolve, reject) => {
|
|
1764
|
+
try {
|
|
1765
|
+
const {
|
|
1766
|
+
format, codedWidth, codedHeight, timestamp, duration,
|
|
1767
|
+
visibleRect, displayWidth, displayHeight, colorSpace
|
|
1768
|
+
} = frame;
|
|
1769
|
+
|
|
1770
|
+
const data = new ArrayBuffer(frame.allocationSize());
|
|
1771
|
+
await frame.copyTo(data);
|
|
1772
|
+
|
|
1773
|
+
resolve({
|
|
1774
|
+
format, codedWidth, codedHeight, timestamp, duration,
|
|
1775
|
+
visibleRect: {
|
|
1776
|
+
x: visibleRect.x,
|
|
1777
|
+
y: visibleRect.y,
|
|
1778
|
+
width: visibleRect.width,
|
|
1779
|
+
height: visibleRect.height
|
|
1780
|
+
},
|
|
1781
|
+
displayWidth, displayHeight,
|
|
1782
|
+
colorSpace: {
|
|
1783
|
+
primaries: colorSpace.primaries,
|
|
1784
|
+
transfer: colorSpace.transfer,
|
|
1785
|
+
matrix: colorSpace.matrix,
|
|
1786
|
+
fullRange: colorSpace.fullRange
|
|
1787
|
+
},
|
|
1788
|
+
data
|
|
1789
|
+
});
|
|
1790
|
+
/* c8 ignore next 3 -- How to simulate? */
|
|
1791
|
+
} catch (err) {
|
|
1792
|
+
reject(err);
|
|
1793
|
+
}
|
|
1794
|
+
});
|
|
1795
|
+
},
|
|
1796
|
+
revive ({
|
|
1797
|
+
format, codedWidth, codedHeight, timestamp, duration,
|
|
1798
|
+
visibleRect, displayWidth, displayHeight, colorSpace, data
|
|
1799
|
+
}) {
|
|
1800
|
+
// A browser's `VideoFrameBufferInit` has no `duration` default
|
|
1801
|
+
// and coerces an explicit `null`/`undefined` to `0`, so only
|
|
1802
|
+
// pass it through when the source frame actually had one
|
|
1803
|
+
// (otherwise `duration` must round-trip as `null`).
|
|
1804
|
+
/** @type {VideoFrameBufferInit} */
|
|
1805
|
+
const init = {
|
|
1806
|
+
format, codedWidth, codedHeight, timestamp,
|
|
1807
|
+
visibleRect, displayWidth, displayHeight, colorSpace
|
|
1808
|
+
};
|
|
1809
|
+
if (duration !== null && duration !== undefined) {
|
|
1810
|
+
init.duration = duration;
|
|
1811
|
+
}
|
|
1812
|
+
return new VideoFrame(new Uint8Array(data), init);
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
};
|
|
1816
|
+
|
|
1817
|
+
/* globals WebTransportError -- Newer API */
|
|
1818
|
+
|
|
1819
|
+
/**
|
|
1820
|
+
* @type {import('typeson').TypeSpecSet}
|
|
1821
|
+
*/
|
|
1822
|
+
const webtransporterror = {
|
|
1823
|
+
webtransporterror: {
|
|
1824
|
+
test (x) { return toStringTag(x) === 'WebTransportError'; },
|
|
1825
|
+
// Note that we can't support the `source` property (defaults
|
|
1826
|
+
// to `stream` instead of `session`)
|
|
1827
|
+
replace ({message, streamErrorCode}) {
|
|
1828
|
+
return {message, streamErrorCode};
|
|
1829
|
+
},
|
|
1830
|
+
revive ({message, streamErrorCode}) {
|
|
1831
|
+
// TS lib still models the older two-argument
|
|
1832
|
+
// `(message, options)` form; browsers implement a single
|
|
1833
|
+
// `init` object (which also carries `message`).
|
|
1834
|
+
// @ts-expect-error - More recent API
|
|
1835
|
+
return new WebTransportError({message, streamErrorCode});
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
};
|
|
1839
|
+
|
|
1516
1840
|
/**
|
|
1517
1841
|
* @type {import('typeson').Preset}
|
|
1518
1842
|
*/
|
|
@@ -1535,7 +1859,7 @@ const arrayNonindexKeys = [
|
|
|
1535
1859
|
// `Number.parseInt(Number())` since scientific
|
|
1536
1860
|
// notation will be pre-resolved if a number
|
|
1537
1861
|
// was given, and it will otherwise be a string
|
|
1538
|
-
return String(Number
|
|
1862
|
+
return String(Number(k)) !== k;
|
|
1539
1863
|
})
|
|
1540
1864
|
) {
|
|
1541
1865
|
stateObj.iterateIn = 'object';
|
|
@@ -1641,8 +1965,9 @@ clone algorithm). This algorithm supports all built-in types as well as many
|
|
|
1641
1965
|
DOM types. Therefore, only types that are not included in the structured clone
|
|
1642
1966
|
algorithm need to be registered, which is:
|
|
1643
1967
|
|
|
1644
|
-
* Error
|
|
1645
|
-
* Specific Errors like SyntaxError, TypeError, etc.
|
|
1968
|
+
* Error (now included in structured cloning)
|
|
1969
|
+
* Specific Errors like SyntaxError, TypeError, etc. (now included in structured
|
|
1970
|
+
* cloning)
|
|
1646
1971
|
* Any custom type you want to send across window- or worker boundraries
|
|
1647
1972
|
|
|
1648
1973
|
This preset will only include the Error types and you can register your
|
|
@@ -1735,15 +2060,55 @@ const expObj = [
|
|
|
1735
2060
|
/* c8 ignore next */
|
|
1736
2061
|
typeof DOMException !== 'undefined' ? domexception : [],
|
|
1737
2062
|
/* c8 ignore next */
|
|
2063
|
+
typeof QuotaExceededError !== 'undefined' ? quotaexceedederror : [],
|
|
2064
|
+
/* c8 ignore next */
|
|
2065
|
+
typeof WebTransportError !== 'undefined' ? webtransporterror : [],
|
|
2066
|
+
/* c8 ignore next */
|
|
1738
2067
|
typeof DOMRect !== 'undefined' ? domrect : [],
|
|
1739
2068
|
/* c8 ignore next */
|
|
1740
2069
|
typeof DOMPoint !== 'undefined' ? dompoint : [],
|
|
1741
2070
|
/* c8 ignore next */
|
|
1742
2071
|
typeof DOMQuad !== 'undefined' ? domquad : [],
|
|
1743
2072
|
/* c8 ignore next */
|
|
1744
|
-
typeof DOMMatrix !== 'undefined' ? dommatrix : []
|
|
2073
|
+
typeof DOMMatrix !== 'undefined' ? dommatrix : [],
|
|
2074
|
+
/* c8 ignore next */
|
|
2075
|
+
typeof AudioData !== 'undefined' ? audiodata : [],
|
|
2076
|
+
/* c8 ignore next */
|
|
2077
|
+
typeof EncodedAudioChunk !== 'undefined' ? encodedaudiochunk : [],
|
|
2078
|
+
/* c8 ignore next */
|
|
2079
|
+
typeof EncodedVideoChunk !== 'undefined' ? encodedvideochunk : [],
|
|
2080
|
+
/* c8 ignore next */
|
|
2081
|
+
typeof VideoFrame !== 'undefined' ? videoframe : []
|
|
1745
2082
|
);
|
|
1746
2083
|
|
|
2084
|
+
/**
|
|
2085
|
+
* @param {BufferSource} buffer
|
|
2086
|
+
* @returns {boolean}
|
|
2087
|
+
*/
|
|
2088
|
+
function isBufferDetached (buffer) {
|
|
2089
|
+
// Use the standard property if available
|
|
2090
|
+
// @ts-expect-error - More recent API
|
|
2091
|
+
if (typeof buffer.detached === 'boolean') {
|
|
2092
|
+
// @ts-expect-error - More recent API
|
|
2093
|
+
return buffer.detached;
|
|
2094
|
+
}
|
|
2095
|
+
/* c8 ignore next 14 -- Older browsers */
|
|
2096
|
+
|
|
2097
|
+
// Fallback check via byteLength and constructor test
|
|
2098
|
+
if (buffer.byteLength !== 0) {
|
|
2099
|
+
return false;
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
try {
|
|
2103
|
+
// @ts-expect-error Ok
|
|
2104
|
+
// eslint-disable-next-line no-new -- Throwaway
|
|
2105
|
+
new Uint8Array(buffer);
|
|
2106
|
+
return false;
|
|
2107
|
+
} catch {
|
|
2108
|
+
return true;
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
|
|
1747
2112
|
/**
|
|
1748
2113
|
* @type {import('typeson').Preset}
|
|
1749
2114
|
*/
|
|
@@ -1751,13 +2116,11 @@ const structuredCloningThrowing = expObj.concat({
|
|
|
1751
2116
|
checkDataCloneException: {
|
|
1752
2117
|
test (val) {
|
|
1753
2118
|
// Should also throw with:
|
|
1754
|
-
// 1. `
|
|
1755
|
-
// ECMAScript spec)
|
|
1756
|
-
// 2. `IsCallable` (covered by `typeof === 'function'` or a
|
|
2119
|
+
// 1. `IsCallable` (covered by `typeof === 'function'` or a
|
|
1757
2120
|
// function's `toStringTag`)
|
|
1758
|
-
//
|
|
2121
|
+
// 2. internal slots besides [[Prototype]] or [[Extensible]] (e.g.,
|
|
1759
2122
|
// [[PromiseState]] or [[WeakMapData]])
|
|
1760
|
-
//
|
|
2123
|
+
// 3. exotic object (e.g., `Proxy`) (unless an `%ObjectPrototype%`
|
|
1761
2124
|
// intrinsic object) (which does not have default
|
|
1762
2125
|
// behavior for one or more of the essential internal methods
|
|
1763
2126
|
// that are limited to the following for non-function objects
|
|
@@ -1797,8 +2160,42 @@ const structuredCloningThrowing = expObj.concat({
|
|
|
1797
2160
|
// HTML-SPECIFIC
|
|
1798
2161
|
'Event',
|
|
1799
2162
|
// Also in Node `worker_threads` (currently experimental)
|
|
1800
|
-
'MessageChannel'
|
|
2163
|
+
'MessageChannel',
|
|
2164
|
+
'MessagePort'
|
|
1801
2165
|
].includes(stringTag) ||
|
|
2166
|
+
// Node's native `worker_threads` `MessageChannel`/
|
|
2167
|
+
// `MessagePort` don't set `Symbol.toStringTag` per
|
|
2168
|
+
// https://github.com/nodejs/node/issues/65527
|
|
2169
|
+
// (verified directly:
|
|
2170
|
+
// `{}.toString.call(new MessageChannel())` is
|
|
2171
|
+
// `"[object Object]"`, and `.port1`'s is
|
|
2172
|
+
// `"[object EventTarget]"`, its own base class), so the
|
|
2173
|
+
// `stringTag` check above can't catch them there; a real
|
|
2174
|
+
// browser's `MessagePort`/`MessageChannel` already match
|
|
2175
|
+
// via `stringTag` (or, for `MessagePort`, would need its
|
|
2176
|
+
// own `stringTag` entry if ever seen failing to match) --
|
|
2177
|
+
// this is purely a fallback for environments (like Node)
|
|
2178
|
+
// that don't set the tag.
|
|
2179
|
+
(val && val.constructor && [
|
|
2180
|
+
'MessageChannel', 'MessagePort'
|
|
2181
|
+
].includes(val.constructor.name)) ||
|
|
2182
|
+
// 1. `IsDetachedBuffer` (a process not called within the
|
|
2183
|
+
// ECMAScript spec)
|
|
2184
|
+
([
|
|
2185
|
+
'ArrayBuffer',
|
|
2186
|
+
'DataView',
|
|
2187
|
+
'Int8Array',
|
|
2188
|
+
'Uint8Array',
|
|
2189
|
+
'Uint8ClampedArray',
|
|
2190
|
+
'Int16Array',
|
|
2191
|
+
'Uint16Array',
|
|
2192
|
+
'Int32Array',
|
|
2193
|
+
'Uint32Array',
|
|
2194
|
+
'Float32Array',
|
|
2195
|
+
'Float64Array',
|
|
2196
|
+
'BigInt64Array',
|
|
2197
|
+
'BigUint64Array'
|
|
2198
|
+
].includes(stringTag) && isBufferDetached(val)) ||
|
|
1802
2199
|
/*
|
|
1803
2200
|
// isClosed is no longer documented
|
|
1804
2201
|
((stringTag === 'Blob' || stringTag === 'File') &&
|
|
@@ -1819,6 +2216,29 @@ const structuredCloningThrowing = expObj.concat({
|
|
|
1819
2216
|
}
|
|
1820
2217
|
});
|
|
1821
2218
|
|
|
2219
|
+
/**
|
|
2220
|
+
* @type {import('typeson').Preset}
|
|
2221
|
+
*/
|
|
2222
|
+
const structuredCloningForStorage = structuredCloningThrowing.concat({
|
|
2223
|
+
checkSharedArrayBufferException: {
|
|
2224
|
+
test (val) {
|
|
2225
|
+
// Per https://webidl.spec.whatwg.org/#idl-SharedArrayBuffer ,
|
|
2226
|
+
// `SharedArrayBuffer` is a structured-cloneable *transferable*
|
|
2227
|
+
// type only for `postMessage`-style contexts (with
|
|
2228
|
+
// `crossOriginIsolated`); storage-oriented consumers of the
|
|
2229
|
+
// structured clone algorithm (e.g. IndexedDB) reject it
|
|
2230
|
+
// outright instead, so this isn't part of the more general
|
|
2231
|
+
// `structuredCloningThrowing` preset this one builds on.
|
|
2232
|
+
if (({}.toString.call(val).slice(8, -1)) === 'SharedArrayBuffer') {
|
|
2233
|
+
throw new DOMException(
|
|
2234
|
+
'The object cannot be cloned.', 'DataCloneError'
|
|
2235
|
+
);
|
|
2236
|
+
}
|
|
2237
|
+
return false;
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
});
|
|
2241
|
+
|
|
1822
2242
|
/**
|
|
1823
2243
|
* @type {import('typeson').Preset}
|
|
1824
2244
|
*/
|
|
@@ -1836,5 +2256,5 @@ const universal = [
|
|
|
1836
2256
|
// built-in into ecmasript standard.
|
|
1837
2257
|
];
|
|
1838
2258
|
|
|
1839
|
-
export {
|
|
2259
|
+
export { c as JSON_TYPES, Typeson, TypesonPromise, Undefined, arrayNonindexKeys, arraybuffer, audiodata, bigint, bigintObject, blob, expObj$1 as builtin, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domquad, domrect, encodedaudiochunk, encodedvideochunk, error, errors, escapeKeyPathComponent, file, filelist, getByKeyPath, getJSONType, hasConstructorOf, imagebitmap, imagedata, infinity, intlTypes, isObject, isPlainObject, isThenable, isUserObject, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, postmessage, primitiveObjects, promise, quotaexceedederror, regexp, resurrectable, set, setAtKeyPath, socketio, sparseUndefined, specialNumbers, expObj as structuredCloning, structuredCloningForStorage, structuredCloningThrowing, symbol, toStringTag, typedArrays, typedArraysSocketIO as typedArraysSocketio, undef$1 as undef, undef as undefPreset, unescapeKeyPathComponent, universal, userObject, videoframe, webtransporterror };
|
|
1840
2260
|
//# sourceMappingURL=index.js.map
|