mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
394
web/node_modules/magic-string/CHANGELOG.md
generated
vendored
Normal file
394
web/node_modules/magic-string/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,394 @@
|
|||
# magic-string changelog
|
||||
|
||||
## 0.25.7
|
||||
|
||||
* fix bundle mappings after remove and move in multiple sources ([#172](https://github.com/Rich-Harris/magic-string/issues/172))
|
||||
|
||||
## 0.25.6
|
||||
|
||||
* Use bitwise operators for small performance boost ([#171](https://github.com/Rich-Harris/magic-string/pull/171))
|
||||
|
||||
## 0.25.5
|
||||
|
||||
* Use a bitset to reduce memory consumption ([#167](https://github.com/Rich-Harris/magic-string/issues/167))
|
||||
|
||||
## 0.25.4
|
||||
|
||||
* Clone `intro` and `outro` ([#162](https://github.com/Rich-Harris/magic-string/issues/162))
|
||||
|
||||
## 0.25.3
|
||||
|
||||
* Fix typing of `SourceMap.version`.
|
||||
|
||||
## 0.25.2
|
||||
|
||||
* Remove deprecated `new Buffer(...)`
|
||||
* Handle characters outside Latin1 range when generating a sourcemap in browser ([#154](https://github.com/Rich-Harris/magic-string/issues/154))
|
||||
|
||||
## 0.25.1
|
||||
|
||||
* Additional types for index.d.ts ([#148](https://github.com/Rich-Harris/magic-string/pull/148))
|
||||
|
||||
## 0.25.0
|
||||
|
||||
* Add `length` method ([#145](https://github.com/Rich-Harris/magic-string/pull/145))
|
||||
* Fix trimming chunks with intro/outro ([#144](https://github.com/Rich-Harris/magic-string/pull/144))
|
||||
|
||||
## 0.24.1
|
||||
|
||||
* Add `lastLine` and `lastChar` methods ([#142](https://github.com/Rich-Harris/magic-string/pull/142))
|
||||
|
||||
## 0.24.0
|
||||
|
||||
* Add `isEmpty` methods ([#137](https://github.com/Rich-Harris/magic-string/pull/137))
|
||||
* Fix a potential race condition ([#136](https://github.com/Rich-Harris/magic-string/pull/136))
|
||||
* Fix CJS/ES bundles inlining `sourcemap-codec` in 0.23.2.
|
||||
|
||||
## 0.23.2
|
||||
|
||||
* Add `generateDecodedMap` methods ([#134](https://github.com/Rich-Harris/magic-string/pull/134))
|
||||
|
||||
## 0.23.1
|
||||
|
||||
* Performance ([#132](https://github.com/Rich-Harris/magic-string/pull/132))
|
||||
|
||||
## 0.23.0
|
||||
|
||||
* Use `sourcemap-codec` for improved performance ([#133](https://github.com/Rich-Harris/magic-string/pull/133))
|
||||
|
||||
## 0.22.5
|
||||
|
||||
* Add TypeScript interfaces used by rollup ([#131](https://github.com/Rich-Harris/magic-string/pull/131))
|
||||
* Remove src directory from npm package
|
||||
|
||||
## 0.22.4
|
||||
|
||||
* `contentOnly` and `storeName` are both optional
|
||||
|
||||
## 0.22.3
|
||||
|
||||
* Add `original` to TS definitions
|
||||
|
||||
## 0.22.2
|
||||
|
||||
* Avoid `declare module` ([#127](https://github.com/Rich-Harris/magic-string/pull/127))
|
||||
|
||||
## 0.22.1
|
||||
|
||||
* Update TypeScript definitions ([#124](https://github.com/Rich-Harris/magic-string/pull/124))
|
||||
|
||||
## 0.22.0
|
||||
|
||||
* Prevent `overwrite` state corruption ([#115](https://github.com/Rich-Harris/magic-string/issues/115))
|
||||
* Various bugfixes ([#126](https://github.com/Rich-Harris/magic-string/pull/126))
|
||||
|
||||
## 0.21.3
|
||||
|
||||
* Clone `indentExclusionRanges` correctly ([#122](https://github.com/Rich-Harris/magic-string/pull/122))
|
||||
* Fix more typings ([#122](https://github.com/Rich-Harris/magic-string/pull/122))
|
||||
|
||||
## 0.21.2
|
||||
|
||||
* Add `default` property referencing self in index-legacy.js, to work around TypeScript bug ([#121](https://github.com/Rich-Harris/magic-string/pull/121))
|
||||
|
||||
## 0.21.1
|
||||
|
||||
* Add typings file to package
|
||||
|
||||
## 0.21.0
|
||||
|
||||
* Add TypeScript bindings ([#119](https://github.com/Rich-Harris/magic-string/pull/119))
|
||||
|
||||
## 0.20.0
|
||||
|
||||
* The fourth argument to `overwrite` is a `{storeName, contentOnly}` options object. `storeName: true` is equivalent to `true` before. `contentOnly` will preserve existing appends/prepends to the chunk in question
|
||||
|
||||
## 0.19.1
|
||||
|
||||
* Prevent overwrites across a split point (i.e. following a `move`)
|
||||
* Implement `remove` separately to `overwrite`
|
||||
|
||||
## 0.19.0
|
||||
|
||||
* More accurate bundle sourcemaps ([#114](https://github.com/Rich-Harris/magic-string/pull/114))
|
||||
|
||||
## 0.18.0
|
||||
|
||||
* Optimisation – remove empty chunks following `overwrite` or `remove` ([#113](https://github.com/Rich-Harris/magic-string/pull/113))
|
||||
|
||||
## 0.17.0
|
||||
|
||||
* Add `appendLeft`, `appendRight`, `prependLeft`, `prependRight` methods ([#109](https://github.com/Rich-Harris/magic-string/issues/109))
|
||||
* `insertLeft` and `insertRight` are deprecated in favour of `appendLeft` and `prependRight` respectively
|
||||
|
||||
## 0.16.0
|
||||
|
||||
* Include inserts in range for `overwrite` and `remove` operations ([#89](https://github.com/Rich-Harris/magic-string/pull/89))
|
||||
* Make options optional for `bundle.generateMap(...)` ([#73](https://github.com/Rich-Harris/magic-string/pull/73))
|
||||
|
||||
## 0.15.2
|
||||
|
||||
* Generate correct bundle sourcemap with prepended/appended content
|
||||
|
||||
## 0.15.1
|
||||
|
||||
* Minor sourcemap fixes
|
||||
|
||||
## 0.15.0
|
||||
|
||||
* Use named export of `Bundle` in ES build, so ES consumers of magic-string can tree-shake it out
|
||||
|
||||
## 0.14.0
|
||||
|
||||
* Throw if overwrite of zero-length range is attempted
|
||||
* Correctly handle redundant move operations
|
||||
|
||||
## 0.13.1
|
||||
|
||||
* Fix a bevy of `s.slice()` issues ([#62](https://github.com/Rich-Harris/magic-string/pull/62))
|
||||
|
||||
## 0.13.0
|
||||
|
||||
* Breaking: `insertAfter` is now `insertLeft`, `insertBefore` is now `insertRight`
|
||||
* Breaking: `insert` is no longer available. Use `insertLeft` and `insertRight`
|
||||
* Significant performance improvements
|
||||
|
||||
## 0.12.1
|
||||
|
||||
* Fix sourcemap generation with `insertAfter` and `insertBefore`
|
||||
|
||||
## 0.12.0
|
||||
|
||||
* Add `insertAfter` and `insertBefore` methods
|
||||
|
||||
## 0.11.4
|
||||
|
||||
* Fix two regression bugs with `trim()`
|
||||
* More informative error message on illegal removals
|
||||
|
||||
## 0.11.3
|
||||
|
||||
* Fix trim methods to ensure correct sourcemaps with trimmed content ([#53](https://github.com/Rich-Harris/magic-string/pull/53))
|
||||
|
||||
## 0.11.2
|
||||
|
||||
* Support sourcemaps with moved content
|
||||
|
||||
## 0.11.1
|
||||
|
||||
* Use `findIndex` helper for 0.12 support
|
||||
|
||||
## 0.11.0
|
||||
|
||||
* Add experimental `move()` method
|
||||
* Refactor internals to support `move()`
|
||||
|
||||
## 0.10.2
|
||||
|
||||
* Do not overwrite inserts at the end of patched ranges ([#35](https://github.com/Rich-Harris/magic-string/pull/35))
|
||||
|
||||
## 0.10.1
|
||||
|
||||
* Zero-length inserts are not removed on adjacent overwrites
|
||||
|
||||
## 0.10.0
|
||||
|
||||
* Complete rewrite, resulting in ~40x speed increase ([#30](https://github.com/Rich-Harris/magic-string/pull/30))
|
||||
* Breaking – `magicString.locate` and `locateOrigin` are deprecated
|
||||
* More forgiving rules about contiguous patches, and which ranges are valid with `magicString.slice(...)`
|
||||
|
||||
## 0.9.1
|
||||
|
||||
* Update deps
|
||||
|
||||
## 0.9.0
|
||||
|
||||
* Update build process
|
||||
|
||||
## 0.8.0
|
||||
|
||||
* Add an ES6 build, change default UMD build to CommonJS (but keeping existing UMD build with bundled dependencies)
|
||||
* Make properties non-enumerable, for cleaner logging
|
||||
* Update dependencies
|
||||
|
||||
## 0.7.0
|
||||
|
||||
* The `names` array is populated when generating sourcemaps, and mappings include name indices where appropriate ([#16](https://github.com/Rich-Harris/magic-string/issues/16))
|
||||
* Replaced content is mapped correctly in sourcemaps ([#15](https://github.com/Rich-Harris/magic-string/issues/15))
|
||||
|
||||
## 0.6.6
|
||||
|
||||
* Adjust mappings correctly when removing replaced content
|
||||
* Error correctly when removed characters are used as slice anchors
|
||||
|
||||
## 0.6.5
|
||||
|
||||
* Fix `jsnext:main` in package.json
|
||||
|
||||
## 0.6.4
|
||||
|
||||
* Fix bug with positive integer coercion
|
||||
|
||||
## 0.6.3
|
||||
|
||||
* Intro content is correctly indented
|
||||
* Content following an intro with trailing newline is correctly indented
|
||||
|
||||
## 0.6.2
|
||||
|
||||
* Noop indents are still chainable (fixes bug introduced in 0.6.1)
|
||||
|
||||
## 0.6.1
|
||||
|
||||
* Indenting with an empty string is a noop
|
||||
|
||||
## 0.6.0
|
||||
|
||||
* Use rollup for bundling, instead of esperanto
|
||||
|
||||
## 0.5.3
|
||||
|
||||
* Correct sourcemap generation with bundles containing varied separators
|
||||
* `s.clone()` clones indent exclusion ranges and sourcemap locations
|
||||
|
||||
## 0.5.2
|
||||
|
||||
* `s.slice()` accepts negative numbers, and the second argument can be omitted (means 'original string length'), just like `String.prototype.slice`
|
||||
* More informative error message when trying to overwrite content illegally
|
||||
|
||||
## 0.5.1
|
||||
|
||||
* Allow bundle separator to be the empty string
|
||||
* Indenting is handled correctly with empty string separator
|
||||
|
||||
## 0.5.0
|
||||
|
||||
* `s.replace()` is deprecated in favour of `s.overwrite()` (identical signature)
|
||||
* `bundle.addSource()` can take a `MagicString` instance as its sole argument, for convenience
|
||||
* The `options` in `new MagicString(str, options)` can include `filename` and `indentExclusionRanges` options, which will be used when bundling
|
||||
* New method: `s.snip( start, end )`
|
||||
|
||||
## 0.4.9
|
||||
|
||||
* `file` option is optional when generating a bundle sourcemap
|
||||
|
||||
## 0.4.7
|
||||
|
||||
* Repeated insertions at position 0 behave the same as other positions ([#10](https://github.com/Rich-Harris/magic-string/pull/10))
|
||||
|
||||
## 0.4.6
|
||||
|
||||
* Overlapping ranges can be removed
|
||||
* Non-string content is rejected ([#9](https://github.com/Rich-Harris/magic-string/pull/9))
|
||||
|
||||
## 0.4.5
|
||||
|
||||
* Implement `source.addSourcemapLocation()`
|
||||
|
||||
## 0.4.4
|
||||
|
||||
* Another Windows fix, this time for file paths when bundling
|
||||
|
||||
## 0.4.3
|
||||
|
||||
* Handle Windows-style CRLF newlines when determining whether a line is empty
|
||||
|
||||
## 0.4.2
|
||||
|
||||
* Fix typo in package.json (d'oh again)
|
||||
* Use only relative paths for internal modules - makes bundling with dependents (i.e. esperanto) possible
|
||||
|
||||
## 0.4.1
|
||||
|
||||
* Includes correct files in npm package (d'oh)
|
||||
|
||||
## 0.4.0
|
||||
|
||||
* Using experimental Esperanto feature ([esperantojs/esperanto#68](https://github.com/esperantojs/esperanto/issues/68)) to generate version with `vlq` dependency included
|
||||
|
||||
## 0.3.1
|
||||
|
||||
* Fixes a bug whereby multiple insertions at the same location would cause text to repeat ([#5](https://github.com/Rich-Harris/magic-string/issues/5))
|
||||
|
||||
## 0.3.0
|
||||
|
||||
* Breaking change - `source.indentStr` is `null` if no lines are indented. Use `source.getIndentString()` for the old behaviour (guess, and if no lines are indented, return `\t`)
|
||||
* `bundle.getIndentString()` ignores sources with no indented lines when guessing indentation ([#3](https://github.com/Rich-Harris/magic-string/issues/3))
|
||||
|
||||
## 0.2.7
|
||||
|
||||
* `source.trimLines()` removes empty lines from start/end of source, leaving other whitespace untouched
|
||||
* Indentation is not added to an empty source
|
||||
|
||||
## 0.2.6
|
||||
|
||||
* Performance improvement - adjustments are only made when necessary
|
||||
|
||||
## 0.2.5
|
||||
|
||||
* Single spaces are ignored when guessing indentation - experience shows these are more likely to be e.g. JSDoc comments than actual indentation
|
||||
* `bundle.addSource()` can take an `indentExclusionRanges` option
|
||||
|
||||
## 0.2.4
|
||||
|
||||
* Empty lines are not indented
|
||||
|
||||
## 0.2.3
|
||||
|
||||
* Fixes edge case with bundle sourcemaps
|
||||
|
||||
## 0.2.2
|
||||
|
||||
* Make `sources` paths in sourcemaps relative to `options.file`
|
||||
|
||||
## 0.2.1
|
||||
|
||||
* Minor fix for `bundle.indent()`
|
||||
|
||||
## 0.2.0
|
||||
|
||||
* Implement `MagicString.Bundle` for concatenating magic strings
|
||||
|
||||
## 0.1.10
|
||||
|
||||
* Fix sourcemap encoding
|
||||
|
||||
## 0.1.9
|
||||
|
||||
* Better performance when indenting large chunks of code
|
||||
|
||||
## 0.1.8
|
||||
|
||||
* Sourcemaps generated with `s.generateMap()` have a `toUrl()` method that generates a DataURI
|
||||
|
||||
## 0.1.7
|
||||
|
||||
* Implement `s.insert( index, content )` - roughly equivalent to `s.replace( index, index, content )`
|
||||
|
||||
## 0.1.6
|
||||
|
||||
* Version bump for npm's benefit
|
||||
|
||||
## 0.1.5
|
||||
|
||||
* `s.indent({ exclude: [ x, y ] })` prevents lines between (original) characters `x` and `y` from being indented. Multiple exclusion ranges are also supported (e.g. `exclude: [[a, b], [c, d]]`)
|
||||
|
||||
## 0.1.4
|
||||
|
||||
* `s.locate()` doesn't throw out-of-bound error if index is equal to original string's length
|
||||
|
||||
## 0.1.3
|
||||
|
||||
* `s.trim()` returns `this` (i.e. is chainable)
|
||||
|
||||
## 0.1.2
|
||||
|
||||
* Implement `s.slice()`
|
||||
|
||||
## 0.1.1
|
||||
|
||||
* Implement `s.trim()`
|
||||
|
||||
## 0.1.0
|
||||
|
||||
* First release
|
7
web/node_modules/magic-string/LICENSE
generated
vendored
Normal file
7
web/node_modules/magic-string/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
Copyright 2018 Rich Harris
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
250
web/node_modules/magic-string/README.md
generated
vendored
Normal file
250
web/node_modules/magic-string/README.md
generated
vendored
Normal file
|
@ -0,0 +1,250 @@
|
|||
# magic-string
|
||||
|
||||
<a href="https://travis-ci.org/Rich-Harris/magic-string">
|
||||
<img src="http://img.shields.io/travis/Rich-Harris/magic-string.svg"
|
||||
alt="build status">
|
||||
</a>
|
||||
<a href="https://npmjs.org/package/magic-string">
|
||||
<img src="https://img.shields.io/npm/v/magic-string.svg"
|
||||
alt="npm version">
|
||||
</a>
|
||||
<a href="https://github.com/Rich-Harris/magic-string/blob/master/LICENSE.md">
|
||||
<img src="https://img.shields.io/npm/l/magic-string.svg"
|
||||
alt="license">
|
||||
</a>
|
||||
|
||||
Suppose you have some source code. You want to make some light modifications to it - replacing a few characters here and there, wrapping it with a header and footer, etc - and ideally you'd like to generate a source map at the end of it. You've thought about using something like [recast](https://github.com/benjamn/recast) (which allows you to generate an AST from some JavaScript, manipulate it, and reprint it with a sourcemap without losing your comments and formatting), but it seems like overkill for your needs (or maybe the source code isn't JavaScript).
|
||||
|
||||
Your requirements are, frankly, rather niche. But they're requirements that I also have, and for which I made magic-string. It's a small, fast utility for manipulating strings and generating sourcemaps.
|
||||
|
||||
## Installation
|
||||
|
||||
magic-string works in both node.js and browser environments. For node, install with npm:
|
||||
|
||||
```bash
|
||||
npm i magic-string
|
||||
```
|
||||
|
||||
To use in browser, grab the [magic-string.umd.js](https://unpkg.com/magic-string/dist/magic-string.umd.js) file and add it to your page:
|
||||
|
||||
```html
|
||||
<script src='magic-string.umd.js'></script>
|
||||
```
|
||||
|
||||
(It also works with various module systems, if you prefer that sort of thing - it has a dependency on [vlq](https://github.com/Rich-Harris/vlq).)
|
||||
|
||||
## Usage
|
||||
|
||||
These examples assume you're in node.js, or something similar:
|
||||
|
||||
```js
|
||||
var MagicString = require( 'magic-string' );
|
||||
var s = new MagicString( 'problems = 99' );
|
||||
|
||||
s.overwrite( 0, 8, 'answer' );
|
||||
s.toString(); // 'answer = 99'
|
||||
|
||||
s.overwrite( 11, 13, '42' ); // character indices always refer to the original string
|
||||
s.toString(); // 'answer = 42'
|
||||
|
||||
s.prepend( 'var ' ).append( ';' ); // most methods are chainable
|
||||
s.toString(); // 'var answer = 42;'
|
||||
|
||||
var map = s.generateMap({
|
||||
source: 'source.js',
|
||||
file: 'converted.js.map',
|
||||
includeContent: true
|
||||
}); // generates a v3 sourcemap
|
||||
|
||||
require( 'fs' ).writeFile( 'converted.js', s.toString() );
|
||||
require( 'fs' ).writeFile( 'converted.js.map', map.toString() );
|
||||
```
|
||||
|
||||
You can pass an options argument:
|
||||
|
||||
```js
|
||||
var s = new MagicString( someCode, {
|
||||
// both these options will be used if you later
|
||||
// call `bundle.addSource( s )` - see below
|
||||
filename: 'foo.js',
|
||||
indentExclusionRanges: [/*...*/]
|
||||
});
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
### s.addSourcemapLocation( index )
|
||||
|
||||
Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is `false` (see below).
|
||||
|
||||
### s.append( content )
|
||||
|
||||
Appends the specified content to the end of the string. Returns `this`.
|
||||
|
||||
### s.appendLeft( index, content )
|
||||
|
||||
Appends the specified `content` at the `index` in the original string. If a range *ending* with `index` is subsequently moved, the insert will be moved with it. Returns `this`. See also `s.prependLeft(...)`.
|
||||
|
||||
### s.appendRight( index, content )
|
||||
|
||||
Appends the specified `content` at the `index` in the original string. If a range *starting* with `index` is subsequently moved, the insert will be moved with it. Returns `this`. See also `s.prependRight(...)`.
|
||||
|
||||
### s.clone()
|
||||
|
||||
Does what you'd expect.
|
||||
|
||||
### s.generateDecodedMap( options )
|
||||
|
||||
Generates a sourcemap object with raw mappings in array form, rather than encoded as a string. See `generateMap` documentation below for options details. Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead.
|
||||
|
||||
### s.generateMap( options )
|
||||
|
||||
Generates a [version 3 sourcemap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit). All options are, well, optional:
|
||||
|
||||
* `file` - the filename where you plan to write the sourcemap
|
||||
* `source` - the filename of the file containing the original source
|
||||
* `includeContent` - whether to include the original content in the map's `sourcesContent` array
|
||||
* `hires` - whether the mapping should be high-resolution. Hi-res mappings map every single character, meaning (for example) your devtools will always be able to pinpoint the exact location of function calls and so on. With lo-res mappings, devtools may only be able to identify the correct line - but they're quicker to generate and less bulky. If sourcemap locations have been specified with `s.addSourceMapLocation()`, they will be used here.
|
||||
|
||||
The returned sourcemap has two (non-enumerable) methods attached for convenience:
|
||||
|
||||
* `toString` - returns the equivalent of `JSON.stringify(map)`
|
||||
* `toUrl` - returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
|
||||
|
||||
```js
|
||||
code += '\n//# sourceMappingURL=' + map.toUrl();
|
||||
```
|
||||
|
||||
### s.indent( prefix[, options] )
|
||||
|
||||
Prefixes each line of the string with `prefix`. If `prefix` is not supplied, the indentation will be guessed from the original content, falling back to a single tab character. Returns `this`.
|
||||
|
||||
The `options` argument can have an `exclude` property, which is an array of `[start, end]` character ranges. These ranges will be excluded from the indentation - useful for (e.g.) multiline strings.
|
||||
|
||||
### s.insertLeft( index, content )
|
||||
|
||||
**DEPRECATED** since 0.17 – use `s.appendLeft(...)` instead
|
||||
|
||||
### s.insertRight( index, content )
|
||||
|
||||
**DEPRECATED** since 0.17 – use `s.prependRight(...)` instead
|
||||
|
||||
### s.locate( index )
|
||||
|
||||
**DEPRECATED** since 0.10 – see [#30](https://github.com/Rich-Harris/magic-string/pull/30)
|
||||
|
||||
### s.locateOrigin( index )
|
||||
|
||||
**DEPRECATED** since 0.10 – see [#30](https://github.com/Rich-Harris/magic-string/pull/30)
|
||||
|
||||
### s.move( start, end, newIndex )
|
||||
|
||||
Moves the characters from `start` and `end` to `index`. Returns `this`.
|
||||
|
||||
### s.overwrite( start, end, content[, options] )
|
||||
|
||||
Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply. Returns `this`.
|
||||
|
||||
The fourth argument is optional. It can have a `storeName` property — if `true`, the original name will be stored for later inclusion in a sourcemap's `names` array — and a `contentOnly` property which determines whether only the content is overwritten, or anything that was appended/prepended to the range as well.
|
||||
|
||||
### s.prepend( content )
|
||||
|
||||
Prepends the string with the specified content. Returns `this`.
|
||||
|
||||
### s.prependLeft ( index, content )
|
||||
|
||||
Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
|
||||
|
||||
### s.prependRight ( index, content )
|
||||
|
||||
Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
|
||||
|
||||
### s.remove( start, end )
|
||||
|
||||
Removes the characters from `start` to `end` (of the original string, **not** the generated string). Removing the same content twice, or making removals that partially overlap, will cause an error. Returns `this`.
|
||||
|
||||
### s.slice( start, end )
|
||||
|
||||
Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string. Throws error if the indices are for characters that were already removed.
|
||||
|
||||
### s.snip( start, end )
|
||||
|
||||
Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed.
|
||||
|
||||
### s.toString()
|
||||
|
||||
Returns the generated string.
|
||||
|
||||
### s.trim([ charType ])
|
||||
|
||||
Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end. Returns `this`.
|
||||
|
||||
### s.trimStart([ charType ])
|
||||
|
||||
Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start. Returns `this`.
|
||||
|
||||
### s.trimEnd([ charType ])
|
||||
|
||||
Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end. Returns `this`.
|
||||
|
||||
### s.trimLines()
|
||||
|
||||
Removes empty lines from the start and end. Returns `this`.
|
||||
|
||||
### s.isEmpty()
|
||||
|
||||
Returns true if the resulting source is empty (disregarding white space).
|
||||
|
||||
## Bundling
|
||||
|
||||
To concatenate several sources, use `MagicString.Bundle`:
|
||||
|
||||
```js
|
||||
var bundle = new MagicString.Bundle();
|
||||
|
||||
bundle.addSource({
|
||||
filename: 'foo.js',
|
||||
content: new MagicString( 'var answer = 42;' )
|
||||
});
|
||||
|
||||
bundle.addSource({
|
||||
filename: 'bar.js',
|
||||
content: new MagicString( 'console.log( answer )' )
|
||||
});
|
||||
|
||||
// Advanced: a source can include an `indentExclusionRanges` property
|
||||
// alongside `filename` and `content`. This will be passed to `s.indent()`
|
||||
// - see documentation above
|
||||
|
||||
bundle.indent() // optionally, pass an indent string, otherwise it will be guessed
|
||||
.prepend( '(function () {\n' )
|
||||
.append( '}());' );
|
||||
|
||||
bundle.toString();
|
||||
// (function () {
|
||||
// var answer = 42;
|
||||
// console.log( answer );
|
||||
// }());
|
||||
|
||||
// options are as per `s.generateMap()` above
|
||||
var map = bundle.generateMap({
|
||||
file: 'bundle.js',
|
||||
includeContent: true,
|
||||
hires: true
|
||||
});
|
||||
```
|
||||
|
||||
As an alternative syntax, if you a) don't have `filename` or `indentExclusionRanges` options, or b) passed those in when you used `new MagicString(...)`, you can simply pass the `MagicString` instance itself:
|
||||
|
||||
```js
|
||||
var bundle = new MagicString.Bundle();
|
||||
var source = new MagicString( someCode, {
|
||||
filename: 'foo.js'
|
||||
});
|
||||
|
||||
bundle.addSource( source );
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
1313
web/node_modules/magic-string/dist/magic-string.cjs.js
generated
vendored
Normal file
1313
web/node_modules/magic-string/dist/magic-string.cjs.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
web/node_modules/magic-string/dist/magic-string.cjs.js.map
generated
vendored
Normal file
1
web/node_modules/magic-string/dist/magic-string.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1308
web/node_modules/magic-string/dist/magic-string.es.js
generated
vendored
Normal file
1308
web/node_modules/magic-string/dist/magic-string.es.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
web/node_modules/magic-string/dist/magic-string.es.js.map
generated
vendored
Normal file
1
web/node_modules/magic-string/dist/magic-string.es.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1369
web/node_modules/magic-string/dist/magic-string.umd.js
generated
vendored
Normal file
1369
web/node_modules/magic-string/dist/magic-string.umd.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
web/node_modules/magic-string/dist/magic-string.umd.js.map
generated
vendored
Normal file
1
web/node_modules/magic-string/dist/magic-string.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
111
web/node_modules/magic-string/index.d.ts
generated
vendored
Normal file
111
web/node_modules/magic-string/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,111 @@
|
|||
export interface BundleOptions {
|
||||
intro?: string;
|
||||
separator?: string;
|
||||
}
|
||||
|
||||
export interface SourceMapOptions {
|
||||
hires: boolean;
|
||||
file: string;
|
||||
source: string;
|
||||
includeContent: boolean;
|
||||
}
|
||||
|
||||
export type SourceMapSegment =
|
||||
| [number]
|
||||
| [number, number, number, number]
|
||||
| [number, number, number, number, number];
|
||||
|
||||
export interface DecodedSourceMap {
|
||||
file: string;
|
||||
sources: string[];
|
||||
sourcesContent: string[];
|
||||
names: string[];
|
||||
mappings: SourceMapSegment[][];
|
||||
}
|
||||
|
||||
export class SourceMap {
|
||||
constructor(properties: DecodedSourceMap);
|
||||
|
||||
version: number;
|
||||
file: string;
|
||||
sources: string[];
|
||||
sourcesContent: string[];
|
||||
names: string[];
|
||||
mappings: string;
|
||||
|
||||
toString(): string;
|
||||
toUrl(): string;
|
||||
}
|
||||
|
||||
export class Bundle {
|
||||
constructor(options?: BundleOptions);
|
||||
addSource(source: MagicString | { filename?: string, content: MagicString }): Bundle;
|
||||
append(str: string, options?: BundleOptions): Bundle;
|
||||
clone(): Bundle;
|
||||
generateMap(options?: Partial<SourceMapOptions>): SourceMap;
|
||||
generateDecodedMap(options?: Partial<SourceMapOptions>): DecodedSourceMap;
|
||||
getIndentString(): string;
|
||||
indent(indentStr?: string): Bundle;
|
||||
indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
|
||||
prepend(str: string): Bundle;
|
||||
toString(): string;
|
||||
trimLines(): Bundle;
|
||||
trim(charType?: string): Bundle;
|
||||
trimStart(charType?: string): Bundle;
|
||||
trimEnd(charType?: string): Bundle;
|
||||
isEmpty(): boolean;
|
||||
length(): number;
|
||||
}
|
||||
|
||||
export type ExclusionRange = [ number, number ];
|
||||
|
||||
export interface MagicStringOptions {
|
||||
filename: string,
|
||||
indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
|
||||
}
|
||||
|
||||
export interface IndentOptions {
|
||||
exclude: ExclusionRange | Array<ExclusionRange>;
|
||||
indentStart: boolean;
|
||||
}
|
||||
|
||||
export interface OverwriteOptions {
|
||||
storeName?: boolean;
|
||||
contentOnly?: boolean;
|
||||
}
|
||||
|
||||
export default class MagicString {
|
||||
constructor(str: string, options?: MagicStringOptions);
|
||||
addSourcemapLocation(char: number): void;
|
||||
append(content: string): MagicString;
|
||||
appendLeft(index: number, content: string): MagicString;
|
||||
appendRight(index: number, content: string): MagicString;
|
||||
clone(): MagicString;
|
||||
generateMap(options?: Partial<SourceMapOptions>): SourceMap;
|
||||
generateDecodedMap(options?: Partial<SourceMapOptions>): DecodedSourceMap;
|
||||
getIndentString(): string;
|
||||
|
||||
indent(options?: IndentOptions): MagicString;
|
||||
indent(indentStr?: string, options?: IndentOptions): MagicString;
|
||||
indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
|
||||
|
||||
move(start: number, end: number, index: number): MagicString;
|
||||
overwrite(start: number, end: number, content: string, options?: boolean | OverwriteOptions): MagicString;
|
||||
prepend(content: string): MagicString;
|
||||
prependLeft(index: number, content: string): MagicString;
|
||||
prependRight(index: number, content: string): MagicString;
|
||||
remove(start: number, end: number): MagicString;
|
||||
slice(start: number, end: number): string;
|
||||
snip(start: number, end: number): MagicString;
|
||||
trim(charType?: string): MagicString;
|
||||
trimStart(charType?: string): MagicString;
|
||||
trimEnd(charType?: string): MagicString;
|
||||
trimLines(): MagicString;
|
||||
|
||||
lastChar(): string;
|
||||
lastLine(): string;
|
||||
isEmpty(): boolean;
|
||||
length(): number;
|
||||
|
||||
original: string;
|
||||
}
|
48
web/node_modules/magic-string/package.json
generated
vendored
Normal file
48
web/node_modules/magic-string/package.json
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"name": "magic-string",
|
||||
"description": "Modify strings, generate sourcemaps",
|
||||
"author": "Rich Harris",
|
||||
"version": "0.25.7",
|
||||
"repository": "https://github.com/rich-harris/magic-string",
|
||||
"main": "dist/magic-string.cjs.js",
|
||||
"module": "dist/magic-string.es.js",
|
||||
"jsnext:main": "dist/magic-string.es.js",
|
||||
"typings": "index.d.ts",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"sourcemap-codec": "^1.4.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^5.16.0",
|
||||
"mocha": "^5.2.0",
|
||||
"prettier": "^1.18.2",
|
||||
"rollup": "^1.16.3",
|
||||
"rollup-plugin-buble": "^0.19.6",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-replace": "^2.2.0",
|
||||
"source-map": "^0.6.1",
|
||||
"source-map-support": "^0.5.12"
|
||||
},
|
||||
"keywords": [
|
||||
"string",
|
||||
"string manipulation",
|
||||
"sourcemap",
|
||||
"templating",
|
||||
"transpilation"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"pretest": "npm run lint && npm run build",
|
||||
"format": "prettier --single-quote --print-width 100 --use-tabs --write src/*.js src/**/*.js",
|
||||
"build": "rollup -c",
|
||||
"prepare": "npm run build",
|
||||
"prepublishOnly": "rm -rf dist && npm test",
|
||||
"lint": "eslint src test",
|
||||
"watch": "rollup -cw"
|
||||
},
|
||||
"files": [
|
||||
"dist/*",
|
||||
"index.d.ts",
|
||||
"README.md"
|
||||
]
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue