typia 13.1.19 → 13.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/executable/FileSystemIdentity.d.ts +23 -0
- package/lib/executable/FileSystemIdentity.js +30 -0
- package/lib/executable/FileSystemIdentity.js.map +1 -1
- package/lib/executable/FileSystemIdentity.mjs +4 -0
- package/lib/executable/FileSystemIdentity.mjs.map +1 -1
- package/lib/executable/TypiaGenerateWizard.js +15 -9
- package/lib/executable/TypiaGenerateWizard.js.map +1 -1
- package/lib/executable/TypiaGenerateWizard.mjs +11 -7
- package/lib/executable/TypiaGenerateWizard.mjs.map +1 -1
- package/lib/internal/_ProtobufReader.d.ts +18 -3
- package/lib/internal/_ProtobufReader.js +39 -11
- package/lib/internal/_ProtobufReader.js.map +1 -1
- package/lib/internal/_ProtobufReader.mjs +37 -10
- package/lib/internal/_ProtobufReader.mjs.map +1 -1
- package/lib/internal/_jsonStringifyArray.d.ts +1 -0
- package/lib/internal/_jsonStringifyArray.js +48 -0
- package/lib/internal/_jsonStringifyArray.js.map +1 -0
- package/lib/internal/_jsonStringifyArray.mjs +40 -0
- package/lib/internal/_jsonStringifyArray.mjs.map +1 -0
- package/lib/internal/_jsonStringifyElement.d.ts +1 -0
- package/lib/internal/_jsonStringifyElement.js +23 -0
- package/lib/internal/_jsonStringifyElement.js.map +1 -0
- package/lib/internal/_jsonStringifyElement.mjs +23 -0
- package/lib/internal/_jsonStringifyElement.mjs.map +1 -0
- package/lib/internal/_jsonStringifyProperty.d.ts +1 -0
- package/lib/internal/_jsonStringifyProperty.js +31 -0
- package/lib/internal/_jsonStringifyProperty.js.map +1 -0
- package/lib/internal/_jsonStringifyProperty.mjs +31 -0
- package/lib/internal/_jsonStringifyProperty.mjs.map +1 -0
- package/lib/internal/_llmApplicationFinalize.js +1 -1
- package/lib/internal/_llmApplicationFinalize.js.map +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs +1 -1
- package/lib/internal/_llmApplicationFinalize.mjs.map +1 -1
- package/lib/internal/_randomFormatByte.js +24 -1
- package/lib/internal/_randomFormatByte.js.map +1 -1
- package/lib/internal/_randomFormatByte.mjs +20 -2
- package/lib/internal/_randomFormatByte.mjs.map +1 -1
- package/lib/internal/_randomFormatDate.d.ts +3 -6
- package/lib/internal/_randomFormatDate.js +2 -10
- package/lib/internal/_randomFormatDate.js.map +1 -1
- package/lib/internal/_randomFormatDate.mjs +2 -6
- package/lib/internal/_randomFormatDate.mjs.map +1 -1
- package/lib/internal/_randomFormatDatetime.d.ts +3 -6
- package/lib/internal/_randomFormatDatetime.js +25 -8
- package/lib/internal/_randomFormatDatetime.js.map +1 -1
- package/lib/internal/_randomFormatDatetime.mjs +17 -7
- package/lib/internal/_randomFormatDatetime.mjs.map +1 -1
- package/lib/internal/_randomFormatDuration.js +23 -15
- package/lib/internal/_randomFormatDuration.js.map +1 -1
- package/lib/internal/_randomFormatDuration.mjs +23 -15
- package/lib/internal/_randomFormatDuration.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv4.js +31 -1
- package/lib/internal/_randomFormatIpv4.js.map +1 -1
- package/lib/internal/_randomFormatIpv4.mjs +23 -2
- package/lib/internal/_randomFormatIpv4.mjs.map +1 -1
- package/lib/internal/_randomFormatIpv6.js +57 -1
- package/lib/internal/_randomFormatIpv6.js.map +1 -1
- package/lib/internal/_randomFormatIpv6.mjs +45 -2
- package/lib/internal/_randomFormatIpv6.mjs.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.js +14 -2
- package/lib/internal/_randomFormatJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatJsonPointer.mjs +13 -3
- package/lib/internal/_randomFormatJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatRegex.js +14 -1
- package/lib/internal/_randomFormatRegex.js.map +1 -1
- package/lib/internal/_randomFormatRegex.mjs +14 -2
- package/lib/internal/_randomFormatRegex.mjs.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.js +19 -5
- package/lib/internal/_randomFormatRelativeJsonPointer.js.map +1 -1
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs +21 -6
- package/lib/internal/_randomFormatRelativeJsonPointer.mjs.map +1 -1
- package/lib/internal/_randomFormatTime.js +33 -7
- package/lib/internal/_randomFormatTime.js.map +1 -1
- package/lib/internal/_randomFormatTime.mjs +37 -5
- package/lib/internal/_randomFormatTime.mjs.map +1 -1
- package/lib/internal/_randomPattern.js.map +1 -1
- package/lib/internal/_randomPattern.mjs.map +1 -1
- package/lib/internal/_randomStringLength.d.ts +41 -10
- package/lib/internal/_randomStringLength.js +49 -13
- package/lib/internal/_randomStringLength.js.map +1 -1
- package/lib/internal/_randomStringLength.mjs +48 -13
- package/lib/internal/_randomStringLength.mjs.map +1 -1
- package/lib/internal/private/__notationRename.js.map +1 -1
- package/lib/internal/private/__notationRename.mjs.map +1 -1
- package/lib/internal/private/__randomComposition.d.ts +23 -0
- package/lib/internal/private/__randomComposition.js +48 -0
- package/lib/internal/private/__randomComposition.js.map +1 -0
- package/lib/internal/private/__randomComposition.mjs +54 -0
- package/lib/internal/private/__randomComposition.mjs.map +1 -0
- package/lib/internal/private/__randomEpoch.d.ts +19 -0
- package/lib/internal/private/__randomEpoch.js +31 -0
- package/lib/internal/private/__randomEpoch.js.map +1 -0
- package/lib/internal/private/__randomEpoch.mjs +28 -0
- package/lib/internal/private/__randomEpoch.mjs.map +1 -0
- package/native/cmd/ttsc-typia/build.go +3 -0
- package/native/cmd/ttsc-typia/callable_interface_function_semantics_transform_test.go +331 -0
- package/native/cmd/ttsc-typia/callable_type_literal_boundaries_transform_test.go +1184 -0
- package/native/cmd/ttsc-typia/compare_functional_union_membership_transform_test.go +434 -0
- package/native/cmd/ttsc-typia/compare_template_literal_union_transform_test.go +241 -0
- package/native/cmd/ttsc-typia/default_library_spoof_native_identity_transform_test.go +216 -0
- package/native/cmd/ttsc-typia/json_schema_dynamic_key_determinism_transform_test.go +246 -0
- package/native/cmd/ttsc-typia/json_stringify_contextual_undefined_transform_test.go +556 -0
- package/native/cmd/ttsc-typia/lib_replacement_native_identity_transform_test.go +277 -0
- package/native/cmd/ttsc-typia/native_named_intersection_union_transform_test.go +390 -0
- package/native/cmd/ttsc-typia/node_buffer_native_exports_is_transform_test.go +526 -0
- package/native/cmd/ttsc-typia/package_declaration_native_identity_is_transform_test.go +293 -0
- package/native/cmd/ttsc-typia/protobuf_diagnostic_code_transform_test.go +167 -0
- package/native/cmd/ttsc-typia/symbol_index_domain_transform_test.go +316 -0
- package/native/cmd/ttsc-typia/transform.go +23 -0
- package/native/cmd/ttsc-typia/transform_helpers_test.go +77 -2
- package/native/cmd/ttsc-typia/user_global_native_identity_transform_test.go +484 -0
- package/native/core/factories/ProtobufFactory.go +6 -1
- package/native/core/factories/internal/metadata/MetadataHelper.go +185 -30
- package/native/core/factories/internal/metadata/emplace_metadata_object.go +25 -0
- package/native/core/factories/internal/metadata/iterate_metadata_function.go +1 -1
- package/native/core/factories/internal/metadata/iterate_metadata_intersection.go +103 -23
- package/native/core/factories/internal/metadata/iterate_metadata_map.go +3 -7
- package/native/core/factories/internal/metadata/iterate_metadata_native.go +32 -14
- package/native/core/factories/internal/metadata/iterate_metadata_set.go +3 -7
- package/native/core/programmers/compare/CompareEqualProgrammer.go +27 -13
- package/native/core/programmers/helpers/FunctionProgrammer.go +6 -13
- package/native/core/programmers/helpers/StringifyJoinder.go +129 -50
- package/native/core/programmers/helpers/joiner_branch_coverage_test.go +116 -120
- package/native/core/programmers/iterate/iterate_check_coverage_test.go +76 -158
- package/native/core/programmers/iterate/iterate_utility_coverage_test.go +231 -270
- package/native/core/programmers/iterate/json_schema_object.go +49 -7
- package/native/core/programmers/iterate/json_schema_pattern_property_order_test.go +44 -0
- package/native/core/programmers/iterate/openapi_v3_downgrader.go +34 -1
- package/native/core/programmers/iterate/template_runtime_pattern.go +11 -0
- package/native/core/programmers/json/JsonStringifyProgrammer.go +47 -6
- package/native/core/programmers/llm/LlmApplicationProgrammer.go +9 -1
- package/native/core/programmers/protobuf/ProtobufMessageProgrammer.go +1 -1
- package/native/core/schemas/metadata/MetadataCollection.go +0 -9
- package/native/core/schemas/metadata/MetadataDefaultLibrary.go +81 -0
- package/native/core/schemas/metadata/MetadataObjectType.go +7 -18
- package/native/go.mod +4 -4
- package/native/transform/features/protobuf/ProtobufMessageTransformer.go +1 -1
- package/package.json +3 -7
- package/src/executable/FileSystemIdentity.ts +33 -0
- package/src/executable/TypiaGenerateWizard.ts +18 -12
- package/src/internal/_ProtobufReader.ts +40 -11
- package/src/internal/_jsonStringifyArray.ts +50 -0
- package/src/internal/_jsonStringifyElement.ts +19 -0
- package/src/internal/_jsonStringifyProperty.ts +30 -0
- package/src/internal/_llmApplicationFinalize.ts +6 -1
- package/src/internal/_randomFormatByte.ts +30 -3
- package/src/internal/_randomFormatDate.ts +4 -20
- package/src/internal/_randomFormatDatetime.ts +34 -20
- package/src/internal/_randomFormatDuration.ts +19 -4
- package/src/internal/_randomFormatIpv4.ts +43 -3
- package/src/internal/_randomFormatIpv6.ts +67 -3
- package/src/internal/_randomFormatJsonPointer.ts +23 -3
- package/src/internal/_randomFormatRegex.ts +21 -3
- package/src/internal/_randomFormatRelativeJsonPointer.ts +23 -10
- package/src/internal/_randomFormatTime.ts +45 -12
- package/src/internal/_randomPattern.ts +4 -1
- package/src/internal/_randomStringLength.ts +61 -17
- package/src/internal/private/__notationRename.ts +1 -4
- package/src/internal/private/__randomComposition.ts +50 -0
- package/src/internal/private/__randomEpoch.ts +34 -0
- package/native/adapter/visit.go +0 -173
- package/native/adapter/visit_property_chain_edges_test.go +0 -129
- package/native/core/programmers/helpers/disable_function_programmer_declare.go +0 -10
- package/native/core/programmers/iterate/check_union_array_like.go +0 -422
- package/native/core/programmers/iterate/prune_object_properties.go +0 -105
- package/native/core/programmers/iterate/stringify_dynamic_properties.go +0 -219
- package/native/core/programmers/iterate/stringify_native.go +0 -14
- package/native/core/programmers/iterate/stringify_regular_properties.go +0 -112
- package/native/core/schemas/metadata/MetadataApplication.go +0 -41
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypiaGenerateWizard.mjs","names":[],"sources":["../../src/executable/TypiaGenerateWizard.ts"],"sourcesContent":["import { createCommand } from \"commander\";\nimport fs from \"fs\";\nimport inquirer from \"inquirer\";\nimport { createRequire } from \"module\";\nimport os from \"os\";\nimport path from \"path\";\nimport { glob, isDynamicPattern } from \"tinyglobby\";\nimport type {\n ITtscCompilerDiagnostic,\n ITtscCompilerTransformation,\n} from \"ttsc\";\n\nimport { FileSystemIdentity } from \"./FileSystemIdentity\";\n\nexport namespace TypiaGenerateWizard {\n export async function generate(): Promise<void> {\n console.log(\"----------------------------------------\");\n console.log(\" Typia Generate Wizard\");\n console.log(\"----------------------------------------\");\n\n const options: IArguments = await parseArguments();\n await build(options);\n }\n\n async function parseArguments(): Promise<IArguments> {\n const command = createCommand(\"typia generate\");\n command.usage(\"[options] [files...]\");\n command.argument(\"[files...]\", \"input TypeScript source files or globs\");\n command.option(\"--input <path>\", \"input directory\");\n command.option(\"--output <directory>\", \"output directory\");\n command.option(\n \"--project <project>\",\n \"tsconfig.json/jsconfig.json file or directory\",\n );\n\n const questioned = { value: false };\n const prompt = inquirer.createPromptModule;\n\n const input = (name: string) => async (message: string) => {\n questioned.value = true;\n const result = await prompt()({\n type: \"input\",\n name,\n message,\n default: \"\",\n });\n return result[name] as string;\n };\n const configure = async (): Promise<string> => {\n const file: string | null = findProjectConfigFile(process.cwd());\n if (file === null) {\n throw new URIError(\n `Unable to find \"tsconfig.json\" or \"jsconfig.json\" file.`,\n );\n }\n return file;\n };\n\n return new Promise<IArguments>((resolve, reject) => {\n command.action(async (files: string[], options: Partial<IArguments>) => {\n try {\n if (files.length !== 0 && options.input !== undefined) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): file arguments cannot be combined with --input.\",\n );\n }\n if (files.length === 0) {\n options.input ??= await input(\"input\")(\"input directory\");\n }\n if (files.length !== 0 && options.output === undefined) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): output directory is required when file arguments are used.\",\n );\n }\n const output: string =\n options.output ?? (await input(\"output\")(\"output directory\"));\n const project: string = options.project ?? (await configure());\n if (questioned.value) console.log(\"\");\n resolve({\n input: options.input,\n output,\n project,\n files,\n });\n } catch (exp) {\n reject(exp);\n }\n });\n command.parseAsync(process.argv.slice(3), { from: \"user\" }).catch(reject);\n });\n }\n\n export interface IArguments {\n input?: string;\n output: string;\n project: string;\n files: string[];\n }\n\n async function build(location: IArguments): Promise<void> {\n location.output = path.resolve(location.output);\n location.project = resolveProjectConfigFile(location.project);\n\n const policy = new FileSystemIdentity.Policy();\n const outputProbe: string = await nearestExistingAncestor(location.output);\n await ensureExistingDirectoryPath({\n label: \"output parent path\",\n directory: outputProbe,\n });\n policy.observe(\n await FileSystemIdentity.probeDirectory(outputProbe),\n outputProbe,\n );\n policy.observe(\n await FileSystemIdentity.inspectDirectory(path.dirname(location.project)),\n path.dirname(location.project),\n );\n\n const entries: IInputFile[] =\n location.files.length === 0\n ? await prepareDirectoryInput(location, policy)\n : await prepareFileInputs(location, policy);\n const identity: FileSystemIdentity.IIdentity = policy.get();\n await inspectTargetDirectories({\n identity,\n output: location.output,\n targets: entries.map((entry) => entry.target),\n });\n\n const binary = resolveTsgoBinary();\n const cwd = path.dirname(location.project);\n const temporaryProject: ITemporaryProject = await createTemporaryProject({\n entries,\n project: location.project,\n });\n let transformed: Record<string, string>;\n try {\n transformed = transformProject({\n binary,\n cwd,\n projectRoot: cwd,\n tsconfig: temporaryProject.config,\n });\n } finally {\n await fs.promises.rm(temporaryProject.directory, {\n force: true,\n recursive: true,\n });\n }\n const outputByKey: Map<string, string> = indexTransformedOutputs(\n transformed,\n identity,\n );\n const outputs: IOutputFile[] = entries.map((entry) => {\n const output = getTransformedOutput({\n cwd,\n entry,\n identity,\n outputByKey,\n });\n if (output === undefined) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): no transformed output for ${entry.file}. Check that --project includes the file.`,\n );\n }\n return { entry, output };\n });\n\n await ensureOutputDirectory(location.output);\n await ensureTargetDirectories({\n identity,\n output: location.output,\n targets: outputs.map(({ entry }) => entry.target),\n });\n await ensurePhysicalTargets({\n identity,\n output: location.output,\n entries: outputs.map(({ entry }) => entry),\n });\n await ensureTargetFiles(\n outputs.map(({ entry }) => entry),\n identity,\n );\n for (const { entry, output } of outputs) {\n await fs.promises.writeFile(entry.target, formatOutput(output), \"utf8\");\n }\n }\n\n interface IInputFile {\n file: string;\n target: string;\n }\n\n interface IOutputFile {\n entry: IInputFile;\n output: string;\n }\n\n interface ITraversalEntry {\n file: string;\n name: string;\n stat: fs.Stats;\n }\n\n interface ITemporaryProject {\n config: string;\n directory: string;\n }\n\n async function createTemporaryProject(props: {\n entries: IInputFile[];\n project: string;\n }): Promise<ITemporaryProject> {\n const directory: string = await fs.promises.mkdtemp(\n path.join(os.tmpdir(), \"typia-generate-project-\"),\n );\n const config: string = path.join(directory, \"tsconfig.json\");\n try {\n await fs.promises.writeFile(\n config,\n JSON.stringify({\n extends: props.project,\n exclude: [],\n files: props.entries.map((entry) => compilerInputPath(entry.file)),\n include: [],\n }),\n \"utf8\",\n );\n return { config, directory };\n } catch (error) {\n await fs.promises.rm(directory, { force: true, recursive: true });\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to prepare the bounded input project: ${formatUnknownError(error)}`,\n );\n }\n }\n\n async function ensureOutputDirectory(output: string): Promise<void> {\n if (fs.existsSync(output) === false) {\n await ensureCreatableDirectory(output);\n await fs.promises.mkdir(output, { recursive: true });\n } else {\n await ensureExistingDirectory({\n label: \"output path\",\n directory: output,\n });\n }\n }\n\n async function ensureTargetDirectories(props: {\n identity: FileSystemIdentity.IIdentity;\n output: string;\n targets: string[];\n }): Promise<void> {\n await inspectTargetDirectories(props);\n const directories: Map<string, string> = targetDirectories(props);\n for (const directory of directories.values()) {\n try {\n await fs.promises.mkdir(directory, { recursive: true });\n } catch (exp) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to create output parent directory ${directory}: ${formatUnknownError(exp)}`,\n );\n }\n await ensureExistingDirectory({\n label: \"output parent path\",\n directory,\n });\n }\n }\n\n async function inspectTargetDirectories(props: {\n identity: FileSystemIdentity.IIdentity;\n output: string;\n targets: string[];\n }): Promise<void> {\n const directories: Map<string, string> = targetDirectories(props);\n for (const directory of directories.values()) {\n await ensureOutputAncestorDirectories({\n identity: props.identity,\n output: props.output,\n directory,\n });\n if (fs.existsSync(directory)) {\n await ensureExistingDirectory({\n label: \"output parent path\",\n directory,\n });\n }\n }\n }\n\n function targetDirectories(props: {\n identity: FileSystemIdentity.IIdentity;\n targets: string[];\n }): Map<string, string> {\n const directories: Map<string, string> = new Map();\n for (const target of props.targets) {\n const directory: string = path.dirname(target);\n directories.set(props.identity.filesystemKey(directory), directory);\n }\n return directories;\n }\n\n async function ensureCreatableDirectory(directory: string): Promise<void> {\n const parent: string = await nearestExistingAncestor(directory);\n await ensureExistingDirectoryPath({\n label: \"output parent path\",\n directory: parent,\n });\n }\n\n async function nearestExistingAncestor(directory: string): Promise<string> {\n let current: string = path.resolve(directory);\n while (fs.existsSync(current) === false) {\n const parent: string = path.dirname(current);\n if (parent === current) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to find existing output parent path: ${directory}`,\n );\n }\n current = parent;\n }\n return current;\n }\n\n async function ensureOutputAncestorDirectories(props: {\n identity: FileSystemIdentity.IIdentity;\n output: string;\n directory: string;\n }): Promise<void> {\n const output: string = path.resolve(props.output);\n const directory: string = path.resolve(props.directory);\n if (props.identity.contains(directory, output) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output parent path escapes output directory: ${props.directory}`,\n );\n }\n\n const relative: string = path.relative(output, directory);\n if (relative === \"\") {\n return;\n }\n\n let current: string = output;\n for (const segment of relative.split(path.sep)) {\n current = path.join(current, segment);\n let stat: fs.Stats;\n try {\n stat = await fs.promises.lstat(current);\n } catch (exp) {\n if (isMissingFileError(exp)) {\n return;\n }\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to inspect output parent path ${current}: ${formatUnknownError(exp)}`,\n );\n }\n if (stat.isSymbolicLink()) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output parent path contains a symbolic link: ${current}`,\n );\n }\n if (stat.isDirectory() === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output parent path is not a directory: ${current}`,\n );\n }\n }\n }\n\n async function ensureExistingDirectory(props: {\n label: string;\n directory: string;\n }): Promise<void> {\n await ensureExistingDirectoryPath(props);\n }\n\n async function ensureExistingDirectoryPath(props: {\n label: string;\n directory: string;\n }): Promise<void> {\n const directory: string = path.resolve(props.directory);\n const parsed: path.ParsedPath = path.parse(directory);\n const relative: string = path.relative(parsed.root, directory);\n let current: string = parsed.root;\n for (const segment of relative === \"\" ? [] : relative.split(path.sep)) {\n current = path.join(current, segment);\n await ensureExistingDirectorySegment({\n label:\n path.normalize(current) === path.normalize(directory)\n ? props.label\n : `${props.label} ancestor`,\n directory: current,\n });\n }\n }\n\n async function ensureExistingDirectorySegment(props: {\n label: string;\n directory: string;\n }): Promise<void> {\n const stat: fs.Stats = await fs.promises.lstat(props.directory);\n if (stat.isSymbolicLink()) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): ${props.label} is a symbolic link: ${props.directory}`,\n );\n }\n if (stat.isDirectory() === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): ${props.label} is not a directory: ${props.directory}`,\n );\n }\n }\n\n async function ensurePhysicalTargets(props: {\n identity: FileSystemIdentity.IIdentity;\n output: string;\n entries: IInputFile[];\n }): Promise<void> {\n const output: string = await fs.promises.realpath(props.output);\n const inputs: Set<string> = new Set();\n for (const entry of props.entries) {\n inputs.add(\n props.identity.filesystemKey(await fs.promises.realpath(entry.file)),\n );\n }\n\n for (const entry of props.entries) {\n const parent: string = path.dirname(entry.target);\n const directory: string = await fs.promises.realpath(parent);\n if (props.identity.contains(directory, output) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output parent path escapes output directory through a symbolic link: ${parent}`,\n );\n }\n\n const target: string = path.join(directory, path.basename(entry.target));\n if (inputs.has(props.identity.filesystemKey(target))) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output file would overwrite input file through a symbolic link: ${entry.target}`,\n );\n }\n }\n }\n\n async function ensureTargetFiles(\n entries: IInputFile[],\n identity: FileSystemIdentity.IIdentity,\n ): Promise<void> {\n const inputs: Set<string> = new Set();\n const files: Map<string, IInputFile> = new Map();\n for (const entry of entries) {\n inputs.add(\n fileIdentityKey(\n await fs.promises.stat(entry.file),\n await fs.promises.realpath(entry.file),\n ),\n );\n files.set(identity.filesystemKey(entry.target), entry);\n }\n\n for (const entry of files.values()) {\n let stat: fs.Stats;\n try {\n stat = await fs.promises.lstat(entry.target);\n } catch (exp) {\n if (isMissingFileError(exp)) {\n continue;\n }\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to inspect output file ${entry.target}: ${formatUnknownError(exp)}`,\n );\n }\n if (stat.isFile() === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output file path is not a regular file: ${entry.target}`,\n );\n }\n if (\n inputs.has(\n fileIdentityKey(stat, await fs.promises.realpath(entry.target)),\n )\n ) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output file would overwrite input file through a physical file alias: ${entry.target}`,\n );\n }\n if (stat.nlink > 1) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output file has multiple hard links: ${entry.target}`,\n );\n }\n }\n }\n\n async function prepareDirectoryInput(\n location: IArguments,\n policy: FileSystemIdentity.Policy,\n ): Promise<IInputFile[]> {\n if (location.input === undefined) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): input path is required.\",\n );\n }\n const input = path.resolve(location.input);\n if (fs.existsSync(input) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input path does not exist: ${input}`,\n );\n }\n if ((await isDirectory(input)) === false) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): input path is not a directory.\",\n );\n }\n\n const inputReal: string = await fs.promises.realpath(input);\n const outputReal: string | undefined = await optionalRealPath(\n location.output,\n );\n const files: string[] = [];\n await gather({\n container: files,\n from: input,\n inputReal,\n outputReal,\n policy,\n visitedDirectories: new Set(),\n visitedFiles: new Set(),\n });\n return files.map((file) => ({\n file,\n target: path.join(location.output, path.relative(input, file)),\n }));\n }\n\n async function prepareFileInputs(\n location: IArguments,\n policy: FileSystemIdentity.Policy,\n ): Promise<IInputFile[]> {\n const targets: Set<string> = new Set();\n const output: IInputFile[] = [];\n for (const input of await expandFileInputs(\n location.files,\n location.output,\n policy,\n )) {\n const file: string = path.resolve(input);\n policy.observe(\n await FileSystemIdentity.inspectDirectory(path.dirname(file)),\n path.dirname(file),\n );\n const identity: FileSystemIdentity.IIdentity = policy.get();\n if (fs.existsSync(file) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input file does not exist: ${input}`,\n );\n } else if ((await isFile(file)) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input path is not a file: ${input}`,\n );\n } else if (identity.isDeclarationFile(file)) {\n continue;\n } else if (identity.isSupportedExtension(file) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input file is not a supported TypeScript source: ${input}`,\n );\n }\n\n const target: string = path.join(location.output, path.basename(file));\n if (identity.isSamePath(file, target)) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output file would overwrite input file: ${input}`,\n );\n }\n const key: string = identity.filesystemKey(target);\n if (targets.has(key)) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): duplicate output filename for ${target}`,\n );\n }\n targets.add(key);\n output.push({ file, target });\n }\n if (output.length === 0) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): input files do not include any supported TypeScript source files outside the output directory.\",\n );\n }\n return output;\n }\n\n async function expandFileInputs(\n inputs: string[],\n directory: string,\n policy: FileSystemIdentity.Policy,\n ): Promise<string[]> {\n const output: string[] = [];\n for (const input of inputs) {\n const pattern: string = toGlobPattern(input);\n if (isDynamicPattern(pattern, { caseSensitiveMatch: true })) {\n const searchDirectory: string = await globSearchDirectory(input);\n const caseSensitive: boolean | undefined =\n await FileSystemIdentity.inspectDirectory(searchDirectory);\n if (caseSensitive === undefined) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to determine filesystem case behavior for input pattern base ${searchDirectory}.`,\n );\n }\n policy.observe(caseSensitive, searchDirectory);\n const identity: FileSystemIdentity.IIdentity = policy.get();\n const matches: string[] = await glob(pattern, {\n absolute: true,\n caseSensitiveMatch: identity.caseSensitive,\n cwd: process.cwd(),\n onlyFiles: true,\n });\n if (matches.length === 0) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input pattern does not match any files: ${input}`,\n );\n }\n output.push(\n ...excludeOutputFiles(matches, directory, identity).filter((file) =>\n identity.isSupportedExtension(file),\n ),\n );\n } else {\n const file: string = path.resolve(input);\n policy.observe(\n await FileSystemIdentity.inspectDirectory(path.dirname(file)),\n path.dirname(file),\n );\n if (policy.get().contains(file, directory) === false) {\n output.push(file);\n }\n }\n }\n return output;\n }\n\n function excludeOutputFiles(\n files: string[],\n directory: string,\n identity: FileSystemIdentity.IIdentity,\n ): string[] {\n return files.filter((file) => identity.contains(file, directory) === false);\n }\n\n async function globSearchDirectory(input: string): Promise<string> {\n let current: string = path.resolve(input);\n while (\n isDynamicPattern(toGlobPattern(current), { caseSensitiveMatch: true })\n ) {\n const parent: string = path.dirname(current);\n if (parent === current) break;\n current = parent;\n }\n if (fs.existsSync(current) && (await isDirectory(current))) return current;\n return nearestExistingAncestor(path.dirname(current));\n }\n\n function toGlobPattern(input: string): string {\n return input.replace(/\\\\/g, \"/\");\n }\n\n function transformProject(props: {\n binary: string;\n cwd: string;\n projectRoot: string;\n tsconfig: string;\n }): Record<string, string> {\n const TtscCompiler = loadTtscCompiler();\n const result: ITtscCompilerTransformation = new TtscCompiler({\n binary: props.binary,\n cwd: props.cwd,\n projectRoot: props.projectRoot,\n tsconfig: props.tsconfig,\n }).transform();\n if (result.type === \"success\") {\n return result.typescript;\n }\n if (result.type === \"failure\") {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): ${formatDiagnostics(result.diagnostics)}`,\n );\n }\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): ${formatUnknownError(result.error)}`,\n );\n }\n\n function resolveProjectConfigFile(project: string): string {\n const resolved: string = path.resolve(project);\n if (fs.existsSync(resolved) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): project path does not exist: ${resolved}`,\n );\n }\n\n const stat: fs.Stats = fs.statSync(resolved);\n if (stat.isDirectory()) {\n for (const filename of [\"tsconfig.json\", \"jsconfig.json\"]) {\n const candidate: string = path.join(resolved, filename);\n if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {\n return resolveRealPath(candidate);\n }\n }\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): project directory has no tsconfig.json or jsconfig.json: ${resolved}`,\n );\n }\n if (stat.isFile() === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): project path is not a file: ${resolved}`,\n );\n }\n return resolveRealPath(resolved);\n }\n\n function findProjectConfigFile(directory: string): string | null {\n let current: string = path.resolve(directory);\n while (true) {\n for (const filename of [\"tsconfig.json\", \"jsconfig.json\"]) {\n const candidate: string = path.join(current, filename);\n if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {\n return resolveRealPath(candidate);\n }\n }\n const parent: string = path.dirname(current);\n if (parent === current) {\n return null;\n }\n current = parent;\n }\n }\n\n function loadTtscCompiler(): typeof import(\"ttsc\").TtscCompiler {\n const packageRoot: string = resolveTypiaPackageRoot();\n const resolved: string | null = resolveFromRoots(\n \"ttsc\",\n resolveRuntimeRoots(packageRoot),\n );\n if (resolved === null) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to resolve ttsc from the current project, typia package, or workspace root. Run \"npm i -D ttsc typescript\" before.`,\n );\n }\n const imported = createRequire(resolved)(resolved) as typeof import(\"ttsc\");\n return imported.TtscCompiler;\n }\n\n function resolveTsgoBinary(): string {\n const explicit: string | undefined = process.env.TTSC_TSGO_BINARY;\n if (explicit !== undefined && explicit.length !== 0) {\n if (path.isAbsolute(explicit) && fs.existsSync(explicit)) {\n return explicit;\n }\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): TTSC_TSGO_BINARY must be an existing absolute path: ${explicit}`,\n );\n }\n\n const packageRoot: string = resolveTypiaPackageRoot();\n const manifest: string | null = resolveFromRoots(\n \"typescript/package.json\",\n resolveRuntimeRoots(packageRoot),\n );\n if (manifest === null) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): unable to resolve typescript from the current project, typia package, or workspace root.\",\n );\n }\n\n const platform: string = `@typescript/typescript-${process.platform}-${process.arch}`;\n const platformManifest: string = createRequire(manifest).resolve(\n `${platform}/package.json`,\n );\n const binary: string = path.join(\n path.dirname(platformManifest),\n \"lib\",\n process.platform === \"win32\" ? \"tsc.exe\" : \"tsc\",\n );\n if (fs.existsSync(binary) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): TypeScript-Go executable not found: ${binary}`,\n );\n }\n return binary;\n }\n\n function resolveTypiaPackageRoot(): string {\n // The CLI entrypoint (`lib/executable/typia.js`) lives in the same\n // directory as this module, so its `process.argv[1]` path anchors the\n // walk-up identically in both the CJS and ESM builds — `__dirname` does\n // not exist in the transcoded `.mjs`.\n const current: string = path.dirname(path.resolve(process.argv[1] ?? \"\"));\n for (const directory of [\n path.resolve(current, \"..\", \"..\"),\n path.resolve(current, \"..\"),\n ]) {\n const file: string = path.join(directory, \"package.json\");\n if (fs.existsSync(file) === false) {\n continue;\n }\n try {\n const pack = JSON.parse(fs.readFileSync(file, \"utf8\")) as Partial<\n Record<\"name\", unknown>\n >;\n if (pack.name === \"typia\") {\n return directory;\n }\n } catch {\n continue;\n }\n }\n\n const resolved: string | null = resolveFromRoots(\"typia/package.json\", [\n process.cwd(),\n current,\n ]);\n if (resolved === null) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): unable to resolve typia package root.\",\n );\n }\n return path.dirname(resolved);\n }\n\n function resolveRuntimeRoots(packageRoot: string): string[] {\n return [process.cwd(), packageRoot, path.resolve(packageRoot, \"..\", \"..\")];\n }\n\n function resolveFromRoots(request: string, roots: string[]): string | null {\n for (const root of roots) {\n try {\n return createRequire(path.join(root, \"package.json\")).resolve(request);\n } catch {\n continue;\n }\n }\n return null;\n }\n\n async function isDirectory(current: string): Promise<boolean> {\n const stat: fs.Stats = await fs.promises.stat(current);\n return stat.isDirectory();\n }\n\n async function isFile(current: string): Promise<boolean> {\n const stat: fs.Stats = await fs.promises.stat(current);\n return stat.isFile();\n }\n\n async function gather(props: {\n container: string[];\n from: string;\n inputReal: string;\n outputReal: string | undefined;\n policy: FileSystemIdentity.Policy;\n visitedDirectories: Set<string>;\n visitedFiles: Set<string>;\n }): Promise<void> {\n const currentReal: string = await resolveTraversalPath(props.from);\n if (\n props.outputReal !== undefined &&\n isPhysicalSameOrChildPath(currentReal, props.outputReal)\n )\n return;\n ensurePhysicalInputContainment({\n file: props.from,\n input: props.inputReal,\n real: currentReal,\n });\n\n const currentStat: fs.Stats = await fs.promises.stat(props.from);\n const directoryIdentity: string = fileIdentityKey(currentStat, currentReal);\n if (props.visitedDirectories.has(directoryIdentity)) {\n const lexicalStat: fs.Stats = await fs.promises.lstat(props.from);\n if (lexicalStat.isSymbolicLink()) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input directory link revisits a physical directory: ${props.from}.`,\n );\n }\n return;\n }\n props.visitedDirectories.add(directoryIdentity);\n\n props.policy.observe(\n await FileSystemIdentity.inspectDirectory(props.from),\n props.from,\n );\n const identity: FileSystemIdentity.IIdentity = props.policy.get();\n const entries: ITraversalEntry[] = await Promise.all(\n (await fs.promises.readdir(props.from)).map(async (name) => {\n const file: string = path.join(props.from, name);\n try {\n return { file, name, stat: await fs.promises.lstat(file) };\n } catch (error) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to inspect input path ${file}: ${formatUnknownError(error)}`,\n );\n }\n }),\n );\n entries.sort((x, y) => {\n const linkOrder: number =\n Number(x.stat.isSymbolicLink()) - Number(y.stat.isSymbolicLink());\n return linkOrder !== 0 ? linkOrder : x.name.localeCompare(y.name);\n });\n\n for (const entry of entries) {\n let stat: fs.Stats;\n let real: string;\n try {\n stat = await fs.promises.stat(entry.file);\n real = await fs.promises.realpath(entry.file);\n } catch (error) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input link target is missing or unreadable: ${entry.file}: ${formatUnknownError(error)}`,\n );\n }\n\n if (\n props.outputReal !== undefined &&\n isPhysicalSameOrChildPath(real, props.outputReal)\n )\n continue;\n ensurePhysicalInputContainment({\n file: entry.file,\n input: props.inputReal,\n real,\n });\n\n if (stat.isDirectory()) {\n await gather({ ...props, from: entry.file });\n continue;\n }\n if (\n stat.isFile() === false ||\n identity.isSupportedExtension(entry.name) === false\n )\n continue;\n\n const fileIdentity: string = fileIdentityKey(stat, real);\n if (props.visitedFiles.has(fileIdentity)) continue;\n props.visitedFiles.add(fileIdentity);\n props.container.push(entry.file);\n }\n }\n\n function formatOutput(output: string): string {\n return output.startsWith(\"// @ts-nocheck\")\n ? output\n : `// @ts-nocheck\\n${output}`;\n }\n\n function indexTransformedOutputs(\n outputs: Record<string, string>,\n identity: FileSystemIdentity.IIdentity,\n ): Map<string, string> {\n const map: Map<string, string> = new Map();\n for (const [file, output] of Object.entries(outputs)) {\n const key: string = identity.projectFileKey(file);\n if (map.has(key)) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): transformed outputs have ambiguous filesystem identities: ${file}.`,\n );\n }\n map.set(key, output);\n }\n return map;\n }\n\n function getTransformedOutput(props: {\n cwd: string;\n entry: IInputFile;\n identity: FileSystemIdentity.IIdentity;\n outputByKey: Map<string, string>;\n }): string | undefined {\n const output = props.outputByKey.get(\n props.identity.projectFileKey(projectKey(props.cwd, props.entry.file)),\n );\n if (output !== undefined) {\n return output;\n }\n\n const compilerFile: string = compilerInputPath(props.entry.file);\n if (\n props.identity.isSamePath(compilerFile, props.entry.file) === false &&\n props.identity.contains(compilerFile, props.cwd)\n ) {\n const compiled: string | undefined = props.outputByKey.get(\n props.identity.projectFileKey(projectKey(props.cwd, compilerFile)),\n );\n if (compiled !== undefined) return compiled;\n }\n\n const real: string = resolveRealPath(props.entry.file);\n if (\n props.identity.isSamePath(real, props.entry.file) ||\n props.identity.contains(real, props.cwd) === false\n ) {\n return undefined;\n }\n return props.outputByKey.get(\n props.identity.projectFileKey(projectKey(props.cwd, real)),\n );\n }\n\n function projectKey(root: string, file: string): string {\n return path.relative(root, file).replace(/\\\\/g, \"/\");\n }\n\n function resolveRealPath(file: string): string {\n try {\n return fs.realpathSync(file);\n } catch {\n return file;\n }\n }\n\n function compilerInputPath(file: string): string {\n try {\n if (fs.lstatSync(file).isSymbolicLink()) {\n return path.join(\n resolveRealPath(path.dirname(file)),\n path.basename(file),\n );\n }\n } catch {\n return file;\n }\n return resolveRealPath(file);\n }\n\n async function optionalRealPath(file: string): Promise<string | undefined> {\n try {\n return await fs.promises.realpath(file);\n } catch (error) {\n if (isMissingFileError(error)) return undefined;\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to resolve path ${file}: ${formatUnknownError(error)}`,\n );\n }\n }\n\n async function resolveTraversalPath(file: string): Promise<string> {\n try {\n return await fs.promises.realpath(file);\n } catch (error) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to resolve input path ${file}: ${formatUnknownError(error)}`,\n );\n }\n }\n\n function ensurePhysicalInputContainment(props: {\n file: string;\n input: string;\n real: string;\n }): void {\n if (isPhysicalSameOrChildPath(props.real, props.input)) return;\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input path resolves outside the input directory: ${props.file}.`,\n );\n }\n\n function isPhysicalSameOrChildPath(file: string, directory: string): boolean {\n const relative: string = path.relative(directory, file);\n return (\n relative === \"\" ||\n (relative !== \"..\" &&\n relative.startsWith(`..${path.sep}`) === false &&\n path.isAbsolute(relative) === false)\n );\n }\n\n function isMissingFileError(exp: unknown): boolean {\n return (\n typeof exp === \"object\" &&\n exp !== null &&\n \"code\" in exp &&\n exp.code === \"ENOENT\"\n );\n }\n\n function fileIdentityKey(stat: fs.Stats, realpath: string): string {\n return stat.ino === 0\n ? `path:${path.normalize(realpath)}`\n : `inode:${stat.dev}:${stat.ino}`;\n }\n\n function formatDiagnostics(diagnostics: ITtscCompilerDiagnostic[]): string {\n return diagnostics.length === 0\n ? \"transformation failed\"\n : diagnostics\n .map((diag) =>\n [\n diag.file ?? \"ttsc\",\n diag.line === undefined\n ? undefined\n : `${diag.line}:${diag.character ?? 1}`,\n diag.messageText,\n ]\n .filter((part) => part !== undefined && part !== \"\")\n .join(\": \"),\n )\n .join(\"\\n\");\n }\n\n function formatUnknownError(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n if (\n typeof error === \"object\" &&\n error !== null &&\n \"message\" in error &&\n typeof error.message === \"string\"\n ) {\n return error.message;\n }\n return String(error);\n }\n}\n"],"mappings":";;;;;;;;;AAcO,IAAA;;CACE,eAAe,WAA0B;EAC9C,QAAQ,IAAI,0CAA0C;EACtD,QAAQ,IAAI,wBAAwB;EACpC,QAAQ,IAAI,0CAA0C;EAGtD,MAAM,MAAM,MADsB,eAAe,CAC9B;CACrB;;CAEA,eAAe,iBAAsC;EACnD,MAAM,UAAU,cAAc,gBAAgB;EAC9C,QAAQ,MAAM,sBAAsB;EACpC,QAAQ,SAAS,cAAc,wCAAwC;EACvE,QAAQ,OAAO,kBAAkB,iBAAiB;EAClD,QAAQ,OAAO,wBAAwB,kBAAkB;EACzD,QAAQ,OACN,uBACA,+CACF;EAEA,MAAM,aAAa,EAAE,OAAO,MAAM;EAClC,MAAM,SAAS,SAAS;EAExB,MAAM,SAAS,SAAiB,OAAO,YAAoB;GACzD,WAAW,QAAQ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GACD,wBAAA,sBAAA,CAAA,EAAD"}
|
|
1
|
+
{"version":3,"file":"TypiaGenerateWizard.mjs","names":[],"sources":["../../src/executable/TypiaGenerateWizard.ts"],"sourcesContent":["import { createCommand } from \"commander\";\nimport fs from \"fs\";\nimport inquirer from \"inquirer\";\nimport { createRequire } from \"module\";\nimport os from \"os\";\nimport path from \"path\";\nimport { glob, isDynamicPattern } from \"tinyglobby\";\nimport type {\n ITtscCompilerDiagnostic,\n ITtscCompilerTransformation,\n} from \"ttsc\";\n\nimport { FileSystemIdentity } from \"./FileSystemIdentity\";\n\nexport namespace TypiaGenerateWizard {\n export async function generate(): Promise<void> {\n console.log(\"----------------------------------------\");\n console.log(\" Typia Generate Wizard\");\n console.log(\"----------------------------------------\");\n\n const options: IArguments = await parseArguments();\n await build(options);\n }\n\n async function parseArguments(): Promise<IArguments> {\n const command = createCommand(\"typia generate\");\n command.usage(\"[options] [files...]\");\n command.argument(\"[files...]\", \"input TypeScript source files or globs\");\n command.option(\"--input <path>\", \"input directory\");\n command.option(\"--output <directory>\", \"output directory\");\n command.option(\n \"--project <project>\",\n \"tsconfig.json/jsconfig.json file or directory\",\n );\n\n const questioned = { value: false };\n const prompt = inquirer.createPromptModule;\n\n const input = (name: string) => async (message: string) => {\n questioned.value = true;\n const result = await prompt()({\n type: \"input\",\n name,\n message,\n default: \"\",\n });\n return result[name] as string;\n };\n const configure = async (): Promise<string> => {\n const file: string | null = findProjectConfigFile(process.cwd());\n if (file === null) {\n throw new URIError(\n `Unable to find \"tsconfig.json\" or \"jsconfig.json\" file.`,\n );\n }\n return file;\n };\n\n return new Promise<IArguments>((resolve, reject) => {\n command.action(async (files: string[], options: Partial<IArguments>) => {\n try {\n if (files.length !== 0 && options.input !== undefined) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): file arguments cannot be combined with --input.\",\n );\n }\n if (files.length === 0) {\n options.input ??= await input(\"input\")(\"input directory\");\n }\n if (files.length !== 0 && options.output === undefined) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): output directory is required when file arguments are used.\",\n );\n }\n const output: string =\n options.output ?? (await input(\"output\")(\"output directory\"));\n const project: string = options.project ?? (await configure());\n if (questioned.value) console.log(\"\");\n resolve({\n input: options.input,\n output,\n project,\n files,\n });\n } catch (exp) {\n reject(exp);\n }\n });\n command.parseAsync(process.argv.slice(3), { from: \"user\" }).catch(reject);\n });\n }\n\n export interface IArguments {\n input?: string;\n output: string;\n project: string;\n files: string[];\n }\n\n async function build(location: IArguments): Promise<void> {\n location.output = path.resolve(location.output);\n location.project = resolveProjectConfigFile(location.project);\n\n const policy = new FileSystemIdentity.Policy();\n const outputProbe: string = await nearestExistingAncestor(location.output);\n await ensureExistingDirectoryPath({\n label: \"output parent path\",\n directory: outputProbe,\n });\n policy.observe(\n await FileSystemIdentity.probeDirectory(outputProbe),\n outputProbe,\n );\n policy.observe(\n await FileSystemIdentity.inspectDirectory(path.dirname(location.project)),\n path.dirname(location.project),\n );\n\n const entries: IInputFile[] =\n location.files.length === 0\n ? await prepareDirectoryInput(location, policy)\n : await prepareFileInputs(location, policy);\n const identity: FileSystemIdentity.IIdentity = policy.get();\n await inspectTargetDirectories({\n identity,\n output: location.output,\n targets: entries.map((entry) => entry.target),\n });\n\n const binary = resolveTsgoBinary();\n const cwd = path.dirname(location.project);\n const temporaryProject: ITemporaryProject = await createTemporaryProject({\n entries,\n project: location.project,\n });\n let transformed: Record<string, string>;\n try {\n transformed = transformProject({\n binary,\n cwd,\n projectRoot: cwd,\n tsconfig: temporaryProject.config,\n });\n } finally {\n await fs.promises.rm(temporaryProject.directory, {\n force: true,\n recursive: true,\n });\n }\n const outputByKey: Map<string, string> = indexTransformedOutputs(\n transformed,\n identity,\n );\n const outputs: IOutputFile[] = entries.map((entry) => {\n const output = getTransformedOutput({\n cwd,\n entry,\n identity,\n outputByKey,\n });\n if (output === undefined) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): no transformed output for ${entry.file}. Check that --project includes the file.`,\n );\n }\n return { entry, output };\n });\n\n await ensureOutputDirectory(location.output);\n await ensureTargetDirectories({\n identity,\n output: location.output,\n targets: outputs.map(({ entry }) => entry.target),\n });\n await ensurePhysicalTargets({\n identity,\n output: location.output,\n entries: outputs.map(({ entry }) => entry),\n });\n await ensureTargetFiles(\n outputs.map(({ entry }) => entry),\n identity,\n );\n for (const { entry, output } of outputs) {\n await fs.promises.writeFile(entry.target, formatOutput(output), \"utf8\");\n }\n }\n\n interface IInputFile {\n file: string;\n target: string;\n }\n\n interface IOutputFile {\n entry: IInputFile;\n output: string;\n }\n\n interface ITraversalEntry {\n file: string;\n name: string;\n stat: fs.Stats;\n }\n\n interface ITemporaryProject {\n config: string;\n directory: string;\n }\n\n async function createTemporaryProject(props: {\n entries: IInputFile[];\n project: string;\n }): Promise<ITemporaryProject> {\n const directory: string = await fs.promises.mkdtemp(\n path.join(os.tmpdir(), \"typia-generate-project-\"),\n );\n const config: string = path.join(directory, \"tsconfig.json\");\n try {\n await fs.promises.writeFile(\n config,\n JSON.stringify({\n extends: props.project,\n exclude: [],\n files: props.entries.map((entry) => compilerInputPath(entry.file)),\n include: [],\n }),\n \"utf8\",\n );\n return { config, directory };\n } catch (error) {\n await fs.promises.rm(directory, { force: true, recursive: true });\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to prepare the bounded input project: ${formatUnknownError(error)}`,\n );\n }\n }\n\n async function ensureOutputDirectory(output: string): Promise<void> {\n if (fs.existsSync(output) === false) {\n await ensureCreatableDirectory(output);\n await fs.promises.mkdir(output, { recursive: true });\n } else {\n await ensureExistingDirectory({\n label: \"output path\",\n directory: output,\n });\n }\n }\n\n async function ensureTargetDirectories(props: {\n identity: FileSystemIdentity.IIdentity;\n output: string;\n targets: string[];\n }): Promise<void> {\n await inspectTargetDirectories(props);\n const directories: Map<string, string> = targetDirectories(props);\n for (const directory of directories.values()) {\n try {\n await fs.promises.mkdir(directory, { recursive: true });\n } catch (exp) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to create output parent directory ${directory}: ${formatUnknownError(exp)}`,\n );\n }\n await ensureExistingDirectory({\n label: \"output parent path\",\n directory,\n });\n }\n }\n\n async function inspectTargetDirectories(props: {\n identity: FileSystemIdentity.IIdentity;\n output: string;\n targets: string[];\n }): Promise<void> {\n const directories: Map<string, string> = targetDirectories(props);\n for (const directory of directories.values()) {\n await ensureOutputAncestorDirectories({\n identity: props.identity,\n output: props.output,\n directory,\n });\n if (fs.existsSync(directory)) {\n await ensureExistingDirectory({\n label: \"output parent path\",\n directory,\n });\n }\n }\n }\n\n function targetDirectories(props: {\n identity: FileSystemIdentity.IIdentity;\n targets: string[];\n }): Map<string, string> {\n const directories: Map<string, string> = new Map();\n for (const target of props.targets) {\n const directory: string = path.dirname(target);\n directories.set(props.identity.filesystemKey(directory), directory);\n }\n return directories;\n }\n\n async function ensureCreatableDirectory(directory: string): Promise<void> {\n const parent: string = await nearestExistingAncestor(directory);\n await ensureExistingDirectoryPath({\n label: \"output parent path\",\n directory: parent,\n });\n }\n\n async function nearestExistingAncestor(directory: string): Promise<string> {\n let current: string = path.resolve(directory);\n while (fs.existsSync(current) === false) {\n const parent: string = path.dirname(current);\n if (parent === current) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to find existing output parent path: ${directory}`,\n );\n }\n current = parent;\n }\n return current;\n }\n\n async function ensureOutputAncestorDirectories(props: {\n identity: FileSystemIdentity.IIdentity;\n output: string;\n directory: string;\n }): Promise<void> {\n const output: string = path.resolve(props.output);\n const directory: string = path.resolve(props.directory);\n if (props.identity.contains(directory, output) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output parent path escapes output directory: ${props.directory}`,\n );\n }\n\n const relative: string = path.relative(output, directory);\n if (relative === \"\") {\n return;\n }\n\n let current: string = output;\n for (const segment of relative.split(path.sep)) {\n current = path.join(current, segment);\n let stat: fs.Stats;\n try {\n stat = await fs.promises.lstat(current);\n } catch (exp) {\n if (isMissingFileError(exp)) {\n return;\n }\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to inspect output parent path ${current}: ${formatUnknownError(exp)}`,\n );\n }\n if (stat.isSymbolicLink()) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output parent path contains a symbolic link: ${current}`,\n );\n }\n if (stat.isDirectory() === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output parent path is not a directory: ${current}`,\n );\n }\n }\n }\n\n async function ensureExistingDirectory(props: {\n label: string;\n directory: string;\n }): Promise<void> {\n await ensureExistingDirectoryPath(props);\n }\n\n async function ensureExistingDirectoryPath(props: {\n label: string;\n directory: string;\n }): Promise<void> {\n const directory: string = path.resolve(props.directory);\n const parsed: path.ParsedPath = path.parse(directory);\n const relative: string = path.relative(parsed.root, directory);\n let current: string = parsed.root;\n for (const segment of relative === \"\" ? [] : relative.split(path.sep)) {\n current = path.join(current, segment);\n await ensureExistingDirectorySegment({\n label:\n path.normalize(current) === path.normalize(directory)\n ? props.label\n : `${props.label} ancestor`,\n directory: current,\n });\n }\n }\n\n async function ensureExistingDirectorySegment(props: {\n label: string;\n directory: string;\n }): Promise<void> {\n const stat: fs.Stats = await fs.promises.lstat(props.directory);\n if (stat.isSymbolicLink()) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): ${props.label} is a symbolic link: ${props.directory}`,\n );\n }\n if (stat.isDirectory() === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): ${props.label} is not a directory: ${props.directory}`,\n );\n }\n }\n\n async function ensurePhysicalTargets(props: {\n identity: FileSystemIdentity.IIdentity;\n output: string;\n entries: IInputFile[];\n }): Promise<void> {\n const output: string = await fs.promises.realpath(props.output);\n const inputs: Set<string> = new Set();\n for (const entry of props.entries) {\n inputs.add(\n props.identity.filesystemKey(await fs.promises.realpath(entry.file)),\n );\n }\n\n for (const entry of props.entries) {\n const parent: string = path.dirname(entry.target);\n const directory: string = await fs.promises.realpath(parent);\n if (props.identity.contains(directory, output) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output parent path escapes output directory through a symbolic link: ${parent}`,\n );\n }\n\n const target: string = path.join(directory, path.basename(entry.target));\n if (inputs.has(props.identity.filesystemKey(target))) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output file would overwrite input file through a symbolic link: ${entry.target}`,\n );\n }\n }\n }\n\n async function ensureTargetFiles(\n entries: IInputFile[],\n identity: FileSystemIdentity.IIdentity,\n ): Promise<void> {\n const inputs: Set<string> = new Set();\n const files: Map<string, IInputFile> = new Map();\n for (const entry of entries) {\n inputs.add(\n fileIdentityKey(\n await fs.promises.stat(entry.file, { bigint: true }),\n await fs.promises.realpath(entry.file),\n ),\n );\n files.set(identity.filesystemKey(entry.target), entry);\n }\n\n for (const entry of files.values()) {\n let stat: fs.BigIntStats;\n try {\n stat = await fs.promises.lstat(entry.target, { bigint: true });\n } catch (exp) {\n if (isMissingFileError(exp)) {\n continue;\n }\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to inspect output file ${entry.target}: ${formatUnknownError(exp)}`,\n );\n }\n if (stat.isFile() === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output file path is not a regular file: ${entry.target}`,\n );\n }\n if (\n inputs.has(\n fileIdentityKey(stat, await fs.promises.realpath(entry.target)),\n )\n ) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output file would overwrite input file through a physical file alias: ${entry.target}`,\n );\n }\n if (stat.nlink > BigInt(1)) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output file has multiple hard links: ${entry.target}`,\n );\n }\n }\n }\n\n async function prepareDirectoryInput(\n location: IArguments,\n policy: FileSystemIdentity.Policy,\n ): Promise<IInputFile[]> {\n if (location.input === undefined) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): input path is required.\",\n );\n }\n const input = path.resolve(location.input);\n if (fs.existsSync(input) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input path does not exist: ${input}`,\n );\n }\n if ((await isDirectory(input)) === false) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): input path is not a directory.\",\n );\n }\n\n const inputReal: string = await fs.promises.realpath(input);\n const outputReal: string | undefined = await optionalRealPath(\n location.output,\n );\n const files: string[] = [];\n await gather({\n container: files,\n from: input,\n inputReal,\n outputReal,\n policy,\n visitedDirectories: new Set(),\n visitedFiles: new Set(),\n });\n return files.map((file) => ({\n file,\n target: path.join(location.output, path.relative(input, file)),\n }));\n }\n\n async function prepareFileInputs(\n location: IArguments,\n policy: FileSystemIdentity.Policy,\n ): Promise<IInputFile[]> {\n const targets: Set<string> = new Set();\n const output: IInputFile[] = [];\n for (const input of await expandFileInputs(\n location.files,\n location.output,\n policy,\n )) {\n const file: string = path.resolve(input);\n policy.observe(\n await FileSystemIdentity.inspectDirectory(path.dirname(file)),\n path.dirname(file),\n );\n const identity: FileSystemIdentity.IIdentity = policy.get();\n if (fs.existsSync(file) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input file does not exist: ${input}`,\n );\n } else if ((await isFile(file)) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input path is not a file: ${input}`,\n );\n } else if (identity.isDeclarationFile(file)) {\n continue;\n } else if (identity.isSupportedExtension(file) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input file is not a supported TypeScript source: ${input}`,\n );\n }\n\n const target: string = path.join(location.output, path.basename(file));\n if (identity.isSamePath(file, target)) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): output file would overwrite input file: ${input}`,\n );\n }\n const key: string = identity.filesystemKey(target);\n if (targets.has(key)) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): duplicate output filename for ${target}`,\n );\n }\n targets.add(key);\n output.push({ file, target });\n }\n if (output.length === 0) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): input files do not include any supported TypeScript source files outside the output directory.\",\n );\n }\n return output;\n }\n\n async function expandFileInputs(\n inputs: string[],\n directory: string,\n policy: FileSystemIdentity.Policy,\n ): Promise<string[]> {\n const output: string[] = [];\n for (const input of inputs) {\n const pattern: string = toGlobPattern(input);\n if (isDynamicPattern(pattern, { caseSensitiveMatch: true })) {\n const searchDirectory: string = await globSearchDirectory(input);\n const caseSensitive: boolean | undefined =\n await FileSystemIdentity.inspectDirectory(searchDirectory);\n if (caseSensitive === undefined) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to determine filesystem case behavior for input pattern base ${searchDirectory}.`,\n );\n }\n policy.observe(caseSensitive, searchDirectory);\n const identity: FileSystemIdentity.IIdentity = policy.get();\n const matches: string[] = await glob(pattern, {\n absolute: true,\n caseSensitiveMatch: identity.caseSensitive,\n cwd: process.cwd(),\n onlyFiles: true,\n });\n if (matches.length === 0) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input pattern does not match any files: ${input}`,\n );\n }\n output.push(\n ...excludeOutputFiles(matches, directory, identity).filter((file) =>\n identity.isSupportedExtension(file),\n ),\n );\n } else {\n const file: string = path.resolve(input);\n policy.observe(\n await FileSystemIdentity.inspectDirectory(path.dirname(file)),\n path.dirname(file),\n );\n if (policy.get().contains(file, directory) === false) {\n output.push(file);\n }\n }\n }\n return output;\n }\n\n function excludeOutputFiles(\n files: string[],\n directory: string,\n identity: FileSystemIdentity.IIdentity,\n ): string[] {\n return files.filter((file) => identity.contains(file, directory) === false);\n }\n\n async function globSearchDirectory(input: string): Promise<string> {\n let current: string = path.resolve(input);\n while (\n isDynamicPattern(toGlobPattern(current), { caseSensitiveMatch: true })\n ) {\n const parent: string = path.dirname(current);\n if (parent === current) break;\n current = parent;\n }\n if (fs.existsSync(current) && (await isDirectory(current))) return current;\n return nearestExistingAncestor(path.dirname(current));\n }\n\n function toGlobPattern(input: string): string {\n return input.replace(/\\\\/g, \"/\");\n }\n\n function transformProject(props: {\n binary: string;\n cwd: string;\n projectRoot: string;\n tsconfig: string;\n }): Record<string, string> {\n const TtscCompiler = loadTtscCompiler();\n const result: ITtscCompilerTransformation = new TtscCompiler({\n binary: props.binary,\n cwd: props.cwd,\n projectRoot: props.projectRoot,\n tsconfig: props.tsconfig,\n }).transform();\n if (result.type === \"success\") {\n return result.typescript;\n }\n if (result.type === \"failure\") {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): ${formatDiagnostics(result.diagnostics)}`,\n );\n }\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): ${formatUnknownError(result.error)}`,\n );\n }\n\n function resolveProjectConfigFile(project: string): string {\n const resolved: string = path.resolve(project);\n if (fs.existsSync(resolved) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): project path does not exist: ${resolved}`,\n );\n }\n\n const stat: fs.Stats = fs.statSync(resolved);\n if (stat.isDirectory()) {\n for (const filename of [\"tsconfig.json\", \"jsconfig.json\"]) {\n const candidate: string = path.join(resolved, filename);\n if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {\n return resolveRealPath(candidate);\n }\n }\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): project directory has no tsconfig.json or jsconfig.json: ${resolved}`,\n );\n }\n if (stat.isFile() === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): project path is not a file: ${resolved}`,\n );\n }\n return resolveRealPath(resolved);\n }\n\n function findProjectConfigFile(directory: string): string | null {\n let current: string = path.resolve(directory);\n while (true) {\n for (const filename of [\"tsconfig.json\", \"jsconfig.json\"]) {\n const candidate: string = path.join(current, filename);\n if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {\n return resolveRealPath(candidate);\n }\n }\n const parent: string = path.dirname(current);\n if (parent === current) {\n return null;\n }\n current = parent;\n }\n }\n\n function loadTtscCompiler(): typeof import(\"ttsc\").TtscCompiler {\n const packageRoot: string = resolveTypiaPackageRoot();\n const resolved: string | null = resolveFromRoots(\n \"ttsc\",\n resolveRuntimeRoots(packageRoot),\n );\n if (resolved === null) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to resolve ttsc from the current project, typia package, or workspace root. Run \"npm i -D ttsc typescript\" before.`,\n );\n }\n const imported = createRequire(resolved)(resolved) as typeof import(\"ttsc\");\n return imported.TtscCompiler;\n }\n\n function resolveTsgoBinary(): string {\n const explicit: string | undefined = process.env.TTSC_TSGO_BINARY;\n if (explicit !== undefined && explicit.length !== 0) {\n if (path.isAbsolute(explicit) && fs.existsSync(explicit)) {\n return explicit;\n }\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): TTSC_TSGO_BINARY must be an existing absolute path: ${explicit}`,\n );\n }\n\n const packageRoot: string = resolveTypiaPackageRoot();\n const manifest: string | null = resolveFromRoots(\n \"typescript/package.json\",\n resolveRuntimeRoots(packageRoot),\n );\n if (manifest === null) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): unable to resolve typescript from the current project, typia package, or workspace root.\",\n );\n }\n\n const platform: string = `@typescript/typescript-${process.platform}-${process.arch}`;\n const platformManifest: string = createRequire(manifest).resolve(\n `${platform}/package.json`,\n );\n const binary: string = path.join(\n path.dirname(platformManifest),\n \"lib\",\n process.platform === \"win32\" ? \"tsc.exe\" : \"tsc\",\n );\n if (fs.existsSync(binary) === false) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): TypeScript-Go executable not found: ${binary}`,\n );\n }\n return binary;\n }\n\n function resolveTypiaPackageRoot(): string {\n // The CLI entrypoint (`lib/executable/typia.js`) lives in the same\n // directory as this module, so its `process.argv[1]` path anchors the\n // walk-up identically in both the CJS and ESM builds — `__dirname` does\n // not exist in the transcoded `.mjs`.\n const current: string = path.dirname(path.resolve(process.argv[1] ?? \"\"));\n for (const directory of [\n path.resolve(current, \"..\", \"..\"),\n path.resolve(current, \"..\"),\n ]) {\n const file: string = path.join(directory, \"package.json\");\n if (fs.existsSync(file) === false) {\n continue;\n }\n try {\n const pack = JSON.parse(fs.readFileSync(file, \"utf8\")) as Partial<\n Record<\"name\", unknown>\n >;\n if (pack.name === \"typia\") {\n return directory;\n }\n } catch {\n continue;\n }\n }\n\n const resolved: string | null = resolveFromRoots(\"typia/package.json\", [\n process.cwd(),\n current,\n ]);\n if (resolved === null) {\n throw new URIError(\n \"Error on TypiaGenerateWizard.generate(): unable to resolve typia package root.\",\n );\n }\n return path.dirname(resolved);\n }\n\n function resolveRuntimeRoots(packageRoot: string): string[] {\n return [process.cwd(), packageRoot, path.resolve(packageRoot, \"..\", \"..\")];\n }\n\n function resolveFromRoots(request: string, roots: string[]): string | null {\n for (const root of roots) {\n try {\n return createRequire(path.join(root, \"package.json\")).resolve(request);\n } catch {\n continue;\n }\n }\n return null;\n }\n\n async function isDirectory(current: string): Promise<boolean> {\n const stat: fs.Stats = await fs.promises.stat(current);\n return stat.isDirectory();\n }\n\n async function isFile(current: string): Promise<boolean> {\n const stat: fs.Stats = await fs.promises.stat(current);\n return stat.isFile();\n }\n\n async function gather(props: {\n container: string[];\n from: string;\n inputReal: string;\n outputReal: string | undefined;\n policy: FileSystemIdentity.Policy;\n visitedDirectories: Set<string>;\n visitedFiles: Set<string>;\n }): Promise<void> {\n const currentReal: string = await resolveTraversalPath(props.from);\n if (\n props.outputReal !== undefined &&\n isPhysicalSameOrChildPath(currentReal, props.outputReal)\n )\n return;\n ensurePhysicalInputContainment({\n file: props.from,\n input: props.inputReal,\n real: currentReal,\n });\n\n const currentStat: fs.BigIntStats = await fs.promises.stat(props.from, {\n bigint: true,\n });\n const directoryIdentity: string = fileIdentityKey(currentStat, currentReal);\n if (props.visitedDirectories.has(directoryIdentity)) {\n const lexicalStat: fs.Stats = await fs.promises.lstat(props.from);\n if (lexicalStat.isSymbolicLink()) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input directory link revisits a physical directory: ${props.from}.`,\n );\n }\n return;\n }\n props.visitedDirectories.add(directoryIdentity);\n\n props.policy.observe(\n await FileSystemIdentity.inspectDirectory(props.from),\n props.from,\n );\n const identity: FileSystemIdentity.IIdentity = props.policy.get();\n const entries: ITraversalEntry[] = await Promise.all(\n (await fs.promises.readdir(props.from)).map(async (name) => {\n const file: string = path.join(props.from, name);\n try {\n return { file, name, stat: await fs.promises.lstat(file) };\n } catch (error) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to inspect input path ${file}: ${formatUnknownError(error)}`,\n );\n }\n }),\n );\n entries.sort((x, y) => {\n const linkOrder: number =\n Number(x.stat.isSymbolicLink()) - Number(y.stat.isSymbolicLink());\n return linkOrder !== 0\n ? linkOrder\n : Buffer.compare(Buffer.from(x.name), Buffer.from(y.name));\n });\n\n for (const entry of entries) {\n let stat: fs.BigIntStats;\n let real: string;\n try {\n stat = await fs.promises.stat(entry.file, { bigint: true });\n real = await fs.promises.realpath(entry.file);\n } catch (error) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input link target is missing or unreadable: ${entry.file}: ${formatUnknownError(error)}`,\n );\n }\n\n if (\n props.outputReal !== undefined &&\n isPhysicalSameOrChildPath(real, props.outputReal)\n )\n continue;\n ensurePhysicalInputContainment({\n file: entry.file,\n input: props.inputReal,\n real,\n });\n\n if (stat.isDirectory()) {\n await gather({ ...props, from: entry.file });\n continue;\n }\n if (\n stat.isFile() === false ||\n identity.isSupportedExtension(entry.name) === false\n )\n continue;\n\n const fileIdentity: string = fileIdentityKey(stat, real);\n if (props.visitedFiles.has(fileIdentity)) continue;\n props.visitedFiles.add(fileIdentity);\n props.container.push(entry.file);\n }\n }\n\n function formatOutput(output: string): string {\n return output.startsWith(\"// @ts-nocheck\")\n ? output\n : `// @ts-nocheck\\n${output}`;\n }\n\n function indexTransformedOutputs(\n outputs: Record<string, string>,\n identity: FileSystemIdentity.IIdentity,\n ): Map<string, string> {\n const map: Map<string, string> = new Map();\n for (const [file, output] of Object.entries(outputs)) {\n const key: string = identity.projectFileKey(file);\n if (map.has(key)) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): transformed outputs have ambiguous filesystem identities: ${file}.`,\n );\n }\n map.set(key, output);\n }\n return map;\n }\n\n function getTransformedOutput(props: {\n cwd: string;\n entry: IInputFile;\n identity: FileSystemIdentity.IIdentity;\n outputByKey: Map<string, string>;\n }): string | undefined {\n const output = props.outputByKey.get(\n props.identity.projectFileKey(projectKey(props.cwd, props.entry.file)),\n );\n if (output !== undefined) {\n return output;\n }\n\n const compilerFile: string = compilerInputPath(props.entry.file);\n if (\n props.identity.isSamePath(compilerFile, props.entry.file) === false &&\n props.identity.contains(compilerFile, props.cwd)\n ) {\n const compiled: string | undefined = props.outputByKey.get(\n props.identity.projectFileKey(projectKey(props.cwd, compilerFile)),\n );\n if (compiled !== undefined) return compiled;\n }\n\n const real: string = resolveRealPath(props.entry.file);\n if (\n props.identity.isSamePath(real, props.entry.file) ||\n props.identity.contains(real, props.cwd) === false\n ) {\n return undefined;\n }\n return props.outputByKey.get(\n props.identity.projectFileKey(projectKey(props.cwd, real)),\n );\n }\n\n function projectKey(root: string, file: string): string {\n return path.relative(root, file).replace(/\\\\/g, \"/\");\n }\n\n function resolveRealPath(file: string): string {\n try {\n return fs.realpathSync(file);\n } catch {\n return file;\n }\n }\n\n function compilerInputPath(file: string): string {\n try {\n if (fs.lstatSync(file).isSymbolicLink()) {\n return path.join(\n resolveRealPath(path.dirname(file)),\n path.basename(file),\n );\n }\n } catch {\n return file;\n }\n return resolveRealPath(file);\n }\n\n async function optionalRealPath(file: string): Promise<string | undefined> {\n try {\n return await fs.promises.realpath(file);\n } catch (error) {\n if (isMissingFileError(error)) return undefined;\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to resolve path ${file}: ${formatUnknownError(error)}`,\n );\n }\n }\n\n async function resolveTraversalPath(file: string): Promise<string> {\n try {\n return await fs.promises.realpath(file);\n } catch (error) {\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): unable to resolve input path ${file}: ${formatUnknownError(error)}`,\n );\n }\n }\n\n function ensurePhysicalInputContainment(props: {\n file: string;\n input: string;\n real: string;\n }): void {\n if (isPhysicalSameOrChildPath(props.real, props.input)) return;\n throw new URIError(\n `Error on TypiaGenerateWizard.generate(): input path resolves outside the input directory: ${props.file}.`,\n );\n }\n\n function isPhysicalSameOrChildPath(file: string, directory: string): boolean {\n const relative: string = path.relative(directory, file);\n return (\n relative === \"\" ||\n (relative !== \"..\" &&\n relative.startsWith(`..${path.sep}`) === false &&\n path.isAbsolute(relative) === false)\n );\n }\n\n function isMissingFileError(exp: unknown): boolean {\n return (\n typeof exp === \"object\" &&\n exp !== null &&\n \"code\" in exp &&\n exp.code === \"ENOENT\"\n );\n }\n\n /**\n * Delegates to {@link FileSystemIdentity.identityKey}, which owns the rule and\n * carries the reasoning for reading the identity as a `bigint`.\n */\n function fileIdentityKey(stat: fs.BigIntStats, realpath: string): string {\n return FileSystemIdentity.identityKey(stat, realpath);\n }\n\n function formatDiagnostics(diagnostics: ITtscCompilerDiagnostic[]): string {\n return diagnostics.length === 0\n ? \"transformation failed\"\n : diagnostics\n .map((diag) =>\n [\n diag.file ?? \"ttsc\",\n diag.line === undefined\n ? undefined\n : `${diag.line}:${diag.character ?? 1}`,\n diag.messageText,\n ]\n .filter((part) => part !== undefined && part !== \"\")\n .join(\": \"),\n )\n .join(\"\\n\");\n }\n\n function formatUnknownError(error: unknown): string {\n if (error instanceof Error) {\n return error.message;\n }\n if (\n typeof error === \"object\" &&\n error !== null &&\n \"message\" in error &&\n typeof error.message === \"string\"\n ) {\n return error.message;\n }\n return String(error);\n }\n}\n"],"mappings":";;;;;;;;;AAcO,IAAA;;CACE,eAAe,WAA0B;EAC9C,QAAQ,IAAI,0CAA0C;EACtD,QAAQ,IAAI,wBAAwB;EACpC,QAAQ,IAAI,0CAA0C;EAGtD,MAAM,MAAM,MADsB,eAAe,CAC9B;CACrB;;CAEA,eAAe,iBAAsC;EACnD,MAAM,UAAU,cAAc,gBAAgB;EAC9C,QAAQ,MAAM,sBAAsB;EACpC,QAAQ,SAAS,cAAc,wCAAwC;EACvE,QAAQ,OAAO,kBAAkB,iBAAiB;EAClD,QAAQ,OAAO,wBAAwB,kBAAkB;EACzD,QAAQ,OACN,uBACA,+CACF;EAE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IAAI,CACd,CAAC,CACA,KAAK,IAAI;CAClB;CAEA,SAAS,mBAAmB,OAAwB;EAClD,IAAI,iBAAiB,OACnB,OAAO,MAAM;EAEf,IACE,OAAO,UAAU,YACjB,UAAU,QACV,aAAa,SACb,OAAO,MAAM,YAAY,UAEzB,OAAO,MAAM;EAEf,OAAO,OAAO,KAAK;CACrB;GACD,wBAAA,sBAAA,CAAA,EAAD"}
|
|
@@ -30,14 +30,29 @@ export declare class _ProtobufReader {
|
|
|
30
30
|
* Advance by exactly one varint, which carries no length prefix.
|
|
31
31
|
*
|
|
32
32
|
* A varint terminates at its first byte without the continuation bit, and may
|
|
33
|
-
* occupy no more than {@link VARINT_MAX_BYTES}.
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* occupy no more than {@link VARINT_MAX_BYTES}. Its tenth byte is bounded
|
|
34
|
+
* twice over, by {@link lastVarintByte}: it may neither continue into an
|
|
35
|
+
* eleventh byte nor carry payload above bit 63. Skipping is where that is
|
|
36
|
+
* easiest to get wrong, because this path discards the bytes it reads and so
|
|
37
|
+
* never notices a value it could not have represented. Relaxing either bound
|
|
38
|
+
* here would accept a varint that `varint32` and `varint64` reject, making
|
|
39
|
+
* the limit depend on which method happens to consume the value.
|
|
36
40
|
*/
|
|
37
41
|
skipVarint(): void;
|
|
38
42
|
skipType(wireType: ProtobufWire): void;
|
|
39
43
|
private varint32;
|
|
40
44
|
private varint64;
|
|
45
|
+
/**
|
|
46
|
+
* Read the only byte whose varint payload is limited to bit 63.
|
|
47
|
+
*
|
|
48
|
+
* Two distinct faults meet on this byte, and each is named for what it is. A
|
|
49
|
+
* continuation bit means the varint would occupy an eleventh byte, which no
|
|
50
|
+
* 64-bit value can reach. Any other payload bit means the varint terminates
|
|
51
|
+
* within its ten bytes but carries a value bit above 63. Reporting the second
|
|
52
|
+
* as a length fault would tell the caller something untrue about a payload
|
|
53
|
+
* that is exactly ten bytes long.
|
|
54
|
+
*/
|
|
55
|
+
private lastVarintByte;
|
|
41
56
|
private u8;
|
|
42
57
|
private u8n;
|
|
43
58
|
private take;
|
|
@@ -85,16 +85,20 @@ class _ProtobufReader {
|
|
|
85
85
|
* Advance by exactly one varint, which carries no length prefix.
|
|
86
86
|
*
|
|
87
87
|
* A varint terminates at its first byte without the continuation bit, and may
|
|
88
|
-
* occupy no more than {@link VARINT_MAX_BYTES}.
|
|
89
|
-
*
|
|
90
|
-
*
|
|
88
|
+
* occupy no more than {@link VARINT_MAX_BYTES}. Its tenth byte is bounded
|
|
89
|
+
* twice over, by {@link lastVarintByte}: it may neither continue into an
|
|
90
|
+
* eleventh byte nor carry payload above bit 63. Skipping is where that is
|
|
91
|
+
* easiest to get wrong, because this path discards the bytes it reads and so
|
|
92
|
+
* never notices a value it could not have represented. Relaxing either bound
|
|
93
|
+
* here would accept a varint that `varint32` and `varint64` reject, making
|
|
94
|
+
* the limit depend on which method happens to consume the value.
|
|
91
95
|
*/
|
|
92
96
|
skipVarint() {
|
|
93
97
|
this.atomic(() => {
|
|
94
|
-
for (let i =
|
|
98
|
+
for (let i = 1; i < VARINT_MAX_BYTES; ++i)
|
|
95
99
|
if ((this.u8() & 0x80) === 0)
|
|
96
100
|
return;
|
|
97
|
-
|
|
101
|
+
this.lastVarintByte();
|
|
98
102
|
});
|
|
99
103
|
}
|
|
100
104
|
skipType(wireType) {
|
|
@@ -149,8 +153,7 @@ class _ProtobufReader {
|
|
|
149
153
|
return value;
|
|
150
154
|
if (this.u8() < 0x80)
|
|
151
155
|
return value;
|
|
152
|
-
|
|
153
|
-
return value;
|
|
156
|
+
this.lastVarintByte();
|
|
154
157
|
return value;
|
|
155
158
|
}
|
|
156
159
|
varint64() {
|
|
@@ -183,9 +186,27 @@ class _ProtobufReader {
|
|
|
183
186
|
value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(56);
|
|
184
187
|
if (loaded < BigInt(0x80))
|
|
185
188
|
return value;
|
|
186
|
-
value |= (this.
|
|
189
|
+
value |= BigInt(this.lastVarintByte()) << BigInt(63);
|
|
187
190
|
return BigInt.asUintN(64, value);
|
|
188
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* Read the only byte whose varint payload is limited to bit 63.
|
|
194
|
+
*
|
|
195
|
+
* Two distinct faults meet on this byte, and each is named for what it is. A
|
|
196
|
+
* continuation bit means the varint would occupy an eleventh byte, which no
|
|
197
|
+
* 64-bit value can reach. Any other payload bit means the varint terminates
|
|
198
|
+
* within its ten bytes but carries a value bit above 63. Reporting the second
|
|
199
|
+
* as a length fault would tell the caller something untrue about a payload
|
|
200
|
+
* that is exactly ten bytes long.
|
|
201
|
+
*/
|
|
202
|
+
lastVarintByte() {
|
|
203
|
+
const loaded = this.u8();
|
|
204
|
+
if ((loaded & 0x80) !== 0)
|
|
205
|
+
throw error(`varint exceeds ${VARINT_MAX_BYTES} bytes.`);
|
|
206
|
+
if (loaded > 0x01)
|
|
207
|
+
throw error(`varint exceeds ${VARINT_MAX_BITS} bits.`);
|
|
208
|
+
return loaded;
|
|
209
|
+
}
|
|
189
210
|
u8() {
|
|
190
211
|
return this.view.getUint8(this.take(1));
|
|
191
212
|
}
|
|
@@ -229,10 +250,17 @@ const error = (message) => new Error(`Error on typia.protobuf.decode(): ${messag
|
|
|
229
250
|
/**
|
|
230
251
|
* The most bytes a varint may occupy: a 64-bit value in seven-bit groups.
|
|
231
252
|
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* holds it by.
|
|
253
|
+
* Every path reads no further than its tenth byte and accepts only bit 63 from
|
|
254
|
+
* that byte. This constant keeps the loop-driven skip path on the same limit.
|
|
235
255
|
*/
|
|
236
256
|
const VARINT_MAX_BYTES = 10;
|
|
257
|
+
/**
|
|
258
|
+
* The widest value a varint may carry: the 64-bit Protocol Buffer wire domain.
|
|
259
|
+
*
|
|
260
|
+
* The tenth byte reaches only bit 63, so a payload bit above it belongs to no
|
|
261
|
+
* representable value. This names the overflow fault apart from the length
|
|
262
|
+
* one.
|
|
263
|
+
*/
|
|
264
|
+
const VARINT_MAX_BITS = 64;
|
|
237
265
|
const utf8 = new utils_1.Singleton(() => new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }));
|
|
238
266
|
//# sourceMappingURL=_ProtobufReader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_ProtobufReader.js","sourceRoot":"","sources":["../../src/internal/_ProtobufReader.ts"],"names":[],"mappings":";;;AAAA,gDAAgD;AAChD,wCAAyC;AAEzC,kHAAkH;AAClH;IAaE,YAAmB,GAAe;QAChC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;QACrE,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;IACxB,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAEM,MAAM;QACX,MAAM,KAAK,GAAW,IAAI,CAAC,QAAQ,EAAE,CAAC;QACtC,OAAO,CAAC,KAAK,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IACtC,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAEM,KAAK;QACV,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC5C,CAAC;IAEM,MAAM;QACX,MAAM,KA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AAG,CAAC;QAC/B,MAAM,GAAG,GAAW,IAAI,CAAC,GAAG,CAAC;QAC7B,IAAI,CAAC;YACH,OAAO,OAAO,EAAE,CAAC;QACnB,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;YACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;YACf,MAAM,MAAM,CAAC;QACf,CAAC;IACH,CAAC;IAEO,QAAQ,CAAC,MAAc;QAC7B,IACE,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,KAAK;YACtC,MAAM,GAAG,CAAC;YACV,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG;YAE/B,MAAM,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACpC,CAAC;CACF;;AAED;;;;;;GAMG;AACH,MAAM,KAAK,GAAG,CAAC,OAAe,EAAS,EAAE,CACvC,IAAI,KAAK,CAAC,qCAAqC,OAAO,EAAE,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAM,IAAI,GAAG,IAAI,iBAAS,CACxB,GAAG,EAAE,CAAC,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CACjE,CAAC"}
|
|
@@ -80,14 +80,18 @@ var _ProtobufReader = class {
|
|
|
80
80
|
* Advance by exactly one varint, which carries no length prefix.
|
|
81
81
|
*
|
|
82
82
|
* A varint terminates at its first byte without the continuation bit, and may
|
|
83
|
-
* occupy no more than {@link VARINT_MAX_BYTES}.
|
|
84
|
-
*
|
|
85
|
-
*
|
|
83
|
+
* occupy no more than {@link VARINT_MAX_BYTES}. Its tenth byte is bounded
|
|
84
|
+
* twice over, by {@link lastVarintByte}: it may neither continue into an
|
|
85
|
+
* eleventh byte nor carry payload above bit 63. Skipping is where that is
|
|
86
|
+
* easiest to get wrong, because this path discards the bytes it reads and so
|
|
87
|
+
* never notices a value it could not have represented. Relaxing either bound
|
|
88
|
+
* here would accept a varint that `varint32` and `varint64` reject, making
|
|
89
|
+
* the limit depend on which method happens to consume the value.
|
|
86
90
|
*/
|
|
87
91
|
skipVarint() {
|
|
88
92
|
this.atomic(() => {
|
|
89
|
-
for (let i =
|
|
90
|
-
|
|
93
|
+
for (let i = 1; i < VARINT_MAX_BYTES; ++i) if ((this.u8() & 128) === 0) return;
|
|
94
|
+
this.lastVarintByte();
|
|
91
95
|
});
|
|
92
96
|
}
|
|
93
97
|
skipType(wireType) {
|
|
@@ -129,7 +133,7 @@ var _ProtobufReader = class {
|
|
|
129
133
|
if (this.u8() < 128) return value;
|
|
130
134
|
if (this.u8() < 128) return value;
|
|
131
135
|
if (this.u8() < 128) return value;
|
|
132
|
-
|
|
136
|
+
this.lastVarintByte();
|
|
133
137
|
return value;
|
|
134
138
|
}
|
|
135
139
|
varint64() {
|
|
@@ -153,9 +157,25 @@ var _ProtobufReader = class {
|
|
|
153
157
|
if (loaded < BigInt(128)) return value;
|
|
154
158
|
value |= ((loaded = this.u8n()) & BigInt(127)) << BigInt(56);
|
|
155
159
|
if (loaded < BigInt(128)) return value;
|
|
156
|
-
value |= (this.
|
|
160
|
+
value |= BigInt(this.lastVarintByte()) << BigInt(63);
|
|
157
161
|
return BigInt.asUintN(64, value);
|
|
158
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Read the only byte whose varint payload is limited to bit 63.
|
|
165
|
+
*
|
|
166
|
+
* Two distinct faults meet on this byte, and each is named for what it is. A
|
|
167
|
+
* continuation bit means the varint would occupy an eleventh byte, which no
|
|
168
|
+
* 64-bit value can reach. Any other payload bit means the varint terminates
|
|
169
|
+
* within its ten bytes but carries a value bit above 63. Reporting the second
|
|
170
|
+
* as a length fault would tell the caller something untrue about a payload
|
|
171
|
+
* that is exactly ten bytes long.
|
|
172
|
+
*/
|
|
173
|
+
lastVarintByte() {
|
|
174
|
+
const loaded = this.u8();
|
|
175
|
+
if ((loaded & 128) !== 0) throw error(`varint exceeds ${VARINT_MAX_BYTES} bytes.`);
|
|
176
|
+
if (loaded > 1) throw error(`varint exceeds ${VARINT_MAX_BITS} bits.`);
|
|
177
|
+
return loaded;
|
|
178
|
+
}
|
|
159
179
|
u8() {
|
|
160
180
|
return this.view.getUint8(this.take(1));
|
|
161
181
|
}
|
|
@@ -194,11 +214,18 @@ const error = (message) => /* @__PURE__ */ new Error(`Error on typia.protobuf.de
|
|
|
194
214
|
/**
|
|
195
215
|
* The most bytes a varint may occupy: a 64-bit value in seven-bit groups.
|
|
196
216
|
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* holds it by.
|
|
217
|
+
* Every path reads no further than its tenth byte and accepts only bit 63 from
|
|
218
|
+
* that byte. This constant keeps the loop-driven skip path on the same limit.
|
|
200
219
|
*/
|
|
201
220
|
const VARINT_MAX_BYTES = 10;
|
|
221
|
+
/**
|
|
222
|
+
* The widest value a varint may carry: the 64-bit Protocol Buffer wire domain.
|
|
223
|
+
*
|
|
224
|
+
* The tenth byte reaches only bit 63, so a payload bit above it belongs to no
|
|
225
|
+
* representable value. This names the overflow fault apart from the length
|
|
226
|
+
* one.
|
|
227
|
+
*/
|
|
228
|
+
const VARINT_MAX_BITS = 64;
|
|
202
229
|
const utf8 = new Singleton(() => new TextDecoder("utf-8", {
|
|
203
230
|
fatal: true,
|
|
204
231
|
ignoreBOM: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_ProtobufReader.mjs","names":[],"sources":["../../src/internal/_ProtobufReader.ts"],"sourcesContent":["import { ProtobufWire } from \"@typia/interface\";\nimport { Singleton } from \"@typia/utils\";\n\n/// @reference https://github.com/piotr-oles/as-proto/blob/main/packages/as-proto/assembly/internal/FixedReader.ts\nexport class _ProtobufReader {\n /** Read buffer */\n private buf: Uint8Array;\n\n /** Read buffer pointer. */\n private ptr: number;\n\n /** DataView for buffer. */\n private view: DataView;\n\n /** Current length-delimited boundary. */\n private end: number;\n\n public constructor(buf: Uint8Array) {\n this.buf = buf;\n this.ptr = 0;\n this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);\n this.end = buf.length;\n }\n\n public index(): number {\n return this.ptr;\n }\n\n public size(): number {\n return this.end;\n }\n\n public uint32(): number {\n return this.varint32() >>> 0;\n }\n\n public int32(): number {\n return this.varint32();\n }\n\n public sint32(): number {\n const value: number = this.varint32();\n return (value >>> 1) ^ -(value & 1);\n }\n\n public uint64(): bigint {\n return this.varint64();\n }\n\n public int64(): bigint {\n return BigInt.asIntN(64, this.varint64());\n }\n\n public sint64(): bigint {\n const value = this.varint64();\n return (value >> BigInt(0x01)) ^ -(value & BigInt(0x01));\n }\n\n public bool(): boolean {\n return this.varint32() !== 0;\n }\n\n public float(): number {\n return this.view.getFloat32(this.take(4), true);\n }\n\n public double(): number {\n return this.view.getFloat64(this.take(8), true);\n }\n\n public bytes(): Uint8Array {\n return this.atomic(() => {\n const length: number = this.uint32();\n const from: number = this.take(length);\n return this.buf.subarray(from, from + length);\n });\n }\n\n public string(): string {\n const bytes: Uint8Array = this.bytes();\n const decoder: TextDecoder = utf8.get();\n try {\n return decoder.decode(bytes);\n } catch {\n throw error(\"invalid UTF-8 string.\");\n }\n }\n\n public fork(): number {\n return this.atomic(() => {\n const previous: number = this.end;\n const length: number = this.uint32();\n this.validate(length);\n this.end = this.ptr + length;\n return previous;\n });\n }\n\n public close(previous: number): void {\n if (this.ptr !== this.end) throw error(\"buffer overflow.\");\n this.end = previous;\n }\n\n /** Advance by exactly `length` bytes, for every length including zero. */\n public skip(length: number): void {\n this.take(length);\n }\n\n /**\n * Advance by exactly one varint, which carries no length prefix.\n *\n * A varint terminates at its first byte without the continuation bit, and may\n * occupy no more than {@link VARINT_MAX_BYTES}. Reading past that limit would\n * accept a varint that `varint32` and `varint64` could not, making the limit\n * depend on which method happens to consume the value.\n */\n public skipVarint(): void {\n this.atomic(() => {\n for (let i: number = 0; i < VARINT_MAX_BYTES; ++i)\n if ((this.u8() & 0x80) === 0) return;\n throw error(`varint exceeds ${VARINT_MAX_BYTES} bytes.`);\n });\n }\n\n public skipType(wireType: ProtobufWire): void {\n this.atomic(() => {\n switch (wireType) {\n case ProtobufWire.VARIANT:\n this.skipVarint();\n break;\n case ProtobufWire.I64:\n this.skip(8);\n break;\n case ProtobufWire.LEN:\n this.skip(this.uint32());\n break;\n case ProtobufWire.START_GROUP:\n while ((wireType = this.uint32() & 0x07) !== ProtobufWire.END_GROUP)\n this.skipType(wireType);\n break;\n case ProtobufWire.I32:\n this.skip(4);\n break;\n default:\n throw error(`invalid wire type ${wireType} at offset ${this.ptr}.`);\n }\n });\n }\n\n private varint32(): number {\n let loaded: number;\n let value: number;\n\n value = (loaded = this.u8()) & 0x7f;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0x7f) << 7;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0x7f) << 14;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0x7f) << 21;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0xf) << 28;\n if (loaded < 0x80) return value;\n\n // increment position until there is no continuation bit, or until this read\n // reaches VARINT_MAX_BYTES and the value can hold no further bits\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n\n return value;\n }\n\n private varint64(): bigint {\n let loaded: bigint;\n let value: bigint;\n\n value = (loaded = this.u8n()) & BigInt(0x7f);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(7);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(14);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(21);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(28);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(35);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(42);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(49);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(56);\n if (loaded < BigInt(0x80)) return value;\n\n value |= (this.u8n() & BigInt(0x01)) << BigInt(63);\n return BigInt.asUintN(64, value);\n }\n\n private u8(): number {\n return this.view.getUint8(this.take(1));\n }\n\n private u8n(): bigint {\n return BigInt(this.u8());\n }\n\n private take(length: number): number {\n this.validate(length);\n const from: number = this.ptr;\n this.ptr += length;\n return from;\n }\n\n private atomic<T>(closure: () => T): T {\n const index: number = this.ptr;\n const end: number = this.end;\n try {\n return closure();\n } catch (thrown) {\n this.ptr = index;\n this.end = end;\n throw thrown;\n }\n }\n\n private validate(length: number): void {\n if (\n Number.isSafeInteger(length) === false ||\n length < 0 ||\n length > this.size() - this.ptr\n )\n throw error(\"buffer overflow.\");\n }\n}\n\n/**\n * Builds every fault this reader raises, so each one names typia as its source.\n *\n * Every decode error a caller can see must be attributable, and the prefix is\n * what attributes it. Composing it here rather than at each throw keeps a new\n * fault from silently shipping without it.\n */\nconst error = (message: string): Error =>\n new Error(`Error on typia.protobuf.decode(): ${message}`);\n\n/**\n * The most bytes a varint may occupy: a 64-bit value in seven-bit groups.\n *\n * `varint32` and `varint64` hold this same limit structurally, by reading no\n * further than their tenth byte. This constant is what a loop-driven consumer\n * holds it by.\n */\nconst VARINT_MAX_BYTES = 10;\n\nconst utf8 = new Singleton(\n () => new TextDecoder(\"utf-8\", { fatal: true, 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AAS,OAAO,GAAI,GAAG,OAAO;EAElC,WAAW,SAAS,KAAK,IAAI,KAAK,OAAO,GAAI,MAAM,OAAO,EAAE;EAC5D,IAAI,SAAS,OAAO,GAAI,GAAG,OAAO;EAElC,UAAU,KAAK,IAAI,IAAI,OAAO,CAAI,MAAM,OAAO,EAAE;EACjD,OAAO,OAAO,QAAQ,IAAI,KAAK;CACjC;CAEA,KAAqB;EACnB,OAAO,KAAK,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC;CACxC;CAEA,MAAsB;EACpB,OAAO,OAAO,KAAK,GAAG,CAAC;CACzB;CAEA,KAAa,QAAwB;EACnC,KAAK,SAAS,MAAM;EACpB,MAAM,OAAe,KAAK;EAC1B,KAAK,OAAO;EACZ,OAAO;CACT;CAEA,OAAkB,SAAqB;EACrC,MAAM,QAAgB,KAAK;EAC3B,MAAM,MAAc,KAAK;EACzB,IAAI;GACF,OAAO,QAAQ;EACjB,SAAS,QAAQ;GACf,KAAK,MAAM;GACX,KAAK,MAAM;GACX,MAAM;EACR;CACF;CAEA,SAAiB,QAAsB;EACrC,IACE,OAAO,cAAc,MAAM,MAAM,SACjC,SAAS,KACT,SAAS,KAAK,KAAK,IAAI,KAAK,KAE5B,MAAM,MAAM,kBAAkB;CAClC;AACF;;;;;;;;AASA,MAAM,SAAS,4BACb,IAAI,MAAM,qCAAqC,SAAS;;;;;;;;AAS1D,MAAM,mBAAmB;AAEzB,MAAM,OAAO,IAAI,gBACT,IAAI,YAAY,SAAS;CAAE,OAAO;CAAM,WAAW;AAAK,CAAC,CACjE"}
|
|
1
|
+
{"version":3,"file":"_ProtobufReader.mjs","names":[],"sources":["../../src/internal/_ProtobufReader.ts"],"sourcesContent":["import { ProtobufWire } from \"@typia/interface\";\nimport { Singleton } from \"@typia/utils\";\n\n/// @reference https://github.com/piotr-oles/as-proto/blob/main/packages/as-proto/assembly/internal/FixedReader.ts\nexport class _ProtobufReader {\n /** Read buffer */\n private buf: Uint8Array;\n\n /** Read buffer pointer. */\n private ptr: number;\n\n /** DataView for buffer. */\n private view: DataView;\n\n /** Current length-delimited boundary. */\n private end: number;\n\n public constructor(buf: Uint8Array) {\n this.buf = buf;\n this.ptr = 0;\n this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);\n this.end = buf.length;\n }\n\n public index(): number {\n return this.ptr;\n }\n\n public size(): number {\n return this.end;\n }\n\n public uint32(): number {\n return this.varint32() >>> 0;\n }\n\n public int32(): number {\n return this.varint32();\n }\n\n public sint32(): number {\n const value: number = this.varint32();\n return (value >>> 1) ^ -(value & 1);\n }\n\n public uint64(): bigint {\n return this.varint64();\n }\n\n public int64(): bigint {\n return BigInt.asIntN(64, this.varint64());\n }\n\n public sint64(): bigint {\n const value = this.varint64();\n return (value >> BigInt(0x01)) ^ -(value & BigInt(0x01));\n }\n\n public bool(): boolean {\n return this.varint32() !== 0;\n }\n\n public float(): number {\n return this.view.getFloat32(this.take(4), true);\n }\n\n public double(): number {\n return this.view.getFloat64(this.take(8), true);\n }\n\n public bytes(): Uint8Array {\n return this.atomic(() => {\n const length: number = this.uint32();\n const from: number = this.take(length);\n return this.buf.subarray(from, from + length);\n });\n }\n\n public string(): string {\n const bytes: Uint8Array = this.bytes();\n const decoder: TextDecoder = utf8.get();\n try {\n return decoder.decode(bytes);\n } catch {\n throw error(\"invalid UTF-8 string.\");\n }\n }\n\n public fork(): number {\n return this.atomic(() => {\n const previous: number = this.end;\n const length: number = this.uint32();\n this.validate(length);\n this.end = this.ptr + length;\n return previous;\n });\n }\n\n public close(previous: number): void {\n if (this.ptr !== this.end) throw error(\"buffer overflow.\");\n this.end = previous;\n }\n\n /** Advance by exactly `length` bytes, for every length including zero. */\n public skip(length: number): void {\n this.take(length);\n }\n\n /**\n * Advance by exactly one varint, which carries no length prefix.\n *\n * A varint terminates at its first byte without the continuation bit, and may\n * occupy no more than {@link VARINT_MAX_BYTES}. Its tenth byte is bounded\n * twice over, by {@link lastVarintByte}: it may neither continue into an\n * eleventh byte nor carry payload above bit 63. Skipping is where that is\n * easiest to get wrong, because this path discards the bytes it reads and so\n * never notices a value it could not have represented. Relaxing either bound\n * here would accept a varint that `varint32` and `varint64` reject, making\n * the limit depend on which method happens to consume the value.\n */\n public skipVarint(): void {\n this.atomic(() => {\n for (let i: number = 1; i < VARINT_MAX_BYTES; ++i)\n if ((this.u8() & 0x80) === 0) return;\n this.lastVarintByte();\n });\n }\n\n public skipType(wireType: ProtobufWire): void {\n this.atomic(() => {\n switch (wireType) {\n case ProtobufWire.VARIANT:\n this.skipVarint();\n break;\n case ProtobufWire.I64:\n this.skip(8);\n break;\n case ProtobufWire.LEN:\n this.skip(this.uint32());\n break;\n case ProtobufWire.START_GROUP:\n while ((wireType = this.uint32() & 0x07) !== ProtobufWire.END_GROUP)\n this.skipType(wireType);\n break;\n case ProtobufWire.I32:\n this.skip(4);\n break;\n default:\n throw error(`invalid wire type ${wireType} at offset ${this.ptr}.`);\n }\n });\n }\n\n private varint32(): number {\n let loaded: number;\n let value: number;\n\n value = (loaded = this.u8()) & 0x7f;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0x7f) << 7;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0x7f) << 14;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0x7f) << 21;\n if (loaded < 0x80) return value;\n\n value |= ((loaded = this.u8()) & 0xf) << 28;\n if (loaded < 0x80) return value;\n\n // increment position until there is no continuation bit, or until this read\n // reaches VARINT_MAX_BYTES and the value can hold no further bits\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n if (this.u8() < 0x80) return value;\n this.lastVarintByte();\n return value;\n }\n\n private varint64(): bigint {\n let loaded: bigint;\n let value: bigint;\n\n value = (loaded = this.u8n()) & BigInt(0x7f);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(7);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(14);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(21);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(28);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(35);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(42);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(49);\n if (loaded < BigInt(0x80)) return value;\n\n value |= ((loaded = this.u8n()) & BigInt(0x7f)) << BigInt(56);\n if (loaded < BigInt(0x80)) return value;\n\n value |= BigInt(this.lastVarintByte()) << BigInt(63);\n return BigInt.asUintN(64, value);\n }\n\n /**\n * Read the only byte whose varint payload is limited to bit 63.\n *\n * Two distinct faults meet on this byte, and each is named for what it is. A\n * continuation bit means the varint would occupy an eleventh byte, which no\n * 64-bit value can reach. Any other payload bit means the varint terminates\n * within its ten bytes but carries a value bit above 63. Reporting the second\n * as a length fault would tell the caller something untrue about a payload\n * that is exactly ten bytes long.\n */\n private lastVarintByte(): number {\n const loaded: number = this.u8();\n if ((loaded & 0x80) !== 0)\n throw error(`varint exceeds ${VARINT_MAX_BYTES} bytes.`);\n if (loaded > 0x01) throw error(`varint exceeds ${VARINT_MAX_BITS} bits.`);\n return loaded;\n }\n\n private u8(): number {\n return this.view.getUint8(this.take(1));\n }\n\n private u8n(): bigint {\n return BigInt(this.u8());\n }\n\n private take(length: number): number {\n this.validate(length);\n const from: number = this.ptr;\n this.ptr += length;\n return from;\n }\n\n private atomic<T>(closure: () => T): T {\n const index: number = this.ptr;\n const end: number = this.end;\n try {\n return closure();\n } catch (thrown) {\n this.ptr = index;\n this.end = end;\n throw thrown;\n }\n }\n\n private validate(length: number): void {\n if (\n Number.isSafeInteger(length) === false ||\n length < 0 ||\n length > this.size() - this.ptr\n )\n throw error(\"buffer overflow.\");\n }\n}\n\n/**\n * Builds every fault this reader raises, so each one names typia as its source.\n *\n * Every decode error a caller can see must be attributable, and the prefix is\n * what attributes it. Composing it here rather than at each throw keeps a new\n * fault from silently shipping without it.\n */\nconst error = (message: string): Error =>\n new Error(`Error on typia.protobuf.decode(): ${message}`);\n\n/**\n * The most bytes a varint may occupy: a 64-bit value in seven-bit groups.\n *\n * Every path reads no further than its tenth byte and accepts only bit 63 from\n * that byte. This constant keeps the loop-driven skip path on the same limit.\n */\nconst VARINT_MAX_BYTES = 10;\n\n/**\n * The widest value a varint may carry: the 64-bit Protocol Buffer wire domain.\n *\n * The tenth byte reaches only bit 63, so a payload bit above it belongs to no\n * representable value. This names the overflow fault apart from the length\n * one.\n */\nconst VARINT_MAX_BITS = 64;\n\nconst utf8 = new Singleton(\n () => new TextDecoder(\"utf-8\", { fatal: true, ignoreBOM: true }),\n);\n"],"mappings":";;;AAIA,IAAa,kBAAb,MAA6B;CAa3B,YAAmB,KAAiB;EAClC,KAAK,MAAM;EACX,KAAK,MAAM;EACX,KAAK,OAAO,IAAI,SAAS,IAAI,QAAQ,IAAI,YAAY,IAAI,UAAU;EACnE,KAAK,MAAM,IAAI;CACjB;CAEA,QAAuB;EACrB,OAAO,KAAK;CACd;CAEA,OAAsB;EACpB,OAAO,KAAK;CACd;CAEA,SAAwB;EACtB,OAAO,KAAK,SAAS,MAAM;CAC7B;CAEA,QAAuB;EACrB,OAAO,KAAK,SAAS;CACvB;CAEA,SAAwB;EACtB,MAAM,QAAgB,KAAK,SAAS;EACpC,OAAQ,UAAU,IAAK,EAAE,QAAQ;CACnC;CAEA,SAAwB;EACtB,OAAO,KAAK,SAAS;CACvB;CAEA,QAAuB;EACrB,OAAO,OAAO,OAAO,IAAI,KAAK,SAAS,CAAC;CAC1C;CAEA,SAAwB;EACtB,MAAM,QAAQ,KAAK,SAAS;EAC5B,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EA,OAAkB,SAAqB;EACrC,MAAM,QAAgB,KAAK;EAC3B,MAAM,MAAc,KAAK;EACzB,IAAI;GACF,OAAO,QAAQ;EACjB,SAAS,QAAQ;GACf,KAAK,MAAM;GACX,KAAK,MAAM;GACX,MAAM;EACR;CACF;CAEA,SAAiB,QAAsB;EACrC,IACE,OAAO,cAAc,MAAM,MAAM,SACjC,SAAS,KACT,SAAS,KAAK,KAAK,IAAI,KAAK,KAE5B,MAAM,MAAM,kBAAkB;CAClC;AACF;;;;;;;;AASA,MAAM,SAAS,4BACb,IAAI,MAAM,qCAAqC,SAAS;;;;;;;AAQ1D,MAAM,mBAAmB;;;;;;;;AASzB,MAAM,kBAAkB;AAExB,MAAM,OAAO,IAAI,gBACT,IAAI,YAAY,SAAS;CAAE,OAAO;CAAM,WAAW;AAAK,CAAC,CACjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._jsonStringifyArray = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Serializes the elements of an array the way ECMAScript `JSON.stringify` does.
|
|
6
|
+
*
|
|
7
|
+
* `SerializeJSONArray` walks index `0` to `LengthOfArrayLike(value) - 1` and
|
|
8
|
+
* writes `null` wherever the element serializes to `undefined`. Neither
|
|
9
|
+
* `Array.prototype.map` nor `Array.prototype.join` reproduces that:
|
|
10
|
+
*
|
|
11
|
+
* - `map` never visits a hole and leaves one behind, and `join` renders a hole as
|
|
12
|
+
* empty text, so a sparse array joined into malformed text such as `[,1]`. A
|
|
13
|
+
* hole exists at runtime whatever the element type declares, so this is not
|
|
14
|
+
* an `any` concern.
|
|
15
|
+
* - `join` renders a mapped `undefined` as empty text too, which is what an `any`
|
|
16
|
+
* or `unknown` element holding a function, a symbol, or a `toJSON` that
|
|
17
|
+
* returns nothing serializes to.
|
|
18
|
+
*
|
|
19
|
+
* The length is converted with `ToLength` and read once, which is both what
|
|
20
|
+
* `JSON.stringify` does and what `Array.prototype.every` - the traversal
|
|
21
|
+
* typia's own array checkers emit - does, so the checker and the serializer
|
|
22
|
+
* walk one index range rather than two that merely usually coincide.
|
|
23
|
+
*
|
|
24
|
+
* @param elements Array being serialized.
|
|
25
|
+
* @param mapper Serializer of one element, emitted by the transform.
|
|
26
|
+
* @returns Comma separated element text, without the enclosing brackets.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
const _jsonStringifyArray = (elements, mapper) => {
|
|
30
|
+
const length = Math.min(Math.max(Math.trunc(elements.length) || 0, 0), Number.MAX_SAFE_INTEGER);
|
|
31
|
+
let output = "";
|
|
32
|
+
for (let i = 0; i < length; ++i) {
|
|
33
|
+
const elem = elements[i];
|
|
34
|
+
// A hole and an explicit `undefined` are answered without calling the
|
|
35
|
+
// mapper, because the mapper is the element type's own serializer and a
|
|
36
|
+
// typed one has no answer for a missing value. Everything else is answered
|
|
37
|
+
// from the mapper's *result*: an element that is present but serializes to
|
|
38
|
+
// nothing — a function, a symbol, or a `toJSON` returning nothing in an
|
|
39
|
+
// `any` slot — is `null` in an array position, exactly as
|
|
40
|
+
// SerializeJSONArray specifies, and testing the input instead would let its
|
|
41
|
+
// text become the literal `undefined`.
|
|
42
|
+
const text = elem === undefined ? undefined : mapper(elem, i);
|
|
43
|
+
output += (i === 0 ? "" : ",") + (text === undefined ? "null" : text);
|
|
44
|
+
}
|
|
45
|
+
return output;
|
|
46
|
+
};
|
|
47
|
+
exports._jsonStringifyArray = _jsonStringifyArray;
|
|
48
|
+
//# sourceMappingURL=_jsonStringifyArray.js.map
|