{"id":13671337,"url":"https://github.com/webpack/webpack-sources","last_synced_at":"2025-05-14T00:04:54.327Z","repository":{"id":3284126,"uuid":"48954523","full_name":"webpack/webpack-sources","owner":"webpack","description":"Source code handling classes for webpack","archived":false,"fork":false,"pushed_at":"2024-10-30T15:01:17.000Z","size":1572,"stargazers_count":265,"open_issues_count":8,"forks_count":71,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-27T00:05:52.310Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webpack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-03T17:30:14.000Z","updated_at":"2025-03-24T10:05:53.000Z","dependencies_parsed_at":"2024-01-17T19:39:03.151Z","dependency_job_id":"7595b4b5-4284-46e4-a9a0-5ddd3e51ab86","html_url":"https://github.com/webpack/webpack-sources","commit_stats":{"total_commits":211,"total_committers":26,"mean_commits":8.115384615384615,"dds":0.3507109004739336,"last_synced_commit":"88d0e043cd4e34dcbbf18b6c4e040be5f6f31dde"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fwebpack-sources","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fwebpack-sources/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fwebpack-sources/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack%2Fwebpack-sources/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpack","download_url":"https://codeload.github.com/webpack/webpack-sources/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245878901,"owners_count":20687295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T09:01:06.596Z","updated_at":"2025-04-03T01:04:53.996Z","avatar_url":"https://github.com/webpack.png","language":"JavaScript","readme":"# webpack-sources\n\nContains multiple classes which represent a `Source`. A `Source` can be asked for source code, size, source map and hash.\n\n## `Source`\n\nBase class for all sources.\n\n### Public methods\n\nAll methods should be considered as expensive as they may need to do computations.\n\n#### `source`\n\n```typescript\nSource.prototype.source() -\u003e String | Buffer\n```\n\nReturns the represented source code as string or Buffer (for binary Sources).\n\n#### `buffer`\n\n```typescript\nSource.prototype.buffer() -\u003e Buffer\n```\n\nReturns the represented source code as Buffer. Strings are converted to utf-8.\n\n#### `size`\n\n```typescript\nSource.prototype.size() -\u003e Number\n```\n\nReturns the size in bytes of the represented source code.\n\n#### `map`\n\n```typescript\nSource.prototype.map(options?: Object) -\u003e Object | null\n```\n\nReturns the SourceMap of the represented source code as JSON. May return `null` if no SourceMap is available.\n\nThe `options` object can contain the following keys:\n\n- `columns: Boolean` (default `true`): If set to false the implementation may omit mappings for columns.\n\n#### `sourceAndMap`\n\n```typescript\nSource.prototype.sourceAndMap(options?: Object) -\u003e {\n\tsource: String | Buffer,\n\tmap: Object | null\n}\n```\n\nReturns both, source code (like `Source.prototype.source()` and SourceMap (like `Source.prototype.map()`). This method could have better performance than calling `source()` and `map()` separately.\n\nSee `map()` for `options`.\n\n#### `updateHash`\n\n```typescript\nSource.prototype.updateHash(hash: Hash) -\u003e void\n```\n\nUpdates the provided `Hash` object with the content of the represented source code. (`Hash` is an object with an `update` method, which is called with string values)\n\n## `RawSource`\n\nRepresents source code without SourceMap.\n\n```typescript\nnew RawSource(sourceCode: String | Buffer)\n```\n\n## `OriginalSource`\n\nRepresents source code, which is a copy of the original file.\n\n```typescript\nnew OriginalSource(\n\tsourceCode: String | Buffer,\n\tname: String\n)\n```\n\n- `sourceCode`: The source code.\n- `name`: The filename of the original source code.\n\nOriginalSource tries to create column mappings if requested, by splitting the source code at typical statement borders (`;`, `{`, `}`).\n\n## `SourceMapSource`\n\nRepresents source code with SourceMap, optionally having an additional SourceMap for the original source.\n\n```typescript\nnew SourceMapSource(\n\tsourceCode: String | Buffer,\n\tname: String,\n\tsourceMap: Object | String | Buffer,\n\toriginalSource?: String | Buffer,\n\tinnerSourceMap?: Object | String | Buffer,\n\tremoveOriginalSource?: boolean\n)\n```\n\n- `sourceCode`: The source code.\n- `name`: The filename of the original source code.\n- `sourceMap`: The SourceMap for the source code.\n- `originalSource`: The source code of the original file. Can be omitted if the `sourceMap` already contains the original source code.\n- `innerSourceMap`: The SourceMap for the `originalSource`/`name`.\n- `removeOriginalSource`: Removes the source code for `name` from the final map, keeping only the deeper mappings for that file.\n\nThe `SourceMapSource` supports \"identity\" mappings for the `innerSourceMap`.\nWhen original source matches generated source for a mapping it's assumed to be mapped char by char allowing to keep finer mappings from `sourceMap`.\n\n## `CachedSource`\n\nDecorates a `Source` and caches returned results of `map`, `source`, `buffer`, `size` and `sourceAndMap` in memory. `updateHash` is not cached.\nIt tries to reused cached results from other methods to avoid calculations, i. e. when `source` is already cached, calling `size` will get the size from the cached source, calling `sourceAndMap` will only call `map` on the wrapped Source.\n\n```typescript\nnew CachedSource(source: Source)\nnew CachedSource(source: Source | () =\u003e Source, cachedData?: CachedData)\n```\n\nInstead of passing a `Source` object directly one can pass an function that returns a `Source` object. The function is only called when needed and once.\n\n### Public methods\n\n#### `getCachedData()`\n\nReturns the cached data for passing to the constructor. All cached entries are converted to Buffers and strings are avoided.\n\n#### `original()`\n\nReturns the original `Source` object.\n\n#### `originalLazy()`\n\nReturns the original `Source` object or a function returning these.\n\n## `PrefixSource`\n\nPrefix every line of the decorated `Source` with a provided string.\n\n```typescript\nnew PrefixSource(\n\tprefix: String,\n\tsource: Source | String | Buffer\n)\n```\n\n## `ConcatSource`\n\nConcatenate multiple `Source`s or strings to a single source.\n\n```typescript\nnew ConcatSource(\n\t...items?: Source | String\n)\n```\n\n### Public methods\n\n#### `add`\n\n```typescript\nConcatSource.prototype.add(item: Source | String)\n```\n\nAdds an item to the source.\n\n## `ReplaceSource`\n\nDecorates a `Source` with replacements and insertions of source code.\n\nThe `ReplaceSource` supports \"identity\" mappings for child source.\nWhen original source matches generated source for a mapping it's assumed to be mapped char by char allowing to split mappings at replacements/insertions.\n\n### Public methods\n\n#### `replace`\n\n```typescript\nReplaceSource.prototype.replace(\n\tstart: Number,\n\tend: Number,\n\treplacement: String\n)\n```\n\nReplaces chars from `start` (0-indexed, inclusive) to `end` (0-indexed, inclusive) with `replacement`.\n\nLocations represents locations in the original source and are not influenced by other replacements or insertions.\n\n#### `insert`\n\n```typescript\nReplaceSource.prototype.insert(\n\tpos: Number,\n\tinsertion: String\n)\n```\n\nInserts the `insertion` before char `pos` (0-indexed).\n\nLocation represents location in the original source and is not influenced by other replacements or insertions.\n\n#### `original`\n\nGet decorated `Source`.\n\n## `CompatSource`\n\nConverts a Source-like object into a real Source object.\n\n### Public methods\n\n#### static `from`\n\n```typescript\nCompatSource.from(sourceLike: any | Source)\n```\n\nIf `sourceLike` is a real Source it returns it unmodified. Otherwise it returns it wrapped in a CompatSource.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack%2Fwebpack-sources","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpack%2Fwebpack-sources","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack%2Fwebpack-sources/lists"}