@fgv/ts-extras 5.1.0-19 → 5.1.0-20
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/dist/index.browser.js.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/packlets/ai-assist/apiClient.js.map +1 -0
- package/dist/packlets/ai-assist/chatRequestBuilders.js.map +1 -0
- package/dist/packlets/ai-assist/converters.js.map +1 -0
- package/dist/packlets/ai-assist/index.js.map +1 -0
- package/dist/packlets/ai-assist/model.js.map +1 -0
- package/dist/packlets/ai-assist/registry.js.map +1 -0
- package/dist/packlets/ai-assist/sseParser.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/anthropic.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/common.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/gemini.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/openaiChat.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/openaiResponses.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/proxy.js.map +1 -0
- package/dist/packlets/ai-assist/streamingClient.js.map +1 -0
- package/dist/packlets/ai-assist/toolFormats.js.map +1 -0
- package/dist/packlets/conversion/converters.js.map +1 -0
- package/dist/packlets/conversion/index.js.map +1 -0
- package/dist/packlets/crypto-utils/constants.js.map +1 -0
- package/dist/packlets/crypto-utils/converters.js.map +1 -0
- package/dist/packlets/crypto-utils/directEncryptionProvider.js.map +1 -0
- package/dist/packlets/crypto-utils/encryptedFile.js.map +1 -0
- package/dist/packlets/crypto-utils/index.browser.js.map +1 -0
- package/dist/packlets/crypto-utils/index.js.map +1 -0
- package/dist/packlets/crypto-utils/keyPairAlgorithmParams.js +10 -0
- package/dist/packlets/crypto-utils/keyPairAlgorithmParams.js.map +1 -0
- package/dist/packlets/crypto-utils/keystore/converters.js.map +1 -0
- package/dist/packlets/crypto-utils/keystore/index.js.map +1 -0
- package/dist/packlets/crypto-utils/keystore/keyStore.js.map +1 -0
- package/dist/packlets/crypto-utils/keystore/model.js.map +1 -0
- package/dist/packlets/crypto-utils/keystore/privateKeyStorage.js.map +1 -0
- package/dist/packlets/crypto-utils/model.js +5 -1
- package/dist/packlets/crypto-utils/model.js.map +1 -0
- package/dist/packlets/crypto-utils/nodeCryptoProvider.js.map +1 -0
- package/dist/packlets/csv/csvFileHelpers.js.map +1 -0
- package/dist/packlets/csv/csvHelpers.js.map +1 -0
- package/dist/packlets/csv/index.browser.js.map +1 -0
- package/dist/packlets/csv/index.js.map +1 -0
- package/dist/packlets/experimental/extendedArray.js.map +1 -0
- package/dist/packlets/experimental/formatter.js.map +1 -0
- package/dist/packlets/experimental/index.js.map +1 -0
- package/dist/packlets/experimental/rangeOf.js.map +1 -0
- package/dist/packlets/hash/index.browser.js.map +1 -0
- package/dist/packlets/hash/index.js.map +1 -0
- package/dist/packlets/hash/index.node.js.map +1 -0
- package/dist/packlets/hash/md5Normalizer.browser.js.map +1 -0
- package/dist/packlets/hash/md5Normalizer.js.map +1 -0
- package/dist/packlets/mustache/index.js.map +1 -0
- package/dist/packlets/mustache/interfaces.js.map +1 -0
- package/dist/packlets/mustache/mustacheTemplate.js.map +1 -0
- package/dist/packlets/record-jar/index.browser.js.map +1 -0
- package/dist/packlets/record-jar/index.js.map +1 -0
- package/dist/packlets/record-jar/recordJarFileHelpers.js.map +1 -0
- package/dist/packlets/record-jar/recordJarHelpers.js.map +1 -0
- package/dist/packlets/yaml/converters.js.map +1 -0
- package/dist/packlets/yaml/index.js.map +1 -0
- package/dist/packlets/yaml/serializers.js.map +1 -0
- package/dist/packlets/zip-file-tree/index.js.map +1 -0
- package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js.map +1 -0
- package/dist/packlets/zip-file-tree/zipFileTreeWriter.js.map +1 -0
- package/dist/ts-extras.d.ts +5 -1
- package/lib/index.browser.d.ts.map +1 -0
- package/lib/index.browser.js.map +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js.map +1 -0
- package/lib/packlets/ai-assist/apiClient.d.ts.map +1 -0
- package/lib/packlets/ai-assist/apiClient.js.map +1 -0
- package/lib/packlets/ai-assist/chatRequestBuilders.d.ts.map +1 -0
- package/lib/packlets/ai-assist/chatRequestBuilders.js.map +1 -0
- package/lib/packlets/ai-assist/converters.d.ts.map +1 -0
- package/lib/packlets/ai-assist/converters.js.map +1 -0
- package/lib/packlets/ai-assist/index.d.ts.map +1 -0
- package/lib/packlets/ai-assist/index.js.map +1 -0
- package/lib/packlets/ai-assist/model.d.ts.map +1 -0
- package/lib/packlets/ai-assist/model.js.map +1 -0
- package/lib/packlets/ai-assist/registry.d.ts.map +1 -0
- package/lib/packlets/ai-assist/registry.js.map +1 -0
- package/lib/packlets/ai-assist/sseParser.d.ts.map +1 -0
- package/lib/packlets/ai-assist/sseParser.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/anthropic.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/anthropic.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/common.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/common.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/gemini.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/gemini.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiChat.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiChat.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/proxy.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/proxy.js.map +1 -0
- package/lib/packlets/ai-assist/streamingClient.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingClient.js.map +1 -0
- package/lib/packlets/ai-assist/toolFormats.d.ts.map +1 -0
- package/lib/packlets/ai-assist/toolFormats.js.map +1 -0
- package/lib/packlets/conversion/converters.d.ts.map +1 -0
- package/lib/packlets/conversion/converters.js.map +1 -0
- package/lib/packlets/conversion/index.d.ts.map +1 -0
- package/lib/packlets/conversion/index.js.map +1 -0
- package/lib/packlets/crypto-utils/constants.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/constants.js.map +1 -0
- package/lib/packlets/crypto-utils/converters.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/converters.js.map +1 -0
- package/lib/packlets/crypto-utils/directEncryptionProvider.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/directEncryptionProvider.js.map +1 -0
- package/lib/packlets/crypto-utils/encryptedFile.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/encryptedFile.js.map +1 -0
- package/lib/packlets/crypto-utils/index.browser.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/index.browser.js.map +1 -0
- package/lib/packlets/crypto-utils/index.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/index.js.map +1 -0
- package/lib/packlets/crypto-utils/keyPairAlgorithmParams.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keyPairAlgorithmParams.js +10 -0
- package/lib/packlets/crypto-utils/keyPairAlgorithmParams.js.map +1 -0
- package/lib/packlets/crypto-utils/keystore/converters.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keystore/converters.js.map +1 -0
- package/lib/packlets/crypto-utils/keystore/index.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keystore/index.js.map +1 -0
- package/lib/packlets/crypto-utils/keystore/keyStore.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keystore/keyStore.js.map +1 -0
- package/lib/packlets/crypto-utils/keystore/model.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keystore/model.js.map +1 -0
- package/lib/packlets/crypto-utils/keystore/privateKeyStorage.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keystore/privateKeyStorage.js.map +1 -0
- package/lib/packlets/crypto-utils/model.d.ts +5 -1
- package/lib/packlets/crypto-utils/model.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/model.js +5 -1
- package/lib/packlets/crypto-utils/model.js.map +1 -0
- package/lib/packlets/crypto-utils/nodeCryptoProvider.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/nodeCryptoProvider.js.map +1 -0
- package/lib/packlets/csv/csvFileHelpers.d.ts.map +1 -0
- package/lib/packlets/csv/csvFileHelpers.js.map +1 -0
- package/lib/packlets/csv/csvHelpers.d.ts.map +1 -0
- package/lib/packlets/csv/csvHelpers.js.map +1 -0
- package/lib/packlets/csv/index.browser.d.ts.map +1 -0
- package/lib/packlets/csv/index.browser.js.map +1 -0
- package/lib/packlets/csv/index.d.ts.map +1 -0
- package/lib/packlets/csv/index.js.map +1 -0
- package/lib/packlets/experimental/extendedArray.d.ts.map +1 -0
- package/lib/packlets/experimental/extendedArray.js.map +1 -0
- package/lib/packlets/experimental/formatter.d.ts.map +1 -0
- package/lib/packlets/experimental/formatter.js.map +1 -0
- package/lib/packlets/experimental/index.d.ts.map +1 -0
- package/lib/packlets/experimental/index.js.map +1 -0
- package/lib/packlets/experimental/rangeOf.d.ts.map +1 -0
- package/lib/packlets/experimental/rangeOf.js.map +1 -0
- package/lib/packlets/hash/index.browser.d.ts.map +1 -0
- package/lib/packlets/hash/index.browser.js.map +1 -0
- package/lib/packlets/hash/index.d.ts.map +1 -0
- package/lib/packlets/hash/index.js.map +1 -0
- package/lib/packlets/hash/index.node.d.ts.map +1 -0
- package/lib/packlets/hash/index.node.js.map +1 -0
- package/lib/packlets/hash/md5Normalizer.browser.d.ts.map +1 -0
- package/lib/packlets/hash/md5Normalizer.browser.js.map +1 -0
- package/lib/packlets/hash/md5Normalizer.d.ts.map +1 -0
- package/lib/packlets/hash/md5Normalizer.js.map +1 -0
- package/lib/packlets/mustache/index.d.ts.map +1 -0
- package/lib/packlets/mustache/index.js.map +1 -0
- package/lib/packlets/mustache/interfaces.d.ts.map +1 -0
- package/lib/packlets/mustache/interfaces.js.map +1 -0
- package/lib/packlets/mustache/mustacheTemplate.d.ts.map +1 -0
- package/lib/packlets/mustache/mustacheTemplate.js.map +1 -0
- package/lib/packlets/record-jar/index.browser.d.ts.map +1 -0
- package/lib/packlets/record-jar/index.browser.js.map +1 -0
- package/lib/packlets/record-jar/index.d.ts.map +1 -0
- package/lib/packlets/record-jar/index.js.map +1 -0
- package/lib/packlets/record-jar/recordJarFileHelpers.d.ts.map +1 -0
- package/lib/packlets/record-jar/recordJarFileHelpers.js.map +1 -0
- package/lib/packlets/record-jar/recordJarHelpers.d.ts.map +1 -0
- package/lib/packlets/record-jar/recordJarHelpers.js.map +1 -0
- package/lib/packlets/yaml/converters.d.ts.map +1 -0
- package/lib/packlets/yaml/converters.js.map +1 -0
- package/lib/packlets/yaml/index.d.ts.map +1 -0
- package/lib/packlets/yaml/index.js.map +1 -0
- package/lib/packlets/yaml/serializers.d.ts.map +1 -0
- package/lib/packlets/yaml/serializers.js.map +1 -0
- package/lib/packlets/zip-file-tree/index.d.ts.map +1 -0
- package/lib/packlets/zip-file-tree/index.js.map +1 -0
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts.map +1 -0
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js.map +1 -0
- package/lib/packlets/zip-file-tree/zipFileTreeWriter.d.ts.map +1 -0
- package/lib/packlets/zip-file-tree/zipFileTreeWriter.js.map +1 -0
- package/package.json +7 -7
- package/dist/test/unit/crypto/keystore/inMemoryPrivateKeyStorage.js +0 -78
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/hash/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,kDAAgC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './md5Normalizer';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.node.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/index.node.ts"],"names":[],"mappings":"AAwBA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.node.js","sourceRoot":"","sources":["../../../src/packlets/hash/index.node.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,kFAAkF;AAClF,+DAA+D;AAC/D,kDAAgC;AAChC,oBAAoB","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/* c8 ignore start - Node.js-specific export used conditionally in package.json */\n// Node.js hash exports - includes crypto-based implementations\nexport * from './md5Normalizer';\n/* c8 ignore stop */\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md5Normalizer.browser.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.browser.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC;;;;;;;;GAQG;AACH,qBAAa,aAAc,SAAQ,IAAI,CAAC,eAAe;CAGtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md5Normalizer.browser.js","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,4CAAqC;AAErC;;;;;;;;GAQG;AACH,MAAa,aAAc,SAAQ,eAAI,CAAC,eAAe;CAGtD;AAHD,sCAGC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Hash } from '@fgv/ts-utils';\n\n/**\n * Browser-compatible MD5 normalizer that uses CRC32 hashing for cross-platform compatibility.\n * This provides the same interface as the Node.js MD5 version but uses CRC32 algorithm\n * which works consistently across both Node.js and browser environments.\n *\n * Note: While this is named Md5Normalizer for API compatibility, it actually uses CRC32\n * hashing to ensure cross-platform compatibility between Node.js and browser environments.\n * @public\n */\nexport class Md5Normalizer extends Hash.Crc32Normalizer {\n // CRC32 normalizer is already cross-platform compatible\n // No additional implementation needed - inherits everything from Crc32Normalizer\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md5Normalizer.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,IAAI,CAAC,iBAAiB;;WAKzC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;CAG/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md5Normalizer.js","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAqC;AACrC,+CAAiC;AACjC;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAI,CAAC,iBAAiB;IACvD;QACE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,OAAO,CAAC,KAAe;QACnC,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC;CACF;AARD,sCAQC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Hash } from '@fgv/ts-utils';\nimport * as crypto from 'crypto';\n/**\n * A hashing normalizer which computes object\n * hash using the MD5 algorithm.\n * @public\n */\nexport class Md5Normalizer extends Hash.HashingNormalizer {\n public constructor() {\n super(Md5Normalizer.md5Hash);\n }\n\n public static md5Hash(parts: string[]): string {\n return crypto.createHash('md5').update(parts.join('|'), 'utf8').digest('hex');\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/mustache/index.ts"],"names":[],"mappings":"AAsBA,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/mustache/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAUH,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport {\n IContextValidationResult,\n IMissingVariableDetail,\n IMustacheTemplateOptions,\n IVariableRef,\n MustacheTokenType\n} from './interfaces';\n\nexport { MustacheTemplate } from './mustacheTemplate';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/packlets/mustache/interfaces.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,MAAM,GACN,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,CAAC;AAER;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IAEtC;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAEhC;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAE7C;;OAEG;IACH,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAE7C;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,SAAS,sBAAsB,EAAE,CAAC;CAC5D;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/packlets/mustache/interfaces.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D;;;;;;;;;;;;;;;;;;;;GAoBG;;AA0HH,oBAAoB","sourcesContent":["/* c8 ignore start - Type definitions only, no runtime code */\n/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * Type of a Mustache token as returned by Mustache.parse()\n * @public\n */\nexport type MustacheTokenType =\n | 'text' // Raw text\n | 'name' // {{ variable }} - escaped value\n | '&' // {{{ variable }}} or {{& variable }} - unescaped value\n | '#' // {{# section }} - section start\n | '^' // {{^ section }} - inverted section\n | '!' // {{! comment }} - comment\n | '>' // {{> partial }} - partial\n | '='; // {{= =}} - set delimiter\n\n/**\n * Represents a variable reference extracted from a Mustache template.\n * @public\n */\nexport interface IVariableRef {\n /**\n * The raw variable name as it appears in the template (e.g., 'user.name')\n */\n readonly name: string;\n\n /**\n * The path segments parsed from the variable name (e.g., ['user', 'name'])\n */\n readonly path: readonly string[];\n\n /**\n * The type of token this variable was extracted from\n */\n readonly tokenType: MustacheTokenType;\n\n /**\n * Whether this variable is used in a section context (# or ^)\n * Section variables may reference arrays/objects for iteration\n */\n readonly isSection: boolean;\n}\n\n/**\n * Details about a missing variable in context validation.\n * @public\n */\nexport interface IMissingVariableDetail {\n /**\n * The variable reference that is missing\n */\n readonly variable: IVariableRef;\n\n /**\n * The path segment where the lookup failed\n * (e.g., for 'user.profile.name' if 'profile' is missing, this would be 'profile')\n */\n readonly failedAtSegment?: string;\n\n /**\n * The parent path that exists (e.g., ['user'] if 'user' exists but 'user.profile' does not)\n */\n readonly existingPath: readonly string[];\n}\n\n/**\n * Result of context validation, containing details about missing variables.\n * @public\n */\nexport interface IContextValidationResult {\n /**\n * Whether the context is valid (has all required variables)\n */\n readonly isValid: boolean;\n\n /**\n * Variables that are present in the context\n */\n readonly presentVariables: readonly string[];\n\n /**\n * Variables that are missing from the context\n */\n readonly missingVariables: readonly string[];\n\n /**\n * Detailed information about each missing variable\n */\n readonly missingDetails: readonly IMissingVariableDetail[];\n}\n\n/**\n * Options for template parsing and validation.\n * @public\n */\nexport interface IMustacheTemplateOptions {\n /**\n * Custom opening and closing tags (default: `['{{', '}}']`)\n */\n readonly tags?: readonly [string, string];\n\n /**\n * Whether to include comment tokens in variable extraction (default: false)\n */\n readonly includeComments?: boolean;\n\n /**\n * Whether to include partial references in variable extraction (default: false)\n */\n readonly includePartials?: boolean;\n}\n\n/**\n * Required version of options with all fields populated.\n * @internal\n */\nexport interface IRequiredMustacheTemplateOptions {\n readonly tags: [string, string];\n readonly includeComments: boolean;\n readonly includePartials: boolean;\n}\n\n/* c8 ignore stop */\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mustacheTemplate.d.ts","sourceRoot":"","sources":["../../../src/packlets/mustache/mustacheTemplate.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAgC,MAAM,eAAe,CAAC;AAGrE,OAAO,EACL,wBAAwB,EAExB,wBAAwB,EACxB,gCAAgC,EAChC,YAAY,EAEb,MAAM,cAAc,CAAC;AAWtB;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,SAAgB,OAAO,EAAE,QAAQ,CAAC,gCAAgC,CAAC,CAAC;IAEpE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgB;IACxC,OAAO,CAAC,UAAU,CAAC,CAA0B;IAE7C,OAAO;IAMP;;;;;OAKG;WACW,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAOpG;;;;;OAKG;WACW,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,MAAM,CAAC,IAAI,CAAC;IAK1F;;;;OAIG;IACI,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC;IAI/B;;;OAGG;IACI,gBAAgB,IAAI,SAAS,YAAY,EAAE;IAOlD;;;OAGG;IACI,oBAAoB,IAA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YACvB,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IACvC,CAAC;CACF;AA/PD,4CA+PC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, fail, succeed } from '@fgv/ts-utils';\nimport Mustache, { TemplateSpans } from 'mustache';\n\nimport {\n IContextValidationResult,\n IMissingVariableDetail,\n IMustacheTemplateOptions,\n IRequiredMustacheTemplateOptions,\n IVariableRef,\n MustacheTokenType\n} from './interfaces';\n\n/**\n * Default options for MustacheTemplate\n */\nconst DEFAULT_OPTIONS: IRequiredMustacheTemplateOptions = {\n tags: ['{{', '}}'],\n includeComments: false,\n includePartials: false\n};\n\n/**\n * A helper class for working with Mustache templates that provides\n * validation, variable extraction, and context validation utilities.\n * @public\n */\nexport class MustacheTemplate {\n /**\n * The original template string\n */\n public readonly template: string;\n\n /**\n * The options used for parsing this template\n */\n public readonly options: Readonly<IRequiredMustacheTemplateOptions>;\n\n private readonly _tokens: TemplateSpans;\n private _variables?: readonly IVariableRef[];\n\n private constructor(template: string, tokens: TemplateSpans, options: IRequiredMustacheTemplateOptions) {\n this.template = template;\n this._tokens = tokens;\n this.options = options;\n }\n\n /**\n * Creates a new MustacheTemplate instance.\n * @param template - The Mustache template string to parse\n * @param options - Optional parsing options\n * @returns Success with the template instance, or Failure if parsing fails\n */\n public static create(template: string, options?: IMustacheTemplateOptions): Result<MustacheTemplate> {\n const resolvedOptions = MustacheTemplate._resolveOptions(options);\n return MustacheTemplate._parseTokens(template, resolvedOptions).onSuccess((tokens) => {\n return succeed(new MustacheTemplate(template, tokens, resolvedOptions));\n });\n }\n\n /**\n * Validates that a template string has valid Mustache syntax.\n * @param template - The template string to validate\n * @param options - Optional parsing options\n * @returns Success with true if valid, or Failure with a descriptive error message\n */\n public static validate(template: string, options?: IMustacheTemplateOptions): Result<true> {\n const resolvedOptions = MustacheTemplate._resolveOptions(options);\n return MustacheTemplate._parseTokens(template, resolvedOptions).onSuccess(() => succeed(true as const));\n }\n\n /**\n * Checks if this template instance has valid syntax.\n * Always returns Success(true) since parsing succeeded in create().\n * @returns Success with true\n */\n public validate(): Result<true> {\n return succeed(true as const);\n }\n\n /**\n * Extracts all variable references from the template.\n * @returns An array of variable references found in the template\n */\n public extractVariables(): readonly IVariableRef[] {\n if (this._variables === undefined) {\n this._variables = this._extractVariablesFromTokens(this._tokens);\n }\n return this._variables;\n }\n\n /**\n * Extracts unique variable names from the template.\n * @returns An array of unique variable name strings (e.g., ['user.name', 'items'])\n */\n public extractVariableNames(): readonly string[] {\n const variables = this.extractVariables();\n const seen = new Set<string>();\n const names: string[] = [];\n\n for (const variable of variables) {\n if (!seen.has(variable.name)) {\n seen.add(variable.name);\n names.push(variable.name);\n }\n }\n\n return names;\n }\n\n /**\n * Validates that a context object has all required variables.\n * @param context - The context object to validate\n * @returns Success with validation result containing details about present/missing variables\n */\n public validateContext(context: unknown): Result<IContextValidationResult> {\n const variables = this.extractVariables();\n const presentVariables: string[] = [];\n const missingVariables: string[] = [];\n const missingDetails: IMissingVariableDetail[] = [];\n const checked = new Set<string>();\n\n for (const variable of variables) {\n if (checked.has(variable.name)) {\n continue;\n }\n checked.add(variable.name);\n\n const lookup = this._lookupPath(context, variable.path);\n\n if (lookup.found) {\n presentVariables.push(variable.name);\n } else {\n missingVariables.push(variable.name);\n missingDetails.push({\n variable,\n failedAtSegment: lookup.failedAt,\n existingPath: lookup.existingPath\n });\n }\n }\n\n return succeed({\n isValid: missingVariables.length === 0,\n presentVariables,\n missingVariables,\n missingDetails\n });\n }\n\n /**\n * Renders the template with the given context.\n * Use this for pre-validated contexts where you've already checked\n * that all required variables are present.\n * @param context - The context object for template rendering\n * @returns Success with the rendered string, or Failure if rendering fails\n */\n public render(context: unknown): Result<string> {\n return captureResult(() => Mustache.render(this.template, context));\n }\n\n /**\n * Validates the context and renders the template if validation passes.\n * @param context - The context object to validate and render with\n * @returns Success with the rendered string, or Failure with validation or render errors\n */\n public validateAndRender(context: unknown): Result<string> {\n return this.validateContext(context).onSuccess((validation) => {\n if (!validation.isValid) {\n const missing = validation.missingVariables.join(', ');\n return fail(`Missing required variables: ${missing}`);\n }\n return this.render(context);\n });\n }\n\n private static _resolveOptions(options?: IMustacheTemplateOptions): IRequiredMustacheTemplateOptions {\n if (options === undefined) {\n return DEFAULT_OPTIONS;\n }\n\n return {\n tags: options.tags ? [options.tags[0], options.tags[1]] : DEFAULT_OPTIONS.tags,\n includeComments: options.includeComments ?? DEFAULT_OPTIONS.includeComments,\n includePartials: options.includePartials ?? DEFAULT_OPTIONS.includePartials\n };\n }\n\n private static _parseTokens(\n template: string,\n options: IRequiredMustacheTemplateOptions\n ): Result<TemplateSpans> {\n return captureResult(() => Mustache.parse(template, options.tags));\n }\n\n private _extractVariablesFromTokens(tokens: TemplateSpans): IVariableRef[] {\n const variables: IVariableRef[] = [];\n\n for (const token of tokens) {\n const type = token[0] as MustacheTokenType;\n const value = token[1] as string;\n\n // Skip text tokens\n if (type === 'text') {\n continue;\n }\n\n // Handle comments based on options\n if (type === '!' && !this.options.includeComments) {\n continue;\n }\n\n // Handle partials based on options\n if (type === '>' && !this.options.includePartials) {\n continue;\n }\n\n // Handle variable tokens: 'name', '&', '#', '^', and optionally '!', '>'\n if (type === 'name' || type === '&' || type === '#' || type === '^' || type === '!' || type === '>') {\n const isSection = type === '#' || type === '^';\n variables.push({\n name: value,\n path: this._parsePath(value),\n tokenType: type,\n isSection\n });\n }\n\n // Recursively extract from nested tokens in sections\n if ((type === '#' || type === '^') && token.length > 4) {\n const nestedTokens = token[4] as TemplateSpans;\n if (nestedTokens) {\n variables.push(...this._extractVariablesFromTokens(nestedTokens));\n }\n }\n }\n\n return variables;\n }\n\n private _parsePath(name: string): readonly string[] {\n // Handle special case of '.' which means current context\n if (name === '.') {\n return ['.'];\n }\n\n // Split on dots to get path segments\n return name.split('.').filter((segment) => segment.length > 0);\n }\n\n private _lookupPath(\n context: unknown,\n path: readonly string[]\n ): { found: boolean; existingPath: string[]; failedAt?: string } {\n // Handle '.' which always exists if context is not null/undefined\n if (path.length === 1 && path[0] === '.') {\n return { found: context !== undefined && context !== null, existingPath: [] };\n }\n\n let current: unknown = context;\n const existingPath: string[] = [];\n\n for (const segment of path) {\n if (current === undefined || current === null) {\n return { found: false, existingPath, failedAt: segment };\n }\n\n if (typeof current !== 'object') {\n return { found: false, existingPath, failedAt: segment };\n }\n\n const obj = current as Record<string, unknown>;\n if (!(segment in obj)) {\n return { found: false, existingPath, failedAt: segment };\n }\n\n current = obj[segment];\n existingPath.push(segment);\n }\n\n return { found: true, existingPath };\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../../src/packlets/record-jar/index.browser.ts"],"names":[],"mappings":"AAyBA,cAAc,oBAAoB,CAAC;AAGnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../../src/packlets/record-jar/index.browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;AAEH,4EAA4E;AAE5E,gDAAgD;AAChD,qDAAmC;AAEnC,iDAAiD;AACjD,+DAA+D;AAAtD,6HAAA,qBAAqB,OAAA;AAE9B,WAAW;AACX,qDAAqD","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// Browser-safe RecordJar exports - excludes Node.js filesystem dependencies\n\n// Export all browser-safe parsing functionality\nexport * from './recordJarHelpers';\n\n// Export FileTree-based reading (web-compatible)\nexport { readRecordJarFromTree } from './recordJarFileHelpers';\n\n// Exclude:\n// - readRecordJarFileSync (requires Node.js fs/path)\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/record-jar/index.ts"],"names":[],"mappings":"AAuBA,cAAc,oBAAoB,CAAC;AAEnC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/record-jar/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,kCAAkC;AAClC,qDAAmC;AACnC,yDAAyD;AACzD,yDAAuC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n// Export tree-shakeable functions\nexport * from './recordJarHelpers';\n// Filesystem helpers in separate module for tree-shaking\nexport * from './recordJarFileHelpers';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordJarFileHelpers.d.ts","sourceRoot":"","sources":["../../../src/packlets/record-jar/recordJarFileHelpers.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAuB,MAAM,oBAAoB,CAAC;AAE5F;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CAAC,SAAS,EAAE,CAAC,CAOrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CAAC,SAAS,EAAE,CAAC,CAQrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordJarFileHelpers.js","sourceRoot":"","sources":["../../../src/packlets/record-jar/recordJarFileHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBH,sDAUC;AAWD,sDAYC;AAhDD,uCAAyB;AACzB,2CAA6B;AAE7B,4CAAsD;AAEtD,yDAA4F;AAE5F;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,OAAe,EACf,OAAgC;IAEhC,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,OAAO,IAAA,sCAAmB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACnC,QAA2B,EAC3B,QAAgB,EAChB,OAAgC;IAEhC,OAAO,QAAQ;SACZ,OAAO,CAAC,QAAQ,CAAC;SACjB,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;SAC1C,SAAS,CAAC,CAAC,QAAQ,EAAE,EAAE;QACtB,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACtC,OAAO,IAAA,sCAAmB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["/*\n * Copyright (c) 2022 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { Result, captureResult } from '@fgv/ts-utils';\nimport { FileTree } from '@fgv/ts-json-base';\nimport { JarRecord, JarRecordParserOptions, parseRecordJarLines } from './recordJarHelpers';\n\n/**\n * Reads a record-jar file from a supplied path.\n * @param srcPath - Source path from which the file is read.\n * @param options - Optional parser configuration\n * @returns The contents of the file as an array of `Record<string, string>`\n * @see https://datatracker.ietf.org/doc/html/draft-phillips-record-jar-01\n * @public\n */\nexport function readRecordJarFileSync(\n srcPath: string,\n options?: JarRecordParserOptions\n): Result<JarRecord[]> {\n return captureResult(() => {\n const fullPath = path.resolve(srcPath);\n return fs.readFileSync(fullPath, 'utf8').toString().split(/\\r?\\n/);\n }).onSuccess((lines) => {\n return parseRecordJarLines(lines, options);\n });\n}\n\n/**\n * Reads a record-jar file from a FileTree.\n * @param fileTree - The FileTree to read from.\n * @param filePath - Path of the file within the tree.\n * @param options - Optional parser configuration\n * @returns The contents of the file as an array of `Record<string, string>`\n * @see https://datatracker.ietf.org/doc/html/draft-phillips-record-jar-01\n * @public\n */\nexport function readRecordJarFromTree(\n fileTree: FileTree.FileTree,\n filePath: string,\n options?: JarRecordParserOptions\n): Result<JarRecord[]> {\n return fileTree\n .getFile(filePath)\n .onSuccess((file) => file.getRawContents())\n .onSuccess((contents) => {\n const lines = contents.split(/\\r?\\n/);\n return parseRecordJarLines(lines, options);\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordJarHelpers.d.ts","sourceRoot":"","sources":["../../../src/packlets/record-jar/recordJarHelpers.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAA0B,MAAM,eAAe,CAAC;AAO/D;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;AAEzF;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OAAO,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["/*\n * Copyright (c) 2022 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, fail, isKeyOf, succeed } from '@fgv/ts-utils';\n\ninterface IRecordBody {\n body: string;\n isContinuation: boolean;\n}\n\n/**\n * Represents a single record in a JAR file\n * @public\n */\nexport type JarRecord = Record<string, string | string[]>;\n\n/**\n * @public\n */\nexport type JarFieldPicker<T extends JarRecord = JarRecord> = (record: T) => (keyof T)[];\n\n/**\n * Options for a JAR record parser.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface JarRecordParserOptions {\n readonly arrayFields?: string[] | JarFieldPicker;\n readonly fixedContinuationSize?: number;\n}\n\nclass RecordParser {\n public readonly records: JarRecord[] = [];\n public readonly options: JarRecordParserOptions;\n\n protected _fields: JarRecord = {};\n protected _name: string | undefined = undefined;\n protected _body: IRecordBody | undefined = undefined;\n\n private constructor(options?: JarRecordParserOptions) {\n this.options = options ?? {};\n }\n\n public static parse(lines: string[], options?: JarRecordParserOptions): Result<JarRecord[]> {\n return new RecordParser(options)._parse(lines);\n }\n\n protected static _parseRecordBody(body: string): Result<IRecordBody> {\n const isContinuation = body.endsWith('\\\\');\n if (isContinuation) {\n body = body.slice(0, body.length - 1);\n }\n if (this._hasEscapes(body)) {\n const result = this._replaceEscapes(body);\n if (result.isFailure()) {\n return fail(result.message);\n }\n body = result.value;\n }\n return succeed({ body, isContinuation });\n }\n\n protected static _hasEscapes(from: string): boolean {\n return from.includes('\\\\') || from.includes('&');\n }\n\n protected static _replaceEscapes(body: string): Result<string> {\n const invalid: string[] = [];\n const escaped = body.replace(/(\\\\.)|(&#x[a-fA-F0-9]{2,6};)/g, (match) => {\n switch (match) {\n case '\\\\\\\\':\n return '\\\\';\n case '\\\\&':\n return '&';\n case '\\\\r':\n return '\\r';\n case '\\\\n':\n return '\\n';\n case '\\\\t':\n return '\\t';\n }\n if (match.startsWith('&')) {\n const hexCode = `0x${match.slice(3, match.length - 1)}`;\n const charCode = Number.parseInt(hexCode, 16);\n return String.fromCharCode(charCode);\n }\n invalid.push(match);\n return '\\\\';\n });\n if (invalid.length > 0) {\n return fail(`unrecognized escape \"${invalid.join(', ')}\" in record-jar body`);\n }\n return succeed(escaped);\n }\n\n protected static _applyOptions(record: JarRecord, options: JarRecordParserOptions): JarRecord {\n if (options.arrayFields) {\n record = { ...record }; // don't edit incoming values\n const arrayFields = Array.isArray(options.arrayFields)\n ? options.arrayFields\n : options.arrayFields(record);\n\n for (const field of arrayFields) {\n if (isKeyOf(field, record) && typeof record[field] === 'string') {\n const current = record[field] as string;\n record[field] = [current];\n }\n }\n }\n return record;\n }\n\n protected _parse(lines: string[]): Result<JarRecord[]> {\n for (let n = 0; n < lines.length; n++) {\n const line = lines[n];\n if (line.startsWith('%%') && !this._body?.isContinuation) {\n const result = this._writePendingRecord();\n if (result.isFailure()) {\n return fail(`${n}: ${result.message}`);\n }\n } else if (/^\\s*$/.test(line)) {\n // ignore blank lines but cancel continuation\n if (this._body) {\n this._body.isContinuation = false;\n }\n continue;\n } else if (this._body?.isContinuation || /^\\s+/.test(line)) {\n // explicit continuation on previous line or implicit starts with whitespace\n if (this._body === undefined) {\n return fail(`${n}: continuation (\"${line}\") without prior value.`);\n }\n const result = this._parseContinuation(line);\n if (result.isFailure()) {\n return fail(`${n}: ${result.message}`);\n }\n this._body = result.value;\n } else {\n const result = this._parseField(line);\n if (result.isFailure()) {\n return fail(`${n}: ${result.message}`);\n }\n }\n }\n\n const result = this._writePendingRecord();\n if (result.isFailure()) {\n return fail(`${lines.length}: ${result.message}`);\n }\n return succeed(this.records);\n }\n\n protected _parseField(line: string): Result<boolean> {\n const separatorIndex = line.indexOf(':');\n if (separatorIndex < 1) {\n return fail(`malformed line (\"${line}\") in record-jar.`);\n }\n const parts = [line.slice(0, separatorIndex), line.slice(separatorIndex + 1)];\n\n return this._writePendingField().onSuccess(() => {\n this._name = parts[0].trimEnd();\n return RecordParser._parseRecordBody(parts[1].trim()).onSuccess((body) => {\n this._body = body;\n return succeed(true);\n });\n });\n }\n\n protected _parseContinuation(line: string): Result<IRecordBody> {\n let trimmed = line.trim();\n if (!this._body!.isContinuation) {\n /* c8 ignore next - functional code tested but coverage intermittently missed */\n const fixedSize = this.options?.fixedContinuationSize ?? 0;\n if (fixedSize > 0) {\n if (trimmed.length < line.length - fixedSize) {\n // oops, took too much\n trimmed = line.slice(fixedSize);\n }\n }\n }\n return RecordParser._parseRecordBody(trimmed).onSuccess((newBody) => {\n return succeed({\n body: `${this._body!.body}${newBody.body}`,\n isContinuation: newBody.isContinuation\n });\n });\n }\n\n protected _havePendingRecord(): boolean {\n return Object.keys(this._fields).length > 0;\n }\n\n protected _writePendingRecord(): Result<JarRecord | undefined> {\n return this._writePendingField().onSuccess(() => {\n let record = this._havePendingRecord() ? this._fields : undefined;\n if (record !== undefined) {\n record = RecordParser._applyOptions(record, this.options);\n this.records.push(record);\n this._fields = {};\n }\n return succeed(undefined);\n });\n }\n\n protected _writePendingField(): Result<boolean> {\n if (this._name !== undefined) {\n if (this._body!.body.length < 1) {\n return fail('empty body value not allowed');\n }\n if (!isKeyOf(this._name, this._fields)) {\n this._fields[this._name] = this._body!.body;\n } else if (typeof this._fields[this._name] === 'string') {\n const current = this._fields[this._name] as string;\n this._fields[this._name] = [current, this._body!.body];\n } else {\n const current = this._fields[this._name] as string[];\n current.push(this._body!.body);\n }\n this._name = undefined;\n this._body = undefined;\n }\n return succeed(true);\n }\n}\n\n/**\n * Reads a record-jar from an array of strings, each of which represents one\n * line in the source file.\n * @param lines - the array of strings to be parsed\n * @param options - Optional parser configuration\n * @returns a corresponding array of `Record<string, string>`\n * @public\n */\nexport function parseRecordJarLines(lines: string[], options?: JarRecordParserOptions): Result<JarRecord[]> {\n return RecordParser.parse(lines, options);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/packlets/yaml/converters.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAc,SAAS,EAA+B,MAAM,eAAe,CAAC;AAGnF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAkBtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converters.js","sourceRoot":"","sources":["../../../src/packlets/yaml/converters.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWH,sCAkBC;AA3BD,4CAAmF;AACnF,8CAAgC;AAEhC;;;;;GAKG;AACH,SAAgB,aAAa,CAAI,SAAuB;IACtD,OAAO,IAAI,qBAAU,CAAC,aAAa,CAAI,CAAC,IAAa,EAAa,EAAE;QAClE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,IAAA,eAAI,EAAC,wBAAwB,CAAC,CAAC;QACxC,CAAC;QAED,MAAM,WAAW,GAAG,IAAA,wBAAa,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACzD,IAAI,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC;YAC5B,OAAO,IAAA,eAAI,EAAC,yBAAyB,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC;QACjC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YAClD,OAAO,IAAA,eAAI,EAAC,sDAAsD,CAAC,CAAC;QACtE,CAAC;QAED,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright (c) 2024 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Conversion, Converter, Result, captureResult, fail } from '@fgv/ts-utils';\nimport * as yaml from 'js-yaml';\n\n/**\n * Creates a converter that parses YAML string content and then applies the supplied converter.\n * @param converter - Converter to apply to the parsed YAML\n * @returns Converter that parses YAML then validates\n * @public\n */\nexport function yamlConverter<T>(converter: Converter<T>): Converter<T> {\n return new Conversion.BaseConverter<T>((from: unknown): Result<T> => {\n if (typeof from !== 'string') {\n return fail('Input must be a string');\n }\n\n const parseResult = captureResult(() => yaml.load(from));\n if (parseResult.isFailure()) {\n return fail(`Failed to parse YAML: ${parseResult.message}`);\n }\n\n const parsed = parseResult.value;\n if (typeof parsed !== 'object' || parsed === null) {\n return fail('Failed to parse YAML: YAML content must be an object');\n }\n\n return converter.convert(parsed);\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/yaml/index.ts"],"names":[],"mappings":"AAsBA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/yaml/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,+CAA6B;AAC7B,gDAA8B","sourcesContent":["/*\n * Copyright (c) 2024 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './converters';\nexport * from './serializers';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializers.d.ts","sourceRoot":"","sources":["../../../src/packlets/yaml/serializers.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAuB,MAAM,eAAe,CAAC;AAG5D;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,CAmB7F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializers.js","sourceRoot":"","sources":["../../../src/packlets/yaml/serializers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDH,sCAmBC;AAvED,4CAA4D;AAC5D,8CAAgC;AA4ChC;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,KAAc,EAAE,OAA+B;IAC3E,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,IAAA,eAAI,EAAC,4CAA4C,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAA,eAAI,EAAC,gDAAgD,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE,CACxB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;QACf,MAAM,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM;QACvB,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS;QAC7B,QAAQ,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ;QAC3B,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS;QAC7B,MAAM,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM;QACvB,aAAa,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,aAAa;QACrC,WAAW,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW;KAClC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["/*\n * Copyright (c) 2024 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, fail } from '@fgv/ts-utils';\nimport * as yaml from 'js-yaml';\n\n/**\n * Options for YAML serialization, mirroring commonly-used `js-yaml` `DumpOptions`.\n * @public\n */\nexport interface IYamlSerializeOptions {\n /**\n * Indentation width in spaces (default: 2).\n */\n readonly indent?: number;\n\n /**\n * Nesting level at which to switch from block to flow style.\n * -1 means block style everywhere (default: -1).\n */\n readonly flowLevel?: number;\n\n /**\n * If true, sort keys when dumping (default: false).\n */\n readonly sortKeys?: boolean;\n\n /**\n * Maximum line width (default: 80).\n */\n readonly lineWidth?: number;\n\n /**\n * If true, don't convert duplicate objects into references (default: false).\n */\n readonly noRefs?: boolean;\n\n /**\n * If true, don't add an indentation level to array elements (default: false).\n */\n readonly noArrayIndent?: boolean;\n\n /**\n * If true, all non-key strings will be quoted (default: false).\n */\n readonly forceQuotes?: boolean;\n}\n\n/**\n * Serializes a value to a YAML string.\n * @param value - The value to serialize (must be an object or array)\n * @param options - Optional serialization options\n * @returns `Success` with YAML string, or `Failure` with error\n * @public\n */\nexport function yamlStringify(value: unknown, options?: IYamlSerializeOptions): Result<string> {\n if (value === null || value === undefined) {\n return fail('Cannot serialize null or undefined to YAML');\n }\n if (typeof value !== 'object') {\n return fail('YAML serialization requires an object or array');\n }\n\n return captureResult(() =>\n yaml.dump(value, {\n indent: options?.indent,\n flowLevel: options?.flowLevel,\n sortKeys: options?.sortKeys,\n lineWidth: options?.lineWidth,\n noRefs: options?.noRefs,\n noArrayIndent: options?.noArrayIndent,\n forceQuotes: options?.forceQuotes\n })\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/index.ts"],"names":[],"mappings":"AAsBA;;;;;;;;GAQG;AAEH,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC7F,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;AAEH;;;;;;;;GAQG;AAEH,+DAA6F;AAApF,4HAAA,oBAAoB,OAAA;AAAE,mHAAA,WAAW,OAAA;AAAE,wHAAA,gBAAgB,OAAA;AAC5D,sDAAoC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * ZIP-based FileTree implementation for ts-extras.\n *\n * This packlet provides a FileTree accessor implementation that can read from ZIP archives,\n * making it useful for browser environments where files need to be bundled and transferred\n * as a single archive.\n *\n * @packageDocumentation\n */\n\nexport { ZipFileTreeAccessors, ZipFileItem, ZipDirectoryItem } from './zipFileTreeAccessors';\nexport * from './zipFileTreeWriter';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zipFileTreeAccessors.d.ts","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/zipFileTreeAccessors.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,MAAM,EAAgC,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;GAKG;AACH,qBAAa,WAAW,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,CAAE,YAAW,QAAQ,CAAC,iBAAiB,CAAC,GAAG,CAAC;IAC9F;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAU;IAEtC;;OAEG;IACH,SAAgB,YAAY,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,SAAgB,SAAS,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,IAAW,WAAW,IAAI,GAAG,GAAG,SAAS,CAMxC;IAED;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA4B;IAEvD;;OAEG;IACH,OAAO,CAAC,YAAY,CAAkB;IAEtC;;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C,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvD,MAAM,eAAe,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAErD,oCAAoC;QACpC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,gBAAgB,GAAG,GAAG,CAAC,EAAE,CAAC;YACxD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,6CAA6C;QAC7C,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAE5E,gEAAgE;QAChE,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;CACF;AA3TD,oDA2TC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { unzipSync, unzip, Unzipped } from 'fflate';\nimport { Result, succeed, fail, captureResult, Converter, Validator } from '@fgv/ts-utils';\nimport { FileTree, JsonValue } from '@fgv/ts-json-base';\n\n/**\n * Implementation of `FileTree.IFileTreeFileItem` for files in a ZIP archive.\n * ZIP files are read-only, so this item does not support mutation.\n * Use {@link FileTree.isMutableFileItem | isMutableFileItem} to check before attempting mutations.\n * @public\n */\nexport class ZipFileItem<TCT extends string = string> implements FileTree.IFileTreeFileItem<TCT> {\n /**\n * Indicates that this `FileTree.FileTreeItem` is a file.\n */\n public readonly type: 'file' = 'file';\n\n /**\n * The absolute path of the file within the ZIP archive.\n */\n public readonly absolutePath: string;\n\n /**\n * The name of the file\n */\n public readonly name: string;\n\n /**\n * The base name of the file (without extension)\n */\n public readonly baseName: string;\n\n /**\n * The extension of the file\n */\n public readonly extension: string;\n\n /**\n * The content type of the file.\n */\n public get contentType(): TCT | undefined {\n if (this._contentType === undefined && this._shouldInferContentType) {\n this._contentType = this._accessors.getFileContentType(this.absolutePath).orDefault();\n this._shouldInferContentType = false;\n }\n return this._contentType;\n }\n\n /**\n * The pre-loaded contents of the file.\n */\n private readonly _contents: string;\n\n /**\n * The ZIP file tree accessors that created this item.\n */\n private readonly _accessors: ZipFileTreeAccessors<TCT>;\n\n /**\n * Mutable content type of the file.\n */\n private _contentType: TCT | undefined;\n\n /**\n * Flag to track if content type should be inferred on first access.\n */\n private _shouldInferContentType: boolean = true;\n\n /**\n * Constructor for ZipFileItem.\n * @param zipFilePath - The path of the file within the ZIP.\n * @param contents - The pre-loaded contents of the file.\n * @param accessors - The ZIP file tree accessors.\n */\n public constructor(zipFilePath: string, contents: string, accessors: ZipFileTreeAccessors<TCT>) {\n this._contents = contents;\n this._accessors = accessors;\n this.absolutePath = '/' + zipFilePath;\n this.name = accessors.getBaseName(zipFilePath);\n this.extension = accessors.getExtension(zipFilePath);\n this.baseName = accessors.getBaseName(zipFilePath, this.extension);\n }\n\n /**\n * Sets the content type of the file.\n * @param contentType - The content type of the file.\n */\n public setContentType(contentType: TCT | undefined): void {\n this._contentType = contentType;\n this._shouldInferContentType = false;\n }\n\n /**\n * Gets the contents of the file as parsed JSON.\n */\n public getContents(): Result<JsonValue>;\n public getContents<T>(converter: Validator<T> | Converter<T>): Result<T>;\n public getContents<T>(converter?: Validator<T> | Converter<T>): Result<T | JsonValue> {\n return this.getRawContents()\n .onSuccess((contents) => {\n return captureResult(() => JSON.parse(contents))\n .onSuccess((parsed) => {\n if (converter) {\n return converter.convert(parsed) as Result<T | JsonValue>;\n }\n return succeed(parsed as JsonValue);\n })\n .onFailure(() => {\n return fail(`Failed to parse JSON from file: ${this.absolutePath}`);\n });\n })\n .onFailure((error) => {\n return fail(`Failed to get contents from file: ${error}`);\n });\n }\n\n /**\n * Gets the raw contents of the file as a string.\n */\n public getRawContents(): Result<string> {\n return succeed(this._contents);\n }\n}\n\n/**\n * Implementation of `IFileTreeDirectoryItem` for directories in a ZIP archive.\n * @public\n */\nexport class ZipDirectoryItem<TCT extends string = string> implements FileTree.IFileTreeDirectoryItem<TCT> {\n /**\n * Indicates that this `FileTree.FileTreeItem` is a directory.\n */\n public readonly type: 'directory' = 'directory';\n\n /**\n * The absolute path of the directory within the ZIP archive.\n */\n public readonly absolutePath: string;\n\n /**\n * The name of the directory\n */\n public readonly name: string;\n\n /**\n * The ZIP file tree accessors that created this item.\n */\n private readonly _accessors: ZipFileTreeAccessors<TCT>;\n\n /**\n * Constructor for ZipDirectoryItem.\n * @param directoryPath - The path of the directory within the ZIP.\n * @param accessors - The ZIP file tree accessors.\n */\n public constructor(directoryPath: string, accessors: ZipFileTreeAccessors<TCT>) {\n this._accessors = accessors;\n this.absolutePath = '/' + directoryPath.replace(/\\/$/, ''); // Normalize path\n this.name = accessors.getBaseName(directoryPath);\n }\n\n /**\n * Gets the children of the directory.\n */\n public getChildren(): Result<ReadonlyArray<FileTree.FileTreeItem<TCT>>> {\n return this._accessors.getChildren(this.absolutePath);\n }\n}\n\n/**\n * Read-only file tree accessors for ZIP archives.\n * ZIP archives are read-only by design — use {@link FileTree.isMutableAccessors | isMutableAccessors}\n * to check before attempting mutations.\n * @public\n */\nexport class ZipFileTreeAccessors<TCT extends string = string> implements FileTree.IFileTreeAccessors<TCT> {\n /**\n * The unzipped file data.\n */\n private readonly _files: Unzipped;\n\n /**\n * Optional prefix to prepend to paths.\n */\n private readonly _prefix: string;\n\n /**\n * Content type inference function.\n */\n private readonly _inferContentType: FileTree.ContentTypeFactory<TCT>;\n\n /**\n * Cache of all items in the ZIP for efficient lookups.\n */\n private readonly _itemCache: Map<string, FileTree.FileTreeItem<TCT>> = new Map();\n\n /**\n * Constructor for ZipFileTreeAccessors.\n * @param files - The unzipped file data from fflate.\n * @param params - Optional initialization parameters.\n */\n private constructor(files: Unzipped, params?: FileTree.IFileTreeInitParams<TCT>) {\n this._files = files;\n this._prefix = params?.prefix || '';\n this._inferContentType = params?.inferContentType ?? ZipFileTreeAccessors.defaultInferContentType;\n this._buildItemCache();\n }\n\n /**\n * Default function to infer the content type of a file.\n * @param __filePath - The path of the file.\n * @param __provided - Optional supplied content type.\n * @returns `Success` with the content type of the file if successful, or\n * `Failure` with an error message otherwise.\n * @remarks This default implementation always returns `Success` with `undefined`.\n * @public\n */\n public static defaultInferContentType<TCT extends string = string>(\n __filePath: string,\n __provided?: string\n ): Result<TCT | undefined> {\n return succeed(undefined);\n }\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (synchronous).\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param prefix - Optional prefix to prepend to paths.\n * @returns Result containing the ZipFileTreeAccessors instance.\n */\n public static fromBuffer<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n prefix?: string\n ): Result<ZipFileTreeAccessors<TCT>>;\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (synchronous).\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param params - Optional initialization parameters.\n * @returns Result containing the ZipFileTreeAccessors instance.\n */\n public static fromBuffer<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n params?: FileTree.IFileTreeInitParams<TCT>\n ): Result<ZipFileTreeAccessors<TCT>>;\n\n public static fromBuffer<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n params?: FileTree.IFileTreeInitParams<TCT> | string\n ): Result<ZipFileTreeAccessors<TCT>> {\n try {\n /* c8 ignore next 1 - defense in depth */\n const uint8Buffer = zipBuffer instanceof Uint8Array ? zipBuffer : new Uint8Array(zipBuffer);\n const files = unzipSync(uint8Buffer);\n const normalizedParams = typeof params === 'string' ? { prefix: params } : params;\n return succeed(new ZipFileTreeAccessors<TCT>(files, normalizedParams));\n } catch (error) {\n /* c8 ignore next 1 - defensive coding: fflate always throws Error objects in practice */\n return fail(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (asynchronous).\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param prefix - Optional prefix to prepend to paths.\n * @returns Promise containing Result with the ZipFileTreeAccessors instance.\n */\n public static async fromBufferAsync<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n prefix?: string\n ): Promise<Result<ZipFileTreeAccessors<TCT>>>;\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (asynchronous).\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param params - Optional initialization parameters.\n * @returns Promise containing Result with the ZipFileTreeAccessors instance.\n */\n public static async fromBufferAsync<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n params?: FileTree.IFileTreeInitParams<TCT>\n ): Promise<Result<ZipFileTreeAccessors<TCT>>>;\n\n public static async fromBufferAsync<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n params?: FileTree.IFileTreeInitParams<TCT> | string\n ): Promise<Result<ZipFileTreeAccessors<TCT>>> {\n return new Promise((resolve) => {\n try {\n /* c8 ignore next 1 - defense in depth */\n const uint8Buffer = zipBuffer instanceof Uint8Array ? zipBuffer : new Uint8Array(zipBuffer);\n unzip(uint8Buffer, (err, files) => {\n if (err) {\n resolve(fail(`Failed to load ZIP archive: ${err.message}`));\n } else {\n const normalizedParams = typeof params === 'string' ? { prefix: params } : params;\n resolve(succeed(new ZipFileTreeAccessors<TCT>(files, normalizedParams)));\n }\n });\n /* c8 ignore next 5 - defensive coding: fflate reports errors via callback, not exceptions */\n } catch (error) {\n resolve(\n fail(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`)\n );\n }\n });\n }\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a File object (browser environment).\n * @param file - The File object containing ZIP data.\n * @param params - Optional initialization parameters.\n * @returns Result containing the ZipFileTreeAccessors instance.\n */\n public static async fromFile<TCT extends string = string>(\n file: File,\n params?: FileTree.IFileTreeInitParams<TCT>\n ): Promise<Result<ZipFileTreeAccessors<TCT>>> {\n try {\n const arrayBuffer = await file.arrayBuffer();\n const uint8Buffer = new Uint8Array(arrayBuffer);\n\n return await ZipFileTreeAccessors.fromBufferAsync<TCT>(uint8Buffer, params);\n } catch (error) {\n return fail(`Failed to read file: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Builds the cache of all items in the ZIP archive.\n */\n private _buildItemCache(): void {\n const directories = new Set<string>();\n\n // Process all files and collect directory paths\n for (const [relativePath, fileData] of Object.entries(this._files)) {\n // Skip directories in fflate output (they have null data)\n /* c8 ignore next 5 - handles explicit directory entries from external ZIP tools (fflate doesn't create these) */\n if (fileData === null || fileData === undefined) {\n const dirPath = relativePath.replace(/\\/$/, '');\n if (dirPath) {\n directories.add(dirPath);\n }\n } else {\n // Extract directory paths from file paths\n const pathParts = relativePath.split('/');\n for (let i = 1; i < pathParts.length; i++) {\n const dirPath = pathParts.slice(0, i).join('/');\n if (dirPath) {\n directories.add(dirPath);\n }\n }\n\n // Add the file item with its contents\n const absolutePath = this.resolveAbsolutePath(relativePath);\n const contents = new TextDecoder().decode(fileData);\n const item = new ZipFileItem<TCT>(relativePath, contents, this);\n this._itemCache.set(absolutePath, item);\n }\n }\n\n // Add directory items to cache\n directories.forEach((dirPath) => {\n const absolutePath = this.resolveAbsolutePath(dirPath);\n const item = new ZipDirectoryItem<TCT>(dirPath, this);\n this._itemCache.set(absolutePath, item);\n });\n }\n\n /**\n * Resolves paths to an absolute path.\n */\n public resolveAbsolutePath(...paths: string[]): string {\n const joinedPath = this.joinPaths(...paths);\n const prefixed = this._prefix ? this.joinPaths(this._prefix, joinedPath) : joinedPath;\n return prefixed.startsWith('/') ? prefixed : '/' + prefixed;\n }\n\n /**\n * Gets the extension of a path.\n */\n public getExtension(path: string): string {\n const name = this.getBaseName(path);\n const lastDotIndex = name.lastIndexOf('.');\n return lastDotIndex >= 0 ? name.substring(lastDotIndex) : '';\n }\n\n /**\n * Gets the base name of a path.\n */\n public getBaseName(path: string, suffix?: string): string {\n const normalizedPath = path.replace(/\\/$/, ''); // Remove trailing slash\n const parts = normalizedPath.split('/');\n let baseName = parts[parts.length - 1] || '';\n\n if (suffix && baseName.endsWith(suffix)) {\n baseName = baseName.substring(0, baseName.length - suffix.length);\n }\n\n return baseName;\n }\n\n /**\n * Joins paths together.\n */\n public joinPaths(...paths: string[]): string {\n return paths\n .filter((p) => p && p.length > 0)\n .map((p) => p.replace(/^\\/+|\\/+$/g, '')) // Remove leading/trailing slashes\n .join('/')\n .replace(/\\/+/g, '/'); // Normalize multiple slashes\n }\n\n /**\n * Gets an item from the file tree.\n */\n public getItem(path: string): Result<FileTree.FileTreeItem<TCT>> {\n const absolutePath = this.resolveAbsolutePath(path);\n const item = this._itemCache.get(absolutePath);\n\n if (item) {\n return succeed(item);\n }\n\n return fail(`Item not found: ${absolutePath}`);\n }\n\n /**\n * Gets the contents of a file in the file tree.\n */\n public getFileContents(path: string): Result<string> {\n return this.getItem(path).onSuccess((item) => {\n if (item.type !== 'file') {\n return fail(`Path is not a file: ${path}`);\n }\n return item.getRawContents();\n });\n }\n\n /**\n * Gets the content type of a file in the file tree.\n */\n public getFileContentType(path: string, provided?: string): Result<TCT | undefined> {\n // If provided contentType is given, use it directly (highest priority)\n if (provided !== undefined) {\n return succeed(provided as TCT);\n }\n\n // For files that exist in the ZIP, we don't store explicit contentType\n // so we always fall back to inference\n return this._inferContentType(path);\n }\n\n /**\n * Gets the children of a directory in the file tree.\n */\n public getChildren(path: string): Result<ReadonlyArray<FileTree.FileTreeItem<TCT>>> {\n const absolutePath = this.resolveAbsolutePath(path);\n const children: FileTree.FileTreeItem<TCT>[] = [];\n\n // Find all items that are direct children of this directory\n for (const [itemPath, item] of this._itemCache) {\n if (this._isDirectChild(absolutePath, itemPath)) {\n children.push(item);\n }\n }\n\n return succeed(children);\n }\n\n /**\n * Checks if childPath is a direct child of parentPath.\n */\n private _isDirectChild(parentPath: string, childPath: string): boolean {\n // Normalize paths\n const normalizedParent = parentPath.replace(/\\/$/, '');\n const normalizedChild = childPath.replace(/\\/$/, '');\n\n // Child must start with parent path\n if (!normalizedChild.startsWith(normalizedParent + '/')) {\n return false;\n }\n\n // Get the relative path from parent to child\n const relativePath = normalizedChild.substring(normalizedParent.length + 1);\n\n // Direct child means no additional slashes in the relative path\n return !relativePath.includes('/');\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zipFileTreeWriter.d.ts","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/zipFileTreeWriter.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,aAAa,CAAC,YAAY,CAAC,EAClC,OAAO,CAAC,EAAE,iBAAiB,GAC1B,MAAM,CAAC,UAAU,CAAC,CAUpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zipFileTreeWriter.js","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/zipFileTreeWriter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAgCH,wDAaC;AA3CD,mCAA0C;AAC1C,4CAAsD;AAyBtD;;;GAGG;AACH,SAAgB,sBAAsB,CACpC,KAAkC,EAClC,OAA2B;IAE3B,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;;QACxB,MAAM,GAAG,GAA+B,EAAE,CAAC;QAC3C,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAClD,GAAG,CAAC,cAAc,CAAC,GAAG,IAAA,gBAAO,EAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,IAAA,gBAAO,EAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,mCAAI,CAAC,EAAE,CAAC,CAAC;QACpD,gFAAgF;IAClF,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["/*\n * Copyright (c) 2026 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { zipSync, strToU8 } from 'fflate';\nimport { Result, captureResult } from '@fgv/ts-utils';\n\n/**\n * Simple interface for a file to be added to a zip file.\n * @public\n */\nexport interface IZipTextFile {\n readonly path: string;\n readonly contents: string;\n}\n\n/**\n * Supported compression levels for zip files.\n * @public\n */\nexport type ZipCompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;\n\n/**\n * Options for creating a zip file from text files.\n * @public\n */\nexport interface ICreateZipOptions {\n readonly level?: ZipCompressionLevel;\n}\n\n/**\n * Creates a zip file from an array of text files.\n * @public\n */\nexport function createZipFromTextFiles(\n files: ReadonlyArray<IZipTextFile>,\n options?: ICreateZipOptions\n): Result<Uint8Array> {\n return captureResult(() => {\n const out: Record<string, Uint8Array> = {};\n for (const f of files) {\n const normalizedPath = f.path.replace(/^\\/+/, '');\n out[normalizedPath] = strToU8(f.contents);\n }\n return zipSync(out, { level: options?.level ?? 6 });\n /* c8 ignore next - defensive: zipSync only throws on internal library errors */\n }).withErrorFormat((e) => `Failed to create zip: ${e}`);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-extras",
|
|
3
|
-
"version": "5.1.0-
|
|
3
|
+
"version": "5.1.0-20",
|
|
4
4
|
"description": "Assorted Typescript Utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-extras.d.ts",
|
|
@@ -86,10 +86,10 @@
|
|
|
86
86
|
"@types/js-yaml": "~4.0.9",
|
|
87
87
|
"typedoc": "~0.28.16",
|
|
88
88
|
"typedoc-plugin-markdown": "~4.9.0",
|
|
89
|
-
"@fgv/heft-dual-rig": "5.1.0-
|
|
90
|
-
"@fgv/typedoc-compact-theme": "5.1.0-
|
|
91
|
-
"@fgv/ts-utils": "5.1.0-
|
|
92
|
-
"@fgv/ts-utils-jest": "5.1.0-
|
|
89
|
+
"@fgv/heft-dual-rig": "5.1.0-20",
|
|
90
|
+
"@fgv/typedoc-compact-theme": "5.1.0-20",
|
|
91
|
+
"@fgv/ts-utils": "5.1.0-20",
|
|
92
|
+
"@fgv/ts-utils-jest": "5.1.0-20"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"luxon": "^3.7.2",
|
|
@@ -97,10 +97,10 @@
|
|
|
97
97
|
"papaparse": "^5.4.1",
|
|
98
98
|
"fflate": "~0.8.2",
|
|
99
99
|
"js-yaml": "~4.1.1",
|
|
100
|
-
"@fgv/ts-json-base": "5.1.0-
|
|
100
|
+
"@fgv/ts-json-base": "5.1.0-20"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
|
-
"@fgv/ts-utils": "5.1.0-
|
|
103
|
+
"@fgv/ts-utils": "5.1.0-20"
|
|
104
104
|
},
|
|
105
105
|
"repository": {
|
|
106
106
|
"type": "git",
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2026 Erik Fortune
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
// in the Software without restriction, including without limitation the rights
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in all
|
|
11
|
-
// copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
-
// SOFTWARE.
|
|
20
|
-
import { fail, succeed } from '@fgv/ts-utils';
|
|
21
|
-
/**
|
|
22
|
-
* In-memory implementation of `IPrivateKeyStorage` for keystore tests.
|
|
23
|
-
*
|
|
24
|
-
* Not exported from `@fgv/ts-extras`. Lives in the test tree as a reference
|
|
25
|
-
* implementation downstream packages may copy if useful, but the public API
|
|
26
|
-
* delegates concrete backends to platform-specific packages
|
|
27
|
-
* (browser/IDB in `@fgv/ts-web-extras`, encrypted-file in `@fgv/ts-chocolate`).
|
|
28
|
-
*
|
|
29
|
-
* Holds `CryptoKey` objects directly in a `Map`, so it advertises
|
|
30
|
-
* `supportsNonExtractable: true` by default. The constructor accepts overrides
|
|
31
|
-
* useful for negative tests:
|
|
32
|
-
* - `supportsNonExtractable: false` exercises the extractable=true codepath.
|
|
33
|
-
* - `failOn: { store?, load?, delete?, list? }` makes the named operations
|
|
34
|
-
* return Failure with a stable message so tests can assert downstream
|
|
35
|
-
* warning/error propagation without resorting to mocks.
|
|
36
|
-
*/
|
|
37
|
-
export class InMemoryPrivateKeyStorage {
|
|
38
|
-
constructor(options) {
|
|
39
|
-
var _a, _b;
|
|
40
|
-
this.supportsNonExtractable = (_a = options === null || options === void 0 ? void 0 : options.supportsNonExtractable) !== null && _a !== void 0 ? _a : true;
|
|
41
|
-
this.entries = new Map();
|
|
42
|
-
this._failOn = (_b = options === null || options === void 0 ? void 0 : options.failOn) !== null && _b !== void 0 ? _b : {};
|
|
43
|
-
}
|
|
44
|
-
async store(id, key) {
|
|
45
|
-
if (this._failOn.store) {
|
|
46
|
-
return fail(this._failOn.store);
|
|
47
|
-
}
|
|
48
|
-
this.entries.set(id, key);
|
|
49
|
-
return succeed(id);
|
|
50
|
-
}
|
|
51
|
-
async load(id) {
|
|
52
|
-
if (this._failOn.load) {
|
|
53
|
-
return fail(this._failOn.load);
|
|
54
|
-
}
|
|
55
|
-
const key = this.entries.get(id);
|
|
56
|
-
if (!key) {
|
|
57
|
-
return fail(`No private key for id '${id}'`);
|
|
58
|
-
}
|
|
59
|
-
return succeed(key);
|
|
60
|
-
}
|
|
61
|
-
async delete(id) {
|
|
62
|
-
if (this._failOn.delete) {
|
|
63
|
-
return fail(this._failOn.delete);
|
|
64
|
-
}
|
|
65
|
-
if (!this.entries.has(id)) {
|
|
66
|
-
return fail(`No private key for id '${id}'`);
|
|
67
|
-
}
|
|
68
|
-
this.entries.delete(id);
|
|
69
|
-
return succeed(id);
|
|
70
|
-
}
|
|
71
|
-
async list() {
|
|
72
|
-
if (this._failOn.list) {
|
|
73
|
-
return fail(this._failOn.list);
|
|
74
|
-
}
|
|
75
|
-
return succeed(Array.from(this.entries.keys()));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=inMemoryPrivateKeyStorage.js.map
|