@futpib/parser 1.0.1 → 1.0.3
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/.github/copilot-instructions.md +149 -0
- package/.github/workflows/copilot-setup-steps.yml +18 -0
- package/.github/workflows/main.yml +29 -8
- package/.yarn/releases/yarn-4.9.4.cjs +942 -0
- package/.yarnrc.yml +1 -1
- package/build/allSettledStream.js +32 -14
- package/build/allSettledStream.test.js +32 -0
- package/build/androidPackage.d.ts +39 -0
- package/build/androidPackageParser.d.ts +17 -0
- package/build/androidPackageParser.js +185 -0
- package/build/androidPackageParser.test.js +22 -0
- package/build/androidPackageUnparser.d.ts +4 -0
- package/build/androidPackageUnparser.js +94 -0
- package/build/androidPackageUnparser.test.js +26 -0
- package/build/arbitrarilySlicedAsyncInterable.d.ts +3 -1
- package/build/arbitrarilySlicedAsyncInterable.js +3 -3
- package/build/arbitrarilySlicedAsyncInterator.js +2 -1
- package/build/arbitraryDalvikBytecode.d.ts +4 -0
- package/build/arbitraryDalvikBytecode.js +640 -0
- package/build/arbitraryDalvikExecutable.d.ts +3 -0
- package/build/arbitraryDalvikExecutable.js +282 -0
- package/build/arbitraryDosDateTime.js +1 -0
- package/build/arbitraryZipStream.js +1 -1
- package/build/arrayParser.js +2 -2
- package/build/arrayParser.test.js +3 -3
- package/build/arrayUnparser.d.ts +1 -1
- package/build/backsmali.d.ts +3 -0
- package/build/backsmali.js +50 -0
- package/build/bsonParser.js +6 -2
- package/build/customInvariant.d.ts +2 -1
- package/build/customInvariant.js +4 -6
- package/build/dalvikBytecodeParser/formatParsers.d.ts +171 -0
- package/build/dalvikBytecodeParser/formatParsers.js +304 -0
- package/build/dalvikBytecodeParser/formatSizes.d.ts +34 -0
- package/build/dalvikBytecodeParser/formatSizes.js +34 -0
- package/build/dalvikBytecodeParser/operationFormats.d.ts +225 -0
- package/build/dalvikBytecodeParser/operationFormats.js +225 -0
- package/build/dalvikBytecodeParser.d.ts +1207 -0
- package/build/dalvikBytecodeParser.js +1289 -0
- package/build/dalvikBytecodeUnparser/formatUnparsers.d.ts +152 -0
- package/build/dalvikBytecodeUnparser/formatUnparsers.js +225 -0
- package/build/dalvikBytecodeUnparser.d.ts +3 -0
- package/build/dalvikBytecodeUnparser.js +642 -0
- package/build/dalvikBytecodeUnparser.test.js +25 -0
- package/build/dalvikExecutable.d.ts +215 -0
- package/build/dalvikExecutable.js +56 -0
- package/build/dalvikExecutableParser/stringSyntaxParser.d.ts +4 -0
- package/build/dalvikExecutableParser/stringSyntaxParser.js +76 -0
- package/build/dalvikExecutableParser/typeParsers.d.ts +11 -0
- package/build/dalvikExecutableParser/typeParsers.js +39 -0
- package/build/dalvikExecutableParser/typedNumbers.d.ts +106 -0
- package/build/dalvikExecutableParser/typedNumbers.js +18 -0
- package/build/dalvikExecutableParser.d.ts +5 -0
- package/build/dalvikExecutableParser.js +1757 -0
- package/build/dalvikExecutableParser.test.js +72 -0
- package/build/dalvikExecutableParserAgainstSmaliParser.test.js +275 -0
- package/build/dalvikExecutableUnparser/annotationUnparsers.d.ts +14 -0
- package/build/dalvikExecutableUnparser/annotationUnparsers.js +97 -0
- package/build/dalvikExecutableUnparser/poolBuilders.d.ts +49 -0
- package/build/dalvikExecutableUnparser/poolBuilders.js +140 -0
- package/build/dalvikExecutableUnparser/poolScanners.d.ts +4 -0
- package/build/dalvikExecutableUnparser/poolScanners.js +220 -0
- package/build/dalvikExecutableUnparser/sectionUnparsers.d.ts +25 -0
- package/build/dalvikExecutableUnparser/sectionUnparsers.js +581 -0
- package/build/dalvikExecutableUnparser/utils.d.ts +10 -0
- package/build/dalvikExecutableUnparser/utils.js +108 -0
- package/build/dalvikExecutableUnparser.d.ts +4 -0
- package/build/dalvikExecutableUnparser.js +406 -0
- package/build/dalvikExecutableUnparser.test.js +31 -0
- package/build/debugLogInputParser.d.ts +4 -0
- package/build/debugLogInputParser.js +16 -0
- package/build/debugLogParser.js +14 -3
- package/build/disjunctionParser.d.ts +2 -1
- package/build/disjunctionParser.js +6 -4
- package/build/elementTerminatedArrayParser.d.ts +3 -0
- package/build/elementTerminatedArrayParser.js +18 -0
- package/build/elementTerminatedArrayParser.test.js +52 -0
- package/build/elementTerminatedSequenceArrayParser.d.ts +3 -0
- package/build/elementTerminatedSequenceArrayParser.js +32 -0
- package/build/elementTerminatedSequenceArrayParser.test.js +34 -0
- package/build/elementTerminatedSequenceParser.d.ts +3 -0
- package/build/elementTerminatedSequenceParser.js +27 -0
- package/build/elementTerminatedSequenceParser.test.js +34 -0
- package/build/endOfInputParser.d.ts +1 -1
- package/build/exactElementParser.js +10 -5
- package/build/exactElementSwitchParser.d.ts +3 -0
- package/build/exactElementSwitchParser.js +22 -0
- package/build/exactSequenceParser.d.ts +2 -1
- package/build/exactSequenceParser.js +12 -2
- package/build/fetchCid.d.ts +1 -0
- package/build/fetchCid.js +103 -0
- package/build/fetchCid.test.js +16 -0
- package/build/fixedLengthSequenceParser.d.ts +1 -0
- package/build/fixedLengthSequenceParser.js +18 -1
- package/build/fixedLengthSequenceParser.test.js +41 -0
- package/build/hasExecutable.d.ts +1 -0
- package/build/hasExecutable.js +8 -0
- package/build/highResolutionTimer.d.ts +16 -0
- package/build/highResolutionTimer.js +42 -0
- package/build/inputReader.d.ts +11 -0
- package/build/inputReader.js +37 -0
- package/build/inputReader.test.js +161 -8
- package/build/inputReaderState.d.ts +10 -0
- package/build/inputReaderState.js +16 -0
- package/build/inspect.d.ts +1 -0
- package/build/inspect.js +7 -0
- package/build/javaKeyStoreParser.test.js +8 -8
- package/build/jsonParser.d.ts +2 -0
- package/build/jsonParser.js +19 -22
- package/build/lazyMessageError.d.ts +48 -0
- package/build/lazyMessageError.js +53 -0
- package/build/lazyMessageError.test.d.ts +1 -0
- package/build/lazyMessageError.test.js +15 -0
- package/build/leb128Parser.d.ts +7 -0
- package/build/leb128Parser.js +82 -0
- package/build/leb128Parser.test.d.ts +1 -0
- package/build/leb128Parser.test.js +107 -0
- package/build/lookaheadParser.d.ts +2 -0
- package/build/lookaheadParser.js +14 -0
- package/build/negativeLookaheadParser.js +22 -16
- package/build/negativeLookaheadParser.test.d.ts +1 -0
- package/build/negativeLookaheadParser.test.js +30 -0
- package/build/noStackCaptureOverheadError.d.ts +4 -0
- package/build/noStackCaptureOverheadError.js +9 -0
- package/build/noStackCaptureOverheadError.test.d.ts +1 -0
- package/build/noStackCaptureOverheadError.test.js +15 -0
- package/build/nonEmptyArrayParser.d.ts +2 -0
- package/build/nonEmptyArrayParser.js +32 -0
- package/build/nonEmptyArrayParser.test.d.ts +1 -0
- package/build/nonEmptyArrayParser.test.js +17 -0
- package/build/optionalParser.js +2 -2
- package/build/parser.d.ts +11 -1
- package/build/parser.js +82 -32
- package/build/parser.test.js +141 -25
- package/build/parserAccessorParser.js +9 -1
- package/build/parserConsumedSequenceParser.d.ts +1 -1
- package/build/parserConsumedSequenceParser.js +21 -16
- package/build/parserContext.d.ts +22 -6
- package/build/parserContext.js +113 -57
- package/build/parserContext.test.js +33 -2
- package/build/parserCreatorCompose.d.ts +1 -0
- package/build/parserCreatorCompose.js +8 -2
- package/build/parserError.d.ts +605 -40
- package/build/parserError.js +98 -53
- package/build/parserImplementationInvariant.d.ts +1 -1
- package/build/parserImplementationInvariant.js +2 -2
- package/build/parserInputCompanion.d.ts +15 -0
- package/build/parserInputCompanion.js +38 -0
- package/build/promiseCompose.d.ts +1 -1
- package/build/promiseCompose.js +11 -1
- package/build/promiseSettled.d.ts +1 -0
- package/build/promiseSettled.js +4 -0
- package/build/separatedArrayParser.d.ts +2 -0
- package/build/separatedArrayParser.js +39 -0
- package/build/separatedArrayParser.test.d.ts +1 -0
- package/build/separatedArrayParser.test.js +21 -0
- package/build/separatedNonEmptyArrayParser.d.ts +2 -0
- package/build/separatedNonEmptyArrayParser.js +40 -0
- package/build/separatedNonEmptyArrayParser.test.d.ts +1 -0
- package/build/separatedNonEmptyArrayParser.test.js +66 -0
- package/build/sequenceBuffer.d.ts +10 -0
- package/build/sequenceBuffer.js +54 -2
- package/build/sequenceBuffer.test.js +57 -0
- package/build/sequenceTerminatedSequenceParser.d.ts +5 -0
- package/build/sequenceTerminatedSequenceParser.js +32 -0
- package/build/sequenceTerminatedSequenceParser.test.d.ts +1 -0
- package/build/sequenceTerminatedSequenceParser.test.js +37 -0
- package/build/sequenceUnparser.d.ts +1 -1
- package/build/skipParser.d.ts +1 -1
- package/build/skipParser.js +4 -2
- package/build/skipToParser.d.ts +2 -0
- package/build/skipToParser.js +11 -0
- package/build/sliceBoundedParser.d.ts +1 -1
- package/build/sliceBoundedParser.js +7 -2
- package/build/sliceBoundedParser.test.js +30 -1
- package/build/smali.d.ts +1 -0
- package/build/smali.js +21 -0
- package/build/smaliParser.d.ts +68 -0
- package/build/smaliParser.js +2081 -0
- package/build/smaliParser.test.d.ts +1 -0
- package/build/smaliParser.test.js +410 -0
- package/build/stringFromAsyncIterable.d.ts +1 -0
- package/build/stringFromAsyncIterable.js +7 -0
- package/build/terminatedArrayParser.d.ts +3 -1
- package/build/terminatedArrayParser.js +79 -2
- package/build/terminatedArrayParser.test.d.ts +1 -0
- package/build/terminatedArrayParser.test.js +131 -0
- package/build/toAsyncIterable.d.ts +1 -0
- package/build/toAsyncIterable.js +7 -0
- package/build/toAsyncIterator.d.ts +1 -0
- package/build/toAsyncIterator.js +33 -0
- package/build/tupleParser.d.ts +4 -0
- package/build/tupleParser.js +1 -5
- package/build/unionParser.d.ts +2 -1
- package/build/unionParser.js +29 -14
- package/build/unionParser.test.d.ts +1 -0
- package/build/unionParser.test.js +60 -0
- package/build/unparser.d.ts +3 -3
- package/build/unparser.js +6 -4
- package/build/unparser.test.js +7 -19
- package/build/unparserContext.d.ts +2 -2
- package/build/unparserContext.js +2 -3
- package/build/unparserError.d.ts +2 -1
- package/build/unparserError.js +2 -1
- package/build/unparserImplementationInvariant.d.ts +1 -1
- package/build/unparserOutputCompanion.d.ts +1 -1
- package/build/unparserOutputCompanion.js +1 -1
- package/build/zipParser.d.ts +7 -2
- package/build/zipParser.js +36 -12
- package/build/zipUnparser.d.ts +7 -4
- package/build/zipUnparser.js +64 -45
- package/build/zipUnparser.test.js +15 -15
- package/package.json +33 -24
- package/src/allSettledStream.test.ts +40 -0
- package/src/allSettledStream.ts +47 -15
- package/src/androidPackage.ts +48 -0
- package/src/androidPackageParser.test.ts +27 -0
- package/src/{apkParser.test.ts.md → androidPackageParser.test.ts.md} +4 -4
- package/src/androidPackageParser.test.ts.snap +0 -0
- package/src/androidPackageParser.ts +398 -0
- package/src/androidPackageUnparser.test.ts +34 -0
- package/src/androidPackageUnparser.ts +126 -0
- package/src/arbitrarilySlicedAsyncInterable.ts +7 -2
- package/src/arbitrarilySlicedAsyncInterator.ts +4 -4
- package/src/arbitraryDalvikBytecode.ts +992 -0
- package/src/arbitraryDalvikExecutable.ts +434 -0
- package/src/arbitraryDosDateTime.ts +1 -0
- package/src/arbitraryZipStream.ts +1 -1
- package/src/arrayParser.test.ts +3 -3
- package/src/arrayParser.ts +2 -2
- package/src/arrayUnparser.ts +2 -2
- package/src/backsmali.ts +74 -0
- package/src/bsonParser.test.ts +12 -14
- package/src/bsonParser.ts +13 -2
- package/src/customInvariant.ts +8 -12
- package/src/dalvikBytecodeParser/formatParsers.ts +780 -0
- package/src/dalvikBytecodeParser/formatSizes.ts +35 -0
- package/src/dalvikBytecodeParser/operationFormats.ts +226 -0
- package/src/dalvikBytecodeParser.ts +2873 -0
- package/src/dalvikBytecodeUnparser/formatUnparsers.ts +442 -0
- package/src/dalvikBytecodeUnparser.test.ts +44 -0
- package/src/dalvikBytecodeUnparser.ts +758 -0
- package/src/dalvikExecutable.ts +282 -0
- package/src/dalvikExecutableParser/stringSyntaxParser.ts +145 -0
- package/src/dalvikExecutableParser/typeParsers.ts +74 -0
- package/src/dalvikExecutableParser/typedNumbers.ts +57 -0
- package/src/dalvikExecutableParser.test.ts +89 -0
- package/src/dalvikExecutableParser.test.ts.md +634 -0
- package/src/dalvikExecutableParser.test.ts.snap +0 -0
- package/src/dalvikExecutableParser.ts +3245 -0
- package/src/dalvikExecutableParserAgainstSmaliParser.test.ts +363 -0
- package/src/dalvikExecutableUnparser/annotationUnparsers.ts +135 -0
- package/src/dalvikExecutableUnparser/poolBuilders.ts +189 -0
- package/src/dalvikExecutableUnparser/poolScanners.ts +297 -0
- package/src/dalvikExecutableUnparser/sectionUnparsers.ts +683 -0
- package/src/dalvikExecutableUnparser/utils.ts +149 -0
- package/src/dalvikExecutableUnparser.test.ts +57 -0
- package/src/dalvikExecutableUnparser.ts +581 -0
- package/src/debugLogInputParser.ts +28 -0
- package/src/debugLogParser.ts +19 -3
- package/src/disjunctionParser.ts +12 -7
- package/src/elementTerminatedArrayParser.test.ts +99 -0
- package/src/elementTerminatedArrayParser.ts +31 -0
- package/src/elementTerminatedSequenceArrayParser.test.ts +52 -0
- package/src/elementTerminatedSequenceArrayParser.ts +52 -0
- package/src/elementTerminatedSequenceParser.test.ts +52 -0
- package/src/elementTerminatedSequenceParser.ts +43 -0
- package/src/endOfInputParser.ts +1 -1
- package/src/exactElementParser.ts +17 -11
- package/src/exactElementSwitchParser.ts +41 -0
- package/src/exactSequenceParser.ts +23 -2
- package/src/fetchCid.test.ts +20 -0
- package/src/fetchCid.ts +121 -0
- package/src/fixedLengthSequenceParser.test.ts +75 -0
- package/src/fixedLengthSequenceParser.ts +28 -1
- package/src/hasExecutable.ts +11 -0
- package/src/highResolutionTimer.ts +49 -0
- package/src/inputReader.test.ts +204 -8
- package/src/inputReader.ts +76 -3
- package/src/inputReaderState.ts +33 -0
- package/src/inspect.ts +9 -0
- package/src/javaKeyStoreParser.test.ts +12 -15
- package/src/javaKeyStoreParser.ts +2 -6
- package/src/jsonParser.test.ts +2 -4
- package/src/jsonParser.ts +46 -62
- package/src/lazyMessageError.test.ts +21 -0
- package/src/lazyMessageError.ts +88 -0
- package/src/leb128Parser.test.ts +173 -0
- package/src/leb128Parser.ts +125 -0
- package/src/lookaheadParser.ts +19 -0
- package/src/negativeLookaheadParser.test.ts +49 -0
- package/src/negativeLookaheadParser.ts +27 -15
- package/src/noStackCaptureOverheadError.test.ts +17 -0
- package/src/noStackCaptureOverheadError.ts +12 -0
- package/src/nonEmptyArrayParser.test.ts +21 -0
- package/src/nonEmptyArrayParser.ts +44 -0
- package/src/optionalParser.ts +3 -2
- package/src/parser.test.ts +203 -31
- package/src/parser.test.ts.md +34 -27
- package/src/parser.test.ts.snap +0 -0
- package/src/parser.ts +172 -45
- package/src/parserAccessorParser.ts +12 -2
- package/src/parserConsumedSequenceParser.ts +26 -17
- package/src/parserContext.test.ts +37 -2
- package/src/parserContext.ts +185 -79
- package/src/parserCreatorCompose.ts +20 -2
- package/src/parserError.ts +144 -61
- package/src/parserImplementationInvariant.ts +3 -3
- package/src/parserInputCompanion.ts +55 -0
- package/src/promiseCompose.ts +17 -3
- package/src/promiseSettled.ts +6 -0
- package/src/separatedArrayParser.test.ts +34 -0
- package/src/separatedArrayParser.ts +55 -0
- package/src/separatedNonEmptyArrayParser.test.ts +117 -0
- package/src/separatedNonEmptyArrayParser.ts +61 -0
- package/src/sequenceBuffer.test.ts +70 -0
- package/src/sequenceBuffer.ts +88 -2
- package/src/sequenceTerminatedSequenceParser.test.ts +58 -0
- package/src/sequenceTerminatedSequenceParser.ts +62 -0
- package/src/sequenceUnparser.ts +2 -2
- package/src/skipParser.ts +7 -5
- package/src/skipToParser.ts +16 -0
- package/src/sliceBoundedParser.test.ts +35 -1
- package/src/sliceBoundedParser.ts +19 -1
- package/src/smali.ts +29 -0
- package/src/smaliParser.test.ts +443 -0
- package/src/smaliParser.test.ts.md +3907 -0
- package/src/smaliParser.test.ts.snap +0 -0
- package/src/smaliParser.ts +3348 -0
- package/src/stringFromAsyncIterable.ts +9 -0
- package/src/terminatedArrayParser.test.ts +258 -0
- package/src/terminatedArrayParser.ts +109 -6
- package/src/toAsyncIterable.ts +7 -0
- package/src/toAsyncIterator.ts +48 -0
- package/src/tupleParser.ts +8 -5
- package/src/uint8Array.ts +2 -3
- package/src/unionParser.test.ts +78 -0
- package/src/unionParser.ts +47 -21
- package/src/unparser.test.ts +18 -34
- package/src/unparser.ts +13 -9
- package/src/unparserContext.ts +9 -13
- package/src/unparserError.ts +2 -1
- package/src/unparserImplementationInvariant.ts +1 -1
- package/src/unparserOutputCompanion.ts +1 -1
- package/src/zip.ts +2 -6
- package/src/zipParser.ts +71 -20
- package/src/zipUnparser.test.ts +19 -19
- package/src/zipUnparser.ts +139 -90
- package/tsconfig.json +7 -1
- package/xo.config.ts +15 -0
- package/.yarn/releases/yarn-4.5.3.cjs +0 -934
- package/build/apk.d.ts +0 -39
- package/build/apkParser.d.ts +0 -16
- package/build/apkParser.js +0 -164
- package/build/apkParser.test.js +0 -22
- package/build/apkUnparser.d.ts +0 -4
- package/build/apkUnparser.js +0 -90
- package/build/apkUnparser.test.js +0 -26
- package/build/arbitraryDosDate.d.ts +0 -2
- package/build/arbitraryDosDate.js +0 -8
- package/build/arbitraryZipEntry.d.ts +0 -3
- package/build/arbitraryZipEntry.js +0 -26
- package/build/createDisjunctionParser.d.ts +0 -2
- package/build/createDisjunctionParser.js +0 -47
- package/build/createExactParser.d.ts +0 -2
- package/build/createExactParser.js +0 -12
- package/build/createSequentialUnionParser.d.ts +0 -2
- package/build/createSequentialUnionParser.js +0 -69
- package/build/fixedLengthChunkParser.d.ts +0 -2
- package/build/fixedLengthChunkParser.js +0 -12
- package/build/fixedLengthParser.d.ts +0 -2
- package/build/fixedLengthParser.js +0 -12
- package/build/inputChunkBuffer.d.ts +0 -15
- package/build/inputChunkBuffer.js +0 -40
- package/build/inputChunkBuffer.test.js +0 -34
- package/build/inputCompanion.d.ts +0 -18
- package/build/inputCompanion.js +0 -28
- package/build/invariantDefined.d.ts +0 -1
- package/build/invariantDefined.js +0 -5
- package/build/invariantIdentity.d.ts +0 -3
- package/build/invariantIdentity.js +0 -5
- package/build/javaKeystoreParser.d.ts +0 -2
- package/build/javaKeystoreParser.js +0 -7
- package/build/jsonParser2.d.ts +0 -3
- package/build/jsonParser2.js +0 -52
- package/build/jsonParser2.test.js +0 -22
- package/build/negativeLookahead.d.ts +0 -2
- package/build/negativeLookahead.js +0 -18
- package/build/parserCompose.d.ts +0 -3
- package/build/parserCompose.js +0 -7
- package/build/parserImplementationInvariantInvariant.d.ts +0 -3
- package/build/parserImplementationInvariantInvariant.js +0 -15
- package/build/parserInvariant.d.ts +0 -4
- package/build/parserInvariant.js +0 -11
- package/build/promiseFish.d.ts +0 -1
- package/build/promiseFish.js +0 -3
- package/build/sequenceParser.d.ts +0 -3
- package/build/sequenceParser.js +0 -10
- package/build/terminatedSequenceParser.d.ts +0 -2
- package/build/terminatedSequenceParser.js +0 -24
- package/build/unparserInputCompanion.d.ts +0 -15
- package/build/unparserInputCompanion.js +0 -13
- package/build/zipEntry.d.ts +0 -28
- package/build/zipFile.d.ts +0 -32
- package/build/zipFileEntry.d.ts +0 -6
- package/src/apk.ts +0 -48
- package/src/apkParser.test.ts +0 -30
- package/src/apkParser.test.ts.snap +0 -0
- package/src/apkParser.ts +0 -392
- package/src/apkUnparser.test.ts +0 -37
- package/src/apkUnparser.ts +0 -120
- package/src/invariantDefined.ts +0 -6
- package/src/invariantIdentity.ts +0 -8
- /package/build/{apk.js → androidPackage.js} +0 -0
- /package/build/{apkParser.test.d.ts → androidPackageParser.test.d.ts} +0 -0
- /package/build/{apkUnparser.test.d.ts → androidPackageUnparser.test.d.ts} +0 -0
- /package/build/{arbitraryDosPermissions.d.ts → dalvikBytecodeUnparser.test.d.ts} +0 -0
- /package/build/{arbitraryDosPermissions.js → dalvikExecutableParser.test.d.ts} +0 -0
- /package/build/{inputChunkBuffer.test.d.ts → dalvikExecutableParserAgainstSmaliParser.test.d.ts} +0 -0
- /package/build/{jsonParser2.test.d.ts → dalvikExecutableUnparser.test.d.ts} +0 -0
- /package/build/{parserParsingInvariant.d.ts → elementTerminatedArrayParser.test.d.ts} +0 -0
- /package/build/{parserParsingInvariant.js → elementTerminatedSequenceArrayParser.test.d.ts} +0 -0
- /package/build/{zipEntry.js → elementTerminatedSequenceParser.test.d.ts} +0 -0
- /package/build/{zipFile.js → fetchCid.test.d.ts} +0 -0
- /package/build/{zipFileEntry.js → fixedLengthSequenceParser.test.d.ts} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import invariant from 'invariant';
|
|
2
|
+
function isAsyncIterable(value) {
|
|
3
|
+
return typeof value === 'object' && value !== null && Symbol.asyncIterator in value && typeof value[Symbol.asyncIterator] === 'function';
|
|
4
|
+
}
|
|
5
|
+
function isIterable(value) {
|
|
6
|
+
return typeof value === 'object' && value !== null && Symbol.iterator in value && typeof value[Symbol.iterator] === 'function';
|
|
7
|
+
}
|
|
8
|
+
function isIterator(value) {
|
|
9
|
+
return typeof value === 'object' && value !== null && 'next' in value && typeof value.next === 'function';
|
|
10
|
+
}
|
|
11
|
+
function iteratorToAsyncIterator(iterator) {
|
|
12
|
+
return {
|
|
13
|
+
next: async () => iterator.next(),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function toAsyncIterator(value) {
|
|
17
|
+
if (typeof value === 'string'
|
|
18
|
+
|| value instanceof Uint8Array) {
|
|
19
|
+
return (async function* () {
|
|
20
|
+
yield value;
|
|
21
|
+
})();
|
|
22
|
+
}
|
|
23
|
+
if (isAsyncIterable(value)) {
|
|
24
|
+
return value[Symbol.asyncIterator]();
|
|
25
|
+
}
|
|
26
|
+
if (isIterable(value)) {
|
|
27
|
+
return iteratorToAsyncIterator(value[Symbol.iterator]());
|
|
28
|
+
}
|
|
29
|
+
if (isIterator(value)) {
|
|
30
|
+
return iteratorToAsyncIterator(value);
|
|
31
|
+
}
|
|
32
|
+
invariant(false, 'Value must be an async iterator, async iterable, iterable or iterator got %s.', value);
|
|
33
|
+
}
|
package/build/tupleParser.d.ts
CHANGED
|
@@ -9,3 +9,7 @@ export declare function createTupleParser<A, B, C, D, E, F, G, H, Sequence>([par
|
|
|
9
9
|
export declare function createTupleParser<A, B, C, D, E, F, G, H, I, Sequence>([parserA, parserB, parserC, parserD, parserE, parserF, parserG, parserH, parserI]: [Parser<A, Sequence>, Parser<B, Sequence>, Parser<C, Sequence>, Parser<D, Sequence>, Parser<E, Sequence>, Parser<F, Sequence>, Parser<G, Sequence>, Parser<H, Sequence>, Parser<I, Sequence>]): Parser<[A, B, C, D, E, F, G, H, I], Sequence>;
|
|
10
10
|
export declare function createTupleParser<A, B, C, D, E, F, G, H, I, J, Sequence>([parserA, parserB, parserC, parserD, parserE, parserF, parserG, parserH, parserI, parserJ]: [Parser<A, Sequence>, Parser<B, Sequence>, Parser<C, Sequence>, Parser<D, Sequence>, Parser<E, Sequence>, Parser<F, Sequence>, Parser<G, Sequence>, Parser<H, Sequence>, Parser<I, Sequence>, Parser<J, Sequence>]): Parser<[A, B, C, D, E, F, G, H, I, J], Sequence>;
|
|
11
11
|
export declare function createTupleParser<A, B, C, D, E, F, G, H, I, J, K, Sequence>([parserA, parserB, parserC, parserD, parserE, parserF, parserG, parserH, parserI, parserJ, parserK]: [Parser<A, Sequence>, Parser<B, Sequence>, Parser<C, Sequence>, Parser<D, Sequence>, Parser<E, Sequence>, Parser<F, Sequence>, Parser<G, Sequence>, Parser<H, Sequence>, Parser<I, Sequence>, Parser<J, Sequence>, Parser<K, Sequence>]): Parser<[A, B, C, D, E, F, G, H, I, J, K], Sequence>;
|
|
12
|
+
export declare function createTupleParser<A, B, C, D, E, F, G, H, I, J, K, L, Sequence>([parserA, parserB, parserC, parserD, parserE, parserF, parserG, parserH, parserI, parserJ, parserK, parserL]: [Parser<A, Sequence>, Parser<B, Sequence>, Parser<C, Sequence>, Parser<D, Sequence>, Parser<E, Sequence>, Parser<F, Sequence>, Parser<G, Sequence>, Parser<H, Sequence>, Parser<I, Sequence>, Parser<J, Sequence>, Parser<K, Sequence>, Parser<L, Sequence>]): Parser<[A, B, C, D, E, F, G, H, I, J, K, L], Sequence>;
|
|
13
|
+
export declare function createTupleParser<A, B, C, D, E, F, G, H, I, J, K, L, M, Sequence>([parserA, parserB, parserC, parserD, parserE, parserF, parserG, parserH, parserI, parserJ, parserK, parserL, parserM]: [Parser<A, Sequence>, Parser<B, Sequence>, Parser<C, Sequence>, Parser<D, Sequence>, Parser<E, Sequence>, Parser<F, Sequence>, Parser<G, Sequence>, Parser<H, Sequence>, Parser<I, Sequence>, Parser<J, Sequence>, Parser<K, Sequence>, Parser<L, Sequence>, Parser<M, Sequence>]): Parser<[A, B, C, D, E, F, G, H, I, J, K, L, M], Sequence>;
|
|
14
|
+
export declare function createTupleParser<A, B, C, D, E, F, G, H, I, J, K, L, M, N, Sequence>([parserA, parserB, parserC, parserD, parserE, parserF, parserG, parserH, parserI, parserJ, parserK, parserL, parserM, parserN]: [Parser<A, Sequence>, Parser<B, Sequence>, Parser<C, Sequence>, Parser<D, Sequence>, Parser<E, Sequence>, Parser<F, Sequence>, Parser<G, Sequence>, Parser<H, Sequence>, Parser<I, Sequence>, Parser<J, Sequence>, Parser<K, Sequence>, Parser<L, Sequence>, Parser<M, Sequence>, Parser<N, Sequence>]): Parser<[A, B, C, D, E, F, G, H, I, J, K, L, M, N], Sequence>;
|
|
15
|
+
export declare function createTupleParser<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, Sequence>([parserA, parserB, parserC, parserD, parserE, parserF, parserG, parserH, parserI, parserJ, parserK, parserL, parserM, parserN, parserO]: [Parser<A, Sequence>, Parser<B, Sequence>, Parser<C, Sequence>, Parser<D, Sequence>, Parser<E, Sequence>, Parser<F, Sequence>, Parser<G, Sequence>, Parser<H, Sequence>, Parser<I, Sequence>, Parser<J, Sequence>, Parser<K, Sequence>, Parser<L, Sequence>, Parser<M, Sequence>, Parser<N, Sequence>, Parser<O, Sequence>]): Parser<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], Sequence>;
|
package/build/tupleParser.js
CHANGED
|
@@ -8,10 +8,6 @@ export function createTupleParser(parsers) {
|
|
|
8
8
|
}
|
|
9
9
|
return values;
|
|
10
10
|
};
|
|
11
|
-
setParserName(tupleParser,
|
|
12
|
-
'[',
|
|
13
|
-
parsers.map(parser => getParserName(parser, 'anonymousTupleChild')).join(','),
|
|
14
|
-
']',
|
|
15
|
-
].join(''));
|
|
11
|
+
setParserName(tupleParser, parsers.map(parser => '(' + getParserName(parser, 'anonymousTupleChild') + ')').join(''));
|
|
16
12
|
return tupleParser;
|
|
17
13
|
}
|
package/build/unionParser.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type Parser } from './parser.js';
|
|
2
|
-
|
|
2
|
+
import { type DeriveSequenceElement } from './sequence.js';
|
|
3
|
+
export declare const createUnionParser: <Output, Sequence, Element = DeriveSequenceElement<Sequence>>(childParsers: Array<Parser<unknown, Sequence, Element>>) => Parser<Output, Sequence, Element>;
|
package/build/unionParser.js
CHANGED
|
@@ -1,35 +1,47 @@
|
|
|
1
1
|
import { allSettledStream } from './allSettledStream.js';
|
|
2
2
|
import { getParserName, setParserName } from './parser.js';
|
|
3
|
-
import {
|
|
3
|
+
import { isParserParsingFailedError } from './parserError.js';
|
|
4
4
|
import { parserImplementationInvariant } from './parserImplementationInvariant.js';
|
|
5
|
+
const bigintReplacer = (_key, value) => {
|
|
6
|
+
if (typeof value === 'bigint') {
|
|
7
|
+
return `${value}n`;
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
5
11
|
export const createUnionParser = (childParsers) => {
|
|
6
12
|
parserImplementationInvariant(childParsers.length > 0, 'Union parser must have at least one child parser.');
|
|
7
13
|
const unionParser = async (parserContext) => {
|
|
8
14
|
let runningChildParserContexts = [];
|
|
9
|
-
const
|
|
15
|
+
const createChildParserTask = (childParser) => {
|
|
10
16
|
const childParserContext = parserContext.lookahead({
|
|
11
17
|
debugName: getParserName(childParser, 'anonymousUnionChild'),
|
|
12
18
|
});
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
const context = {
|
|
20
|
+
childParser,
|
|
21
|
+
childParserContext,
|
|
22
|
+
};
|
|
23
|
+
runningChildParserContexts.push(context);
|
|
24
|
+
const getChildParserPromise = (async () => childParser(childParserContext));
|
|
25
|
+
const promise = getChildParserPromise();
|
|
15
26
|
return {
|
|
16
27
|
promise,
|
|
17
|
-
context
|
|
28
|
+
context,
|
|
18
29
|
};
|
|
19
|
-
}
|
|
30
|
+
};
|
|
31
|
+
const childParserResults = allSettledStream(childParsers.map(createChildParserTask));
|
|
20
32
|
const parserParsingFailedErrors = [];
|
|
21
33
|
const successfulParserOutputs = [];
|
|
22
|
-
const
|
|
34
|
+
const successfulTaskContexts = [];
|
|
23
35
|
let didUnlookahead = false;
|
|
24
36
|
for await (const childParserResult of childParserResults) {
|
|
25
37
|
runningChildParserContexts = runningChildParserContexts.filter(runningChildParserContext => runningChildParserContext !== childParserResult.context);
|
|
26
38
|
if (childParserResult.status === 'fulfilled') {
|
|
27
39
|
successfulParserOutputs.push(childParserResult.value);
|
|
28
|
-
|
|
40
|
+
successfulTaskContexts.push(childParserResult.context);
|
|
29
41
|
}
|
|
30
42
|
else {
|
|
31
43
|
const error = childParserResult.reason;
|
|
32
|
-
if (error
|
|
44
|
+
if (isParserParsingFailedError(error)) {
|
|
33
45
|
parserParsingFailedErrors.push(error);
|
|
34
46
|
}
|
|
35
47
|
else {
|
|
@@ -41,7 +53,7 @@ export const createUnionParser = (childParsers) => {
|
|
|
41
53
|
parserImplementationInvariant(!didUnlookahead, 'Union parser unlookaheaded multiple times.');
|
|
42
54
|
didUnlookahead = true;
|
|
43
55
|
const [runningChildParserContext] = runningChildParserContexts;
|
|
44
|
-
runningChildParserContext.unlookahead();
|
|
56
|
+
runningChildParserContext.childParserContext.unlookahead();
|
|
45
57
|
}
|
|
46
58
|
}
|
|
47
59
|
parserImplementationInvariant(successfulParserOutputs.length <= 1, [
|
|
@@ -49,13 +61,16 @@ export const createUnionParser = (childParsers) => {
|
|
|
49
61
|
'Successful parser outputs, indented, separated by newlines:',
|
|
50
62
|
'%s',
|
|
51
63
|
'End of successful parser outputs.',
|
|
52
|
-
|
|
64
|
+
'Successful parser names, indented, separated by newlines:',
|
|
65
|
+
'%s',
|
|
66
|
+
'End of successful parser names.',
|
|
67
|
+
], () => successfulParserOutputs.map(output => ' ' + JSON.stringify(output, bigintReplacer)).join('\n'), () => successfulTaskContexts.map(taskContext => ' ' + getParserName(taskContext.childParser, 'anonymousUnionChild')).join('\n'));
|
|
53
68
|
parserContext.invariantJoin(successfulParserOutputs.length === 1, parserParsingFailedErrors, 'No union child parser succeeded.');
|
|
54
|
-
const [successfulParserContext] =
|
|
69
|
+
const [successfulParserContext] = successfulTaskContexts;
|
|
55
70
|
if (!didUnlookahead) {
|
|
56
|
-
successfulParserContext.unlookahead();
|
|
71
|
+
successfulParserContext.childParserContext.unlookahead();
|
|
57
72
|
}
|
|
58
|
-
successfulParserContext.dispose();
|
|
73
|
+
successfulParserContext.childParserContext.dispose();
|
|
59
74
|
const [successfulParserOutput] = successfulParserOutputs;
|
|
60
75
|
return successfulParserOutput;
|
|
61
76
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import { createUnionParser } from './unionParser.js';
|
|
3
|
+
import { runParser, setParserName } from './parser.js';
|
|
4
|
+
import { stringParserInputCompanion } from './parserInputCompanion.js';
|
|
5
|
+
import { createArrayParser } from './arrayParser.js';
|
|
6
|
+
import { createExactElementParser } from './exactElementParser.js';
|
|
7
|
+
import { createExactSequenceParser } from './exactSequenceParser.js';
|
|
8
|
+
test('union of union of union', async (t) => {
|
|
9
|
+
const parser = createUnionParser([
|
|
10
|
+
createExactElementParser('a'),
|
|
11
|
+
createUnionParser([
|
|
12
|
+
createExactElementParser('b'),
|
|
13
|
+
createUnionParser([
|
|
14
|
+
createExactElementParser('c'),
|
|
15
|
+
createExactElementParser('d'),
|
|
16
|
+
]),
|
|
17
|
+
createExactElementParser('e'),
|
|
18
|
+
]),
|
|
19
|
+
createExactElementParser('f'),
|
|
20
|
+
createUnionParser([
|
|
21
|
+
createExactElementParser('g'),
|
|
22
|
+
createExactElementParser('h'),
|
|
23
|
+
]),
|
|
24
|
+
]);
|
|
25
|
+
for (const character of 'abcdefgh') {
|
|
26
|
+
t.deepEqual(await runParser(parser, character, stringParserInputCompanion), character);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
test('sync and async child parsers', async (t) => {
|
|
30
|
+
const parser = createArrayParser(createUnionParser([
|
|
31
|
+
async (parserContext) => {
|
|
32
|
+
parserContext.invariant(parserContext.position % 2 === 0, 'Expected an even position.');
|
|
33
|
+
return parserContext.read(0);
|
|
34
|
+
},
|
|
35
|
+
parserContext => {
|
|
36
|
+
parserContext.invariant(parserContext.position % 2 === 1, 'Expected an odd position.');
|
|
37
|
+
parserContext.skip(1);
|
|
38
|
+
return String.fromCodePoint('A'.codePointAt(0) + parserContext.position - 1);
|
|
39
|
+
},
|
|
40
|
+
]));
|
|
41
|
+
const result = await runParser(parser, 'a?c?', stringParserInputCompanion, {
|
|
42
|
+
errorJoinMode: 'all',
|
|
43
|
+
});
|
|
44
|
+
t.deepEqual(result, [...'aBcD']);
|
|
45
|
+
});
|
|
46
|
+
test('multiple parsers succeeded error', async (t) => {
|
|
47
|
+
const parser = createUnionParser([
|
|
48
|
+
setParserName(createExactSequenceParser('foo'), 'foo1'),
|
|
49
|
+
setParserName(createExactSequenceParser('foo'), 'foo2'),
|
|
50
|
+
]);
|
|
51
|
+
const error = await t.throwsAsync(runParser(parser, 'foo', stringParserInputCompanion, {
|
|
52
|
+
errorJoinMode: 'all',
|
|
53
|
+
}), {
|
|
54
|
+
any: true,
|
|
55
|
+
name: 'ParserImplementationInvariantError',
|
|
56
|
+
});
|
|
57
|
+
t.true(error.message.includes('foo'));
|
|
58
|
+
t.true(error.message.includes('foo1'));
|
|
59
|
+
t.true(error.message.includes('foo2'));
|
|
60
|
+
});
|
package/build/unparser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DeriveSequenceElement } from
|
|
2
|
-
import { UnparserContext, WriteEarlier, WriteLater } from
|
|
3
|
-
import { UnparserOutputCompanion } from
|
|
1
|
+
import { type DeriveSequenceElement } from './sequence.js';
|
|
2
|
+
import { type UnparserContext, WriteEarlier, WriteLater } from './unparserContext.js';
|
|
3
|
+
import { type UnparserOutputCompanion } from './unparserOutputCompanion.js';
|
|
4
4
|
type UnparserIterableValue<Sequence, Element> = Sequence | Element | WriteLater<Sequence, Element> | WriteEarlier<Sequence, Element>;
|
|
5
5
|
export type UnparserResult<Sequence, Element> = AsyncIterable<UnparserIterableValue<Sequence, Element>>;
|
|
6
6
|
export type Unparser<Input, Sequence, Element = DeriveSequenceElement<Sequence>> = (input: Input, unparserContext: UnparserContext<Sequence, Element>) => UnparserResult<Sequence, Element>;
|
package/build/unparser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import invariant from
|
|
2
|
-
import { UnparserContextImplementation, WriteEarlier, WriteLater } from
|
|
3
|
-
import { unparserImplementationInvariant } from
|
|
1
|
+
import invariant from 'invariant';
|
|
2
|
+
import { UnparserContextImplementation, WriteEarlier, WriteLater, } from './unparserContext.js';
|
|
3
|
+
import { unparserImplementationInvariant } from './unparserImplementationInvariant.js';
|
|
4
4
|
async function* onYield(asyncIterable, onYield) {
|
|
5
5
|
for await (const value of asyncIterable) {
|
|
6
6
|
onYield(value);
|
|
@@ -40,7 +40,9 @@ async function* elementsToSequences(values, unparserOutputCompanion) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function wrapUnparserResult(unparserResult, unparserContext, unparserOutputCompanion) {
|
|
43
|
-
return onYield(elementsToSequences(unparserResult, unparserOutputCompanion), value =>
|
|
43
|
+
return onYield(elementsToSequences(unparserResult, unparserOutputCompanion), value => {
|
|
44
|
+
unparserContext.handleYield(value);
|
|
45
|
+
});
|
|
44
46
|
}
|
|
45
47
|
export async function* runUnparser(unparser, input, unparserOutputCompanion) {
|
|
46
48
|
const unparserContext = new UnparserContextImplementation(unparserOutputCompanion);
|
package/build/unparser.test.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import * as fc from 'fast-check';
|
|
3
|
+
import { testProp } from '@fast-check/ava';
|
|
3
4
|
import { runUnparser } from './unparser.js';
|
|
4
5
|
import { stringUnparserOutputCompanion } from './unparserOutputCompanion.js';
|
|
5
|
-
import { testProp } from '@fast-check/ava';
|
|
6
6
|
test('writeLater', async (t) => {
|
|
7
7
|
const stringToBeWrittenBefore = 'before writeLater\n';
|
|
8
8
|
const stringToBeWrittenLater = 'written later\n';
|
|
@@ -92,12 +92,10 @@ testProp('writeLater positions and lengths', [
|
|
|
92
92
|
const numberUnparser = async function* (input, unparserContext) {
|
|
93
93
|
yield input.toString().padStart(8, '0');
|
|
94
94
|
};
|
|
95
|
-
const createLengthPrefixedUnparser = (unparser) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
yield* unparserContext.writeEarlier(length, numberUnparser, unparserContext.position - length.positionEnd);
|
|
100
|
-
};
|
|
95
|
+
const createLengthPrefixedUnparser = (unparser) => async function* (input, unparserContext) {
|
|
96
|
+
const length = yield* unparserContext.writeLater(8);
|
|
97
|
+
yield* unparser(input, unparserContext);
|
|
98
|
+
yield* unparserContext.writeEarlier(length, numberUnparser, unparserContext.position - length.positionEnd);
|
|
101
99
|
};
|
|
102
100
|
const unparser0 = createLengthPrefixedUnparser(async function* (input, unparserContext) {
|
|
103
101
|
yield input;
|
|
@@ -109,22 +107,12 @@ testProp('writeLater positions and lengths', [
|
|
|
109
107
|
});
|
|
110
108
|
const unparser2 = createLengthPrefixedUnparser(async function* (input, unparserContext) {
|
|
111
109
|
for (const stringArray2 of input) {
|
|
112
|
-
|
|
113
|
-
yield* unparser0(stringArray2, unparserContext);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
yield* unparser1(stringArray2, unparserContext);
|
|
117
|
-
}
|
|
110
|
+
yield* (typeof stringArray2 === 'string' ? unparser0(stringArray2, unparserContext) : unparser1(stringArray2, unparserContext));
|
|
118
111
|
}
|
|
119
112
|
});
|
|
120
113
|
const unparser3 = createLengthPrefixedUnparser(async function* (input, unparserContext) {
|
|
121
114
|
for (const stringArray3 of input) {
|
|
122
|
-
|
|
123
|
-
yield* unparser0(stringArray3, unparserContext);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
yield* unparser2(stringArray3, unparserContext);
|
|
127
|
-
}
|
|
115
|
+
yield* (typeof stringArray3 === 'string' ? unparser0(stringArray3, unparserContext) : unparser2(stringArray3, unparserContext));
|
|
128
116
|
}
|
|
129
117
|
});
|
|
130
118
|
const stringsAsyncIterable = runUnparser(unparser3, stringArray3, stringUnparserOutputCompanion);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Unparser, UnparserResult } from
|
|
2
|
-
import { UnparserOutputCompanion } from
|
|
1
|
+
import { type Unparser, type UnparserResult } from './unparser.js';
|
|
2
|
+
import { type UnparserOutputCompanion } from './unparserOutputCompanion.js';
|
|
3
3
|
export type UnparserContext<Sequence, Element> = {
|
|
4
4
|
get position(): number;
|
|
5
5
|
writeLater(length: number): AsyncIterable<WriteLater<Sequence, Element>, WriteLater<Sequence, Element>>;
|
package/build/unparserContext.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { parserImplementationInvariant } from "./parserImplementationInvariant.js";
|
|
1
|
+
import { unparserImplementationInvariant } from './unparserImplementationInvariant.js';
|
|
2
|
+
import { parserImplementationInvariant } from './parserImplementationInvariant.js';
|
|
4
3
|
export class WriteLater extends Error {
|
|
5
4
|
_position;
|
|
6
5
|
_length;
|
package/build/unparserError.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { NormalLazyMessageError } from "./lazyMessageError.js";
|
|
2
|
+
export declare class UnparserError extends NormalLazyMessageError {
|
|
2
3
|
name: string;
|
|
3
4
|
}
|
|
4
5
|
export declare class UnparserImplementationError extends UnparserError {
|
package/build/unparserError.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type Falsy, type ValueOrAccessor } from './customInvariant.js';
|
|
2
|
-
export declare function unparserImplementationInvariant<T>(value: T, format: ValueOrAccessor<string | string[]>, ...formatArguments:
|
|
2
|
+
export declare function unparserImplementationInvariant<T>(value: T, format: ValueOrAccessor<string | string[]>, ...formatArguments: unknown[]): Exclude<T, Falsy>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StringParserInputCompanion, Uint8ArrayParserInputCompanion } from
|
|
1
|
+
import { StringParserInputCompanion, Uint8ArrayParserInputCompanion } from './parserInputCompanion.js';
|
|
2
2
|
export type UnparserOutputCompanion<Sequence, Element> = {
|
|
3
3
|
is(value: unknown): value is Sequence;
|
|
4
4
|
from(elements: Element[]): Sequence;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StringParserInputCompanion, Uint8ArrayParserInputCompanion } from
|
|
1
|
+
import { StringParserInputCompanion, Uint8ArrayParserInputCompanion } from './parserInputCompanion.js';
|
|
2
2
|
export class StringUnparserOutputCompanion extends StringParserInputCompanion {
|
|
3
3
|
concat(sequences) {
|
|
4
4
|
return sequences.join('');
|
package/build/zipParser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Parser } from './parser.js';
|
|
2
2
|
import { type Zip, type ZipCompression, type ZipEntry } from './zip.js';
|
|
3
|
-
type ZipLocalFileHeader = {
|
|
3
|
+
export type ZipLocalFileHeader = {
|
|
4
4
|
versionNeededToExtract: number;
|
|
5
5
|
generalPurposeBitFlag: number;
|
|
6
6
|
compressionMethod: ZipCompression;
|
|
@@ -11,11 +11,16 @@ type ZipLocalFileHeader = {
|
|
|
11
11
|
filePath: string;
|
|
12
12
|
extraField: Uint8Array;
|
|
13
13
|
};
|
|
14
|
+
type ZipDataDescriptor = {
|
|
15
|
+
crc32: number;
|
|
16
|
+
compressedSize: number;
|
|
17
|
+
uncompressedSize: number;
|
|
18
|
+
};
|
|
14
19
|
export type ZipLocalFile = {
|
|
15
20
|
zipLocalFileHeader: ZipLocalFileHeader;
|
|
16
21
|
zipEncryptionHeader: unknown;
|
|
17
22
|
compressedData: Uint8Array;
|
|
18
|
-
zipDataDescriptor:
|
|
23
|
+
zipDataDescriptor: undefined | ZipDataDescriptor;
|
|
19
24
|
};
|
|
20
25
|
export declare const zipLocalFileParser: Parser<ZipLocalFile, Uint8Array>;
|
|
21
26
|
export declare const zipArchiveDecryptionHeaderParser: Parser<unknown, Uint8Array>;
|
package/build/zipParser.js
CHANGED
|
@@ -11,6 +11,8 @@ import { createFixedLengthSequenceParser } from './fixedLengthSequenceParser.js'
|
|
|
11
11
|
import { createOptionalParser } from './optionalParser.js';
|
|
12
12
|
import { parserCreatorCompose } from './parserCreatorCompose.js';
|
|
13
13
|
import { uint8ArrayAsyncIterableToUint8Array } from './uint8Array.js';
|
|
14
|
+
import { createNegativeLookaheadParser } from './negativeLookaheadParser.js';
|
|
15
|
+
import { createSequenceTerminatedSequenceParser } from './sequenceTerminatedSequenceParser.js';
|
|
14
16
|
// https://pkwaredownloads.blob.core.windows.net/pem/APPNOTE.txt
|
|
15
17
|
const uint16LEParser = promiseCompose(createFixedLengthSequenceParser(2), array => Buffer.from(array).readUInt16LE());
|
|
16
18
|
setParserName(uint16LEParser, 'uint16LEParser');
|
|
@@ -29,8 +31,9 @@ const zipCompressionMethodParser = promiseCompose(uint16LEParser, compressionMet
|
|
|
29
31
|
}
|
|
30
32
|
invariant(false, 'Unsupported compression method %s', compressionMethod);
|
|
31
33
|
});
|
|
34
|
+
const zipLocalFileHeaderSignatureParser = createExactSequenceParser(Buffer.from('504b0304', 'hex'));
|
|
32
35
|
const zipLocalFileHeaderParser_ = createTupleParser([
|
|
33
|
-
|
|
36
|
+
zipLocalFileHeaderSignatureParser,
|
|
34
37
|
uint16LEParser,
|
|
35
38
|
uint16LEParser,
|
|
36
39
|
zipCompressionMethodParser,
|
|
@@ -61,20 +64,40 @@ const zipLocalFileHeaderParser = promiseCompose(zipLocalFileHeaderParser_, ([_zi
|
|
|
61
64
|
const zipEncryptionHeaderParser = async (parserContext) => {
|
|
62
65
|
parserContext.invariant(false, 'Not implemented');
|
|
63
66
|
};
|
|
64
|
-
const
|
|
67
|
+
const zipDataDescriptorSignature = Buffer.from('504b0708', 'hex');
|
|
68
|
+
const zipDataDescriptorSignatureParser = createExactSequenceParser(zipDataDescriptorSignature);
|
|
69
|
+
const zipDataDescriptorParser = promiseCompose(createTupleParser([
|
|
70
|
+
createNegativeLookaheadParser(zipLocalFileHeaderSignatureParser),
|
|
65
71
|
// FIXME: optional in spec
|
|
66
|
-
// createOptionalParser(
|
|
67
|
-
|
|
72
|
+
// createOptionalParser(zipDataDescriptorSignatureParser),
|
|
73
|
+
zipDataDescriptorSignatureParser,
|
|
68
74
|
uint32LEParser,
|
|
69
75
|
uint32LEParser,
|
|
70
76
|
uint32LEParser,
|
|
71
|
-
])
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
]), ([_notZipLocalFileHeaderSignature, _zipDataDescriptorSignature, crc32, compressedSize, uncompressedSize,]) => ({
|
|
78
|
+
crc32,
|
|
79
|
+
compressedSize,
|
|
80
|
+
uncompressedSize,
|
|
81
|
+
}));
|
|
82
|
+
setParserName(zipDataDescriptorParser, 'zipDataDescriptorParser');
|
|
83
|
+
export const zipLocalFileParser = promiseCompose(parserCreatorCompose(() => zipLocalFileHeaderParser, zipLocalFileHeader => {
|
|
84
|
+
const sizeInDataDescriptor = Boolean(zipLocalFileHeader.generalPurposeBitFlag & 0b0000_0000_0000_1000
|
|
85
|
+
&& zipLocalFileHeader.crc32 === 0
|
|
86
|
+
&& zipLocalFileHeader.compressedSize === 0
|
|
87
|
+
&& zipLocalFileHeader.uncompressedSize === 0);
|
|
88
|
+
return createTupleParser([
|
|
89
|
+
async () => zipLocalFileHeader,
|
|
90
|
+
createOptionalParser(zipEncryptionHeaderParser),
|
|
91
|
+
(sizeInDataDescriptor
|
|
92
|
+
? createSequenceTerminatedSequenceParser(zipDataDescriptorSignature, {
|
|
93
|
+
consumeTerminator: false,
|
|
94
|
+
})
|
|
95
|
+
: createFixedLengthSequenceParser(zipLocalFileHeader.compressedSize)),
|
|
96
|
+
(sizeInDataDescriptor
|
|
97
|
+
? ((parser) => parser)
|
|
98
|
+
: createOptionalParser)(zipDataDescriptorParser),
|
|
99
|
+
]);
|
|
100
|
+
})(), ([zipLocalFileHeader, zipEncryptionHeader, compressedData, zipDataDescriptor,]) => ({
|
|
78
101
|
zipLocalFileHeader,
|
|
79
102
|
zipEncryptionHeader,
|
|
80
103
|
compressedData,
|
|
@@ -163,7 +186,7 @@ const zipEndOfCentralDirectoryRecordParser_ = createTupleParser([
|
|
|
163
186
|
uint32LEParser,
|
|
164
187
|
zipFileCommentParser,
|
|
165
188
|
]);
|
|
166
|
-
setParserName(zipEndOfCentralDirectoryRecordParser_, '
|
|
189
|
+
setParserName(zipEndOfCentralDirectoryRecordParser_, 'zipEndOfCentralDirectoryRecordParser_');
|
|
167
190
|
export const zipEndOfCentralDirectoryRecordParser = promiseCompose(zipEndOfCentralDirectoryRecordParser_, ([_endOfCentralDirectoryRecordSignature, numberOfThisDisk, numberOfTheDiskWithTheStartOfTheCentralDirectory, totalNumberOfEntriesInTheCentralDirectoryOnThisDisk, totalNumberOfEntriesInTheCentralDirectory, sizeOfTheCentralDirectory, offsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber, zipFileComment,]) => ({
|
|
168
191
|
numberOfThisDisk,
|
|
169
192
|
numberOfTheDiskWithTheStartOfTheCentralDirectory,
|
|
@@ -173,6 +196,7 @@ export const zipEndOfCentralDirectoryRecordParser = promiseCompose(zipEndOfCentr
|
|
|
173
196
|
offsetOfStartOfCentralDirectoryWithRespectToTheStartingDiskNumber,
|
|
174
197
|
zipFileComment,
|
|
175
198
|
}));
|
|
199
|
+
setParserName(zipEndOfCentralDirectoryRecordParser, 'zipEndOfCentralDirectoryRecordParser');
|
|
176
200
|
const zipParser_ = createTupleParser([
|
|
177
201
|
createArrayParser(zipLocalFileParser),
|
|
178
202
|
createOptionalParser(zipArchiveDecryptionHeaderParser),
|
package/build/zipUnparser.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { Unparser } from
|
|
2
|
-
import { Zip } from
|
|
3
|
-
import { ZipEndOfCentralDirectoryRecord } from './zipParser.js';
|
|
1
|
+
import { type Unparser } from './unparser.js';
|
|
2
|
+
import { type Zip } from './zip.js';
|
|
3
|
+
import { type ZipEndOfCentralDirectoryRecord } from './zipParser.js';
|
|
4
4
|
export declare const zipEndOfCentralDirectoryRecordUnparser: Unparser<ZipEndOfCentralDirectoryRecord, Uint8Array>;
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const createZipUnparser: ({ dataDescriptor, }?: {
|
|
6
|
+
dataDescriptor?: boolean;
|
|
7
|
+
}) => Unparser<Zip, Uint8Array>;
|
|
8
|
+
export declare const zipUnparser: Unparser<Zip, Uint8Array<ArrayBufferLike>>;
|