@wener/common 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ai/qwen3vl/index.js +2 -0
- package/lib/ai/qwen3vl/index.js.map +1 -0
- package/lib/ai/qwen3vl/utils.js +31 -0
- package/lib/ai/qwen3vl/utils.js.map +1 -0
- package/lib/ai/vision/DocLayoutElementTypeSchema.js +28 -0
- package/lib/ai/vision/DocLayoutElementTypeSchema.js.map +1 -0
- package/lib/ai/vision/ImageAnnotationSchema.js +50 -0
- package/lib/ai/vision/ImageAnnotationSchema.js.map +1 -0
- package/lib/ai/vision/index.js +3 -0
- package/lib/ai/vision/index.js.map +1 -0
- package/lib/ai/vision/resolveImageAnnotation.js +105 -0
- package/lib/ai/vision/resolveImageAnnotation.js.map +1 -0
- package/lib/cn/ChineseResidentIdNo.js +48 -0
- package/lib/cn/ChineseResidentIdNo.js.map +1 -0
- package/lib/cn/ChineseResidentIdNo.mod.js +1 -0
- package/lib/cn/{ResidentIdentityCardNumber.test.js → ChineseResidentIdNo.test.js} +7 -6
- package/lib/cn/DivisionCode.js +217 -301
- package/lib/cn/DivisionCode.js.map +1 -0
- package/lib/cn/DivisionCode.mod.js +1 -0
- package/lib/cn/DivisionCode.test.js +9 -15
- package/lib/cn/Mod11.js +43 -0
- package/lib/cn/Mod11.js.map +1 -0
- package/lib/cn/Mod31.js +49 -0
- package/lib/cn/Mod31.js.map +1 -0
- package/lib/cn/UnifiedSocialCreditCode.js +137 -113
- package/lib/cn/UnifiedSocialCreditCode.js.map +1 -0
- package/lib/cn/UnifiedSocialCreditCode.mod.js +1 -0
- package/lib/cn/UnifiedSocialCreditCode.test.js +1 -1
- package/lib/cn/formatChineseAmount.js +77 -0
- package/lib/cn/formatChineseAmount.js.map +1 -0
- package/lib/cn/index.js +6 -2
- package/lib/cn/index.js.map +1 -0
- package/lib/cn/mod.js +6 -0
- package/lib/cn/parseChineseNumber.js +94 -0
- package/lib/cn/parseChineseNumber.js.map +1 -0
- package/lib/cn/parseChineseNumber.test.js +278 -0
- package/lib/cn/pinyin/cartesianProduct.js +22 -0
- package/lib/cn/pinyin/cartesianProduct.js.map +1 -0
- package/lib/cn/pinyin/cartesianProduct.test.js +179 -0
- package/lib/cn/pinyin/data.json +23573 -0
- package/lib/cn/pinyin/loader.js +14 -0
- package/lib/cn/pinyin/loader.js.map +1 -0
- package/lib/cn/pinyin/preload.js +3 -0
- package/lib/cn/pinyin/preload.js.map +1 -0
- package/lib/cn/pinyin/toPinyin.test.js +167 -0
- package/lib/cn/pinyin/toPinyinPure.js +33 -0
- package/lib/cn/pinyin/toPinyinPure.js.map +1 -0
- package/lib/cn/pinyin/transform.js +14 -0
- package/lib/cn/pinyin/transform.js.map +1 -0
- package/lib/cn/types.d.js +2 -0
- package/lib/cn/types.d.js.map +1 -0
- package/lib/consola/createStandardConsolaReporter.js +6 -6
- package/lib/consola/createStandardConsolaReporter.js.map +1 -0
- package/lib/consola/formatLogObject.js +67 -135
- package/lib/consola/formatLogObject.js.map +1 -0
- package/lib/consola/formatLogObject.test.js +184 -0
- package/lib/consola/index.js +1 -0
- package/lib/consola/index.js.map +1 -0
- package/lib/data/formatSort.js +6 -5
- package/lib/data/formatSort.js.map +1 -0
- package/lib/data/index.js +1 -0
- package/lib/data/index.js.map +1 -0
- package/lib/data/maybeNumber.js +5 -7
- package/lib/data/maybeNumber.js.map +1 -0
- package/lib/data/parseSort.js +22 -28
- package/lib/data/parseSort.js.map +1 -0
- package/lib/data/resolvePagination.js +13 -17
- package/lib/data/resolvePagination.js.map +1 -0
- package/lib/data/types.d.js +2 -0
- package/lib/data/types.d.js.map +1 -0
- package/lib/dayjs/dayjs.js +40 -0
- package/lib/dayjs/dayjs.js.map +1 -0
- package/lib/dayjs/formatDuration.js +59 -0
- package/lib/dayjs/formatDuration.js.map +1 -0
- package/lib/dayjs/formatDuration.test.js +90 -0
- package/lib/dayjs/index.js +5 -0
- package/lib/dayjs/index.js.map +1 -0
- package/lib/dayjs/parseDuration.js +29 -0
- package/lib/dayjs/parseDuration.js.map +1 -0
- package/lib/dayjs/parseRelativeTime.js +90 -0
- package/lib/dayjs/parseRelativeTime.js.map +1 -0
- package/lib/dayjs/parseRelativeTime.test.js +247 -0
- package/lib/dayjs/resolveRelativeTime.js +158 -0
- package/lib/dayjs/resolveRelativeTime.js.map +1 -0
- package/lib/dayjs/resolveRelativeTime.test.js +310 -0
- package/lib/decimal/index.js +2 -0
- package/lib/decimal/index.js.map +1 -0
- package/lib/decimal/parseDecimal.js +15 -0
- package/lib/decimal/parseDecimal.js.map +1 -0
- package/lib/emittery/emitter.js +10 -0
- package/lib/emittery/emitter.js.map +1 -0
- package/lib/emittery/index.js +2 -0
- package/lib/emittery/index.js.map +1 -0
- package/lib/foundation/schema/SexType.js +16 -0
- package/lib/foundation/schema/SexType.js.map +1 -0
- package/lib/foundation/schema/index.js +2 -0
- package/lib/foundation/schema/index.js.map +1 -0
- package/lib/foundation/schema/parseSexType.js +19 -0
- package/lib/foundation/schema/parseSexType.js.map +1 -0
- package/lib/foundation/schema/types.js +7 -0
- package/lib/foundation/schema/types.js.map +1 -0
- package/lib/fs/FileSystemError.js +23 -0
- package/lib/fs/FileSystemError.js.map +1 -0
- package/lib/fs/IFileSystem.d.js +3 -0
- package/lib/fs/IFileSystem.d.js.map +1 -0
- package/lib/fs/MemoryFileSystem.test.js +188 -0
- package/lib/fs/createBrowserFileSystem.js +248 -0
- package/lib/fs/createBrowserFileSystem.js.map +1 -0
- package/lib/fs/createMemoryFileSystem.js +516 -0
- package/lib/fs/createMemoryFileSystem.js.map +1 -0
- package/lib/fs/createSandboxFileSystem.js +108 -0
- package/lib/fs/createSandboxFileSystem.js.map +1 -0
- package/lib/fs/createWebDavFileSystem.js +137 -0
- package/lib/fs/createWebDavFileSystem.js.map +1 -0
- package/lib/fs/findMimeType.js +17 -0
- package/lib/fs/findMimeType.js.map +1 -0
- package/lib/fs/index.js +8 -0
- package/lib/fs/index.js.map +1 -0
- package/lib/fs/orpc/FileSystemContract.js +93 -0
- package/lib/fs/orpc/FileSystemContract.js.map +1 -0
- package/lib/fs/orpc/createContractClientFileSystem.js +93 -0
- package/lib/fs/orpc/createContractClientFileSystem.js.map +1 -0
- package/lib/fs/orpc/index.js +3 -0
- package/lib/fs/orpc/index.js.map +1 -0
- package/lib/fs/orpc/server/createFileSystemContractImpl.js +63 -0
- package/lib/fs/orpc/server/createFileSystemContractImpl.js.map +1 -0
- package/lib/fs/orpc/server/index.js +2 -0
- package/lib/fs/orpc/server/index.js.map +1 -0
- package/lib/fs/s3/createS3MiniFileSystem.js +705 -0
- package/lib/fs/s3/createS3MiniFileSystem.js.map +1 -0
- package/lib/fs/s3/index.js +2 -0
- package/lib/fs/s3/index.js.map +1 -0
- package/lib/fs/s3/s3mini.test.js +584 -0
- package/lib/fs/scandir.js +59 -0
- package/lib/fs/scandir.js.map +1 -0
- package/lib/fs/server/createDatabaseFileSystem.js +750 -0
- package/lib/fs/server/createDatabaseFileSystem.js.map +1 -0
- package/lib/fs/server/createNodeFileSystem.js +401 -0
- package/lib/fs/server/createNodeFileSystem.js.map +1 -0
- package/lib/fs/server/dbfs.test.js +221 -0
- package/lib/fs/server/index.js +2 -0
- package/lib/fs/server/index.js.map +1 -0
- package/lib/fs/server/loadTestDatabase.js +127 -0
- package/lib/fs/server/loadTestDatabase.js.map +1 -0
- package/lib/fs/tests/runFileSystemTest.js +318 -0
- package/lib/fs/tests/runFileSystemTest.js.map +1 -0
- package/lib/fs/types.js +27 -0
- package/lib/fs/types.js.map +1 -0
- package/lib/fs/utils/getFileUrl.js +35 -0
- package/lib/fs/utils/getFileUrl.js.map +1 -0
- package/lib/fs/utils.js +22 -0
- package/lib/fs/utils.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -0
- package/lib/jsonschema/JsonSchema.js +146 -172
- package/lib/jsonschema/JsonSchema.js.map +1 -0
- package/lib/jsonschema/forEachJsonSchema.js +44 -0
- package/lib/jsonschema/forEachJsonSchema.js.map +1 -0
- package/lib/jsonschema/index.js +2 -0
- package/lib/jsonschema/index.js.map +1 -0
- package/lib/jsonschema/types.d.js +2 -0
- package/lib/jsonschema/types.d.js.map +1 -0
- package/lib/meta/defineFileType.js +20 -103
- package/lib/meta/defineFileType.js.map +1 -0
- package/lib/meta/defineInit.js +31 -250
- package/lib/meta/defineInit.js.map +1 -0
- package/lib/meta/defineMetadata.js +24 -140
- package/lib/meta/defineMetadata.js.map +1 -0
- package/lib/meta/index.js +1 -0
- package/lib/meta/index.js.map +1 -0
- package/lib/orpc/createOpenApiContractClient.js +27 -0
- package/lib/orpc/createOpenApiContractClient.js.map +1 -0
- package/lib/orpc/createRpcContractClient.js +34 -0
- package/lib/orpc/createRpcContractClient.js.map +1 -0
- package/lib/orpc/index.js +3 -0
- package/lib/orpc/index.js.map +1 -0
- package/lib/orpc/resolveLinkPlugins.js +28 -0
- package/lib/orpc/resolveLinkPlugins.js.map +1 -0
- package/lib/password/PHC.js +63 -87
- package/lib/password/PHC.js.map +1 -0
- package/lib/password/PHC.test.js +11 -3
- package/lib/password/Password.js +30 -292
- package/lib/password/Password.js.map +1 -0
- package/lib/password/Password.test.js +35 -22
- package/lib/password/createArgon2PasswordAlgorithm.js +35 -191
- package/lib/password/createArgon2PasswordAlgorithm.js.map +1 -0
- package/lib/password/createBase64PasswordAlgorithm.js +8 -141
- package/lib/password/createBase64PasswordAlgorithm.js.map +1 -0
- package/lib/password/createBcryptPasswordAlgorithm.js +13 -168
- package/lib/password/createBcryptPasswordAlgorithm.js.map +1 -0
- package/lib/password/createPBKDF2PasswordAlgorithm.js +46 -228
- package/lib/password/createPBKDF2PasswordAlgorithm.js.map +1 -0
- package/lib/password/createScryptPasswordAlgorithm.js +55 -211
- package/lib/password/createScryptPasswordAlgorithm.js.map +1 -0
- package/lib/password/index.js +1 -0
- package/lib/password/index.js.map +1 -0
- package/lib/password/server/index.js +1 -0
- package/lib/password/server/index.js.map +1 -0
- package/lib/resource/Identifiable.js +2 -0
- package/lib/resource/Identifiable.js.map +1 -0
- package/lib/resource/ListQuery.js +47 -0
- package/lib/resource/ListQuery.js.map +1 -0
- package/lib/resource/getTitleOfResource.js +3 -5
- package/lib/resource/getTitleOfResource.js.map +1 -0
- package/lib/resource/index.js +2 -0
- package/lib/resource/index.js.map +1 -0
- package/lib/resource/schema/AnyResourceSchema.js +3 -2
- package/lib/resource/schema/AnyResourceSchema.js.map +1 -0
- package/lib/resource/schema/BaseResourceSchema.js +2 -1
- package/lib/resource/schema/BaseResourceSchema.js.map +1 -0
- package/lib/resource/schema/ResourceActionType.js +6 -4
- package/lib/resource/schema/ResourceActionType.js.map +1 -0
- package/lib/resource/schema/ResourceStatus.js +5 -3
- package/lib/resource/schema/ResourceStatus.js.map +1 -0
- package/lib/resource/schema/ResourceType.js +5 -3
- package/lib/resource/schema/ResourceType.js.map +1 -0
- package/lib/resource/schema/index.js +6 -0
- package/lib/resource/schema/index.js.map +1 -0
- package/lib/resource/schema/types.js +16 -20
- package/lib/resource/schema/types.js.map +1 -0
- package/lib/s3/formatS3Url.js +65 -0
- package/lib/s3/formatS3Url.js.map +1 -0
- package/lib/s3/formatS3Url.test.js +262 -0
- package/lib/s3/index.js +3 -0
- package/lib/s3/index.js.map +1 -0
- package/lib/s3/parseS3Url.js +65 -0
- package/lib/s3/parseS3Url.js.map +1 -0
- package/lib/s3/parseS3Url.test.js +270 -0
- package/lib/schema/SchemaRegistry.js +45 -0
- package/lib/schema/SchemaRegistry.js.map +1 -0
- package/lib/schema/SchemaRegistry.mod.js +2 -0
- package/lib/schema/TypeSchema.d.js +2 -0
- package/lib/schema/TypeSchema.d.js.map +1 -0
- package/lib/schema/createSchemaData.js +26 -125
- package/lib/schema/createSchemaData.js.map +1 -0
- package/lib/schema/findJsonSchemaByPath.js +13 -36
- package/lib/schema/findJsonSchemaByPath.js.map +1 -0
- package/lib/schema/formatZodError.js +140 -0
- package/lib/schema/formatZodError.js.map +1 -0
- package/lib/schema/formatZodError.test.js +196 -0
- package/lib/schema/getSchemaCache.js +5 -5
- package/lib/schema/getSchemaCache.js.map +1 -0
- package/lib/schema/getSchemaOptions.js +8 -11
- package/lib/schema/getSchemaOptions.js.map +1 -0
- package/lib/schema/index.js +2 -0
- package/lib/schema/index.js.map +1 -0
- package/lib/schema/toJsonSchema.js +47 -290
- package/lib/schema/toJsonSchema.js.map +1 -0
- package/lib/schema/validate.js +33 -45
- package/lib/schema/validate.js.map +1 -0
- package/lib/tools/generateSchema.js +39 -197
- package/lib/tools/generateSchema.js.map +1 -0
- package/lib/tools/renderJsonSchemaToMarkdownDoc.js +55 -143
- package/lib/tools/renderJsonSchemaToMarkdownDoc.js.map +1 -0
- package/lib/utils/buildBaseUrl.js +13 -0
- package/lib/utils/buildBaseUrl.js.map +1 -0
- package/lib/utils/buildRedactorFormSchema.js +59 -0
- package/lib/utils/buildRedactorFormSchema.js.map +1 -0
- package/lib/utils/getEstimateProcessTime.js +21 -0
- package/lib/utils/getEstimateProcessTime.js.map +1 -0
- package/lib/utils/index.js +4 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/resolveFeatureOptions.js +12 -0
- package/lib/utils/resolveFeatureOptions.js.map +1 -0
- package/package.json +77 -20
- package/src/ai/qwen3vl/index.ts +1 -0
- package/src/ai/qwen3vl/utils.ts +36 -0
- package/src/ai/vision/DocLayoutElementTypeSchema.ts +30 -0
- package/src/ai/vision/ImageAnnotationSchema.ts +60 -0
- package/src/ai/vision/index.ts +2 -0
- package/src/ai/vision/resolveImageAnnotation.ts +135 -0
- package/src/cn/ChineseResidentIdNo.test.ts +18 -0
- package/src/cn/ChineseResidentIdNo.ts +74 -0
- package/src/cn/DivisionCode.test.ts +3 -13
- package/src/cn/DivisionCode.ts +138 -193
- package/src/cn/{Mod11Checksum.ts → Mod11.ts} +3 -1
- package/src/cn/{Mod31Checksum.ts → Mod31.ts} +2 -0
- package/src/cn/UnifiedSocialCreditCode.test.ts +2 -2
- package/src/cn/UnifiedSocialCreditCode.ts +119 -124
- package/src/cn/__snapshots__/ChineseResidentIdNo.test.ts.snap +14 -0
- package/src/cn/__snapshots__/UnifiedSocialCreditCode.test.ts.snap +41 -12
- package/src/cn/formatChineseAmount.ts +61 -0
- package/src/cn/index.ts +6 -2
- package/src/cn/parseChineseNumber.test.ts +159 -0
- package/src/cn/parseChineseNumber.ts +97 -0
- package/src/cn/pinyin/cartesianProduct.test.ts +64 -0
- package/src/cn/pinyin/cartesianProduct.ts +24 -0
- package/src/cn/pinyin/data.json +23573 -0
- package/src/cn/pinyin/loader.ts +12 -0
- package/src/cn/pinyin/preload.ts +3 -0
- package/src/cn/pinyin/toPinyin.test.ts +12 -0
- package/src/cn/pinyin/toPinyinPure.ts +43 -0
- package/src/cn/pinyin/transform.ts +12 -0
- package/src/consola/formatLogObject.test.ts +27 -0
- package/src/consola/formatLogObject.ts +46 -10
- package/src/dayjs/dayjs.ts +40 -0
- package/src/dayjs/formatDuration.test.ts +14 -0
- package/src/dayjs/formatDuration.ts +86 -0
- package/src/dayjs/index.ts +5 -0
- package/src/dayjs/parseDuration.ts +40 -0
- package/src/dayjs/parseRelativeTime.test.ts +185 -0
- package/src/dayjs/parseRelativeTime.ts +115 -0
- package/src/dayjs/resolveRelativeTime.test.ts +357 -0
- package/src/dayjs/resolveRelativeTime.ts +167 -0
- package/src/decimal/index.ts +1 -0
- package/src/decimal/parseDecimal.ts +16 -0
- package/src/emittery/emitter.ts +9 -0
- package/src/emittery/index.ts +1 -0
- package/src/foundation/schema/SexType.ts +21 -0
- package/src/foundation/schema/index.ts +1 -0
- package/src/foundation/schema/parseSexType.ts +19 -0
- package/src/foundation/schema/types.ts +8 -0
- package/src/fs/FileSystemError.ts +26 -0
- package/src/fs/IFileSystem.d.ts +102 -0
- package/src/fs/MemoryFileSystem.test.ts +37 -0
- package/src/fs/createBrowserFileSystem.ts +291 -0
- package/src/fs/createMemoryFileSystem.ts +604 -0
- package/src/fs/createSandboxFileSystem.ts +136 -0
- package/src/fs/createWebDavFileSystem.ts +172 -0
- package/src/fs/findMimeType.ts +23 -0
- package/src/fs/index.ts +8 -0
- package/src/fs/orpc/FileSystemContract.ts +92 -0
- package/src/fs/orpc/createContractClientFileSystem.ts +115 -0
- package/src/fs/orpc/index.ts +2 -0
- package/src/fs/orpc/server/createFileSystemContractImpl.ts +64 -0
- package/src/fs/orpc/server/index.ts +1 -0
- package/src/fs/s3/createS3MiniFileSystem.ts +830 -0
- package/src/fs/s3/index.ts +1 -0
- package/src/fs/s3/s3mini.test.ts +264 -0
- package/src/fs/scandir.ts +75 -0
- package/src/fs/server/createDatabaseFileSystem.ts +668 -0
- package/src/fs/server/createNodeFileSystem.ts +499 -0
- package/src/fs/server/dbfs.test.ts +47 -0
- package/src/fs/server/index.ts +1 -0
- package/src/fs/server/loadTestDatabase.ts +131 -0
- package/src/fs/tests/runFileSystemTest.ts +288 -0
- package/src/fs/types.ts +29 -0
- package/src/fs/utils/getFileUrl.ts +44 -0
- package/src/fs/utils.ts +23 -0
- package/src/jsonschema/JsonSchema.ts +118 -110
- package/src/jsonschema/forEachJsonSchema.ts +50 -0
- package/src/jsonschema/index.ts +1 -0
- package/src/orpc/createOpenApiContractClient.ts +52 -0
- package/src/orpc/createRpcContractClient.ts +50 -0
- package/src/orpc/index.ts +2 -0
- package/src/orpc/resolveLinkPlugins.ts +29 -0
- package/src/password/PHC.ts +3 -3
- package/src/password/Password.test.ts +1 -1
- package/src/password/Password.ts +2 -2
- package/src/password/createPBKDF2PasswordAlgorithm.ts +2 -2
- package/src/resource/ListQuery.ts +53 -0
- package/src/resource/index.ts +1 -0
- package/src/resource/schema/AnyResourceSchema.ts +17 -3
- package/src/resource/schema/index.ts +5 -0
- package/src/s3/formatS3Url.test.ts +254 -0
- package/src/s3/formatS3Url.ts +84 -0
- package/src/s3/index.ts +2 -0
- package/src/s3/parseS3Url.test.ts +258 -0
- package/src/s3/parseS3Url.ts +88 -0
- package/src/schema/SchemaRegistry.ts +48 -0
- package/src/schema/createSchemaData.ts +1 -1
- package/src/schema/formatZodError.test.ts +196 -0
- package/src/schema/formatZodError.ts +151 -0
- package/src/schema/getSchemaOptions.ts +3 -3
- package/src/schema/index.ts +1 -0
- package/src/utils/buildBaseUrl.ts +12 -0
- package/src/utils/buildRedactorFormSchema.ts +85 -0
- package/src/utils/getEstimateProcessTime.ts +36 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/resolveFeatureOptions.ts +14 -0
- package/lib/cn/Mod11Checksum.js +0 -85
- package/lib/cn/Mod31Checksum.js +0 -97
- package/lib/cn/ResidentIdentityCardNumber.js +0 -50
- package/lib/cn/formatDate.js +0 -13
- package/lib/cn/parseSex.js +0 -20
- package/lib/resource/schema/SchemaRegistry.js +0 -38
- package/lib/resource/schema/SexType.js +0 -10
- package/lib/search/AdvanceSearch.js +0 -9
- package/lib/search/AdvanceSearch.test.js +0 -435
- package/lib/search/formatAdvanceSearch.js +0 -78
- package/lib/search/index.js +0 -1
- package/lib/search/optimizeAdvanceSearch.js +0 -143
- package/lib/search/parseAdvanceSearch.js +0 -20
- package/lib/search/parser.d.js +0 -1
- package/lib/search/parser.js +0 -3088
- package/lib/search/types.d.js +0 -1
- package/src/cn/ResidentIdentityCardNumber.test.ts +0 -17
- package/src/cn/ResidentIdentityCardNumber.ts +0 -96
- package/src/cn/__snapshots__/ResidentIdentityCardNumber.test.ts.snap +0 -15
- package/src/cn/formatDate.ts +0 -12
- package/src/cn/parseSex.ts +0 -13
- package/src/resource/schema/SchemaRegistry.ts +0 -42
- package/src/resource/schema/SexType.ts +0 -13
- package/src/search/AdvanceSearch.test.ts +0 -149
- package/src/search/AdvanceSearch.ts +0 -14
- package/src/search/Makefile +0 -2
- package/src/search/__snapshots__/AdvanceSearch.test.ts.snap +0 -675
- package/src/search/formatAdvanceSearch.ts +0 -52
- package/src/search/index.ts +0 -1
- package/src/search/optimizeAdvanceSearch.ts +0 -77
- package/src/search/parseAdvanceSearch.ts +0 -23
- package/src/search/parser.d.ts +0 -8
- package/src/search/parser.js +0 -2794
- package/src/search/parser.peggy +0 -237
- package/src/search/types.d.ts +0 -45
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
}
|
|
6
|
+
catch (error) {
|
|
7
|
+
reject(error);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
if (info.done) {
|
|
11
|
+
resolve(value);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
Promise.resolve(value).then(_next, _throw);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function _async_to_generator(fn) {
|
|
18
|
+
return function () {
|
|
19
|
+
var self = this, args = arguments;
|
|
20
|
+
return new Promise(function (resolve, reject) {
|
|
21
|
+
var gen = fn.apply(self, args);
|
|
22
|
+
function _next(value) {
|
|
23
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
24
|
+
}
|
|
25
|
+
function _throw(err) {
|
|
26
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
27
|
+
}
|
|
28
|
+
_next(undefined);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function _ts_generator(thisArg, body) {
|
|
33
|
+
var f, y, t, _ = {
|
|
34
|
+
label: 0,
|
|
35
|
+
sent: function () {
|
|
36
|
+
if (t[0] & 1)
|
|
37
|
+
throw t[1];
|
|
38
|
+
return t[1];
|
|
39
|
+
},
|
|
40
|
+
trys: [],
|
|
41
|
+
ops: []
|
|
42
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
43
|
+
return d(g, "next", {
|
|
44
|
+
value: verb(0)
|
|
45
|
+
}), d(g, "throw", {
|
|
46
|
+
value: verb(1)
|
|
47
|
+
}), d(g, "return", {
|
|
48
|
+
value: verb(2)
|
|
49
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
50
|
+
value: function () {
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
}), g;
|
|
54
|
+
function verb(n) {
|
|
55
|
+
return function (v) {
|
|
56
|
+
return step([
|
|
57
|
+
n,
|
|
58
|
+
v
|
|
59
|
+
]);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function step(op) {
|
|
63
|
+
if (f)
|
|
64
|
+
throw new TypeError("Generator is already executing.");
|
|
65
|
+
while (g && (g = 0, op[0] && (_ = 0)), _)
|
|
66
|
+
try {
|
|
67
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
68
|
+
return t;
|
|
69
|
+
if (y = 0, t)
|
|
70
|
+
op = [
|
|
71
|
+
op[0] & 2,
|
|
72
|
+
t.value
|
|
73
|
+
];
|
|
74
|
+
switch (op[0]) {
|
|
75
|
+
case 0:
|
|
76
|
+
case 1:
|
|
77
|
+
t = op;
|
|
78
|
+
break;
|
|
79
|
+
case 4:
|
|
80
|
+
_.label++;
|
|
81
|
+
return {
|
|
82
|
+
value: op[1],
|
|
83
|
+
done: false
|
|
84
|
+
};
|
|
85
|
+
case 5:
|
|
86
|
+
_.label++;
|
|
87
|
+
y = op[1];
|
|
88
|
+
op = [
|
|
89
|
+
0
|
|
90
|
+
];
|
|
91
|
+
continue;
|
|
92
|
+
case 7:
|
|
93
|
+
op = _.ops.pop();
|
|
94
|
+
_.trys.pop();
|
|
95
|
+
continue;
|
|
96
|
+
default:
|
|
97
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
98
|
+
_ = 0;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
102
|
+
_.label = op[1];
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
106
|
+
_.label = t[1];
|
|
107
|
+
t = op;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
if (t && _.label < t[2]) {
|
|
111
|
+
_.label = t[2];
|
|
112
|
+
_.ops.push(op);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
if (t[2])
|
|
116
|
+
_.ops.pop();
|
|
117
|
+
_.trys.pop();
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
op = body.call(thisArg, _);
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
op = [
|
|
124
|
+
6,
|
|
125
|
+
e
|
|
126
|
+
];
|
|
127
|
+
y = 0;
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
f = t = 0;
|
|
131
|
+
}
|
|
132
|
+
if (op[0] & 5)
|
|
133
|
+
throw op[1];
|
|
134
|
+
return {
|
|
135
|
+
value: op[0] ? op[1] : void 0,
|
|
136
|
+
done: true
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
import { beforeEach, describe, test } from "vitest";
|
|
141
|
+
import { createMemoryFileSystem } from "./createMemoryFileSystem.js";
|
|
142
|
+
import { runFileSystemTest } from "./tests/runFileSystemTest.js";
|
|
143
|
+
describe("MemoryFileSystem", function () {
|
|
144
|
+
var fs;
|
|
145
|
+
beforeEach(function () {
|
|
146
|
+
fs = createMemoryFileSystem({
|
|
147
|
+
root: {
|
|
148
|
+
path: "/",
|
|
149
|
+
directory: "",
|
|
150
|
+
name: "",
|
|
151
|
+
kind: "directory",
|
|
152
|
+
meta: {},
|
|
153
|
+
mtime: Date.now(),
|
|
154
|
+
size: 0,
|
|
155
|
+
children: [
|
|
156
|
+
{
|
|
157
|
+
path: "/README.txt",
|
|
158
|
+
directory: "/",
|
|
159
|
+
name: "README.txt",
|
|
160
|
+
kind: "file",
|
|
161
|
+
content: "Hello",
|
|
162
|
+
size: 5,
|
|
163
|
+
meta: {},
|
|
164
|
+
mtime: Date.now()
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
test("common tests", function () {
|
|
171
|
+
return _async_to_generator(function () {
|
|
172
|
+
return _ts_generator(this, function (_state) {
|
|
173
|
+
switch (_state.label) {
|
|
174
|
+
case 0:
|
|
175
|
+
return [
|
|
176
|
+
4,
|
|
177
|
+
runFileSystemTest(fs)
|
|
178
|
+
];
|
|
179
|
+
case 1:
|
|
180
|
+
_state.sent();
|
|
181
|
+
return [
|
|
182
|
+
2
|
|
183
|
+
];
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
})();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { dirname, join, normalize } from "pathe";
|
|
2
|
+
let BrowserFSError = class BrowserFSError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(message, code){
|
|
5
|
+
super(message), this.code = code;
|
|
6
|
+
this.name = 'BrowserFSError';
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Creates an IFileSystem instance backed by the browser's File System Access API.
|
|
11
|
+
* @param root A FileSystemDirectoryHandle, usually obtained from `window.showDirectoryPicker()`.
|
|
12
|
+
*/ export function createBrowserFileSystem(root) {
|
|
13
|
+
return new BrowserFS(root);
|
|
14
|
+
}
|
|
15
|
+
let BrowserFS = class BrowserFS {
|
|
16
|
+
root;
|
|
17
|
+
node;
|
|
18
|
+
constructor(root){
|
|
19
|
+
this.root = root;
|
|
20
|
+
this.node = {
|
|
21
|
+
path: '/',
|
|
22
|
+
name: '',
|
|
23
|
+
directory: '',
|
|
24
|
+
kind: 'directory',
|
|
25
|
+
mtime: 0,
|
|
26
|
+
size: 0,
|
|
27
|
+
meta: {
|
|
28
|
+
handle: root
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Resolves a path string to a file or directory handle. This is the core navigation logic.
|
|
34
|
+
* @returns A tuple of [handle, parentHandle, name] or [null, parentHandle, name] if not found.
|
|
35
|
+
*/ async _getHandle(path) {
|
|
36
|
+
const normalized = normalize(path);
|
|
37
|
+
if (normalized === '/' || normalized === '.') {
|
|
38
|
+
return [
|
|
39
|
+
this.root,
|
|
40
|
+
null,
|
|
41
|
+
this.root.name
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
const parts = normalized.split('/').filter((p)=>p);
|
|
45
|
+
const name = parts.pop();
|
|
46
|
+
let parent = this.root;
|
|
47
|
+
for (const part of parts){
|
|
48
|
+
try {
|
|
49
|
+
parent = await parent.getDirectoryHandle(part);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
if (e.name === 'NotFoundError' || e.name === 'TypeMismatchError') {
|
|
52
|
+
return [
|
|
53
|
+
null,
|
|
54
|
+
null,
|
|
55
|
+
name
|
|
56
|
+
]; // Parent path does not exist or is a file
|
|
57
|
+
}
|
|
58
|
+
throw e;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
// Check for file first, then directory
|
|
63
|
+
const handle = await parent.getFileHandle(name).catch(()=>parent.getDirectoryHandle(name));
|
|
64
|
+
return [
|
|
65
|
+
handle,
|
|
66
|
+
parent,
|
|
67
|
+
name
|
|
68
|
+
];
|
|
69
|
+
} catch (e) {
|
|
70
|
+
if (e.name === 'NotFoundError') {
|
|
71
|
+
return [
|
|
72
|
+
null,
|
|
73
|
+
parent,
|
|
74
|
+
name
|
|
75
|
+
]; // Entry not found
|
|
76
|
+
}
|
|
77
|
+
throw e;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Converts a FileSystemHandle into our standard IFileStat object.
|
|
82
|
+
*/ async _toFileStat(handle, path) {
|
|
83
|
+
const isFile = handle.kind === 'file';
|
|
84
|
+
const file = isFile ? await handle.getFile() : undefined;
|
|
85
|
+
return {
|
|
86
|
+
name: handle.name,
|
|
87
|
+
kind: handle.kind,
|
|
88
|
+
path: path,
|
|
89
|
+
directory: dirname(path),
|
|
90
|
+
size: file?.size ?? 0,
|
|
91
|
+
mtime: file?.lastModified ?? Date.now(),
|
|
92
|
+
meta: {
|
|
93
|
+
handle,
|
|
94
|
+
file
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// --- IFileSystem Implementation ---
|
|
99
|
+
async stat(path) {
|
|
100
|
+
const [handle] = await this._getHandle(path);
|
|
101
|
+
if (!handle) {
|
|
102
|
+
throw new BrowserFSError(`Path not found: ${path}`, 'ENOENT');
|
|
103
|
+
}
|
|
104
|
+
return this._toFileStat(handle, path);
|
|
105
|
+
}
|
|
106
|
+
async exists(path) {
|
|
107
|
+
const [handle] = await this._getHandle(path);
|
|
108
|
+
return !!handle;
|
|
109
|
+
}
|
|
110
|
+
async readdir(dir, options) {
|
|
111
|
+
const [handle] = await this._getHandle(dir);
|
|
112
|
+
if (!handle) {
|
|
113
|
+
throw new BrowserFSError(`Directory not found: ${dir}`, 'ENOENT');
|
|
114
|
+
}
|
|
115
|
+
if (handle.kind !== 'directory') {
|
|
116
|
+
throw new BrowserFSError(`Not a directory: ${dir}`, 'ENOTDIR');
|
|
117
|
+
}
|
|
118
|
+
const entries = [];
|
|
119
|
+
for await (const entry of handle.values()){
|
|
120
|
+
entries.push(await this._toFileStat(entry, join(dir, entry.name)));
|
|
121
|
+
}
|
|
122
|
+
return entries;
|
|
123
|
+
}
|
|
124
|
+
async mkdir(path, options = {}) {
|
|
125
|
+
const parts = normalize(path).split('/').filter((p)=>p);
|
|
126
|
+
let currentDir = this.root;
|
|
127
|
+
for (const part of parts){
|
|
128
|
+
try {
|
|
129
|
+
currentDir = await currentDir.getDirectoryHandle(part, {
|
|
130
|
+
create: options.recursive
|
|
131
|
+
});
|
|
132
|
+
} catch (e) {
|
|
133
|
+
// If recursive is false, getDirectoryHandle throws if a segment is missing.
|
|
134
|
+
// We re-throw a more standard error.
|
|
135
|
+
if (e.name === 'NotFoundError' && !options.recursive) {
|
|
136
|
+
throw new BrowserFSError(`Cannot create directory: Parent does not exist for path ${path}`, 'ENOENT');
|
|
137
|
+
}
|
|
138
|
+
// If it's another error (like a file with the same name), re-throw it.
|
|
139
|
+
throw e;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async readFile(path, options) {
|
|
144
|
+
const [handle] = await this._getHandle(path);
|
|
145
|
+
if (!handle || handle.kind !== 'file') {
|
|
146
|
+
throw new BrowserFSError(`File not found: ${path}`, 'ENOENT');
|
|
147
|
+
}
|
|
148
|
+
const file = await handle.getFile();
|
|
149
|
+
return options?.encoding === 'text' ? file.text() : file.bytes();
|
|
150
|
+
}
|
|
151
|
+
async writeFile(path, data, options = {}) {
|
|
152
|
+
const { overwrite = true } = options;
|
|
153
|
+
const [handle, parent, name] = await this._getHandle(path);
|
|
154
|
+
if (!parent) {
|
|
155
|
+
throw new BrowserFSError(`Parent directory does not exist for path: ${path}`, 'ENOENT');
|
|
156
|
+
}
|
|
157
|
+
if (handle && !overwrite) {
|
|
158
|
+
throw new BrowserFSError(`File already exists: ${path}`, 'EEXIST');
|
|
159
|
+
}
|
|
160
|
+
const fileHandle = await parent.getFileHandle(name, {
|
|
161
|
+
create: true
|
|
162
|
+
});
|
|
163
|
+
const writable = await fileHandle.createWritable();
|
|
164
|
+
await writable.write(data);
|
|
165
|
+
await writable.close();
|
|
166
|
+
}
|
|
167
|
+
async rm(path, options = {}) {
|
|
168
|
+
const { recursive = false, force = false } = options;
|
|
169
|
+
const [handle, parent, name] = await this._getHandle(path);
|
|
170
|
+
if (!handle) {
|
|
171
|
+
if (force) return; // If force is true, do not error on not found.
|
|
172
|
+
throw new BrowserFSError(`Path not found: ${path}`, 'ENOENT');
|
|
173
|
+
}
|
|
174
|
+
if (!parent) {
|
|
175
|
+
throw new BrowserFSError(`Cannot remove root directory`);
|
|
176
|
+
}
|
|
177
|
+
await parent.removeEntry(name, {
|
|
178
|
+
recursive
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
async rename(oldPath, newPath, options) {
|
|
182
|
+
// The File System Access API does NOT have a native move/rename.
|
|
183
|
+
// The standard workaround is to copy, then delete the original.
|
|
184
|
+
await this.copy(oldPath, newPath, options);
|
|
185
|
+
await this.rm(oldPath, {
|
|
186
|
+
recursive: true
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
async copy(srcPath, destPath, options) {
|
|
190
|
+
const [srcHandle] = await this._getHandle(srcPath);
|
|
191
|
+
if (!srcHandle) {
|
|
192
|
+
throw new BrowserFSError(`Source not found: ${srcPath}`, 'ENOENT');
|
|
193
|
+
}
|
|
194
|
+
const [destHandle, destParent, destName] = await this._getHandle(destPath);
|
|
195
|
+
if (!destParent) {
|
|
196
|
+
throw new BrowserFSError(`Destination directory does not exist: ${dirname(destPath)}`, 'ENOENT');
|
|
197
|
+
}
|
|
198
|
+
if (destHandle && !options?.overwrite) {
|
|
199
|
+
throw new BrowserFSError(`Destination already exists: ${destPath}`, 'EEXIST');
|
|
200
|
+
}
|
|
201
|
+
if (destHandle?.kind === 'directory' && srcHandle.kind === 'file') {
|
|
202
|
+
throw new BrowserFSError(`Cannot overwrite a directory with a file: ${destPath}`, 'EISDIR');
|
|
203
|
+
}
|
|
204
|
+
await this._copyEntry(srcHandle, destParent, destName);
|
|
205
|
+
}
|
|
206
|
+
async _copyEntry(srcHandle, destDirHandle, newName) {
|
|
207
|
+
if (srcHandle.kind === 'file') {
|
|
208
|
+
const file = await srcHandle.getFile();
|
|
209
|
+
const destFileHandle = await destDirHandle.getFileHandle(newName, {
|
|
210
|
+
create: true
|
|
211
|
+
});
|
|
212
|
+
const writable = await destFileHandle.createWritable();
|
|
213
|
+
await writable.write(file);
|
|
214
|
+
await writable.close();
|
|
215
|
+
} else if (srcHandle.kind === 'directory') {
|
|
216
|
+
const newDirHandle = await destDirHandle.getDirectoryHandle(newName, {
|
|
217
|
+
create: true
|
|
218
|
+
});
|
|
219
|
+
for await (const entry of srcHandle.values()){
|
|
220
|
+
await this._copyEntry(entry, newDirHandle, entry.name);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async createUrl(stat, options) {
|
|
225
|
+
// The handle is stored in the meta property in our _toFileStat method
|
|
226
|
+
const handle = stat.meta.handle;
|
|
227
|
+
if (handle?.kind !== 'file') {
|
|
228
|
+
// Return a placeholder or throw an error for directories
|
|
229
|
+
return '';
|
|
230
|
+
}
|
|
231
|
+
const file = await handle.getFile();
|
|
232
|
+
return URL.createObjectURL(file);
|
|
233
|
+
}
|
|
234
|
+
createReadStream() {
|
|
235
|
+
throw new Error('Streaming is not implemented for BrowserFS. Use readFile instead.');
|
|
236
|
+
}
|
|
237
|
+
createWriteStream() {
|
|
238
|
+
throw new Error('Streaming is not implemented for BrowserFS. Use writeFile instead.');
|
|
239
|
+
}
|
|
240
|
+
createWritableStream() {
|
|
241
|
+
throw new Error('Streaming is not implemented for BrowserFS. Use writeFile instead.');
|
|
242
|
+
}
|
|
243
|
+
createReadableStream() {
|
|
244
|
+
throw new Error('Streaming is not implemented for BrowserFS. Use readFile instead.');
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
//# sourceMappingURL=createBrowserFileSystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/fs/createBrowserFileSystem.ts"],"sourcesContent":["import { dirname, join, normalize } from 'pathe';\nimport type {\n\tCopyOptions,\n\tIFileStat,\n\tIFileSystem,\n\tMkdirOptions,\n\tReaddirOptions,\n\tReadFileOptions,\n\tRenameOptions,\n\tRmOptions,\n\tWriteFileOptions,\n} from './IFileSystem';\nimport type { FileUrlOptions } from './types';\n\nclass BrowserFSError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic code?: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'BrowserFSError';\n\t}\n}\n\ntype BrowserFile = IFileStat & {\n\tkind: 'file';\n\tmeta: {\n\t\thandle: FileSystemFileHandle;\n\t\tfile: File;\n\t};\n};\n\ntype BrowserDirectory = IFileStat & {\n\tkind: 'directory';\n\tmeta: {\n\t\thandle: FileSystemDirectoryHandle;\n\t};\n};\n\ntype BrowserNode = BrowserFile | BrowserDirectory;\n\n/**\n * Creates an IFileSystem instance backed by the browser's File System Access API.\n * @param root A FileSystemDirectoryHandle, usually obtained from `window.showDirectoryPicker()`.\n */\nexport function createBrowserFileSystem(root: FileSystemDirectoryHandle): IFileSystem {\n\treturn new BrowserFS(root);\n}\n\nclass BrowserFS implements IFileSystem {\n\troot: FileSystemDirectoryHandle;\n\tnode: BrowserDirectory;\n\n\tconstructor(root: FileSystemDirectoryHandle) {\n\t\tthis.root = root;\n\t\tthis.node = {\n\t\t\tpath: '/',\n\t\t\tname: '',\n\t\t\tdirectory: '',\n\t\t\tkind: 'directory',\n\t\t\tmtime: 0,\n\t\t\tsize: 0,\n\t\t\tmeta: {\n\t\t\t\thandle: root,\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Resolves a path string to a file or directory handle. This is the core navigation logic.\n\t * @returns A tuple of [handle, parentHandle, name] or [null, parentHandle, name] if not found.\n\t */\n\tprivate async _getHandle(path: string): Promise<[FileSystemHandle | null, FileSystemDirectoryHandle | null, string]> {\n\t\tconst normalized = normalize(path);\n\t\tif (normalized === '/' || normalized === '.') {\n\t\t\treturn [this.root, null, this.root.name];\n\t\t}\n\n\t\tconst parts = normalized.split('/').filter((p) => p);\n\t\tconst name = parts.pop()!;\n\n\t\tlet parent: FileSystemDirectoryHandle = this.root;\n\t\tfor (const part of parts) {\n\t\t\ttry {\n\t\t\t\tparent = await parent.getDirectoryHandle(part);\n\t\t\t} catch (e: any) {\n\t\t\t\tif (e.name === 'NotFoundError' || e.name === 'TypeMismatchError') {\n\t\t\t\t\treturn [null, null, name]; // Parent path does not exist or is a file\n\t\t\t\t}\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\t// Check for file first, then directory\n\t\t\tconst handle = await parent.getFileHandle(name).catch(() => parent.getDirectoryHandle(name));\n\t\t\treturn [handle, parent, name];\n\t\t} catch (e: any) {\n\t\t\tif (e.name === 'NotFoundError') {\n\t\t\t\treturn [null, parent, name]; // Entry not found\n\t\t\t}\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\t/**\n\t * Converts a FileSystemHandle into our standard IFileStat object.\n\t */\n\tprivate async _toFileStat(handle: FileSystemHandle, path: string): Promise<IFileStat> {\n\t\tconst isFile = handle.kind === 'file';\n\t\tconst file = isFile ? await (handle as FileSystemFileHandle).getFile() : undefined;\n\n\t\treturn {\n\t\t\tname: handle.name,\n\t\t\tkind: handle.kind,\n\t\t\tpath: path,\n\t\t\tdirectory: dirname(path),\n\t\t\tsize: file?.size ?? 0,\n\t\t\tmtime: file?.lastModified ?? Date.now(),\n\t\t\tmeta: { handle, file },\n\t\t};\n\t}\n\n\t// --- IFileSystem Implementation ---\n\n\tasync stat(path: string): Promise<IFileStat> {\n\t\tconst [handle] = await this._getHandle(path);\n\t\tif (!handle) {\n\t\t\tthrow new BrowserFSError(`Path not found: ${path}`, 'ENOENT');\n\t\t}\n\t\treturn this._toFileStat(handle, path);\n\t}\n\n\tasync exists(path: string): Promise<boolean> {\n\t\tconst [handle] = await this._getHandle(path);\n\t\treturn !!handle;\n\t}\n\n\tasync readdir(dir: string, options?: ReaddirOptions): Promise<IFileStat[]> {\n\t\tconst [handle] = await this._getHandle(dir);\n\t\tif (!handle) {\n\t\t\tthrow new BrowserFSError(`Directory not found: ${dir}`, 'ENOENT');\n\t\t}\n\t\tif (handle.kind !== 'directory') {\n\t\t\tthrow new BrowserFSError(`Not a directory: ${dir}`, 'ENOTDIR');\n\t\t}\n\n\t\tconst entries: IFileStat[] = [];\n\t\tfor await (const entry of (handle as FileSystemDirectoryHandle).values()) {\n\t\t\tentries.push(await this._toFileStat(entry, join(dir, entry.name)));\n\t\t}\n\t\treturn entries;\n\t}\n\n\tasync mkdir(path: string, options: MkdirOptions = {}): Promise<void> {\n\t\tconst parts = normalize(path)\n\t\t\t.split('/')\n\t\t\t.filter((p) => p);\n\t\tlet currentDir = this.root;\n\n\t\tfor (const part of parts) {\n\t\t\ttry {\n\t\t\t\tcurrentDir = await currentDir.getDirectoryHandle(part, { create: options.recursive });\n\t\t\t} catch (e: any) {\n\t\t\t\t// If recursive is false, getDirectoryHandle throws if a segment is missing.\n\t\t\t\t// We re-throw a more standard error.\n\t\t\t\tif (e.name === 'NotFoundError' && !options.recursive) {\n\t\t\t\t\tthrow new BrowserFSError(`Cannot create directory: Parent does not exist for path ${path}`, 'ENOENT');\n\t\t\t\t}\n\t\t\t\t// If it's another error (like a file with the same name), re-throw it.\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\t}\n\n\treadFile(path: string, options?: ReadFileOptions & { encoding: 'text' }): Promise<string>;\n\treadFile(path: string, options?: ReadFileOptions): Promise<Uint8Array>;\n\tasync readFile(path: string, options?: ReadFileOptions): Promise<string | Uint8Array> {\n\t\tconst [handle] = await this._getHandle(path);\n\t\tif (!handle || handle.kind !== 'file') {\n\t\t\tthrow new BrowserFSError(`File not found: ${path}`, 'ENOENT');\n\t\t}\n\t\tconst file = await (handle as FileSystemFileHandle).getFile();\n\t\treturn options?.encoding === 'text' ? file.text() : file.bytes();\n\t}\n\n\tasync writeFile(path: string, data: any, options: WriteFileOptions = {}): Promise<void> {\n\t\tconst { overwrite = true } = options;\n\t\tconst [handle, parent, name] = await this._getHandle(path);\n\n\t\tif (!parent) {\n\t\t\tthrow new BrowserFSError(`Parent directory does not exist for path: ${path}`, 'ENOENT');\n\t\t}\n\t\tif (handle && !overwrite) {\n\t\t\tthrow new BrowserFSError(`File already exists: ${path}`, 'EEXIST');\n\t\t}\n\n\t\tconst fileHandle = await parent.getFileHandle(name, { create: true });\n\t\tconst writable = await fileHandle.createWritable();\n\t\tawait writable.write(data);\n\t\tawait writable.close();\n\t}\n\n\tasync rm(path: string, options: RmOptions = {}): Promise<void> {\n\t\tconst { recursive = false, force = false } = options;\n\t\tconst [handle, parent, name] = await this._getHandle(path);\n\n\t\tif (!handle) {\n\t\t\tif (force) return; // If force is true, do not error on not found.\n\t\t\tthrow new BrowserFSError(`Path not found: ${path}`, 'ENOENT');\n\t\t}\n\t\tif (!parent) {\n\t\t\tthrow new BrowserFSError(`Cannot remove root directory`);\n\t\t}\n\n\t\tawait parent.removeEntry(name, { recursive });\n\t}\n\n\tasync rename(oldPath: string, newPath: string, options?: RenameOptions): Promise<void> {\n\t\t// The File System Access API does NOT have a native move/rename.\n\t\t// The standard workaround is to copy, then delete the original.\n\t\tawait this.copy(oldPath, newPath, options);\n\t\tawait this.rm(oldPath, { recursive: true });\n\t}\n\n\tasync copy(srcPath: string, destPath: string, options?: CopyOptions): Promise<void> {\n\t\tconst [srcHandle] = await this._getHandle(srcPath);\n\t\tif (!srcHandle) {\n\t\t\tthrow new BrowserFSError(`Source not found: ${srcPath}`, 'ENOENT');\n\t\t}\n\n\t\tconst [destHandle, destParent, destName] = await this._getHandle(destPath);\n\t\tif (!destParent) {\n\t\t\tthrow new BrowserFSError(`Destination directory does not exist: ${dirname(destPath)}`, 'ENOENT');\n\t\t}\n\t\tif (destHandle && !options?.overwrite) {\n\t\t\tthrow new BrowserFSError(`Destination already exists: ${destPath}`, 'EEXIST');\n\t\t}\n\t\tif (destHandle?.kind === 'directory' && srcHandle.kind === 'file') {\n\t\t\tthrow new BrowserFSError(`Cannot overwrite a directory with a file: ${destPath}`, 'EISDIR');\n\t\t}\n\n\t\tawait this._copyEntry(srcHandle, destParent, destName);\n\t}\n\n\tprivate async _copyEntry(\n\t\tsrcHandle: FileSystemHandle,\n\t\tdestDirHandle: FileSystemDirectoryHandle,\n\t\tnewName: string,\n\t): Promise<void> {\n\t\tif (srcHandle.kind === 'file') {\n\t\t\tconst file = await (srcHandle as FileSystemFileHandle).getFile();\n\t\t\tconst destFileHandle = await destDirHandle.getFileHandle(newName, { create: true });\n\t\t\tconst writable = await destFileHandle.createWritable();\n\t\t\tawait writable.write(file);\n\t\t\tawait writable.close();\n\t\t} else if (srcHandle.kind === 'directory') {\n\t\t\tconst newDirHandle = await destDirHandle.getDirectoryHandle(newName, { create: true });\n\t\t\tfor await (const entry of (srcHandle as FileSystemDirectoryHandle).values()) {\n\t\t\t\tawait this._copyEntry(entry, newDirHandle, entry.name);\n\t\t\t}\n\t\t}\n\t}\n\n\tasync createUrl(stat: IFileStat, options?: FileUrlOptions): Promise<string> {\n\t\t// The handle is stored in the meta property in our _toFileStat method\n\t\tconst handle = stat.meta.handle as FileSystemHandle | undefined;\n\t\tif (handle?.kind !== 'file') {\n\t\t\t// Return a placeholder or throw an error for directories\n\t\t\treturn '';\n\t\t}\n\t\tconst file = await (handle as FileSystemFileHandle).getFile();\n\t\treturn URL.createObjectURL(file);\n\t}\n\n\tcreateReadStream(): never {\n\t\tthrow new Error('Streaming is not implemented for BrowserFS. Use readFile instead.');\n\t}\n\n\tcreateWriteStream(): never {\n\t\tthrow new Error('Streaming is not implemented for BrowserFS. Use writeFile instead.');\n\t}\n\n\tcreateWritableStream(): never {\n\t\tthrow new Error('Streaming is not implemented for BrowserFS. Use writeFile instead.');\n\t}\n\n\tcreateReadableStream(): never {\n\t\tthrow new Error('Streaming is not implemented for BrowserFS. Use readFile instead.');\n\t}\n}\n"],"names":["dirname","join","normalize","BrowserFSError","Error","message","code","name","createBrowserFileSystem","root","BrowserFS","node","path","directory","kind","mtime","size","meta","handle","_getHandle","normalized","parts","split","filter","p","pop","parent","part","getDirectoryHandle","e","getFileHandle","catch","_toFileStat","isFile","file","getFile","undefined","lastModified","Date","now","stat","exists","readdir","dir","options","entries","entry","values","push","mkdir","currentDir","create","recursive","readFile","encoding","text","bytes","writeFile","data","overwrite","fileHandle","writable","createWritable","write","close","rm","force","removeEntry","rename","oldPath","newPath","copy","srcPath","destPath","srcHandle","destHandle","destParent","destName","_copyEntry","destDirHandle","newName","destFileHandle","newDirHandle","createUrl","URL","createObjectURL","createReadStream","createWriteStream","createWritableStream","createReadableStream"],"mappings":"AAAA,SAASA,OAAO,EAAEC,IAAI,EAAEC,SAAS,QAAQ,QAAQ;AAcjD,IAAA,AAAMC,iBAAN,MAAMA,uBAAuBC;;IAC5B,YACCC,OAAe,EACf,AAAOC,IAAa,CACnB;QACD,KAAK,CAACD,eAFCC,OAAAA;QAGP,IAAI,CAACC,IAAI,GAAG;IACb;AACD;AAmBA;;;CAGC,GACD,OAAO,SAASC,wBAAwBC,IAA+B;IACtE,OAAO,IAAIC,UAAUD;AACtB;AAEA,IAAA,AAAMC,YAAN,MAAMA;IACLD,KAAgC;IAChCE,KAAuB;IAEvB,YAAYF,IAA+B,CAAE;QAC5C,IAAI,CAACA,IAAI,GAAGA;QACZ,IAAI,CAACE,IAAI,GAAG;YACXC,MAAM;YACNL,MAAM;YACNM,WAAW;YACXC,MAAM;YACNC,OAAO;YACPC,MAAM;YACNC,MAAM;gBACLC,QAAQT;YACT;QACD;IACD;IAEA;;;EAGC,GACD,MAAcU,WAAWP,IAAY,EAAgF;QACpH,MAAMQ,aAAalB,UAAUU;QAC7B,IAAIQ,eAAe,OAAOA,eAAe,KAAK;YAC7C,OAAO;gBAAC,IAAI,CAACX,IAAI;gBAAE;gBAAM,IAAI,CAACA,IAAI,CAACF,IAAI;aAAC;QACzC;QAEA,MAAMc,QAAQD,WAAWE,KAAK,CAAC,KAAKC,MAAM,CAAC,CAACC,IAAMA;QAClD,MAAMjB,OAAOc,MAAMI,GAAG;QAEtB,IAAIC,SAAoC,IAAI,CAACjB,IAAI;QACjD,KAAK,MAAMkB,QAAQN,MAAO;YACzB,IAAI;gBACHK,SAAS,MAAMA,OAAOE,kBAAkB,CAACD;YAC1C,EAAE,OAAOE,GAAQ;gBAChB,IAAIA,EAAEtB,IAAI,KAAK,mBAAmBsB,EA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