typescript fuckery?? is this still correct?
This commit is contained in:
parent
085d7c68ba
commit
2ec3cca800
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
|
@ -0,0 +1,6 @@
|
||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (new)" project-jdk-type="Python SDK" />
|
||||||
|
<component name="PyCharmProfessionalAdvertiser">
|
||||||
|
<option name="shown" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/new.iml" filepath="$PROJECT_DIR$/.idea/new.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.10 (new)" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
<component name="PyDocumentationSettings">
|
||||||
|
<option name="format" value="PLAIN" />
|
||||||
|
<option name="myDocStringFormat" value="Plain" />
|
||||||
|
</component>
|
||||||
|
</module>
|
|
@ -14,5 +14,17 @@
|
||||||
</introspection-scope>
|
</introspection-scope>
|
||||||
</schema-mapping>
|
</schema-mapping>
|
||||||
</data-source>
|
</data-source>
|
||||||
|
<data-source name="db [2]" uuid="90dbce14-c550-4450-973e-ce471278a4c1">
|
||||||
|
<database-info product="SQLite" version="3.39.2" jdbc-version="2.1" driver-name="SQLite JDBC" driver-version="3.39.2.0" dbms="SQLITE" exact-version="3.39.2" exact-driver-version="3.39">
|
||||||
|
<identifier-quote-string>"</identifier-quote-string>
|
||||||
|
</database-info>
|
||||||
|
<case-sensitivity plain-identifiers="mixed" quoted-identifiers="mixed" />
|
||||||
|
<auth-provider>no-auth</auth-provider>
|
||||||
|
<schema-mapping>
|
||||||
|
<introspection-scope>
|
||||||
|
<node kind="schema" qname="@" />
|
||||||
|
</introspection-scope>
|
||||||
|
</schema-mapping>
|
||||||
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -8,5 +8,17 @@
|
||||||
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/app/Backend/db.sqlite</jdbc-url>
|
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/app/Backend/db.sqlite</jdbc-url>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="db [2]" uuid="90dbce14-c550-4450-973e-ce471278a4c1">
|
||||||
|
<driver-ref>sqlite.xerial</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/app/Backend/db.sqlite-original</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
<libraries>
|
||||||
|
<library>
|
||||||
|
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.39.2/sqlite-jdbc-3.39.2.jar</url>
|
||||||
|
</library>
|
||||||
|
</libraries>
|
||||||
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -1473,88 +1473,92 @@
|
||||||
<DasType>varchar|0s</DasType>
|
<DasType>varchar|0s</DasType>
|
||||||
<Position>7</Position>
|
<Position>7</Position>
|
||||||
</column>
|
</column>
|
||||||
<index id="526" parent="485" name="User_Email">
|
<column id="526" parent="485" name="Salt">
|
||||||
|
<DasType>varchar|0s</DasType>
|
||||||
|
<Position>8</Position>
|
||||||
|
</column>
|
||||||
|
<index id="527" parent="485" name="User_Email">
|
||||||
<ColNames>Email</ColNames>
|
<ColNames>Email</ColNames>
|
||||||
</index>
|
</index>
|
||||||
<index id="527" parent="485" name="User_ParentId">
|
<index id="528" parent="485" name="User_ParentId">
|
||||||
<ColNames>ParentId</ColNames>
|
<ColNames>ParentId</ColNames>
|
||||||
</index>
|
</index>
|
||||||
<key id="528" parent="485">
|
<key id="529" parent="485">
|
||||||
<ColNames>Id</ColNames>
|
<ColNames>Id</ColNames>
|
||||||
<Primary>1</Primary>
|
<Primary>1</Primary>
|
||||||
</key>
|
</key>
|
||||||
<column id="529" parent="486" name="UserId">
|
<column id="530" parent="486" name="UserId">
|
||||||
<DasType>integer|0s</DasType>
|
<DasType>integer|0s</DasType>
|
||||||
<Position>1</Position>
|
<Position>1</Position>
|
||||||
</column>
|
</column>
|
||||||
<column id="530" parent="486" name="FolderId">
|
<column id="531" parent="486" name="FolderId">
|
||||||
<DasType>integer|0s</DasType>
|
<DasType>integer|0s</DasType>
|
||||||
<Position>2</Position>
|
<Position>2</Position>
|
||||||
</column>
|
</column>
|
||||||
<column id="531" parent="486" name="Id">
|
<column id="532" parent="486" name="Id">
|
||||||
<AutoIncrement>1</AutoIncrement>
|
<AutoIncrement>1</AutoIncrement>
|
||||||
<DasType>integer|0s</DasType>
|
<DasType>integer|0s</DasType>
|
||||||
<NotNull>1</NotNull>
|
<NotNull>1</NotNull>
|
||||||
<Position>3</Position>
|
<Position>3</Position>
|
||||||
</column>
|
</column>
|
||||||
<index id="532" parent="486" name="User2Folder_UserId">
|
<index id="533" parent="486" name="User2Folder_UserId">
|
||||||
<ColNames>UserId</ColNames>
|
<ColNames>UserId</ColNames>
|
||||||
</index>
|
</index>
|
||||||
<index id="533" parent="486" name="User2Folder_FolderId">
|
<index id="534" parent="486" name="User2Folder_FolderId">
|
||||||
<ColNames>FolderId</ColNames>
|
<ColNames>FolderId</ColNames>
|
||||||
</index>
|
</index>
|
||||||
<key id="534" parent="486">
|
<key id="535" parent="486">
|
||||||
<ColNames>Id</ColNames>
|
<ColNames>Id</ColNames>
|
||||||
<Primary>1</Primary>
|
<Primary>1</Primary>
|
||||||
</key>
|
</key>
|
||||||
<column id="535" parent="487" name="UserId">
|
<column id="536" parent="487" name="UserId">
|
||||||
<DasType>integer|0s</DasType>
|
<DasType>integer|0s</DasType>
|
||||||
<Position>1</Position>
|
<Position>1</Position>
|
||||||
</column>
|
</column>
|
||||||
<column id="536" parent="487" name="InstallationId">
|
<column id="537" parent="487" name="InstallationId">
|
||||||
<DasType>integer|0s</DasType>
|
<DasType>integer|0s</DasType>
|
||||||
<Position>2</Position>
|
<Position>2</Position>
|
||||||
</column>
|
</column>
|
||||||
<column id="537" parent="487" name="Id">
|
<column id="538" parent="487" name="Id">
|
||||||
<AutoIncrement>1</AutoIncrement>
|
<AutoIncrement>1</AutoIncrement>
|
||||||
<DasType>integer|0s</DasType>
|
<DasType>integer|0s</DasType>
|
||||||
<NotNull>1</NotNull>
|
<NotNull>1</NotNull>
|
||||||
<Position>3</Position>
|
<Position>3</Position>
|
||||||
</column>
|
</column>
|
||||||
<index id="538" parent="487" name="User2Installation_UserId">
|
<index id="539" parent="487" name="User2Installation_UserId">
|
||||||
<ColNames>UserId</ColNames>
|
<ColNames>UserId</ColNames>
|
||||||
</index>
|
</index>
|
||||||
<index id="539" parent="487" name="User2Installation_InstallationId">
|
<index id="540" parent="487" name="User2Installation_InstallationId">
|
||||||
<ColNames>InstallationId</ColNames>
|
<ColNames>InstallationId</ColNames>
|
||||||
</index>
|
</index>
|
||||||
<key id="540" parent="487">
|
<key id="541" parent="487">
|
||||||
<ColNames>Id</ColNames>
|
<ColNames>Id</ColNames>
|
||||||
<Primary>1</Primary>
|
<Primary>1</Primary>
|
||||||
</key>
|
</key>
|
||||||
<column id="541" parent="488" name="type">
|
<column id="542" parent="488" name="type">
|
||||||
<DasType>TEXT|0s</DasType>
|
<DasType>TEXT|0s</DasType>
|
||||||
<Position>1</Position>
|
<Position>1</Position>
|
||||||
</column>
|
</column>
|
||||||
<column id="542" parent="488" name="name">
|
<column id="543" parent="488" name="name">
|
||||||
<DasType>TEXT|0s</DasType>
|
<DasType>TEXT|0s</DasType>
|
||||||
<Position>2</Position>
|
<Position>2</Position>
|
||||||
</column>
|
</column>
|
||||||
<column id="543" parent="488" name="tbl_name">
|
<column id="544" parent="488" name="tbl_name">
|
||||||
<DasType>TEXT|0s</DasType>
|
<DasType>TEXT|0s</DasType>
|
||||||
<Position>3</Position>
|
<Position>3</Position>
|
||||||
</column>
|
</column>
|
||||||
<column id="544" parent="488" name="rootpage">
|
<column id="545" parent="488" name="rootpage">
|
||||||
<DasType>INT|0s</DasType>
|
<DasType>INT|0s</DasType>
|
||||||
<Position>4</Position>
|
<Position>4</Position>
|
||||||
</column>
|
</column>
|
||||||
<column id="545" parent="488" name="sql">
|
<column id="546" parent="488" name="sql">
|
||||||
<DasType>TEXT|0s</DasType>
|
<DasType>TEXT|0s</DasType>
|
||||||
<Position>5</Position>
|
<Position>5</Position>
|
||||||
</column>
|
</column>
|
||||||
<column id="546" parent="489" name="name">
|
<column id="547" parent="489" name="name">
|
||||||
<Position>1</Position>
|
<Position>1</Position>
|
||||||
</column>
|
</column>
|
||||||
<column id="547" parent="489" name="seq">
|
<column id="548" parent="489" name="seq">
|
||||||
<Position>2</Position>
|
<Position>2</Position>
|
||||||
</column>
|
</column>
|
||||||
</database-model>
|
</database-model>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -42,6 +42,22 @@ public class Controller
|
||||||
return ses.Token;
|
return ses.Token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ProducesResponseType(200)]
|
||||||
|
[ProducesResponseType(401)]
|
||||||
|
[HttpPost($"{nameof(Logout)}")]
|
||||||
|
public Object Logout()
|
||||||
|
{
|
||||||
|
var ctxAccessor = new HttpContextAccessor();
|
||||||
|
var ctx = ctxAccessor.HttpContext;
|
||||||
|
using var db = Db.Connect();
|
||||||
|
var currentUser = (User)ctx.Items["User"];
|
||||||
|
|
||||||
|
if (currentUser is null)
|
||||||
|
return new HttpResponseMessage(HttpStatusCode.Conflict);
|
||||||
|
|
||||||
|
return db.DeleteSession(currentUser.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[ProducesResponseType(200)]
|
[ProducesResponseType(200)]
|
||||||
[ProducesResponseType(401)]
|
[ProducesResponseType(401)]
|
||||||
|
|
|
@ -207,5 +207,22 @@ public partial class Db : IDisposable
|
||||||
|
|
||||||
return Result.Ok;
|
return Result.Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Result DeleteSession(Int64 id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Sessions
|
||||||
|
.Where(u => u.UserId == id)
|
||||||
|
.Delete();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return Result.Error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.Ok;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7,9 +7,8 @@ public class User : TreeNode
|
||||||
[Indexed]
|
[Indexed]
|
||||||
public String Email { get; set; } = "";
|
public String Email { get; set; } = "";
|
||||||
public Boolean HasWriteAccess { get; set; }
|
public Boolean HasWriteAccess { get; set; }
|
||||||
public String Salt { get; set; }
|
public String Salt { get; set; }
|
||||||
|
public String Password { get; set; }
|
||||||
public String Password { get; set; }
|
|
||||||
|
|
||||||
// TODO: must reset pwd
|
// TODO: must reset pwd
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,10 @@ public static class Crypto
|
||||||
{
|
{
|
||||||
public static String ComputeHash(Byte[] bytesToHash, Byte[] salt)
|
public static String ComputeHash(Byte[] bytesToHash, Byte[] salt)
|
||||||
{
|
{
|
||||||
var byteResult = new Rfc2898DeriveBytes(bytesToHash, salt, 10000);
|
using var mySHA256 = SHA256.Create();
|
||||||
return Convert.ToBase64String(byteResult.GetBytes(24));
|
var hashValue = mySHA256.ComputeHash(bytesToHash);
|
||||||
|
// var hashValue = new Rfc2898DeriveBytes(hashValue, salt, 10000);
|
||||||
|
return Convert.ToBase64String(hashValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String GenerateSalt()
|
public static String GenerateSalt()
|
||||||
|
|
|
@ -100,6 +100,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"DecimalMath.DecimalEx/1.0.2": {
|
||||||
|
"runtime": {
|
||||||
|
"lib/netstandard2.0/DecimalEx.dll": {
|
||||||
|
"assemblyVersion": "1.0.2.0",
|
||||||
|
"fileVersion": "1.0.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"Flurl/3.0.1": {
|
"Flurl/3.0.1": {
|
||||||
"runtime": {
|
"runtime": {
|
||||||
"lib/netstandard2.0/Flurl.dll": {
|
"lib/netstandard2.0/Flurl.dll": {
|
||||||
|
@ -1806,6 +1814,7 @@
|
||||||
"Utils/1.0.0": {
|
"Utils/1.0.0": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"CliWrap": "3.3.1",
|
"CliWrap": "3.3.1",
|
||||||
|
"DecimalMath.DecimalEx": "1.0.2",
|
||||||
"System.Reactive.Linq": "5.0.0"
|
"System.Reactive.Linq": "5.0.0"
|
||||||
},
|
},
|
||||||
"runtime": {
|
"runtime": {
|
||||||
|
@ -1866,6 +1875,13 @@
|
||||||
"path": "cliwrap/3.3.1",
|
"path": "cliwrap/3.3.1",
|
||||||
"hashPath": "cliwrap.3.3.1.nupkg.sha512"
|
"hashPath": "cliwrap.3.3.1.nupkg.sha512"
|
||||||
},
|
},
|
||||||
|
"DecimalMath.DecimalEx/1.0.2": {
|
||||||
|
"type": "package",
|
||||||
|
"serviceable": true,
|
||||||
|
"sha512": "sha512-BCii/IxT7Tx7BPZ7MtrpqVlEii/iaHi4OOXpgaPi+zrphnkbe251KKI3S+pgnTzobfn0jS/SF7bgidqOMj1oGw==",
|
||||||
|
"path": "decimalmath.decimalex/1.0.2",
|
||||||
|
"hashPath": "decimalmath.decimalex.1.0.2.nupkg.sha512"
|
||||||
|
},
|
||||||
"Flurl/3.0.1": {
|
"Flurl/3.0.1": {
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"serviceable": true,
|
"serviceable": true,
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
||||||
b3504e7812bd1a87b219c2244d41209de3c42075
|
0ab5225c4cc41cf94cee403f98b2900d6f369d86
|
||||||
|
|
|
@ -207,3 +207,4 @@
|
||||||
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/runtimes/win/lib/netcoreapp3.0/System.Drawing.Common.dll
|
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/runtimes/win/lib/netcoreapp3.0/System.Drawing.Common.dll
|
||||||
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/runtimes/win/lib/net6.0/System.Security.Cryptography.Pkcs.dll
|
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/runtimes/win/lib/net6.0/System.Security.Cryptography.Pkcs.dll
|
||||||
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/runtimes/win/lib/netstandard2.0/System.Security.Cryptography.ProtectedData.dll
|
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/runtimes/win/lib/netstandard2.0/System.Security.Cryptography.ProtectedData.dll
|
||||||
|
/home/kim/code/innovenergy/new/csharp/app/Backend/bin/Debug/net6.0/DecimalEx.dll
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,5 @@
|
||||||
|
2.0
|
||||||
|
2.0
|
||||||
|
2.0
|
||||||
|
2.0
|
||||||
|
2.0
|
|
@ -0,0 +1,104 @@
|
||||||
|
using Backend.Controllers;
|
||||||
|
using Backend.Database;
|
||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
|
|
||||||
|
|
||||||
|
using (var db = Db.Connect())
|
||||||
|
{
|
||||||
|
db.CreateFakeRelations();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
builder.Services.AddControllers(); // TODO: remove magic, specify controllers explicitly
|
||||||
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
|
|
||||||
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
builder.Services.AddCors(o => o.AddDefaultPolicy(p => p.WithOrigins("*"))); // TODO
|
||||||
|
builder.Services.AddSwaggerGen(config =>
|
||||||
|
{
|
||||||
|
config.SwaggerDoc("v1", new OpenApiInfo{ Title = "My API", Version = "V1" });
|
||||||
|
config.OperationFilter<MyHeaderFilter>(); //Todo testing throw me out
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI(cfg => cfg.EnableFilter());
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseCors();
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
app.UseAuthorization();
|
||||||
|
app.Use(SetSessionUser);
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//================= Functions for above ===================
|
||||||
|
|
||||||
|
//Setting User for current Session
|
||||||
|
async Task SetSessionUser(HttpContext ctx, RequestDelegate next)
|
||||||
|
{
|
||||||
|
var headers = ctx.Request.Headers;
|
||||||
|
var hasToken = headers.TryGetValue("auth", out var token);
|
||||||
|
|
||||||
|
if (!ctx.Request.Path.ToString().Contains(nameof(Controller.Login)))
|
||||||
|
{
|
||||||
|
if (!hasToken)
|
||||||
|
{
|
||||||
|
ctx.Response.StatusCode = 403;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var db = Db.Connect();
|
||||||
|
var user = db.GetUserByToken(token.ToString());
|
||||||
|
|
||||||
|
if (user is null)
|
||||||
|
{
|
||||||
|
ctx.Response.StatusCode = 403;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Items["User"] = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
await next(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is for convenient testing! Todo throw me out?
|
||||||
|
/// Operation filter to add the requirement of the custom header
|
||||||
|
/// </summary>
|
||||||
|
public class MyHeaderFilter : IOperationFilter
|
||||||
|
{
|
||||||
|
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||||
|
{
|
||||||
|
operation.Parameters ??= new List<OpenApiParameter>();
|
||||||
|
|
||||||
|
operation.Parameters.Add(new OpenApiParameter
|
||||||
|
{
|
||||||
|
Name = "auth",
|
||||||
|
In = ParameterLocation.Header,
|
||||||
|
Content = new Dictionary<String, OpenApiMediaType>(),
|
||||||
|
Required = false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,18 +15,18 @@ public class TextBlock
|
||||||
public static TextBlock AlignRight(params Object[] lines) => AlignHorizontal((l, w) => l.PadLeft(w), lines);
|
public static TextBlock AlignRight(params Object[] lines) => AlignHorizontal((l, w) => l.PadLeft(w), lines);
|
||||||
public static TextBlock AlignHCenter(params Object[] lines) => AlignHorizontal((l,w) => l.PadLeft((w + l.Length) / 2).PadRight(w), lines);
|
public static TextBlock AlignHCenter(params Object[] lines) => AlignHorizontal((l,w) => l.PadLeft((w + l.Length) / 2).PadRight(w), lines);
|
||||||
|
|
||||||
public static TextBlock AlignTop(params Object[] columns)
|
// public static TextBlock AlignTop(params Object[] columns)
|
||||||
{
|
// {
|
||||||
if (!columns.Any())
|
// if (!columns.Any())
|
||||||
return Empty;
|
// return Empty;
|
||||||
|
//
|
||||||
var cs = columns.Select(GetLines).ToArray(columns.Length);
|
// var cs = columns.Select(GetLines).ToArray(columns.Length);
|
||||||
var ws = cs.Select(c => c.Count).ToArray(cs.Length);
|
// var ws = cs.Select(c => c.Count).ToArray(cs.Length);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
public static TextBlock HSpace(Int32 width) => new TextBlock(new []{"".PadRight(width)});
|
public static TextBlock HSpace(Int32 width) => new TextBlock(new []{"".PadRight(width)});
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"Utils/1.0.0": {
|
"Utils/1.0.0": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"CliWrap": "3.3.1",
|
"CliWrap": "3.3.1",
|
||||||
|
"DecimalMath.DecimalEx": "1.0.2",
|
||||||
"System.Reactive.Linq": "5.0.0"
|
"System.Reactive.Linq": "5.0.0"
|
||||||
},
|
},
|
||||||
"runtime": {
|
"runtime": {
|
||||||
|
@ -23,6 +24,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"DecimalMath.DecimalEx/1.0.2": {
|
||||||
|
"runtime": {
|
||||||
|
"lib/netstandard2.0/DecimalEx.dll": {
|
||||||
|
"assemblyVersion": "1.0.2.0",
|
||||||
|
"fileVersion": "1.0.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"System.Reactive/5.0.0": {
|
"System.Reactive/5.0.0": {
|
||||||
"runtime": {
|
"runtime": {
|
||||||
"lib/net5.0/System.Reactive.dll": {
|
"lib/net5.0/System.Reactive.dll": {
|
||||||
|
@ -59,6 +68,13 @@
|
||||||
"path": "cliwrap/3.3.1",
|
"path": "cliwrap/3.3.1",
|
||||||
"hashPath": "cliwrap.3.3.1.nupkg.sha512"
|
"hashPath": "cliwrap.3.3.1.nupkg.sha512"
|
||||||
},
|
},
|
||||||
|
"DecimalMath.DecimalEx/1.0.2": {
|
||||||
|
"type": "package",
|
||||||
|
"serviceable": true,
|
||||||
|
"sha512": "sha512-BCii/IxT7Tx7BPZ7MtrpqVlEii/iaHi4OOXpgaPi+zrphnkbe251KKI3S+pgnTzobfn0jS/SF7bgidqOMj1oGw==",
|
||||||
|
"path": "decimalmath.decimalex/1.0.2",
|
||||||
|
"hashPath": "decimalmath.decimalex.1.0.2.nupkg.sha512"
|
||||||
|
},
|
||||||
"System.Reactive/5.0.0": {
|
"System.Reactive/5.0.0": {
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"serviceable": true,
|
"serviceable": true,
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
||||||
c3bd759de6556fb8e50a84ea9e024baa10772e42
|
2abce69979f93cc6b590df81d6f55221ed7274bd
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -25,6 +25,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"DecimalMath.DecimalEx/1.0.2": {
|
||||||
|
"runtime": {
|
||||||
|
"lib/netstandard2.0/DecimalEx.dll": {
|
||||||
|
"assemblyVersion": "1.0.2.0",
|
||||||
|
"fileVersion": "1.0.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"Flurl/3.0.1": {
|
"Flurl/3.0.1": {
|
||||||
"runtime": {
|
"runtime": {
|
||||||
"lib/netstandard2.0/Flurl.dll": {
|
"lib/netstandard2.0/Flurl.dll": {
|
||||||
|
@ -86,6 +94,7 @@
|
||||||
"Utils/1.0.0": {
|
"Utils/1.0.0": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"CliWrap": "3.3.1",
|
"CliWrap": "3.3.1",
|
||||||
|
"DecimalMath.DecimalEx": "1.0.2",
|
||||||
"System.Reactive.Linq": "5.0.0"
|
"System.Reactive.Linq": "5.0.0"
|
||||||
},
|
},
|
||||||
"runtime": {
|
"runtime": {
|
||||||
|
@ -107,6 +116,13 @@
|
||||||
"path": "cliwrap/3.3.1",
|
"path": "cliwrap/3.3.1",
|
||||||
"hashPath": "cliwrap.3.3.1.nupkg.sha512"
|
"hashPath": "cliwrap.3.3.1.nupkg.sha512"
|
||||||
},
|
},
|
||||||
|
"DecimalMath.DecimalEx/1.0.2": {
|
||||||
|
"type": "package",
|
||||||
|
"serviceable": true,
|
||||||
|
"sha512": "sha512-BCii/IxT7Tx7BPZ7MtrpqVlEii/iaHi4OOXpgaPi+zrphnkbe251KKI3S+pgnTzobfn0jS/SF7bgidqOMj1oGw==",
|
||||||
|
"path": "decimalmath.decimalex/1.0.2",
|
||||||
|
"hashPath": "decimalmath.decimalex.1.0.2.nupkg.sha512"
|
||||||
|
},
|
||||||
"Flurl/3.0.1": {
|
"Flurl/3.0.1": {
|
||||||
"type": "package",
|
"type": "package",
|
||||||
"serviceable": true,
|
"serviceable": true,
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
||||||
7f86522378ad51b1c4716642be74986d455f5de9
|
774cc1b82b93f9e57e444f1701bc420fae6f0723
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"name": "new",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {}
|
||||||
|
}
|
|
@ -1,19 +0,0 @@
|
||||||
Copyright (c) 2014 Forbes Lindesay
|
|
||||||
|
|
||||||
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.
|
|
|
@ -1,81 +0,0 @@
|
||||||
# acorn-globals
|
|
||||||
|
|
||||||
Detect global variables in JavaScript using acorn
|
|
||||||
|
|
||||||
[Get supported acorn-globals with the Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-acorn_globals?utm_source=npm-acorn-globals&utm_medium=referral&utm_campaign=readme)
|
|
||||||
|
|
||||||
[![Build Status](https://img.shields.io/github/workflow/status/ForbesLindesay/acorn-globals/Publish%20Canary/master?style=for-the-badge)](https://github.com/ForbesLindesay/acorn-globals/actions?query=workflow%3APublish%20Canary+branch%3Amaster)
|
|
||||||
[![Rolling Versions](https://img.shields.io/badge/Rolling%20Versions-Enabled-brightgreen?style=for-the-badge)](https://rollingversions.com/ForbesLindesay/acorn-globals)
|
|
||||||
[![NPM version](https://img.shields.io/npm/v/acorn-globals?style=for-the-badge)](https://www.npmjs.com/package/acorn-globals)
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
npm install acorn-globals
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
detect.js
|
|
||||||
|
|
||||||
```js
|
|
||||||
var fs = require('fs');
|
|
||||||
var detect = require('acorn-globals');
|
|
||||||
|
|
||||||
var src = fs.readFileSync(__dirname + '/input.js', 'utf8');
|
|
||||||
|
|
||||||
var scope = detect(src);
|
|
||||||
console.dir(scope);
|
|
||||||
```
|
|
||||||
|
|
||||||
input.js
|
|
||||||
|
|
||||||
```js
|
|
||||||
var x = 5;
|
|
||||||
var y = 3, z = 2;
|
|
||||||
|
|
||||||
w.foo();
|
|
||||||
w = 2;
|
|
||||||
|
|
||||||
RAWR=444;
|
|
||||||
RAWR.foo();
|
|
||||||
|
|
||||||
BLARG=3;
|
|
||||||
|
|
||||||
foo(function () {
|
|
||||||
var BAR = 3;
|
|
||||||
process.nextTick(function (ZZZZZZZZZZZZ) {
|
|
||||||
console.log('beep boop');
|
|
||||||
var xyz = 4;
|
|
||||||
x += 10;
|
|
||||||
x.zzzzzz;
|
|
||||||
ZZZ=6;
|
|
||||||
});
|
|
||||||
function doom () {
|
|
||||||
}
|
|
||||||
ZZZ.foo();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(xyz);
|
|
||||||
```
|
|
||||||
|
|
||||||
output:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ node example/detect.js
|
|
||||||
[ { name: 'BLARG', nodes: [ [Object] ] },
|
|
||||||
{ name: 'RAWR', nodes: [ [Object], [Object] ] },
|
|
||||||
{ name: 'ZZZ', nodes: [ [Object], [Object] ] },
|
|
||||||
{ name: 'console', nodes: [ [Object], [Object] ] },
|
|
||||||
{ name: 'foo', nodes: [ [Object] ] },
|
|
||||||
{ name: 'process', nodes: [ [Object] ] },
|
|
||||||
{ name: 'w', nodes: [ [Object], [Object] ] },
|
|
||||||
{ name: 'xyz', nodes: [ [Object] ] } ]
|
|
||||||
```
|
|
||||||
|
|
||||||
## Security contact information
|
|
||||||
|
|
||||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT
|
|
|
@ -1,178 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var acorn = require('acorn');
|
|
||||||
var walk = require('acorn-walk');
|
|
||||||
|
|
||||||
function isScope(node) {
|
|
||||||
return node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration' || node.type === 'ArrowFunctionExpression' || node.type === 'Program';
|
|
||||||
}
|
|
||||||
function isBlockScope(node) {
|
|
||||||
// The body of switch statement is a block.
|
|
||||||
return node.type === 'BlockStatement' || node.type === 'SwitchStatement' || isScope(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
function declaresArguments(node) {
|
|
||||||
return node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration';
|
|
||||||
}
|
|
||||||
|
|
||||||
function reallyParse(source, options) {
|
|
||||||
var parseOptions = Object.assign(
|
|
||||||
{
|
|
||||||
allowReturnOutsideFunction: true,
|
|
||||||
allowImportExportEverywhere: true,
|
|
||||||
allowHashBang: true,
|
|
||||||
ecmaVersion: "latest"
|
|
||||||
},
|
|
||||||
options
|
|
||||||
);
|
|
||||||
return acorn.parse(source, parseOptions);
|
|
||||||
}
|
|
||||||
module.exports = findGlobals;
|
|
||||||
module.exports.parse = reallyParse;
|
|
||||||
function findGlobals(source, options) {
|
|
||||||
options = options || {};
|
|
||||||
var globals = [];
|
|
||||||
var ast;
|
|
||||||
// istanbul ignore else
|
|
||||||
if (typeof source === 'string') {
|
|
||||||
ast = reallyParse(source, options);
|
|
||||||
} else {
|
|
||||||
ast = source;
|
|
||||||
}
|
|
||||||
// istanbul ignore if
|
|
||||||
if (!(ast && typeof ast === 'object' && ast.type === 'Program')) {
|
|
||||||
throw new TypeError('Source must be either a string of JavaScript or an acorn AST');
|
|
||||||
}
|
|
||||||
var declareFunction = function (node) {
|
|
||||||
var fn = node;
|
|
||||||
fn.locals = fn.locals || Object.create(null);
|
|
||||||
node.params.forEach(function (node) {
|
|
||||||
declarePattern(node, fn);
|
|
||||||
});
|
|
||||||
if (node.id) {
|
|
||||||
fn.locals[node.id.name] = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var declareClass = function (node) {
|
|
||||||
node.locals = node.locals || Object.create(null);
|
|
||||||
if (node.id) {
|
|
||||||
node.locals[node.id.name] = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var declarePattern = function (node, parent) {
|
|
||||||
switch (node.type) {
|
|
||||||
case 'Identifier':
|
|
||||||
parent.locals[node.name] = true;
|
|
||||||
break;
|
|
||||||
case 'ObjectPattern':
|
|
||||||
node.properties.forEach(function (node) {
|
|
||||||
declarePattern(node.value || node.argument, parent);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 'ArrayPattern':
|
|
||||||
node.elements.forEach(function (node) {
|
|
||||||
if (node) declarePattern(node, parent);
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 'RestElement':
|
|
||||||
declarePattern(node.argument, parent);
|
|
||||||
break;
|
|
||||||
case 'AssignmentPattern':
|
|
||||||
declarePattern(node.left, parent);
|
|
||||||
break;
|
|
||||||
// istanbul ignore next
|
|
||||||
default:
|
|
||||||
throw new Error('Unrecognized pattern type: ' + node.type);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var declareModuleSpecifier = function (node, parents) {
|
|
||||||
ast.locals = ast.locals || Object.create(null);
|
|
||||||
ast.locals[node.local.name] = true;
|
|
||||||
};
|
|
||||||
walk.ancestor(ast, {
|
|
||||||
'VariableDeclaration': function (node, parents) {
|
|
||||||
var parent = null;
|
|
||||||
for (var i = parents.length - 1; i >= 0 && parent === null; i--) {
|
|
||||||
if (node.kind === 'var' ? isScope(parents[i]) : isBlockScope(parents[i])) {
|
|
||||||
parent = parents[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parent.locals = parent.locals || Object.create(null);
|
|
||||||
node.declarations.forEach(function (declaration) {
|
|
||||||
declarePattern(declaration.id, parent);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
'FunctionDeclaration': function (node, parents) {
|
|
||||||
var parent = null;
|
|
||||||
for (var i = parents.length - 2; i >= 0 && parent === null; i--) {
|
|
||||||
if (isScope(parents[i])) {
|
|
||||||
parent = parents[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parent.locals = parent.locals || Object.create(null);
|
|
||||||
if (node.id) {
|
|
||||||
parent.locals[node.id.name] = true;
|
|
||||||
}
|
|
||||||
declareFunction(node);
|
|
||||||
},
|
|
||||||
'Function': declareFunction,
|
|
||||||
'ClassDeclaration': function (node, parents) {
|
|
||||||
var parent = null;
|
|
||||||
for (var i = parents.length - 2; i >= 0 && parent === null; i--) {
|
|
||||||
if (isBlockScope(parents[i])) {
|
|
||||||
parent = parents[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parent.locals = parent.locals || Object.create(null);
|
|
||||||
if (node.id) {
|
|
||||||
parent.locals[node.id.name] = true;
|
|
||||||
}
|
|
||||||
declareClass(node);
|
|
||||||
},
|
|
||||||
'Class': declareClass,
|
|
||||||
'TryStatement': function (node) {
|
|
||||||
if (node.handler === null || node.handler.param === null) return;
|
|
||||||
node.handler.locals = node.handler.locals || Object.create(null);
|
|
||||||
declarePattern(node.handler.param, node.handler);
|
|
||||||
},
|
|
||||||
'ImportDefaultSpecifier': declareModuleSpecifier,
|
|
||||||
'ImportSpecifier': declareModuleSpecifier,
|
|
||||||
'ImportNamespaceSpecifier': declareModuleSpecifier
|
|
||||||
});
|
|
||||||
function identifier(node, parents) {
|
|
||||||
var name = node.name;
|
|
||||||
if (name === 'undefined') return;
|
|
||||||
for (var i = 0; i < parents.length; i++) {
|
|
||||||
if (name === 'arguments' && declaresArguments(parents[i])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (parents[i].locals && name in parents[i].locals) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node.parents = parents.slice();
|
|
||||||
globals.push(node);
|
|
||||||
}
|
|
||||||
walk.ancestor(ast, {
|
|
||||||
'VariablePattern': identifier,
|
|
||||||
'Identifier': identifier,
|
|
||||||
'ThisExpression': function (node, parents) {
|
|
||||||
for (var i = 0; i < parents.length; i++) {
|
|
||||||
var parent = parents[i];
|
|
||||||
if ( parent.type === 'FunctionExpression' || parent.type === 'FunctionDeclaration' ) { return; }
|
|
||||||
if ( parent.type === 'PropertyDefinition' && parents[i+1]===parent.value ) { return; }
|
|
||||||
}
|
|
||||||
node.parents = parents.slice();
|
|
||||||
globals.push(node);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var groupedGlobals = Object.create(null);
|
|
||||||
globals.forEach(function (node) {
|
|
||||||
var name = node.type === 'ThisExpression' ? 'this' : node.name;
|
|
||||||
groupedGlobals[name] = (groupedGlobals[name] || []);
|
|
||||||
groupedGlobals[name].push(node);
|
|
||||||
});
|
|
||||||
return Object.keys(groupedGlobals).sort().map(function (name) {
|
|
||||||
return {name: name, nodes: groupedGlobals[name]};
|
|
||||||
});
|
|
||||||
}
|
|
826
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/CHANGELOG.md
generated
vendored
826
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/CHANGELOG.md
generated
vendored
|
@ -1,826 +0,0 @@
|
||||||
## 8.8.2 (2023-01-23)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix a bug that caused `allowHashBang` to be set to false when not provided, even with `ecmaVersion >= 14`.
|
|
||||||
|
|
||||||
Fix an exception when passing no option object to `parse` or `new Parser`.
|
|
||||||
|
|
||||||
Fix incorrect parse error on `if (0) let\n[astral identifier char]`.
|
|
||||||
|
|
||||||
## 8.8.1 (2022-10-24)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Make type for `Comment` compatible with estree types.
|
|
||||||
|
|
||||||
## 8.8.0 (2022-07-21)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Allow parentheses around spread args in destructuring object assignment.
|
|
||||||
|
|
||||||
Fix an issue where the tree contained `directive` properties in when parsing with a language version that doesn't support them.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Support hashbang comments by default in ECMAScript 2023 and later.
|
|
||||||
|
|
||||||
## 8.7.1 (2021-04-26)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Stop handling `"use strict"` directives in ECMAScript versions before 5.
|
|
||||||
|
|
||||||
Fix an issue where duplicate quoted export names in `export *` syntax were incorrectly checked.
|
|
||||||
|
|
||||||
Add missing type for `tokTypes`.
|
|
||||||
|
|
||||||
## 8.7.0 (2021-12-27)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Support quoted export names.
|
|
||||||
|
|
||||||
Upgrade to Unicode 14.
|
|
||||||
|
|
||||||
Add support for Unicode 13 properties in regular expressions.
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Use a loop to find line breaks, because the existing regexp search would overrun the end of the searched range and waste a lot of time in minified code.
|
|
||||||
|
|
||||||
## 8.6.0 (2021-11-18)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix a bug where an object literal with multiple `__proto__` properties would incorrectly be accepted if a later property value held an assigment.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Support class private fields with the `in` operator.
|
|
||||||
|
|
||||||
## 8.5.0 (2021-09-06)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Improve context-dependent tokenization in a number of corner cases.
|
|
||||||
|
|
||||||
Fix location tracking after a 0x2028 or 0x2029 character in a string literal (which before did not increase the line number).
|
|
||||||
|
|
||||||
Fix an issue where arrow function bodies in for loop context would inappropriately consume `in` operators.
|
|
||||||
|
|
||||||
Fix wrong end locations stored on SequenceExpression nodes.
|
|
||||||
|
|
||||||
Implement restriction that `for`/`of` loop LHS can't start with `let`.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Add support for ES2022 class static blocks.
|
|
||||||
|
|
||||||
Allow multiple input files to be passed to the CLI tool.
|
|
||||||
|
|
||||||
## 8.4.1 (2021-06-24)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix a bug where `allowAwaitOutsideFunction` would allow `await` in class field initializers, and setting `ecmaVersion` to 13 or higher would allow top-level await in non-module sources.
|
|
||||||
|
|
||||||
## 8.4.0 (2021-06-11)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
A new option, `allowSuperOutsideMethod`, can be used to suppress the error when `super` is used in the wrong context.
|
|
||||||
|
|
||||||
## 8.3.0 (2021-05-31)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Default `allowAwaitOutsideFunction` to true for ECMAScript 2022 an higher.
|
|
||||||
|
|
||||||
Add support for the `d` ([indices](https://github.com/tc39/proposal-regexp-match-indices)) regexp flag.
|
|
||||||
|
|
||||||
## 8.2.4 (2021-05-04)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix spec conformity in corner case 'for await (async of ...)'.
|
|
||||||
|
|
||||||
## 8.2.3 (2021-05-04)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix an issue where the library couldn't parse 'for (async of ...)'.
|
|
||||||
|
|
||||||
Fix a bug in UTF-16 decoding that would read characters incorrectly in some circumstances.
|
|
||||||
|
|
||||||
## 8.2.2 (2021-04-29)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix a bug where a class field initialized to an async arrow function wouldn't allow await inside it. Same issue existed for generator arrow functions with yield.
|
|
||||||
|
|
||||||
## 8.2.1 (2021-04-24)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix a regression introduced in 8.2.0 where static or async class methods with keyword names fail to parse.
|
|
||||||
|
|
||||||
## 8.2.0 (2021-04-24)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Add support for ES2022 class fields and private methods.
|
|
||||||
|
|
||||||
## 8.1.1 (2021-04-12)
|
|
||||||
|
|
||||||
### Various
|
|
||||||
|
|
||||||
Stop shipping source maps in the NPM package.
|
|
||||||
|
|
||||||
## 8.1.0 (2021-03-09)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix a spurious error in nested destructuring arrays.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Expose `allowAwaitOutsideFunction` in CLI interface.
|
|
||||||
|
|
||||||
Make `allowImportExportAnywhere` also apply to `import.meta`.
|
|
||||||
|
|
||||||
## 8.0.5 (2021-01-25)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Adjust package.json to work with Node 12.16.0 and 13.0-13.6.
|
|
||||||
|
|
||||||
## 8.0.4 (2020-10-05)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Make `await x ** y` an error, following the spec.
|
|
||||||
|
|
||||||
Fix potentially exponential regular expression.
|
|
||||||
|
|
||||||
## 8.0.3 (2020-10-02)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix a wasteful loop during `Parser` creation when setting `ecmaVersion` to `"latest"`.
|
|
||||||
|
|
||||||
## 8.0.2 (2020-09-30)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Make the TypeScript types reflect the current allowed values for `ecmaVersion`.
|
|
||||||
|
|
||||||
Fix another regexp/division tokenizer issue.
|
|
||||||
|
|
||||||
## 8.0.1 (2020-08-12)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Provide the correct value in the `version` export.
|
|
||||||
|
|
||||||
## 8.0.0 (2020-08-12)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Disallow expressions like `(a = b) = c`.
|
|
||||||
|
|
||||||
Make non-octal escape sequences a syntax error in strict mode.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
The package can now be loaded directly as an ECMAScript module in node 13+.
|
|
||||||
|
|
||||||
Update to the set of Unicode properties from ES2021.
|
|
||||||
|
|
||||||
### Breaking changes
|
|
||||||
|
|
||||||
The `ecmaVersion` option is now required. For the moment, omitting it will still work with a warning, but that will change in a future release.
|
|
||||||
|
|
||||||
Some changes to method signatures that may be used by plugins.
|
|
||||||
|
|
||||||
## 7.4.0 (2020-08-03)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Add support for logical assignment operators.
|
|
||||||
|
|
||||||
Add support for numeric separators.
|
|
||||||
|
|
||||||
## 7.3.1 (2020-06-11)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Make the string in the `version` export match the actual library version.
|
|
||||||
|
|
||||||
## 7.3.0 (2020-06-11)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix a bug that caused parsing of object patterns with a property named `set` that had a default value to fail.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Add support for optional chaining (`?.`).
|
|
||||||
|
|
||||||
## 7.2.0 (2020-05-09)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix precedence issue in parsing of async arrow functions.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Add support for nullish coalescing.
|
|
||||||
|
|
||||||
Add support for `import.meta`.
|
|
||||||
|
|
||||||
Support `export * as ...` syntax.
|
|
||||||
|
|
||||||
Upgrade to Unicode 13.
|
|
||||||
|
|
||||||
## 6.4.1 (2020-03-09)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
More carefully check for valid UTF16 surrogate pairs in regexp validator.
|
|
||||||
|
|
||||||
## 7.1.1 (2020-03-01)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Treat `\8` and `\9` as invalid escapes in template strings.
|
|
||||||
|
|
||||||
Allow unicode escapes in property names that are keywords.
|
|
||||||
|
|
||||||
Don't error on an exponential operator expression as argument to `await`.
|
|
||||||
|
|
||||||
More carefully check for valid UTF16 surrogate pairs in regexp validator.
|
|
||||||
|
|
||||||
## 7.1.0 (2019-09-24)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Disallow trailing object literal commas when ecmaVersion is less than 5.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Add a static `acorn` property to the `Parser` class that contains the entire module interface, to allow plugins to access the instance of the library that they are acting on.
|
|
||||||
|
|
||||||
## 7.0.0 (2019-08-13)
|
|
||||||
|
|
||||||
### Breaking changes
|
|
||||||
|
|
||||||
Changes the node format for dynamic imports to use the `ImportExpression` node type, as defined in [ESTree](https://github.com/estree/estree/blob/master/es2020.md#importexpression).
|
|
||||||
|
|
||||||
Makes 10 (ES2019) the default value for the `ecmaVersion` option.
|
|
||||||
|
|
||||||
## 6.3.0 (2019-08-12)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
`sourceType: "module"` can now be used even when `ecmaVersion` is less than 6, to parse module-style code that otherwise conforms to an older standard.
|
|
||||||
|
|
||||||
## 6.2.1 (2019-07-21)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix bug causing Acorn to treat some characters as identifier characters that shouldn't be treated as such.
|
|
||||||
|
|
||||||
Fix issue where setting the `allowReserved` option to `"never"` allowed reserved words in some circumstances.
|
|
||||||
|
|
||||||
## 6.2.0 (2019-07-04)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Improve valid assignment checking in `for`/`in` and `for`/`of` loops.
|
|
||||||
|
|
||||||
Disallow binding `let` in patterns.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Support bigint syntax with `ecmaVersion` >= 11.
|
|
||||||
|
|
||||||
Support dynamic `import` syntax with `ecmaVersion` >= 11.
|
|
||||||
|
|
||||||
Upgrade to Unicode version 12.
|
|
||||||
|
|
||||||
## 6.1.1 (2019-02-27)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix bug that caused parsing default exports of with names to fail.
|
|
||||||
|
|
||||||
## 6.1.0 (2019-02-08)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix scope checking when redefining a `var` as a lexical binding.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Split up `parseSubscripts` to use an internal `parseSubscript` method to make it easier to extend with plugins.
|
|
||||||
|
|
||||||
## 6.0.7 (2019-02-04)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Check that exported bindings are defined.
|
|
||||||
|
|
||||||
Don't treat `\u180e` as a whitespace character.
|
|
||||||
|
|
||||||
Check for duplicate parameter names in methods.
|
|
||||||
|
|
||||||
Don't allow shorthand properties when they are generators or async methods.
|
|
||||||
|
|
||||||
Forbid binding `await` in async arrow function's parameter list.
|
|
||||||
|
|
||||||
## 6.0.6 (2019-01-30)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
The content of class declarations and expressions is now always parsed in strict mode.
|
|
||||||
|
|
||||||
Don't allow `let` or `const` to bind the variable name `let`.
|
|
||||||
|
|
||||||
Treat class declarations as lexical.
|
|
||||||
|
|
||||||
Don't allow a generator function declaration as the sole body of an `if` or `else`.
|
|
||||||
|
|
||||||
Ignore `"use strict"` when after an empty statement.
|
|
||||||
|
|
||||||
Allow string line continuations with special line terminator characters.
|
|
||||||
|
|
||||||
Treat `for` bodies as part of the `for` scope when checking for conflicting bindings.
|
|
||||||
|
|
||||||
Fix bug with parsing `yield` in a `for` loop initializer.
|
|
||||||
|
|
||||||
Implement special cases around scope checking for functions.
|
|
||||||
|
|
||||||
## 6.0.5 (2019-01-02)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix TypeScript type for `Parser.extend` and add `allowAwaitOutsideFunction` to options type.
|
|
||||||
|
|
||||||
Don't treat `let` as a keyword when the next token is `{` on the next line.
|
|
||||||
|
|
||||||
Fix bug that broke checking for parentheses around an object pattern in a destructuring assignment when `preserveParens` was on.
|
|
||||||
|
|
||||||
## 6.0.4 (2018-11-05)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Further improvements to tokenizing regular expressions in corner cases.
|
|
||||||
|
|
||||||
## 6.0.3 (2018-11-04)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix bug in tokenizing an expression-less return followed by a function followed by a regular expression.
|
|
||||||
|
|
||||||
Remove stray symlink in the package tarball.
|
|
||||||
|
|
||||||
## 6.0.2 (2018-09-26)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix bug where default expressions could fail to parse inside an object destructuring assignment expression.
|
|
||||||
|
|
||||||
## 6.0.1 (2018-09-14)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix wrong value in `version` export.
|
|
||||||
|
|
||||||
## 6.0.0 (2018-09-14)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Better handle variable-redefinition checks for catch bindings and functions directly under if statements.
|
|
||||||
|
|
||||||
Forbid `new.target` in top-level arrow functions.
|
|
||||||
|
|
||||||
Fix issue with parsing a regexp after `yield` in some contexts.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
The package now comes with TypeScript definitions.
|
|
||||||
|
|
||||||
### Breaking changes
|
|
||||||
|
|
||||||
The default value of the `ecmaVersion` option is now 9 (2018).
|
|
||||||
|
|
||||||
Plugins work differently, and will have to be rewritten to work with this version.
|
|
||||||
|
|
||||||
The loose parser and walker have been moved into separate packages (`acorn-loose` and `acorn-walk`).
|
|
||||||
|
|
||||||
## 5.7.3 (2018-09-10)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix failure to tokenize regexps after expressions like `x.of`.
|
|
||||||
|
|
||||||
Better error message for unterminated template literals.
|
|
||||||
|
|
||||||
## 5.7.2 (2018-08-24)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Properly handle `allowAwaitOutsideFunction` in for statements.
|
|
||||||
|
|
||||||
Treat function declarations at the top level of modules like let bindings.
|
|
||||||
|
|
||||||
Don't allow async function declarations as the only statement under a label.
|
|
||||||
|
|
||||||
## 5.7.0 (2018-06-15)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Upgraded to Unicode 11.
|
|
||||||
|
|
||||||
## 5.6.0 (2018-05-31)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Allow U+2028 and U+2029 in string when ECMAVersion >= 10.
|
|
||||||
|
|
||||||
Allow binding-less catch statements when ECMAVersion >= 10.
|
|
||||||
|
|
||||||
Add `allowAwaitOutsideFunction` option for parsing top-level `await`.
|
|
||||||
|
|
||||||
## 5.5.3 (2018-03-08)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
A _second_ republish of the code in 5.5.1, this time with yarn, to hopefully get valid timestamps.
|
|
||||||
|
|
||||||
## 5.5.2 (2018-03-08)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
A republish of the code in 5.5.1 in an attempt to solve an issue with the file timestamps in the npm package being 0.
|
|
||||||
|
|
||||||
## 5.5.1 (2018-03-06)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix misleading error message for octal escapes in template strings.
|
|
||||||
|
|
||||||
## 5.5.0 (2018-02-27)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
The identifier character categorization is now based on Unicode version 10.
|
|
||||||
|
|
||||||
Acorn will now validate the content of regular expressions, including new ES9 features.
|
|
||||||
|
|
||||||
## 5.4.0 (2018-02-01)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Disallow duplicate or escaped flags on regular expressions.
|
|
||||||
|
|
||||||
Disallow octal escapes in strings in strict mode.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Add support for async iteration.
|
|
||||||
|
|
||||||
Add support for object spread and rest.
|
|
||||||
|
|
||||||
## 5.3.0 (2017-12-28)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix parsing of floating point literals with leading zeroes in loose mode.
|
|
||||||
|
|
||||||
Allow duplicate property names in object patterns.
|
|
||||||
|
|
||||||
Don't allow static class methods named `prototype`.
|
|
||||||
|
|
||||||
Disallow async functions directly under `if` or `else`.
|
|
||||||
|
|
||||||
Parse right-hand-side of `for`/`of` as an assignment expression.
|
|
||||||
|
|
||||||
Stricter parsing of `for`/`in`.
|
|
||||||
|
|
||||||
Don't allow unicode escapes in contextual keywords.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Parsing class members was factored into smaller methods to allow plugins to hook into it.
|
|
||||||
|
|
||||||
## 5.2.1 (2017-10-30)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix a token context corruption bug.
|
|
||||||
|
|
||||||
## 5.2.0 (2017-10-30)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix token context tracking for `class` and `function` in property-name position.
|
|
||||||
|
|
||||||
Make sure `%*` isn't parsed as a valid operator.
|
|
||||||
|
|
||||||
Allow shorthand properties `get` and `set` to be followed by default values.
|
|
||||||
|
|
||||||
Disallow `super` when not in callee or object position.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Support [`directive` property](https://github.com/estree/estree/compare/b3de58c9997504d6fba04b72f76e6dd1619ee4eb...1da8e603237144f44710360f8feb7a9977e905e0) on directive expression statements.
|
|
||||||
|
|
||||||
## 5.1.2 (2017-09-04)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Disable parsing of legacy HTML-style comments in modules.
|
|
||||||
|
|
||||||
Fix parsing of async methods whose names are keywords.
|
|
||||||
|
|
||||||
## 5.1.1 (2017-07-06)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix problem with disambiguating regexp and division after a class.
|
|
||||||
|
|
||||||
## 5.1.0 (2017-07-05)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix tokenizing of regexps in an object-desctructuring `for`/`of` loop and after `yield`.
|
|
||||||
|
|
||||||
Parse zero-prefixed numbers with non-octal digits as decimal.
|
|
||||||
|
|
||||||
Allow object/array patterns in rest parameters.
|
|
||||||
|
|
||||||
Don't error when `yield` is used as a property name.
|
|
||||||
|
|
||||||
Allow `async` as a shorthand object property.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Implement the [template literal revision proposal](https://github.com/tc39/proposal-template-literal-revision) for ES9.
|
|
||||||
|
|
||||||
## 5.0.3 (2017-04-01)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix spurious duplicate variable definition errors for named functions.
|
|
||||||
|
|
||||||
## 5.0.2 (2017-03-30)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
A binary operator after a parenthesized arrow expression is no longer incorrectly treated as an error.
|
|
||||||
|
|
||||||
## 5.0.0 (2017-03-28)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Raise an error for duplicated lexical bindings.
|
|
||||||
|
|
||||||
Fix spurious error when an assignement expression occurred after a spread expression.
|
|
||||||
|
|
||||||
Accept regular expressions after `of` (in `for`/`of`), `yield` (in a generator), and braced arrow functions.
|
|
||||||
|
|
||||||
Allow labels in front or `var` declarations, even in strict mode.
|
|
||||||
|
|
||||||
### Breaking changes
|
|
||||||
|
|
||||||
Parse declarations following `export default` as declaration nodes, not expressions. This means that class and function declarations nodes can now have `null` as their `id`.
|
|
||||||
|
|
||||||
## 4.0.11 (2017-02-07)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Allow all forms of member expressions to be parenthesized as lvalue.
|
|
||||||
|
|
||||||
## 4.0.10 (2017-02-07)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Don't expect semicolons after default-exported functions or classes, even when they are expressions.
|
|
||||||
|
|
||||||
Check for use of `'use strict'` directives in non-simple parameter functions, even when already in strict mode.
|
|
||||||
|
|
||||||
## 4.0.9 (2017-02-06)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix incorrect error raised for parenthesized simple assignment targets, so that `(x) = 1` parses again.
|
|
||||||
|
|
||||||
## 4.0.8 (2017-02-03)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Solve spurious parenthesized pattern errors by temporarily erring on the side of accepting programs that our delayed errors don't handle correctly yet.
|
|
||||||
|
|
||||||
## 4.0.7 (2017-02-02)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Accept invalidly rejected code like `(x).y = 2` again.
|
|
||||||
|
|
||||||
Don't raise an error when a function _inside_ strict code has a non-simple parameter list.
|
|
||||||
|
|
||||||
## 4.0.6 (2017-02-02)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix exponential behavior (manifesting itself as a complete hang for even relatively small source files) introduced by the new 'use strict' check.
|
|
||||||
|
|
||||||
## 4.0.5 (2017-02-02)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Disallow parenthesized pattern expressions.
|
|
||||||
|
|
||||||
Allow keywords as export names.
|
|
||||||
|
|
||||||
Don't allow the `async` keyword to be parenthesized.
|
|
||||||
|
|
||||||
Properly raise an error when a keyword contains a character escape.
|
|
||||||
|
|
||||||
Allow `"use strict"` to appear after other string literal expressions.
|
|
||||||
|
|
||||||
Disallow labeled declarations.
|
|
||||||
|
|
||||||
## 4.0.4 (2016-12-19)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix crash when `export` was followed by a keyword that can't be
|
|
||||||
exported.
|
|
||||||
|
|
||||||
## 4.0.3 (2016-08-16)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Allow regular function declarations inside single-statement `if` branches in loose mode. Forbid them entirely in strict mode.
|
|
||||||
|
|
||||||
Properly parse properties named `async` in ES2017 mode.
|
|
||||||
|
|
||||||
Fix bug where reserved words were broken in ES2017 mode.
|
|
||||||
|
|
||||||
## 4.0.2 (2016-08-11)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Don't ignore period or 'e' characters after octal numbers.
|
|
||||||
|
|
||||||
Fix broken parsing for call expressions in default parameter values of arrow functions.
|
|
||||||
|
|
||||||
## 4.0.1 (2016-08-08)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix false positives in duplicated export name errors.
|
|
||||||
|
|
||||||
## 4.0.0 (2016-08-07)
|
|
||||||
|
|
||||||
### Breaking changes
|
|
||||||
|
|
||||||
The default `ecmaVersion` option value is now 7.
|
|
||||||
|
|
||||||
A number of internal method signatures changed, so plugins might need to be updated.
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
The parser now raises errors on duplicated export names.
|
|
||||||
|
|
||||||
`arguments` and `eval` can now be used in shorthand properties.
|
|
||||||
|
|
||||||
Duplicate parameter names in non-simple argument lists now always produce an error.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
The `ecmaVersion` option now also accepts year-style version numbers
|
|
||||||
(2015, etc).
|
|
||||||
|
|
||||||
Support for `async`/`await` syntax when `ecmaVersion` is >= 8.
|
|
||||||
|
|
||||||
Support for trailing commas in call expressions when `ecmaVersion` is >= 8.
|
|
||||||
|
|
||||||
## 3.3.0 (2016-07-25)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix bug in tokenizing of regexp operator after a function declaration.
|
|
||||||
|
|
||||||
Fix parser crash when parsing an array pattern with a hole.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Implement check against complex argument lists in functions that enable strict mode in ES7.
|
|
||||||
|
|
||||||
## 3.2.0 (2016-06-07)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Improve handling of lack of unicode regexp support in host
|
|
||||||
environment.
|
|
||||||
|
|
||||||
Properly reject shorthand properties whose name is a keyword.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Visitors created with `visit.make` now have their base as _prototype_, rather than copying properties into a fresh object.
|
|
||||||
|
|
||||||
## 3.1.0 (2016-04-18)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Properly tokenize the division operator directly after a function expression.
|
|
||||||
|
|
||||||
Allow trailing comma in destructuring arrays.
|
|
||||||
|
|
||||||
## 3.0.4 (2016-02-25)
|
|
||||||
|
|
||||||
### Fixes
|
|
||||||
|
|
||||||
Allow update expressions as left-hand-side of the ES7 exponential operator.
|
|
||||||
|
|
||||||
## 3.0.2 (2016-02-10)
|
|
||||||
|
|
||||||
### Fixes
|
|
||||||
|
|
||||||
Fix bug that accidentally made `undefined` a reserved word when parsing ES7.
|
|
||||||
|
|
||||||
## 3.0.0 (2016-02-10)
|
|
||||||
|
|
||||||
### Breaking changes
|
|
||||||
|
|
||||||
The default value of the `ecmaVersion` option is now 6 (used to be 5).
|
|
||||||
|
|
||||||
Support for comprehension syntax (which was dropped from the draft spec) has been removed.
|
|
||||||
|
|
||||||
### Fixes
|
|
||||||
|
|
||||||
`let` and `yield` are now “contextual keywords”, meaning you can mostly use them as identifiers in ES5 non-strict code.
|
|
||||||
|
|
||||||
A parenthesized class or function expression after `export default` is now parsed correctly.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
When `ecmaVersion` is set to 7, Acorn will parse the exponentiation operator (`**`).
|
|
||||||
|
|
||||||
The identifier character ranges are now based on Unicode 8.0.0.
|
|
||||||
|
|
||||||
Plugins can now override the `raiseRecoverable` method to override the way non-critical errors are handled.
|
|
||||||
|
|
||||||
## 2.7.0 (2016-01-04)
|
|
||||||
|
|
||||||
### Fixes
|
|
||||||
|
|
||||||
Stop allowing rest parameters in setters.
|
|
||||||
|
|
||||||
Disallow `y` rexexp flag in ES5.
|
|
||||||
|
|
||||||
Disallow `\00` and `\000` escapes in strict mode.
|
|
||||||
|
|
||||||
Raise an error when an import name is a reserved word.
|
|
||||||
|
|
||||||
## 2.6.2 (2015-11-10)
|
|
||||||
|
|
||||||
### Fixes
|
|
||||||
|
|
||||||
Don't crash when no options object is passed.
|
|
||||||
|
|
||||||
## 2.6.0 (2015-11-09)
|
|
||||||
|
|
||||||
### Fixes
|
|
||||||
|
|
||||||
Add `await` as a reserved word in module sources.
|
|
||||||
|
|
||||||
Disallow `yield` in a parameter default value for a generator.
|
|
||||||
|
|
||||||
Forbid using a comma after a rest pattern in an array destructuring.
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Support parsing stdin in command-line tool.
|
|
||||||
|
|
||||||
## 2.5.0 (2015-10-27)
|
|
||||||
|
|
||||||
### Fixes
|
|
||||||
|
|
||||||
Fix tokenizer support in the command-line tool.
|
|
||||||
|
|
||||||
Stop allowing `new.target` outside of functions.
|
|
||||||
|
|
||||||
Remove legacy `guard` and `guardedHandler` properties from try nodes.
|
|
||||||
|
|
||||||
Stop allowing multiple `__proto__` properties on an object literal in strict mode.
|
|
||||||
|
|
||||||
Don't allow rest parameters to be non-identifier patterns.
|
|
||||||
|
|
||||||
Check for duplicate paramter names in arrow functions.
|
|
21
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/LICENSE
generated
vendored
21
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/LICENSE
generated
vendored
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (C) 2012-2022 by various contributors (see AUTHORS)
|
|
||||||
|
|
||||||
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.
|
|
273
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/README.md
generated
vendored
273
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/README.md
generated
vendored
|
@ -1,273 +0,0 @@
|
||||||
# Acorn
|
|
||||||
|
|
||||||
A tiny, fast JavaScript parser written in JavaScript.
|
|
||||||
|
|
||||||
## Community
|
|
||||||
|
|
||||||
Acorn is open source software released under an
|
|
||||||
[MIT license](https://github.com/acornjs/acorn/blob/master/acorn/LICENSE).
|
|
||||||
|
|
||||||
You are welcome to
|
|
||||||
[report bugs](https://github.com/acornjs/acorn/issues) or create pull
|
|
||||||
requests on [github](https://github.com/acornjs/acorn). For questions
|
|
||||||
and discussion, please use the
|
|
||||||
[Tern discussion forum](https://discuss.ternjs.net).
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
The easiest way to install acorn is from [`npm`](https://www.npmjs.com/):
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install acorn
|
|
||||||
```
|
|
||||||
|
|
||||||
Alternately, you can download the source and build acorn yourself:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
git clone https://github.com/acornjs/acorn.git
|
|
||||||
cd acorn
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
## Interface
|
|
||||||
|
|
||||||
**parse**`(input, options)` is the main interface to the library. The
|
|
||||||
`input` parameter is a string, `options` must be an object setting
|
|
||||||
some of the options listed below. The return value will be an abstract
|
|
||||||
syntax tree object as specified by the [ESTree
|
|
||||||
spec](https://github.com/estree/estree).
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
let acorn = require("acorn");
|
|
||||||
console.log(acorn.parse("1 + 1", {ecmaVersion: 2020}));
|
|
||||||
```
|
|
||||||
|
|
||||||
When encountering a syntax error, the parser will raise a
|
|
||||||
`SyntaxError` object with a meaningful message. The error object will
|
|
||||||
have a `pos` property that indicates the string offset at which the
|
|
||||||
error occurred, and a `loc` object that contains a `{line, column}`
|
|
||||||
object referring to that same position.
|
|
||||||
|
|
||||||
Options are provided by in a second argument, which should be an
|
|
||||||
object containing any of these fields (only `ecmaVersion` is
|
|
||||||
required):
|
|
||||||
|
|
||||||
- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be
|
|
||||||
either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10 (2019),
|
|
||||||
11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"` (the
|
|
||||||
latest the library supports). This influences support for strict
|
|
||||||
mode, the set of reserved words, and support for new syntax
|
|
||||||
features.
|
|
||||||
|
|
||||||
**NOTE**: Only 'stage 4' (finalized) ECMAScript features are being
|
|
||||||
implemented by Acorn. Other proposed new features must be
|
|
||||||
implemented through plugins.
|
|
||||||
|
|
||||||
- **sourceType**: Indicate the mode the code should be parsed in. Can be
|
|
||||||
either `"script"` or `"module"`. This influences global strict mode
|
|
||||||
and parsing of `import` and `export` declarations.
|
|
||||||
|
|
||||||
**NOTE**: If set to `"module"`, then static `import` / `export` syntax
|
|
||||||
will be valid, even if `ecmaVersion` is less than 6.
|
|
||||||
|
|
||||||
- **onInsertedSemicolon**: If given a callback, that callback will be
|
|
||||||
called whenever a missing semicolon is inserted by the parser. The
|
|
||||||
callback will be given the character offset of the point where the
|
|
||||||
semicolon is inserted as argument, and if `locations` is on, also a
|
|
||||||
`{line, column}` object representing this position.
|
|
||||||
|
|
||||||
- **onTrailingComma**: Like `onInsertedSemicolon`, but for trailing
|
|
||||||
commas.
|
|
||||||
|
|
||||||
- **allowReserved**: If `false`, using a reserved word will generate
|
|
||||||
an error. Defaults to `true` for `ecmaVersion` 3, `false` for higher
|
|
||||||
versions. When given the value `"never"`, reserved words and
|
|
||||||
keywords can also not be used as property names (as in Internet
|
|
||||||
Explorer's old parser).
|
|
||||||
|
|
||||||
- **allowReturnOutsideFunction**: By default, a return statement at
|
|
||||||
the top level raises an error. Set this to `true` to accept such
|
|
||||||
code.
|
|
||||||
|
|
||||||
- **allowImportExportEverywhere**: By default, `import` and `export`
|
|
||||||
declarations can only appear at a program's top level. Setting this
|
|
||||||
option to `true` allows them anywhere where a statement is allowed,
|
|
||||||
and also allows `import.meta` expressions to appear in scripts
|
|
||||||
(when `sourceType` is not `"module"`).
|
|
||||||
|
|
||||||
- **allowAwaitOutsideFunction**: If `false`, `await` expressions can
|
|
||||||
only appear inside `async` functions. Defaults to `true` for
|
|
||||||
`ecmaVersion` 2022 and later, `false` for lower versions. Setting this option to
|
|
||||||
`true` allows to have top-level `await` expressions. They are
|
|
||||||
still not allowed in non-`async` functions, though.
|
|
||||||
|
|
||||||
- **allowSuperOutsideMethod**: By default, `super` outside a method
|
|
||||||
raises an error. Set this to `true` to accept such code.
|
|
||||||
|
|
||||||
- **allowHashBang**: When this is enabled, if the code starts with the
|
|
||||||
characters `#!` (as in a shellscript), the first line will be
|
|
||||||
treated as a comment. Defaults to true when `ecmaVersion` >= 2023.
|
|
||||||
|
|
||||||
- **locations**: When `true`, each node has a `loc` object attached
|
|
||||||
with `start` and `end` subobjects, each of which contains the
|
|
||||||
one-based line and zero-based column numbers in `{line, column}`
|
|
||||||
form. Default is `false`.
|
|
||||||
|
|
||||||
- **onToken**: If a function is passed for this option, each found
|
|
||||||
token will be passed in same format as tokens returned from
|
|
||||||
`tokenizer().getToken()`.
|
|
||||||
|
|
||||||
If array is passed, each found token is pushed to it.
|
|
||||||
|
|
||||||
Note that you are not allowed to call the parser from the
|
|
||||||
callback—that will corrupt its internal state.
|
|
||||||
|
|
||||||
- **onComment**: If a function is passed for this option, whenever a
|
|
||||||
comment is encountered the function will be called with the
|
|
||||||
following parameters:
|
|
||||||
|
|
||||||
- `block`: `true` if the comment is a block comment, false if it
|
|
||||||
is a line comment.
|
|
||||||
- `text`: The content of the comment.
|
|
||||||
- `start`: Character offset of the start of the comment.
|
|
||||||
- `end`: Character offset of the end of the comment.
|
|
||||||
|
|
||||||
When the `locations` options is on, the `{line, column}` locations
|
|
||||||
of the comment’s start and end are passed as two additional
|
|
||||||
parameters.
|
|
||||||
|
|
||||||
If array is passed for this option, each found comment is pushed
|
|
||||||
to it as object in Esprima format:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
{
|
|
||||||
"type": "Line" | "Block",
|
|
||||||
"value": "comment text",
|
|
||||||
"start": Number,
|
|
||||||
"end": Number,
|
|
||||||
// If `locations` option is on:
|
|
||||||
"loc": {
|
|
||||||
"start": {line: Number, column: Number}
|
|
||||||
"end": {line: Number, column: Number}
|
|
||||||
},
|
|
||||||
// If `ranges` option is on:
|
|
||||||
"range": [Number, Number]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Note that you are not allowed to call the parser from the
|
|
||||||
callback—that will corrupt its internal state.
|
|
||||||
|
|
||||||
- **ranges**: Nodes have their start and end characters offsets
|
|
||||||
recorded in `start` and `end` properties (directly on the node,
|
|
||||||
rather than the `loc` object, which holds line/column data. To also
|
|
||||||
add a
|
|
||||||
[semi-standardized](https://bugzilla.mozilla.org/show_bug.cgi?id=745678)
|
|
||||||
`range` property holding a `[start, end]` array with the same
|
|
||||||
numbers, set the `ranges` option to `true`.
|
|
||||||
|
|
||||||
- **program**: It is possible to parse multiple files into a single
|
|
||||||
AST by passing the tree produced by parsing the first file as the
|
|
||||||
`program` option in subsequent parses. This will add the toplevel
|
|
||||||
forms of the parsed file to the "Program" (top) node of an existing
|
|
||||||
parse tree.
|
|
||||||
|
|
||||||
- **sourceFile**: When the `locations` option is `true`, you can pass
|
|
||||||
this option to add a `source` attribute in every node’s `loc`
|
|
||||||
object. Note that the contents of this option are not examined or
|
|
||||||
processed in any way; you are free to use whatever format you
|
|
||||||
choose.
|
|
||||||
|
|
||||||
- **directSourceFile**: Like `sourceFile`, but a `sourceFile` property
|
|
||||||
will be added (regardless of the `location` option) directly to the
|
|
||||||
nodes, rather than the `loc` object.
|
|
||||||
|
|
||||||
- **preserveParens**: If this option is `true`, parenthesized expressions
|
|
||||||
are represented by (non-standard) `ParenthesizedExpression` nodes
|
|
||||||
that have a single `expression` property containing the expression
|
|
||||||
inside parentheses.
|
|
||||||
|
|
||||||
**parseExpressionAt**`(input, offset, options)` will parse a single
|
|
||||||
expression in a string, and return its AST. It will not complain if
|
|
||||||
there is more of the string left after the expression.
|
|
||||||
|
|
||||||
**tokenizer**`(input, options)` returns an object with a `getToken`
|
|
||||||
method that can be called repeatedly to get the next token, a `{start,
|
|
||||||
end, type, value}` object (with added `loc` property when the
|
|
||||||
`locations` option is enabled and `range` property when the `ranges`
|
|
||||||
option is enabled). When the token's type is `tokTypes.eof`, you
|
|
||||||
should stop calling the method, since it will keep returning that same
|
|
||||||
token forever.
|
|
||||||
|
|
||||||
In ES6 environment, returned result can be used as any other
|
|
||||||
protocol-compliant iterable:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
for (let token of acorn.tokenizer(str)) {
|
|
||||||
// iterate over the tokens
|
|
||||||
}
|
|
||||||
|
|
||||||
// transform code to array of tokens:
|
|
||||||
var tokens = [...acorn.tokenizer(str)];
|
|
||||||
```
|
|
||||||
|
|
||||||
**tokTypes** holds an object mapping names to the token type objects
|
|
||||||
that end up in the `type` properties of tokens.
|
|
||||||
|
|
||||||
**getLineInfo**`(input, offset)` can be used to get a `{line,
|
|
||||||
column}` object for a given program string and offset.
|
|
||||||
|
|
||||||
### The `Parser` class
|
|
||||||
|
|
||||||
Instances of the **`Parser`** class contain all the state and logic
|
|
||||||
that drives a parse. It has static methods `parse`,
|
|
||||||
`parseExpressionAt`, and `tokenizer` that match the top-level
|
|
||||||
functions by the same name.
|
|
||||||
|
|
||||||
When extending the parser with plugins, you need to call these methods
|
|
||||||
on the extended version of the class. To extend a parser with plugins,
|
|
||||||
you can use its static `extend` method.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var acorn = require("acorn");
|
|
||||||
var jsx = require("acorn-jsx");
|
|
||||||
var JSXParser = acorn.Parser.extend(jsx());
|
|
||||||
JSXParser.parse("foo(<bar/>)", {ecmaVersion: 2020});
|
|
||||||
```
|
|
||||||
|
|
||||||
The `extend` method takes any number of plugin values, and returns a
|
|
||||||
new `Parser` class that includes the extra parser logic provided by
|
|
||||||
the plugins.
|
|
||||||
|
|
||||||
## Command line interface
|
|
||||||
|
|
||||||
The `bin/acorn` utility can be used to parse a file from the command
|
|
||||||
line. It accepts as arguments its input file and the following
|
|
||||||
options:
|
|
||||||
|
|
||||||
- `--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|--ecma10`: Sets the ECMAScript version
|
|
||||||
to parse. Default is version 9.
|
|
||||||
|
|
||||||
- `--module`: Sets the parsing mode to `"module"`. Is set to `"script"` otherwise.
|
|
||||||
|
|
||||||
- `--locations`: Attaches a "loc" object to each node with "start" and
|
|
||||||
"end" subobjects, each of which contains the one-based line and
|
|
||||||
zero-based column numbers in `{line, column}` form.
|
|
||||||
|
|
||||||
- `--allow-hash-bang`: If the code starts with the characters #! (as
|
|
||||||
in a shellscript), the first line will be treated as a comment.
|
|
||||||
|
|
||||||
- `--allow-await-outside-function`: Allows top-level `await` expressions.
|
|
||||||
See the `allowAwaitOutsideFunction` option for more information.
|
|
||||||
|
|
||||||
- `--compact`: No whitespace is used in the AST output.
|
|
||||||
|
|
||||||
- `--silent`: Do not output the AST, just return the exit status.
|
|
||||||
|
|
||||||
- `--help`: Print the usage information and quit.
|
|
||||||
|
|
||||||
The utility spits out the syntax tree as JSON data.
|
|
||||||
|
|
||||||
## Existing plugins
|
|
||||||
|
|
||||||
- [`acorn-jsx`](https://github.com/RReverser/acorn-jsx): Parse [Facebook JSX syntax extensions](https://github.com/facebook/jsx)
|
|
|
@ -1,4 +0,0 @@
|
||||||
#!/usr/bin/env node
|
|
||||||
"use strict"
|
|
||||||
|
|
||||||
require("../dist/bin.js")
|
|
252
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/dist/acorn.d.ts
generated
vendored
252
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/dist/acorn.d.ts
generated
vendored
|
@ -1,252 +0,0 @@
|
||||||
export as namespace acorn
|
|
||||||
export = acorn
|
|
||||||
|
|
||||||
declare namespace acorn {
|
|
||||||
function parse(input: string, options: Options): Node
|
|
||||||
|
|
||||||
function parseExpressionAt(input: string, pos: number, options: Options): Node
|
|
||||||
|
|
||||||
function tokenizer(input: string, options: Options): {
|
|
||||||
getToken(): Token
|
|
||||||
[Symbol.iterator](): Iterator<Token>
|
|
||||||
}
|
|
||||||
|
|
||||||
type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 'latest'
|
|
||||||
|
|
||||||
interface Options {
|
|
||||||
ecmaVersion: ecmaVersion
|
|
||||||
sourceType?: 'script' | 'module'
|
|
||||||
onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
|
|
||||||
onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
|
|
||||||
allowReserved?: boolean | 'never'
|
|
||||||
allowReturnOutsideFunction?: boolean
|
|
||||||
allowImportExportEverywhere?: boolean
|
|
||||||
allowAwaitOutsideFunction?: boolean
|
|
||||||
allowSuperOutsideMethod?: boolean
|
|
||||||
allowHashBang?: boolean
|
|
||||||
locations?: boolean
|
|
||||||
onToken?: ((token: Token) => any) | Token[]
|
|
||||||
onComment?: ((
|
|
||||||
isBlock: boolean, text: string, start: number, end: number, startLoc?: Position,
|
|
||||||
endLoc?: Position
|
|
||||||
) => void) | Comment[]
|
|
||||||
ranges?: boolean
|
|
||||||
program?: Node
|
|
||||||
sourceFile?: string
|
|
||||||
directSourceFile?: string
|
|
||||||
preserveParens?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
class Parser {
|
|
||||||
// state.js
|
|
||||||
lineStart: number;
|
|
||||||
options: Options;
|
|
||||||
curLine: number;
|
|
||||||
start: number;
|
|
||||||
end: number;
|
|
||||||
input: string;
|
|
||||||
type: TokenType;
|
|
||||||
|
|
||||||
// state.js
|
|
||||||
constructor(options: Options, input: string, startPos?: number)
|
|
||||||
parse(this: Parser): Node
|
|
||||||
|
|
||||||
// tokenize.js
|
|
||||||
next(): void;
|
|
||||||
nextToken(): void;
|
|
||||||
|
|
||||||
// statement.js
|
|
||||||
parseTopLevel(node: Node): Node;
|
|
||||||
|
|
||||||
// node.js
|
|
||||||
finishNode(node: Node, type: string): Node;
|
|
||||||
finishNodeAt(node: Node, type: string, pos: number, loc: Position): Node;
|
|
||||||
|
|
||||||
// location.js
|
|
||||||
raise(pos: number, message: string) : void;
|
|
||||||
raiseRecoverable?(pos: number, message: string) : void;
|
|
||||||
|
|
||||||
// parseutils.js
|
|
||||||
unexpected(pos: number) : void;
|
|
||||||
|
|
||||||
// index.js
|
|
||||||
static acorn: typeof acorn;
|
|
||||||
|
|
||||||
// state.js
|
|
||||||
static parse(this: typeof Parser, input: string, options: Options): Node
|
|
||||||
static parseExpressionAt(this: typeof Parser, input: string, pos: number, options: Options): Node
|
|
||||||
static tokenizer(this: typeof Parser, input: string, options: Options): {
|
|
||||||
getToken(): Token
|
|
||||||
[Symbol.iterator](): Iterator<Token>
|
|
||||||
}
|
|
||||||
static extend(this: typeof Parser, ...plugins: ((BaseParser: typeof Parser) => typeof Parser)[]): typeof Parser
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Position { line: number; column: number; offset: number }
|
|
||||||
|
|
||||||
const defaultOptions: Options
|
|
||||||
|
|
||||||
function getLineInfo(input: string, offset: number): Position
|
|
||||||
|
|
||||||
class SourceLocation {
|
|
||||||
start: Position
|
|
||||||
end: Position
|
|
||||||
source?: string | null
|
|
||||||
constructor(p: Parser, start: Position, end: Position)
|
|
||||||
}
|
|
||||||
|
|
||||||
class Node {
|
|
||||||
type: string
|
|
||||||
start: number
|
|
||||||
end: number
|
|
||||||
loc?: SourceLocation
|
|
||||||
sourceFile?: string
|
|
||||||
range?: [number, number]
|
|
||||||
constructor(parser: Parser, pos: number, loc?: SourceLocation)
|
|
||||||
}
|
|
||||||
|
|
||||||
class TokenType {
|
|
||||||
label: string
|
|
||||||
keyword: string
|
|
||||||
beforeExpr: boolean
|
|
||||||
startsExpr: boolean
|
|
||||||
isLoop: boolean
|
|
||||||
isAssign: boolean
|
|
||||||
prefix: boolean
|
|
||||||
postfix: boolean
|
|
||||||
binop: number
|
|
||||||
updateContext?: (prevType: TokenType) => void
|
|
||||||
constructor(label: string, conf?: any)
|
|
||||||
}
|
|
||||||
|
|
||||||
const tokTypes: {
|
|
||||||
num: TokenType
|
|
||||||
regexp: TokenType
|
|
||||||
string: TokenType
|
|
||||||
name: TokenType
|
|
||||||
privateId: TokenType
|
|
||||||
eof: TokenType
|
|
||||||
bracketL: TokenType
|
|
||||||
bracketR: TokenType
|
|
||||||
braceL: TokenType
|
|
||||||
braceR: TokenType
|
|
||||||
parenL: TokenType
|
|
||||||
parenR: TokenType
|
|
||||||
comma: TokenType
|
|
||||||
semi: TokenType
|
|
||||||
colon: TokenType
|
|
||||||
dot: TokenType
|
|
||||||
question: TokenType
|
|
||||||
questionDot: TokenType
|
|
||||||
arrow: TokenType
|
|
||||||
template: TokenType
|
|
||||||
invalidTemplate: TokenType
|
|
||||||
ellipsis: TokenType
|
|
||||||
backQuote: TokenType
|
|
||||||
dollarBraceL: TokenType
|
|
||||||
eq: TokenType
|
|
||||||
assign: TokenType
|
|
||||||
incDec: TokenType
|
|
||||||
prefix: TokenType
|
|
||||||
logicalOR: TokenType
|
|
||||||
logicalAND: TokenType
|
|
||||||
bitwiseOR: TokenType
|
|
||||||
bitwiseXOR: TokenType
|
|
||||||
bitwiseAND: TokenType
|
|
||||||
equality: TokenType
|
|
||||||
relational: TokenType
|
|
||||||
bitShift: TokenType
|
|
||||||
plusMin: TokenType
|
|
||||||
modulo: TokenType
|
|
||||||
star: TokenType
|
|
||||||
slash: TokenType
|
|
||||||
starstar: TokenType
|
|
||||||
coalesce: TokenType
|
|
||||||
_break: TokenType
|
|
||||||
_case: TokenType
|
|
||||||
_catch: TokenType
|
|
||||||
_continue: TokenType
|
|
||||||
_debugger: TokenType
|
|
||||||
_default: TokenType
|
|
||||||
_do: TokenType
|
|
||||||
_else: TokenType
|
|
||||||
_finally: TokenType
|
|
||||||
_for: TokenType
|
|
||||||
_function: TokenType
|
|
||||||
_if: TokenType
|
|
||||||
_return: TokenType
|
|
||||||
_switch: TokenType
|
|
||||||
_throw: TokenType
|
|
||||||
_try: TokenType
|
|
||||||
_var: TokenType
|
|
||||||
_const: TokenType
|
|
||||||
_while: TokenType
|
|
||||||
_with: TokenType
|
|
||||||
_new: TokenType
|
|
||||||
_this: TokenType
|
|
||||||
_super: TokenType
|
|
||||||
_class: TokenType
|
|
||||||
_extends: TokenType
|
|
||||||
_export: TokenType
|
|
||||||
_import: TokenType
|
|
||||||
_null: TokenType
|
|
||||||
_true: TokenType
|
|
||||||
_false: TokenType
|
|
||||||
_in: TokenType
|
|
||||||
_instanceof: TokenType
|
|
||||||
_typeof: TokenType
|
|
||||||
_void: TokenType
|
|
||||||
_delete: TokenType
|
|
||||||
}
|
|
||||||
|
|
||||||
class TokContext {
|
|
||||||
constructor(token: string, isExpr: boolean, preserveSpace: boolean, override?: (p: Parser) => void)
|
|
||||||
}
|
|
||||||
|
|
||||||
const tokContexts: {
|
|
||||||
b_stat: TokContext
|
|
||||||
b_expr: TokContext
|
|
||||||
b_tmpl: TokContext
|
|
||||||
p_stat: TokContext
|
|
||||||
p_expr: TokContext
|
|
||||||
q_tmpl: TokContext
|
|
||||||
f_expr: TokContext
|
|
||||||
f_stat: TokContext
|
|
||||||
f_expr_gen: TokContext
|
|
||||||
f_gen: TokContext
|
|
||||||
}
|
|
||||||
|
|
||||||
function isIdentifierStart(code: number, astral?: boolean): boolean
|
|
||||||
|
|
||||||
function isIdentifierChar(code: number, astral?: boolean): boolean
|
|
||||||
|
|
||||||
interface AbstractToken {
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Comment extends AbstractToken {
|
|
||||||
type: 'Line' | 'Block'
|
|
||||||
value: string
|
|
||||||
start: number
|
|
||||||
end: number
|
|
||||||
loc?: SourceLocation
|
|
||||||
range?: [number, number]
|
|
||||||
}
|
|
||||||
|
|
||||||
class Token {
|
|
||||||
type: TokenType
|
|
||||||
value: any
|
|
||||||
start: number
|
|
||||||
end: number
|
|
||||||
loc?: SourceLocation
|
|
||||||
range?: [number, number]
|
|
||||||
constructor(p: Parser)
|
|
||||||
}
|
|
||||||
|
|
||||||
function isNewLine(code: number): boolean
|
|
||||||
|
|
||||||
const lineBreak: RegExp
|
|
||||||
|
|
||||||
const lineBreakG: RegExp
|
|
||||||
|
|
||||||
const version: string
|
|
||||||
}
|
|
5608
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/dist/acorn.js
generated
vendored
5608
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/dist/acorn.js
generated
vendored
File diff suppressed because it is too large
Load Diff
5579
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/dist/acorn.mjs
generated
vendored
5579
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/dist/acorn.mjs
generated
vendored
File diff suppressed because it is too large
Load Diff
90
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/dist/bin.js
generated
vendored
90
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/dist/bin.js
generated
vendored
|
@ -1,90 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var path = require('path');
|
|
||||||
var fs = require('fs');
|
|
||||||
var acorn = require('./acorn.js');
|
|
||||||
|
|
||||||
function _interopNamespaceDefault(e) {
|
|
||||||
var n = Object.create(null);
|
|
||||||
if (e) {
|
|
||||||
Object.keys(e).forEach(function (k) {
|
|
||||||
if (k !== 'default') {
|
|
||||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
||||||
Object.defineProperty(n, k, d.get ? d : {
|
|
||||||
enumerable: true,
|
|
||||||
get: function () { return e[k]; }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
n.default = e;
|
|
||||||
return Object.freeze(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
var acorn__namespace = /*#__PURE__*/_interopNamespaceDefault(acorn);
|
|
||||||
|
|
||||||
var inputFilePaths = [], forceFileName = false, fileMode = false, silent = false, compact = false, tokenize = false;
|
|
||||||
var options = {};
|
|
||||||
|
|
||||||
function help(status) {
|
|
||||||
var print = (status === 0) ? console.log : console.error;
|
|
||||||
print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|...|--ecma2015|--ecma2016|--ecma2017|--ecma2018|...]");
|
|
||||||
print(" [--tokenize] [--locations] [--allow-hash-bang] [--allow-await-outside-function] [--compact] [--silent] [--module] [--help] [--] [<infile>...]");
|
|
||||||
process.exit(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 2; i < process.argv.length; ++i) {
|
|
||||||
var arg = process.argv[i];
|
|
||||||
if (arg[0] !== "-" || arg === "-") { inputFilePaths.push(arg); }
|
|
||||||
else if (arg === "--") {
|
|
||||||
inputFilePaths.push.apply(inputFilePaths, process.argv.slice(i + 1));
|
|
||||||
forceFileName = true;
|
|
||||||
break
|
|
||||||
} else if (arg === "--locations") { options.locations = true; }
|
|
||||||
else if (arg === "--allow-hash-bang") { options.allowHashBang = true; }
|
|
||||||
else if (arg === "--allow-await-outside-function") { options.allowAwaitOutsideFunction = true; }
|
|
||||||
else if (arg === "--silent") { silent = true; }
|
|
||||||
else if (arg === "--compact") { compact = true; }
|
|
||||||
else if (arg === "--help") { help(0); }
|
|
||||||
else if (arg === "--tokenize") { tokenize = true; }
|
|
||||||
else if (arg === "--module") { options.sourceType = "module"; }
|
|
||||||
else {
|
|
||||||
var match = arg.match(/^--ecma(\d+)$/);
|
|
||||||
if (match)
|
|
||||||
{ options.ecmaVersion = +match[1]; }
|
|
||||||
else
|
|
||||||
{ help(1); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function run(codeList) {
|
|
||||||
var result = [], fileIdx = 0;
|
|
||||||
try {
|
|
||||||
codeList.forEach(function (code, idx) {
|
|
||||||
fileIdx = idx;
|
|
||||||
if (!tokenize) {
|
|
||||||
result = acorn__namespace.parse(code, options);
|
|
||||||
options.program = result;
|
|
||||||
} else {
|
|
||||||
var tokenizer = acorn__namespace.tokenizer(code, options), token;
|
|
||||||
do {
|
|
||||||
token = tokenizer.getToken();
|
|
||||||
result.push(token);
|
|
||||||
} while (token.type !== acorn__namespace.tokTypes.eof)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
console.error(fileMode ? e.message.replace(/\(\d+:\d+\)$/, function (m) { return m.slice(0, 1) + inputFilePaths[fileIdx] + " " + m.slice(1); }) : e.message);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
if (!silent) { console.log(JSON.stringify(result, null, compact ? null : 2)); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fileMode = inputFilePaths.length && (forceFileName || !inputFilePaths.includes("-") || inputFilePaths.length !== 1)) {
|
|
||||||
run(inputFilePaths.map(function (path) { return fs.readFileSync(path, "utf8"); }));
|
|
||||||
} else {
|
|
||||||
var code = "";
|
|
||||||
process.stdin.resume();
|
|
||||||
process.stdin.on("data", function (chunk) { return code += chunk; });
|
|
||||||
process.stdin.on("end", function () { return run([code]); });
|
|
||||||
}
|
|
50
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/package.json
generated
vendored
50
typescript/Frontend/node_modules/.acorn-globals-2BnPyRAw/node_modules/acorn/package.json
generated
vendored
|
@ -1,50 +0,0 @@
|
||||||
{
|
|
||||||
"name": "acorn",
|
|
||||||
"description": "ECMAScript parser",
|
|
||||||
"homepage": "https://github.com/acornjs/acorn",
|
|
||||||
"main": "dist/acorn.js",
|
|
||||||
"types": "dist/acorn.d.ts",
|
|
||||||
"module": "dist/acorn.mjs",
|
|
||||||
"exports": {
|
|
||||||
".": [
|
|
||||||
{
|
|
||||||
"import": "./dist/acorn.mjs",
|
|
||||||
"require": "./dist/acorn.js",
|
|
||||||
"default": "./dist/acorn.js"
|
|
||||||
},
|
|
||||||
"./dist/acorn.js"
|
|
||||||
],
|
|
||||||
"./package.json": "./package.json"
|
|
||||||
},
|
|
||||||
"version": "8.8.2",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.4.0"
|
|
||||||
},
|
|
||||||
"maintainers": [
|
|
||||||
{
|
|
||||||
"name": "Marijn Haverbeke",
|
|
||||||
"email": "marijnh@gmail.com",
|
|
||||||
"web": "https://marijnhaverbeke.nl"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Ingvar Stepanyan",
|
|
||||||
"email": "me@rreverser.com",
|
|
||||||
"web": "https://rreverser.com/"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Adrian Heine",
|
|
||||||
"web": "http://adrianheine.de"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/acornjs/acorn.git"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"scripts": {
|
|
||||||
"prepare": "cd ..; npm run build:main"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"acorn": "./bin/acorn"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
{
|
|
||||||
"name": "acorn-globals",
|
|
||||||
"version": "7.0.1",
|
|
||||||
"description": "Detect global variables in JavaScript using acorn",
|
|
||||||
"keywords": [
|
|
||||||
"ast",
|
|
||||||
"variable",
|
|
||||||
"name",
|
|
||||||
"lexical",
|
|
||||||
"scope",
|
|
||||||
"local",
|
|
||||||
"global",
|
|
||||||
"implicit"
|
|
||||||
],
|
|
||||||
"files": [
|
|
||||||
"index.js",
|
|
||||||
"LICENSE"
|
|
||||||
],
|
|
||||||
"dependencies": {
|
|
||||||
"acorn": "^8.1.0",
|
|
||||||
"acorn-walk": "^8.0.2"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"testit": "^3.1.0"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "node test"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/ForbesLindesay/acorn-globals.git"
|
|
||||||
},
|
|
||||||
"author": "ForbesLindesay",
|
|
||||||
"license": "MIT"
|
|
||||||
}
|
|
|
@ -1,167 +0,0 @@
|
||||||
## 8.2.0 (2021-09-06)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Add support for walking ES2022 class static blocks.
|
|
||||||
|
|
||||||
## 8.1.1 (2021-06-29)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Include `base` in the type declarations.
|
|
||||||
|
|
||||||
## 8.1.0 (2021-04-24)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Support node types for class fields and private methods.
|
|
||||||
|
|
||||||
## 8.0.2 (2021-01-25)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Adjust package.json to work with Node 12.16.0 and 13.0-13.6.
|
|
||||||
|
|
||||||
## 8.0.0 (2021-01-05)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix a bug where `full` and `fullAncestor` would skip nodes with overridden types.
|
|
||||||
|
|
||||||
## 8.0.0 (2020-08-12)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
The package can now be loaded directly as an ECMAScript module in node 13+.
|
|
||||||
|
|
||||||
## 7.2.0 (2020-06-17)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Support optional chaining and nullish coalescing.
|
|
||||||
|
|
||||||
Support `import.meta`.
|
|
||||||
|
|
||||||
Add support for `export * as ns from "source"`.
|
|
||||||
|
|
||||||
## 7.1.1 (2020-02-13)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Clean up the type definitions to actually work well with the main parser.
|
|
||||||
|
|
||||||
## 7.1.0 (2020-02-11)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Add a TypeScript definition file for the library.
|
|
||||||
|
|
||||||
## 7.0.0 (2017-08-12)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Support walking `ImportExpression` nodes.
|
|
||||||
|
|
||||||
## 6.2.0 (2017-07-04)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Add support for `Import` nodes.
|
|
||||||
|
|
||||||
## 6.1.0 (2018-09-28)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
The walker now walks `TemplateElement` nodes.
|
|
||||||
|
|
||||||
## 6.0.1 (2018-09-14)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix bad "main" field in package.json.
|
|
||||||
|
|
||||||
## 6.0.0 (2018-09-14)
|
|
||||||
|
|
||||||
### Breaking changes
|
|
||||||
|
|
||||||
This is now a separate package, `acorn-walk`, rather than part of the main `acorn` package.
|
|
||||||
|
|
||||||
The `ScopeBody` and `ScopeExpression` meta-node-types are no longer supported.
|
|
||||||
|
|
||||||
## 5.7.1 (2018-06-15)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Make sure the walker and bin files are rebuilt on release (the previous release didn't get the up-to-date versions).
|
|
||||||
|
|
||||||
## 5.7.0 (2018-06-15)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix crash in walker when walking a binding-less catch node.
|
|
||||||
|
|
||||||
## 5.6.2 (2018-06-05)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
In the walker, go back to allowing the `baseVisitor` argument to be null to default to the default base everywhere.
|
|
||||||
|
|
||||||
## 5.6.1 (2018-06-01)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix regression when passing `null` as fourth argument to `walk.recursive`.
|
|
||||||
|
|
||||||
## 5.6.0 (2018-05-31)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix a bug in the walker that caused a crash when walking an object pattern spread.
|
|
||||||
|
|
||||||
## 5.5.1 (2018-03-06)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Fix regression in walker causing property values in object patterns to be walked as expressions.
|
|
||||||
|
|
||||||
## 5.5.0 (2018-02-27)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
Support object spread in the AST walker.
|
|
||||||
|
|
||||||
## 5.4.1 (2018-02-02)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
5.4.0 somehow accidentally included an old version of walk.js.
|
|
||||||
|
|
||||||
## 5.2.0 (2017-10-30)
|
|
||||||
|
|
||||||
### Bug fixes
|
|
||||||
|
|
||||||
The `full` and `fullAncestor` walkers no longer visit nodes multiple times.
|
|
||||||
|
|
||||||
## 5.1.0 (2017-07-05)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
New walker functions `full` and `fullAncestor`.
|
|
||||||
|
|
||||||
## 3.2.0 (2016-06-07)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
Make it possible to use `visit.ancestor` with a walk state.
|
|
||||||
|
|
||||||
## 3.1.0 (2016-04-18)
|
|
||||||
|
|
||||||
### New features
|
|
||||||
|
|
||||||
The walker now allows defining handlers for `CatchClause` nodes.
|
|
||||||
|
|
||||||
## 2.5.2 (2015-10-27)
|
|
||||||
|
|
||||||
### Fixes
|
|
||||||
|
|
||||||
Fix bug where the walker walked an exported `let` statement as an expression.
|
|
|
@ -1,21 +0,0 @@
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (C) 2012-2020 by various contributors (see AUTHORS)
|
|
||||||
|
|
||||||
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.
|
|
|
@ -1,126 +0,0 @@
|
||||||
# Acorn AST walker
|
|
||||||
|
|
||||||
An abstract syntax tree walker for the
|
|
||||||
[ESTree](https://github.com/estree/estree) format.
|
|
||||||
|
|
||||||
## Community
|
|
||||||
|
|
||||||
Acorn is open source software released under an
|
|
||||||
[MIT license](https://github.com/acornjs/acorn/blob/master/acorn-walk/LICENSE).
|
|
||||||
|
|
||||||
You are welcome to
|
|
||||||
[report bugs](https://github.com/acornjs/acorn/issues) or create pull
|
|
||||||
requests on [github](https://github.com/acornjs/acorn). For questions
|
|
||||||
and discussion, please use the
|
|
||||||
[Tern discussion forum](https://discuss.ternjs.net).
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
The easiest way to install acorn is from [`npm`](https://www.npmjs.com/):
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install acorn-walk
|
|
||||||
```
|
|
||||||
|
|
||||||
Alternately, you can download the source and build acorn yourself:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
git clone https://github.com/acornjs/acorn.git
|
|
||||||
cd acorn
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
## Interface
|
|
||||||
|
|
||||||
An algorithm for recursing through a syntax tree is stored as an
|
|
||||||
object, with a property for each tree node type holding a function
|
|
||||||
that will recurse through such a node. There are several ways to run
|
|
||||||
such a walker.
|
|
||||||
|
|
||||||
**simple**`(node, visitors, base, state)` does a 'simple' walk over a
|
|
||||||
tree. `node` should be the AST node to walk, and `visitors` an object
|
|
||||||
with properties whose names correspond to node types in the [ESTree
|
|
||||||
spec](https://github.com/estree/estree). The properties should contain
|
|
||||||
functions that will be called with the node object and, if applicable
|
|
||||||
the state at that point. The last two arguments are optional. `base`
|
|
||||||
is a walker algorithm, and `state` is a start state. The default
|
|
||||||
walker will simply visit all statements and expressions and not
|
|
||||||
produce a meaningful state. (An example of a use of state is to track
|
|
||||||
scope at each point in the tree.)
|
|
||||||
|
|
||||||
```js
|
|
||||||
const acorn = require("acorn")
|
|
||||||
const walk = require("acorn-walk")
|
|
||||||
|
|
||||||
walk.simple(acorn.parse("let x = 10"), {
|
|
||||||
Literal(node) {
|
|
||||||
console.log(`Found a literal: ${node.value}`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
**ancestor**`(node, visitors, base, state)` does a 'simple' walk over
|
|
||||||
a tree, building up an array of ancestor nodes (including the current node)
|
|
||||||
and passing the array to the callbacks as a third parameter.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const acorn = require("acorn")
|
|
||||||
const walk = require("acorn-walk")
|
|
||||||
|
|
||||||
walk.ancestor(acorn.parse("foo('hi')"), {
|
|
||||||
Literal(_, ancestors) {
|
|
||||||
console.log("This literal's ancestors are:", ancestors.map(n => n.type))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
**recursive**`(node, state, functions, base)` does a 'recursive'
|
|
||||||
walk, where the walker functions are responsible for continuing the
|
|
||||||
walk on the child nodes of their target node. `state` is the start
|
|
||||||
state, and `functions` should contain an object that maps node types
|
|
||||||
to walker functions. Such functions are called with `(node, state, c)`
|
|
||||||
arguments, and can cause the walk to continue on a sub-node by calling
|
|
||||||
the `c` argument on it with `(node, state)` arguments. The optional
|
|
||||||
`base` argument provides the fallback walker functions for node types
|
|
||||||
that aren't handled in the `functions` object. If not given, the
|
|
||||||
default walkers will be used.
|
|
||||||
|
|
||||||
**make**`(functions, base)` builds a new walker object by using the
|
|
||||||
walker functions in `functions` and filling in the missing ones by
|
|
||||||
taking defaults from `base`.
|
|
||||||
|
|
||||||
**full**`(node, callback, base, state)` does a 'full' walk over a
|
|
||||||
tree, calling the callback with the arguments (node, state, type) for
|
|
||||||
each node
|
|
||||||
|
|
||||||
**fullAncestor**`(node, callback, base, state)` does a 'full' walk
|
|
||||||
over a tree, building up an array of ancestor nodes (including the
|
|
||||||
current node) and passing the array to the callbacks as a third
|
|
||||||
parameter.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const acorn = require("acorn")
|
|
||||||
const walk = require("acorn-walk")
|
|
||||||
|
|
||||||
walk.full(acorn.parse("1 + 1"), node => {
|
|
||||||
console.log(`There's a ${node.type} node at ${node.ch}`)
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
**findNodeAt**`(node, start, end, test, base, state)` tries to locate
|
|
||||||
a node in a tree at the given start and/or end offsets, which
|
|
||||||
satisfies the predicate `test`. `start` and `end` can be either `null`
|
|
||||||
(as wildcard) or a number. `test` may be a string (indicating a node
|
|
||||||
type) or a function that takes `(nodeType, node)` arguments and
|
|
||||||
returns a boolean indicating whether this node is interesting. `base`
|
|
||||||
and `state` are optional, and can be used to specify a custom walker.
|
|
||||||
Nodes are tested from inner to outer, so if two nodes match the
|
|
||||||
boundaries, the inner one will be preferred.
|
|
||||||
|
|
||||||
**findNodeAround**`(node, pos, test, base, state)` is a lot like
|
|
||||||
`findNodeAt`, but will match any node that exists 'around' (spanning)
|
|
||||||
the given position.
|
|
||||||
|
|
||||||
**findNodeAfter**`(node, pos, test, base, state)` is similar to
|
|
||||||
`findNodeAround`, but will match all nodes *after* the given position
|
|
||||||
(testing outer nodes before inner nodes).
|
|
|
@ -1,114 +0,0 @@
|
||||||
import {Node} from 'acorn';
|
|
||||||
|
|
||||||
declare module "acorn-walk" {
|
|
||||||
type FullWalkerCallback<TState> = (
|
|
||||||
node: Node,
|
|
||||||
state: TState,
|
|
||||||
type: string
|
|
||||||
) => void;
|
|
||||||
|
|
||||||
type FullAncestorWalkerCallback<TState> = (
|
|
||||||
node: Node,
|
|
||||||
state: TState | Node[],
|
|
||||||
ancestors: Node[],
|
|
||||||
type: string
|
|
||||||
) => void;
|
|
||||||
type WalkerCallback<TState> = (node: Node, state: TState) => void;
|
|
||||||
|
|
||||||
type SimpleWalkerFn<TState> = (
|
|
||||||
node: Node,
|
|
||||||
state: TState
|
|
||||||
) => void;
|
|
||||||
|
|
||||||
type AncestorWalkerFn<TState> = (
|
|
||||||
node: Node,
|
|
||||||
state: TState| Node[],
|
|
||||||
ancestors: Node[]
|
|
||||||
) => void;
|
|
||||||
|
|
||||||
type RecursiveWalkerFn<TState> = (
|
|
||||||
node: Node,
|
|
||||||
state: TState,
|
|
||||||
callback: WalkerCallback<TState>
|
|
||||||
) => void;
|
|
||||||
|
|
||||||
type SimpleVisitors<TState> = {
|
|
||||||
[type: string]: SimpleWalkerFn<TState>
|
|
||||||
};
|
|
||||||
|
|
||||||
type AncestorVisitors<TState> = {
|
|
||||||
[type: string]: AncestorWalkerFn<TState>
|
|
||||||
};
|
|
||||||
|
|
||||||
type RecursiveVisitors<TState> = {
|
|
||||||
[type: string]: RecursiveWalkerFn<TState>
|
|
||||||
};
|
|
||||||
|
|
||||||
type FindPredicate = (type: string, node: Node) => boolean;
|
|
||||||
|
|
||||||
interface Found<TState> {
|
|
||||||
node: Node,
|
|
||||||
state: TState
|
|
||||||
}
|
|
||||||
|
|
||||||
export function simple<TState>(
|
|
||||||
node: Node,
|
|
||||||
visitors: SimpleVisitors<TState>,
|
|
||||||
base?: RecursiveVisitors<TState>,
|
|
||||||
state?: TState
|
|
||||||
): void;
|
|
||||||
|
|
||||||
export function ancestor<TState>(
|
|
||||||
node: Node,
|
|
||||||
visitors: AncestorVisitors<TState>,
|
|
||||||
base?: RecursiveVisitors<TState>,
|
|
||||||
state?: TState
|
|
||||||
): void;
|
|
||||||
|
|
||||||
export function recursive<TState>(
|
|
||||||
node: Node,
|
|
||||||
state: TState,
|
|
||||||
functions: RecursiveVisitors<TState>,
|
|
||||||
base?: RecursiveVisitors<TState>
|
|
||||||
): void;
|
|
||||||
|
|
||||||
export function full<TState>(
|
|
||||||
node: Node,
|
|
||||||
callback: FullWalkerCallback<TState>,
|
|
||||||
base?: RecursiveVisitors<TState>,
|
|
||||||
state?: TState
|
|
||||||
): void;
|
|
||||||
|
|
||||||
export function fullAncestor<TState>(
|
|
||||||
node: Node,
|
|
||||||
callback: FullAncestorWalkerCallback<TState>,
|
|
||||||
base?: RecursiveVisitors<TState>,
|
|
||||||
state?: TState
|
|
||||||
): void;
|
|
||||||
|
|
||||||
export function make<TState>(
|
|
||||||
functions: RecursiveVisitors<TState>,
|
|
||||||
base?: RecursiveVisitors<TState>
|
|
||||||
): RecursiveVisitors<TState>;
|
|
||||||
|
|
||||||
export function findNodeAt<TState>(
|
|
||||||
node: Node,
|
|
||||||
start: number | undefined,
|
|
||||||
end?: number | undefined,
|
|
||||||
type?: FindPredicate | string,
|
|
||||||
base?: RecursiveVisitors<TState>,
|
|
||||||
state?: TState
|
|
||||||
): Found<TState> | undefined;
|
|
||||||
|
|
||||||
export function findNodeAround<TState>(
|
|
||||||
node: Node,
|
|
||||||
start: number | undefined,
|
|
||||||
type?: FindPredicate | string,
|
|
||||||
base?: RecursiveVisitors<TState>,
|
|
||||||
state?: TState
|
|
||||||
): Found<TState> | undefined;
|
|
||||||
|
|
||||||
export const findNodeAfter: typeof findNodeAround;
|
|
||||||
|
|
||||||
export const base: RecursiveVisitors<any>;
|
|
||||||
}
|
|
|
@ -1,463 +0,0 @@
|
||||||
(function (global, factory) {
|
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
||||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
||||||
(global = global || self, factory((global.acorn = global.acorn || {}, global.acorn.walk = {})));
|
|
||||||
}(this, (function (exports) { 'use strict';
|
|
||||||
|
|
||||||
// AST walker module for Mozilla Parser API compatible trees
|
|
||||||
|
|
||||||
// A simple walk is one where you simply specify callbacks to be
|
|
||||||
// called on specific nodes. The last two arguments are optional. A
|
|
||||||
// simple use would be
|
|
||||||
//
|
|
||||||
// walk.simple(myTree, {
|
|
||||||
// Expression: function(node) { ... }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// to do something with all expressions. All Parser API node types
|
|
||||||
// can be used to identify node types, as well as Expression and
|
|
||||||
// Statement, which denote categories of nodes.
|
|
||||||
//
|
|
||||||
// The base argument can be used to pass a custom (recursive)
|
|
||||||
// walker, and state can be used to give this walked an initial
|
|
||||||
// state.
|
|
||||||
|
|
||||||
function simple(node, visitors, baseVisitor, state, override) {
|
|
||||||
if (!baseVisitor) { baseVisitor = base
|
|
||||||
; }(function c(node, st, override) {
|
|
||||||
var type = override || node.type, found = visitors[type];
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
if (found) { found(node, st); }
|
|
||||||
})(node, state, override);
|
|
||||||
}
|
|
||||||
|
|
||||||
// An ancestor walk keeps an array of ancestor nodes (including the
|
|
||||||
// current node) and passes them to the callback as third parameter
|
|
||||||
// (and also as state parameter when no other state is present).
|
|
||||||
function ancestor(node, visitors, baseVisitor, state, override) {
|
|
||||||
var ancestors = [];
|
|
||||||
if (!baseVisitor) { baseVisitor = base
|
|
||||||
; }(function c(node, st, override) {
|
|
||||||
var type = override || node.type, found = visitors[type];
|
|
||||||
var isNew = node !== ancestors[ancestors.length - 1];
|
|
||||||
if (isNew) { ancestors.push(node); }
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
if (found) { found(node, st || ancestors, ancestors); }
|
|
||||||
if (isNew) { ancestors.pop(); }
|
|
||||||
})(node, state, override);
|
|
||||||
}
|
|
||||||
|
|
||||||
// A recursive walk is one where your functions override the default
|
|
||||||
// walkers. They can modify and replace the state parameter that's
|
|
||||||
// threaded through the walk, and can opt how and whether to walk
|
|
||||||
// their child nodes (by calling their third argument on these
|
|
||||||
// nodes).
|
|
||||||
function recursive(node, state, funcs, baseVisitor, override) {
|
|
||||||
var visitor = funcs ? make(funcs, baseVisitor || undefined) : baseVisitor
|
|
||||||
;(function c(node, st, override) {
|
|
||||||
visitor[override || node.type](node, st, c);
|
|
||||||
})(node, state, override);
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeTest(test) {
|
|
||||||
if (typeof test === "string")
|
|
||||||
{ return function (type) { return type === test; } }
|
|
||||||
else if (!test)
|
|
||||||
{ return function () { return true; } }
|
|
||||||
else
|
|
||||||
{ return test }
|
|
||||||
}
|
|
||||||
|
|
||||||
var Found = function Found(node, state) { this.node = node; this.state = state; };
|
|
||||||
|
|
||||||
// A full walk triggers the callback on each node
|
|
||||||
function full(node, callback, baseVisitor, state, override) {
|
|
||||||
if (!baseVisitor) { baseVisitor = base; }
|
|
||||||
var last
|
|
||||||
;(function c(node, st, override) {
|
|
||||||
var type = override || node.type;
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
if (last !== node) {
|
|
||||||
callback(node, st, type);
|
|
||||||
last = node;
|
|
||||||
}
|
|
||||||
})(node, state, override);
|
|
||||||
}
|
|
||||||
|
|
||||||
// An fullAncestor walk is like an ancestor walk, but triggers
|
|
||||||
// the callback on each node
|
|
||||||
function fullAncestor(node, callback, baseVisitor, state) {
|
|
||||||
if (!baseVisitor) { baseVisitor = base; }
|
|
||||||
var ancestors = [], last
|
|
||||||
;(function c(node, st, override) {
|
|
||||||
var type = override || node.type;
|
|
||||||
var isNew = node !== ancestors[ancestors.length - 1];
|
|
||||||
if (isNew) { ancestors.push(node); }
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
if (last !== node) {
|
|
||||||
callback(node, st || ancestors, ancestors, type);
|
|
||||||
last = node;
|
|
||||||
}
|
|
||||||
if (isNew) { ancestors.pop(); }
|
|
||||||
})(node, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find a node with a given start, end, and type (all are optional,
|
|
||||||
// null can be used as wildcard). Returns a {node, state} object, or
|
|
||||||
// undefined when it doesn't find a matching node.
|
|
||||||
function findNodeAt(node, start, end, test, baseVisitor, state) {
|
|
||||||
if (!baseVisitor) { baseVisitor = base; }
|
|
||||||
test = makeTest(test);
|
|
||||||
try {
|
|
||||||
(function c(node, st, override) {
|
|
||||||
var type = override || node.type;
|
|
||||||
if ((start == null || node.start <= start) &&
|
|
||||||
(end == null || node.end >= end))
|
|
||||||
{ baseVisitor[type](node, st, c); }
|
|
||||||
if ((start == null || node.start === start) &&
|
|
||||||
(end == null || node.end === end) &&
|
|
||||||
test(type, node))
|
|
||||||
{ throw new Found(node, st) }
|
|
||||||
})(node, state);
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof Found) { return e }
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the innermost node of a given type that contains the given
|
|
||||||
// position. Interface similar to findNodeAt.
|
|
||||||
function findNodeAround(node, pos, test, baseVisitor, state) {
|
|
||||||
test = makeTest(test);
|
|
||||||
if (!baseVisitor) { baseVisitor = base; }
|
|
||||||
try {
|
|
||||||
(function c(node, st, override) {
|
|
||||||
var type = override || node.type;
|
|
||||||
if (node.start > pos || node.end < pos) { return }
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
if (test(type, node)) { throw new Found(node, st) }
|
|
||||||
})(node, state);
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof Found) { return e }
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the outermost matching node after a given position.
|
|
||||||
function findNodeAfter(node, pos, test, baseVisitor, state) {
|
|
||||||
test = makeTest(test);
|
|
||||||
if (!baseVisitor) { baseVisitor = base; }
|
|
||||||
try {
|
|
||||||
(function c(node, st, override) {
|
|
||||||
if (node.end < pos) { return }
|
|
||||||
var type = override || node.type;
|
|
||||||
if (node.start >= pos && test(type, node)) { throw new Found(node, st) }
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
})(node, state);
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof Found) { return e }
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the outermost matching node before a given position.
|
|
||||||
function findNodeBefore(node, pos, test, baseVisitor, state) {
|
|
||||||
test = makeTest(test);
|
|
||||||
if (!baseVisitor) { baseVisitor = base; }
|
|
||||||
var max
|
|
||||||
;(function c(node, st, override) {
|
|
||||||
if (node.start > pos) { return }
|
|
||||||
var type = override || node.type;
|
|
||||||
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node))
|
|
||||||
{ max = new Found(node, st); }
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
})(node, state);
|
|
||||||
return max
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used to create a custom walker. Will fill in all missing node
|
|
||||||
// type properties with the defaults.
|
|
||||||
function make(funcs, baseVisitor) {
|
|
||||||
var visitor = Object.create(baseVisitor || base);
|
|
||||||
for (var type in funcs) { visitor[type] = funcs[type]; }
|
|
||||||
return visitor
|
|
||||||
}
|
|
||||||
|
|
||||||
function skipThrough(node, st, c) { c(node, st); }
|
|
||||||
function ignore(_node, _st, _c) {}
|
|
||||||
|
|
||||||
// Node walkers.
|
|
||||||
|
|
||||||
var base = {};
|
|
||||||
|
|
||||||
base.Program = base.BlockStatement = base.StaticBlock = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.body; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var stmt = list[i];
|
|
||||||
|
|
||||||
c(stmt, st, "Statement");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.Statement = skipThrough;
|
|
||||||
base.EmptyStatement = ignore;
|
|
||||||
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
|
|
||||||
function (node, st, c) { return c(node.expression, st, "Expression"); };
|
|
||||||
base.IfStatement = function (node, st, c) {
|
|
||||||
c(node.test, st, "Expression");
|
|
||||||
c(node.consequent, st, "Statement");
|
|
||||||
if (node.alternate) { c(node.alternate, st, "Statement"); }
|
|
||||||
};
|
|
||||||
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); };
|
|
||||||
base.BreakStatement = base.ContinueStatement = ignore;
|
|
||||||
base.WithStatement = function (node, st, c) {
|
|
||||||
c(node.object, st, "Expression");
|
|
||||||
c(node.body, st, "Statement");
|
|
||||||
};
|
|
||||||
base.SwitchStatement = function (node, st, c) {
|
|
||||||
c(node.discriminant, st, "Expression");
|
|
||||||
for (var i$1 = 0, list$1 = node.cases; i$1 < list$1.length; i$1 += 1) {
|
|
||||||
var cs = list$1[i$1];
|
|
||||||
|
|
||||||
if (cs.test) { c(cs.test, st, "Expression"); }
|
|
||||||
for (var i = 0, list = cs.consequent; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var cons = list[i];
|
|
||||||
|
|
||||||
c(cons, st, "Statement");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.SwitchCase = function (node, st, c) {
|
|
||||||
if (node.test) { c(node.test, st, "Expression"); }
|
|
||||||
for (var i = 0, list = node.consequent; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var cons = list[i];
|
|
||||||
|
|
||||||
c(cons, st, "Statement");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
|
|
||||||
if (node.argument) { c(node.argument, st, "Expression"); }
|
|
||||||
};
|
|
||||||
base.ThrowStatement = base.SpreadElement =
|
|
||||||
function (node, st, c) { return c(node.argument, st, "Expression"); };
|
|
||||||
base.TryStatement = function (node, st, c) {
|
|
||||||
c(node.block, st, "Statement");
|
|
||||||
if (node.handler) { c(node.handler, st); }
|
|
||||||
if (node.finalizer) { c(node.finalizer, st, "Statement"); }
|
|
||||||
};
|
|
||||||
base.CatchClause = function (node, st, c) {
|
|
||||||
if (node.param) { c(node.param, st, "Pattern"); }
|
|
||||||
c(node.body, st, "Statement");
|
|
||||||
};
|
|
||||||
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
|
|
||||||
c(node.test, st, "Expression");
|
|
||||||
c(node.body, st, "Statement");
|
|
||||||
};
|
|
||||||
base.ForStatement = function (node, st, c) {
|
|
||||||
if (node.init) { c(node.init, st, "ForInit"); }
|
|
||||||
if (node.test) { c(node.test, st, "Expression"); }
|
|
||||||
if (node.update) { c(node.update, st, "Expression"); }
|
|
||||||
c(node.body, st, "Statement");
|
|
||||||
};
|
|
||||||
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
|
|
||||||
c(node.left, st, "ForInit");
|
|
||||||
c(node.right, st, "Expression");
|
|
||||||
c(node.body, st, "Statement");
|
|
||||||
};
|
|
||||||
base.ForInit = function (node, st, c) {
|
|
||||||
if (node.type === "VariableDeclaration") { c(node, st); }
|
|
||||||
else { c(node, st, "Expression"); }
|
|
||||||
};
|
|
||||||
base.DebuggerStatement = ignore;
|
|
||||||
|
|
||||||
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); };
|
|
||||||
base.VariableDeclaration = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.declarations; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var decl = list[i];
|
|
||||||
|
|
||||||
c(decl, st);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.VariableDeclarator = function (node, st, c) {
|
|
||||||
c(node.id, st, "Pattern");
|
|
||||||
if (node.init) { c(node.init, st, "Expression"); }
|
|
||||||
};
|
|
||||||
|
|
||||||
base.Function = function (node, st, c) {
|
|
||||||
if (node.id) { c(node.id, st, "Pattern"); }
|
|
||||||
for (var i = 0, list = node.params; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var param = list[i];
|
|
||||||
|
|
||||||
c(param, st, "Pattern");
|
|
||||||
}
|
|
||||||
c(node.body, st, node.expression ? "Expression" : "Statement");
|
|
||||||
};
|
|
||||||
|
|
||||||
base.Pattern = function (node, st, c) {
|
|
||||||
if (node.type === "Identifier")
|
|
||||||
{ c(node, st, "VariablePattern"); }
|
|
||||||
else if (node.type === "MemberExpression")
|
|
||||||
{ c(node, st, "MemberPattern"); }
|
|
||||||
else
|
|
||||||
{ c(node, st); }
|
|
||||||
};
|
|
||||||
base.VariablePattern = ignore;
|
|
||||||
base.MemberPattern = skipThrough;
|
|
||||||
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); };
|
|
||||||
base.ArrayPattern = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
|
||||||
var elt = list[i];
|
|
||||||
|
|
||||||
if (elt) { c(elt, st, "Pattern"); }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.ObjectPattern = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
|
||||||
var prop = list[i];
|
|
||||||
|
|
||||||
if (prop.type === "Property") {
|
|
||||||
if (prop.computed) { c(prop.key, st, "Expression"); }
|
|
||||||
c(prop.value, st, "Pattern");
|
|
||||||
} else if (prop.type === "RestElement") {
|
|
||||||
c(prop.argument, st, "Pattern");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
base.Expression = skipThrough;
|
|
||||||
base.ThisExpression = base.Super = base.MetaProperty = ignore;
|
|
||||||
base.ArrayExpression = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
|
||||||
var elt = list[i];
|
|
||||||
|
|
||||||
if (elt) { c(elt, st, "Expression"); }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.ObjectExpression = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.properties; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var prop = list[i];
|
|
||||||
|
|
||||||
c(prop, st);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
|
||||||
base.SequenceExpression = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.expressions; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var expr = list[i];
|
|
||||||
|
|
||||||
c(expr, st, "Expression");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.TemplateLiteral = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.quasis; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var quasi = list[i];
|
|
||||||
|
|
||||||
c(quasi, st);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i$1 = 0, list$1 = node.expressions; i$1 < list$1.length; i$1 += 1)
|
|
||||||
{
|
|
||||||
var expr = list$1[i$1];
|
|
||||||
|
|
||||||
c(expr, st, "Expression");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.TemplateElement = ignore;
|
|
||||||
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
|
|
||||||
c(node.argument, st, "Expression");
|
|
||||||
};
|
|
||||||
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
|
|
||||||
c(node.left, st, "Expression");
|
|
||||||
c(node.right, st, "Expression");
|
|
||||||
};
|
|
||||||
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
|
|
||||||
c(node.left, st, "Pattern");
|
|
||||||
c(node.right, st, "Expression");
|
|
||||||
};
|
|
||||||
base.ConditionalExpression = function (node, st, c) {
|
|
||||||
c(node.test, st, "Expression");
|
|
||||||
c(node.consequent, st, "Expression");
|
|
||||||
c(node.alternate, st, "Expression");
|
|
||||||
};
|
|
||||||
base.NewExpression = base.CallExpression = function (node, st, c) {
|
|
||||||
c(node.callee, st, "Expression");
|
|
||||||
if (node.arguments)
|
|
||||||
{ for (var i = 0, list = node.arguments; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var arg = list[i];
|
|
||||||
|
|
||||||
c(arg, st, "Expression");
|
|
||||||
} }
|
|
||||||
};
|
|
||||||
base.MemberExpression = function (node, st, c) {
|
|
||||||
c(node.object, st, "Expression");
|
|
||||||
if (node.computed) { c(node.property, st, "Expression"); }
|
|
||||||
};
|
|
||||||
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
|
|
||||||
if (node.declaration)
|
|
||||||
{ c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); }
|
|
||||||
if (node.source) { c(node.source, st, "Expression"); }
|
|
||||||
};
|
|
||||||
base.ExportAllDeclaration = function (node, st, c) {
|
|
||||||
if (node.exported)
|
|
||||||
{ c(node.exported, st); }
|
|
||||||
c(node.source, st, "Expression");
|
|
||||||
};
|
|
||||||
base.ImportDeclaration = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.specifiers; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var spec = list[i];
|
|
||||||
|
|
||||||
c(spec, st);
|
|
||||||
}
|
|
||||||
c(node.source, st, "Expression");
|
|
||||||
};
|
|
||||||
base.ImportExpression = function (node, st, c) {
|
|
||||||
c(node.source, st, "Expression");
|
|
||||||
};
|
|
||||||
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
|
|
||||||
|
|
||||||
base.TaggedTemplateExpression = function (node, st, c) {
|
|
||||||
c(node.tag, st, "Expression");
|
|
||||||
c(node.quasi, st, "Expression");
|
|
||||||
};
|
|
||||||
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); };
|
|
||||||
base.Class = function (node, st, c) {
|
|
||||||
if (node.id) { c(node.id, st, "Pattern"); }
|
|
||||||
if (node.superClass) { c(node.superClass, st, "Expression"); }
|
|
||||||
c(node.body, st);
|
|
||||||
};
|
|
||||||
base.ClassBody = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.body; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var elt = list[i];
|
|
||||||
|
|
||||||
c(elt, st);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.MethodDefinition = base.PropertyDefinition = base.Property = function (node, st, c) {
|
|
||||||
if (node.computed) { c(node.key, st, "Expression"); }
|
|
||||||
if (node.value) { c(node.value, st, "Expression"); }
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.ancestor = ancestor;
|
|
||||||
exports.base = base;
|
|
||||||
exports.findNodeAfter = findNodeAfter;
|
|
||||||
exports.findNodeAround = findNodeAround;
|
|
||||||
exports.findNodeAt = findNodeAt;
|
|
||||||
exports.findNodeBefore = findNodeBefore;
|
|
||||||
exports.full = full;
|
|
||||||
exports.fullAncestor = fullAncestor;
|
|
||||||
exports.make = make;
|
|
||||||
exports.recursive = recursive;
|
|
||||||
exports.simple = simple;
|
|
||||||
|
|
||||||
Object.defineProperty(exports, '__esModule', { value: true });
|
|
||||||
|
|
||||||
})));
|
|
|
@ -1,443 +0,0 @@
|
||||||
// AST walker module for Mozilla Parser API compatible trees
|
|
||||||
|
|
||||||
// A simple walk is one where you simply specify callbacks to be
|
|
||||||
// called on specific nodes. The last two arguments are optional. A
|
|
||||||
// simple use would be
|
|
||||||
//
|
|
||||||
// walk.simple(myTree, {
|
|
||||||
// Expression: function(node) { ... }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// to do something with all expressions. All Parser API node types
|
|
||||||
// can be used to identify node types, as well as Expression and
|
|
||||||
// Statement, which denote categories of nodes.
|
|
||||||
//
|
|
||||||
// The base argument can be used to pass a custom (recursive)
|
|
||||||
// walker, and state can be used to give this walked an initial
|
|
||||||
// state.
|
|
||||||
|
|
||||||
function simple(node, visitors, baseVisitor, state, override) {
|
|
||||||
if (!baseVisitor) { baseVisitor = base
|
|
||||||
; }(function c(node, st, override) {
|
|
||||||
var type = override || node.type, found = visitors[type];
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
if (found) { found(node, st); }
|
|
||||||
})(node, state, override);
|
|
||||||
}
|
|
||||||
|
|
||||||
// An ancestor walk keeps an array of ancestor nodes (including the
|
|
||||||
// current node) and passes them to the callback as third parameter
|
|
||||||
// (and also as state parameter when no other state is present).
|
|
||||||
function ancestor(node, visitors, baseVisitor, state, override) {
|
|
||||||
var ancestors = [];
|
|
||||||
if (!baseVisitor) { baseVisitor = base
|
|
||||||
; }(function c(node, st, override) {
|
|
||||||
var type = override || node.type, found = visitors[type];
|
|
||||||
var isNew = node !== ancestors[ancestors.length - 1];
|
|
||||||
if (isNew) { ancestors.push(node); }
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
if (found) { found(node, st || ancestors, ancestors); }
|
|
||||||
if (isNew) { ancestors.pop(); }
|
|
||||||
})(node, state, override);
|
|
||||||
}
|
|
||||||
|
|
||||||
// A recursive walk is one where your functions override the default
|
|
||||||
// walkers. They can modify and replace the state parameter that's
|
|
||||||
// threaded through the walk, and can opt how and whether to walk
|
|
||||||
// their child nodes (by calling their third argument on these
|
|
||||||
// nodes).
|
|
||||||
function recursive(node, state, funcs, baseVisitor, override) {
|
|
||||||
var visitor = funcs ? make(funcs, baseVisitor || undefined) : baseVisitor
|
|
||||||
;(function c(node, st, override) {
|
|
||||||
visitor[override || node.type](node, st, c);
|
|
||||||
})(node, state, override);
|
|
||||||
}
|
|
||||||
|
|
||||||
function makeTest(test) {
|
|
||||||
if (typeof test === "string")
|
|
||||||
{ return function (type) { return type === test; } }
|
|
||||||
else if (!test)
|
|
||||||
{ return function () { return true; } }
|
|
||||||
else
|
|
||||||
{ return test }
|
|
||||||
}
|
|
||||||
|
|
||||||
var Found = function Found(node, state) { this.node = node; this.state = state; };
|
|
||||||
|
|
||||||
// A full walk triggers the callback on each node
|
|
||||||
function full(node, callback, baseVisitor, state, override) {
|
|
||||||
if (!baseVisitor) { baseVisitor = base; }
|
|
||||||
var last
|
|
||||||
;(function c(node, st, override) {
|
|
||||||
var type = override || node.type;
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
if (last !== node) {
|
|
||||||
callback(node, st, type);
|
|
||||||
last = node;
|
|
||||||
}
|
|
||||||
})(node, state, override);
|
|
||||||
}
|
|
||||||
|
|
||||||
// An fullAncestor walk is like an ancestor walk, but triggers
|
|
||||||
// the callback on each node
|
|
||||||
function fullAncestor(node, callback, baseVisitor, state) {
|
|
||||||
if (!baseVisitor) { baseVisitor = base; }
|
|
||||||
var ancestors = [], last
|
|
||||||
;(function c(node, st, override) {
|
|
||||||
var type = override || node.type;
|
|
||||||
var isNew = node !== ancestors[ancestors.length - 1];
|
|
||||||
if (isNew) { ancestors.push(node); }
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
if (last !== node) {
|
|
||||||
callback(node, st || ancestors, ancestors, type);
|
|
||||||
last = node;
|
|
||||||
}
|
|
||||||
if (isNew) { ancestors.pop(); }
|
|
||||||
})(node, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find a node with a given start, end, and type (all are optional,
|
|
||||||
// null can be used as wildcard). Returns a {node, state} object, or
|
|
||||||
// undefined when it doesn't find a matching node.
|
|
||||||
function findNodeAt(node, start, end, test, baseVisitor, state) {
|
|
||||||
if (!baseVisitor) { baseVisitor = base; }
|
|
||||||
test = makeTest(test);
|
|
||||||
try {
|
|
||||||
(function c(node, st, override) {
|
|
||||||
var type = override || node.type;
|
|
||||||
if ((start == null || node.start <= start) &&
|
|
||||||
(end == null || node.end >= end))
|
|
||||||
{ baseVisitor[type](node, st, c); }
|
|
||||||
if ((start == null || node.start === start) &&
|
|
||||||
(end == null || node.end === end) &&
|
|
||||||
test(type, node))
|
|
||||||
{ throw new Found(node, st) }
|
|
||||||
})(node, state);
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof Found) { return e }
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the innermost node of a given type that contains the given
|
|
||||||
// position. Interface similar to findNodeAt.
|
|
||||||
function findNodeAround(node, pos, test, baseVisitor, state) {
|
|
||||||
test = makeTest(test);
|
|
||||||
if (!baseVisitor) { baseVisitor = base; }
|
|
||||||
try {
|
|
||||||
(function c(node, st, override) {
|
|
||||||
var type = override || node.type;
|
|
||||||
if (node.start > pos || node.end < pos) { return }
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
if (test(type, node)) { throw new Found(node, st) }
|
|
||||||
})(node, state);
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof Found) { return e }
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the outermost matching node after a given position.
|
|
||||||
function findNodeAfter(node, pos, test, baseVisitor, state) {
|
|
||||||
test = makeTest(test);
|
|
||||||
if (!baseVisitor) { baseVisitor = base; }
|
|
||||||
try {
|
|
||||||
(function c(node, st, override) {
|
|
||||||
if (node.end < pos) { return }
|
|
||||||
var type = override || node.type;
|
|
||||||
if (node.start >= pos && test(type, node)) { throw new Found(node, st) }
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
})(node, state);
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof Found) { return e }
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the outermost matching node before a given position.
|
|
||||||
function findNodeBefore(node, pos, test, baseVisitor, state) {
|
|
||||||
test = makeTest(test);
|
|
||||||
if (!baseVisitor) { baseVisitor = base; }
|
|
||||||
var max
|
|
||||||
;(function c(node, st, override) {
|
|
||||||
if (node.start > pos) { return }
|
|
||||||
var type = override || node.type;
|
|
||||||
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node))
|
|
||||||
{ max = new Found(node, st); }
|
|
||||||
baseVisitor[type](node, st, c);
|
|
||||||
})(node, state);
|
|
||||||
return max
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used to create a custom walker. Will fill in all missing node
|
|
||||||
// type properties with the defaults.
|
|
||||||
function make(funcs, baseVisitor) {
|
|
||||||
var visitor = Object.create(baseVisitor || base);
|
|
||||||
for (var type in funcs) { visitor[type] = funcs[type]; }
|
|
||||||
return visitor
|
|
||||||
}
|
|
||||||
|
|
||||||
function skipThrough(node, st, c) { c(node, st); }
|
|
||||||
function ignore(_node, _st, _c) {}
|
|
||||||
|
|
||||||
// Node walkers.
|
|
||||||
|
|
||||||
var base = {};
|
|
||||||
|
|
||||||
base.Program = base.BlockStatement = base.StaticBlock = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.body; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var stmt = list[i];
|
|
||||||
|
|
||||||
c(stmt, st, "Statement");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.Statement = skipThrough;
|
|
||||||
base.EmptyStatement = ignore;
|
|
||||||
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
|
|
||||||
function (node, st, c) { return c(node.expression, st, "Expression"); };
|
|
||||||
base.IfStatement = function (node, st, c) {
|
|
||||||
c(node.test, st, "Expression");
|
|
||||||
c(node.consequent, st, "Statement");
|
|
||||||
if (node.alternate) { c(node.alternate, st, "Statement"); }
|
|
||||||
};
|
|
||||||
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); };
|
|
||||||
base.BreakStatement = base.ContinueStatement = ignore;
|
|
||||||
base.WithStatement = function (node, st, c) {
|
|
||||||
c(node.object, st, "Expression");
|
|
||||||
c(node.body, st, "Statement");
|
|
||||||
};
|
|
||||||
base.SwitchStatement = function (node, st, c) {
|
|
||||||
c(node.discriminant, st, "Expression");
|
|
||||||
for (var i$1 = 0, list$1 = node.cases; i$1 < list$1.length; i$1 += 1) {
|
|
||||||
var cs = list$1[i$1];
|
|
||||||
|
|
||||||
if (cs.test) { c(cs.test, st, "Expression"); }
|
|
||||||
for (var i = 0, list = cs.consequent; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var cons = list[i];
|
|
||||||
|
|
||||||
c(cons, st, "Statement");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.SwitchCase = function (node, st, c) {
|
|
||||||
if (node.test) { c(node.test, st, "Expression"); }
|
|
||||||
for (var i = 0, list = node.consequent; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var cons = list[i];
|
|
||||||
|
|
||||||
c(cons, st, "Statement");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
|
|
||||||
if (node.argument) { c(node.argument, st, "Expression"); }
|
|
||||||
};
|
|
||||||
base.ThrowStatement = base.SpreadElement =
|
|
||||||
function (node, st, c) { return c(node.argument, st, "Expression"); };
|
|
||||||
base.TryStatement = function (node, st, c) {
|
|
||||||
c(node.block, st, "Statement");
|
|
||||||
if (node.handler) { c(node.handler, st); }
|
|
||||||
if (node.finalizer) { c(node.finalizer, st, "Statement"); }
|
|
||||||
};
|
|
||||||
base.CatchClause = function (node, st, c) {
|
|
||||||
if (node.param) { c(node.param, st, "Pattern"); }
|
|
||||||
c(node.body, st, "Statement");
|
|
||||||
};
|
|
||||||
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
|
|
||||||
c(node.test, st, "Expression");
|
|
||||||
c(node.body, st, "Statement");
|
|
||||||
};
|
|
||||||
base.ForStatement = function (node, st, c) {
|
|
||||||
if (node.init) { c(node.init, st, "ForInit"); }
|
|
||||||
if (node.test) { c(node.test, st, "Expression"); }
|
|
||||||
if (node.update) { c(node.update, st, "Expression"); }
|
|
||||||
c(node.body, st, "Statement");
|
|
||||||
};
|
|
||||||
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
|
|
||||||
c(node.left, st, "ForInit");
|
|
||||||
c(node.right, st, "Expression");
|
|
||||||
c(node.body, st, "Statement");
|
|
||||||
};
|
|
||||||
base.ForInit = function (node, st, c) {
|
|
||||||
if (node.type === "VariableDeclaration") { c(node, st); }
|
|
||||||
else { c(node, st, "Expression"); }
|
|
||||||
};
|
|
||||||
base.DebuggerStatement = ignore;
|
|
||||||
|
|
||||||
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); };
|
|
||||||
base.VariableDeclaration = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.declarations; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var decl = list[i];
|
|
||||||
|
|
||||||
c(decl, st);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.VariableDeclarator = function (node, st, c) {
|
|
||||||
c(node.id, st, "Pattern");
|
|
||||||
if (node.init) { c(node.init, st, "Expression"); }
|
|
||||||
};
|
|
||||||
|
|
||||||
base.Function = function (node, st, c) {
|
|
||||||
if (node.id) { c(node.id, st, "Pattern"); }
|
|
||||||
for (var i = 0, list = node.params; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var param = list[i];
|
|
||||||
|
|
||||||
c(param, st, "Pattern");
|
|
||||||
}
|
|
||||||
c(node.body, st, node.expression ? "Expression" : "Statement");
|
|
||||||
};
|
|
||||||
|
|
||||||
base.Pattern = function (node, st, c) {
|
|
||||||
if (node.type === "Identifier")
|
|
||||||
{ c(node, st, "VariablePattern"); }
|
|
||||||
else if (node.type === "MemberExpression")
|
|
||||||
{ c(node, st, "MemberPattern"); }
|
|
||||||
else
|
|
||||||
{ c(node, st); }
|
|
||||||
};
|
|
||||||
base.VariablePattern = ignore;
|
|
||||||
base.MemberPattern = skipThrough;
|
|
||||||
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); };
|
|
||||||
base.ArrayPattern = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
|
||||||
var elt = list[i];
|
|
||||||
|
|
||||||
if (elt) { c(elt, st, "Pattern"); }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.ObjectPattern = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
|
||||||
var prop = list[i];
|
|
||||||
|
|
||||||
if (prop.type === "Property") {
|
|
||||||
if (prop.computed) { c(prop.key, st, "Expression"); }
|
|
||||||
c(prop.value, st, "Pattern");
|
|
||||||
} else if (prop.type === "RestElement") {
|
|
||||||
c(prop.argument, st, "Pattern");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
base.Expression = skipThrough;
|
|
||||||
base.ThisExpression = base.Super = base.MetaProperty = ignore;
|
|
||||||
base.ArrayExpression = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
|
||||||
var elt = list[i];
|
|
||||||
|
|
||||||
if (elt) { c(elt, st, "Expression"); }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.ObjectExpression = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.properties; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var prop = list[i];
|
|
||||||
|
|
||||||
c(prop, st);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
|
||||||
base.SequenceExpression = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.expressions; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var expr = list[i];
|
|
||||||
|
|
||||||
c(expr, st, "Expression");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.TemplateLiteral = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.quasis; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var quasi = list[i];
|
|
||||||
|
|
||||||
c(quasi, st);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i$1 = 0, list$1 = node.expressions; i$1 < list$1.length; i$1 += 1)
|
|
||||||
{
|
|
||||||
var expr = list$1[i$1];
|
|
||||||
|
|
||||||
c(expr, st, "Expression");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.TemplateElement = ignore;
|
|
||||||
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
|
|
||||||
c(node.argument, st, "Expression");
|
|
||||||
};
|
|
||||||
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
|
|
||||||
c(node.left, st, "Expression");
|
|
||||||
c(node.right, st, "Expression");
|
|
||||||
};
|
|
||||||
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
|
|
||||||
c(node.left, st, "Pattern");
|
|
||||||
c(node.right, st, "Expression");
|
|
||||||
};
|
|
||||||
base.ConditionalExpression = function (node, st, c) {
|
|
||||||
c(node.test, st, "Expression");
|
|
||||||
c(node.consequent, st, "Expression");
|
|
||||||
c(node.alternate, st, "Expression");
|
|
||||||
};
|
|
||||||
base.NewExpression = base.CallExpression = function (node, st, c) {
|
|
||||||
c(node.callee, st, "Expression");
|
|
||||||
if (node.arguments)
|
|
||||||
{ for (var i = 0, list = node.arguments; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var arg = list[i];
|
|
||||||
|
|
||||||
c(arg, st, "Expression");
|
|
||||||
} }
|
|
||||||
};
|
|
||||||
base.MemberExpression = function (node, st, c) {
|
|
||||||
c(node.object, st, "Expression");
|
|
||||||
if (node.computed) { c(node.property, st, "Expression"); }
|
|
||||||
};
|
|
||||||
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
|
|
||||||
if (node.declaration)
|
|
||||||
{ c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); }
|
|
||||||
if (node.source) { c(node.source, st, "Expression"); }
|
|
||||||
};
|
|
||||||
base.ExportAllDeclaration = function (node, st, c) {
|
|
||||||
if (node.exported)
|
|
||||||
{ c(node.exported, st); }
|
|
||||||
c(node.source, st, "Expression");
|
|
||||||
};
|
|
||||||
base.ImportDeclaration = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.specifiers; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var spec = list[i];
|
|
||||||
|
|
||||||
c(spec, st);
|
|
||||||
}
|
|
||||||
c(node.source, st, "Expression");
|
|
||||||
};
|
|
||||||
base.ImportExpression = function (node, st, c) {
|
|
||||||
c(node.source, st, "Expression");
|
|
||||||
};
|
|
||||||
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
|
|
||||||
|
|
||||||
base.TaggedTemplateExpression = function (node, st, c) {
|
|
||||||
c(node.tag, st, "Expression");
|
|
||||||
c(node.quasi, st, "Expression");
|
|
||||||
};
|
|
||||||
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); };
|
|
||||||
base.Class = function (node, st, c) {
|
|
||||||
if (node.id) { c(node.id, st, "Pattern"); }
|
|
||||||
if (node.superClass) { c(node.superClass, st, "Expression"); }
|
|
||||||
c(node.body, st);
|
|
||||||
};
|
|
||||||
base.ClassBody = function (node, st, c) {
|
|
||||||
for (var i = 0, list = node.body; i < list.length; i += 1)
|
|
||||||
{
|
|
||||||
var elt = list[i];
|
|
||||||
|
|
||||||
c(elt, st);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
base.MethodDefinition = base.PropertyDefinition = base.Property = function (node, st, c) {
|
|
||||||
if (node.computed) { c(node.key, st, "Expression"); }
|
|
||||||
if (node.value) { c(node.value, st, "Expression"); }
|
|
||||||
};
|
|
||||||
|
|
||||||
export { ancestor, base, findNodeAfter, findNodeAround, findNodeAt, findNodeBefore, full, fullAncestor, make, recursive, simple };
|
|
|
@ -1,45 +0,0 @@
|
||||||
{
|
|
||||||
"name": "acorn-walk",
|
|
||||||
"description": "ECMAScript (ESTree) AST walker",
|
|
||||||
"homepage": "https://github.com/acornjs/acorn",
|
|
||||||
"main": "dist/walk.js",
|
|
||||||
"types": "dist/walk.d.ts",
|
|
||||||
"module": "dist/walk.mjs",
|
|
||||||
"exports": {
|
|
||||||
".": [
|
|
||||||
{
|
|
||||||
"import": "./dist/walk.mjs",
|
|
||||||
"require": "./dist/walk.js",
|
|
||||||
"default": "./dist/walk.js"
|
|
||||||
},
|
|
||||||
"./dist/walk.js"
|
|
||||||
],
|
|
||||||
"./package.json": "./package.json"
|
|
||||||
},
|
|
||||||
"version": "8.2.0",
|
|
||||||
"engines": {"node": ">=0.4.0"},
|
|
||||||
"maintainers": [
|
|
||||||
{
|
|
||||||
"name": "Marijn Haverbeke",
|
|
||||||
"email": "marijnh@gmail.com",
|
|
||||||
"web": "https://marijnhaverbeke.nl"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Ingvar Stepanyan",
|
|
||||||
"email": "me@rreverser.com",
|
|
||||||
"web": "https://rreverser.com/"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Adrian Heine",
|
|
||||||
"web": "http://adrianheine.de"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/acornjs/acorn.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"prepare": "cd ..; npm run build:walk"
|
|
||||||
},
|
|
||||||
"license": "MIT"
|
|
||||||
}
|
|
|
@ -1,169 +0,0 @@
|
||||||
# Changelog
|
|
||||||
|
|
||||||
For changes in version v7.0.0 and up please go to [release](https://github.com/babel/babel-loader/releases)
|
|
||||||
|
|
||||||
# Old Changelog
|
|
||||||
|
|
||||||
## v6.4.1
|
|
||||||
|
|
||||||
### 🐛 Bug Fix
|
|
||||||
|
|
||||||
- Fixed reset of BABEL_ENV when options.forceEnv is used (#420) @nikopavlica
|
|
||||||
|
|
||||||
## v6.4.0
|
|
||||||
|
|
||||||
### 🚀 New Feature
|
|
||||||
|
|
||||||
- added metadata passing from babel to webpack, which is currently used by react-intl (#398) @Ognian
|
|
||||||
|
|
||||||
## v6.3.2
|
|
||||||
|
|
||||||
### 😢 Regression
|
|
||||||
|
|
||||||
- `forceEnv` was interfering with regular environment handling
|
|
||||||
|
|
||||||
## v6.3.1
|
|
||||||
|
|
||||||
### 🐛 Bug Fix
|
|
||||||
|
|
||||||
- The new `forceEnv` options wasn't working as expected (#379) @chrisvasz
|
|
||||||
|
|
||||||
## v6.3.0
|
|
||||||
|
|
||||||
### 🚀 New Feature
|
|
||||||
|
|
||||||
- Add new config option `forceEnv` (#368) @moimael
|
|
||||||
|
|
||||||
Allow to override BABEL_ENV/NODE_ENV at loader-level. Useful for isomorphic applications which have separate babel config for client and server.
|
|
||||||
|
|
||||||
### 🐛 Bug Fix
|
|
||||||
|
|
||||||
- Update loader-utils dependency to ^0.2.16 to fix compatibility with webpack 2 (#371) @leonaves
|
|
||||||
|
|
||||||
### 💅 Polish
|
|
||||||
|
|
||||||
- Improve FS caching to do less sync calls which improves performance slightly (#375) @akx
|
|
||||||
|
|
||||||
## v6.2.10
|
|
||||||
|
|
||||||
Support for webpack 2.2-rc has been added in this release
|
|
||||||
|
|
||||||
### 🐛 Bug Fix
|
|
||||||
|
|
||||||
- If cache directory not writable, try to fallback to tmpdir before failing
|
|
||||||
|
|
||||||
## v6.2.9
|
|
||||||
|
|
||||||
### 😢 Regression
|
|
||||||
|
|
||||||
Source maps on windows did not work correctly with v6.2.8.
|
|
||||||
Thanks @josephst
|
|
||||||
|
|
||||||
### 🏠 Internal
|
|
||||||
|
|
||||||
- Add AppVeyor to run tests on windows @danez
|
|
||||||
- Fix tests on windows (#343) @danez
|
|
||||||
|
|
||||||
## v6.2.8
|
|
||||||
|
|
||||||
### 🐛 Bug Fix
|
|
||||||
|
|
||||||
- gzipped files should have `.gz` as the extension, not `.gzip` (#326) @bjornstar
|
|
||||||
- fix options.sourceFileName gennerate bug (#260) @creeperyang
|
|
||||||
|
|
||||||
### 📝 Documentation
|
|
||||||
|
|
||||||
- Update README docs for cacheDirectory's actual behaviour (#245) @sohkai
|
|
||||||
- updates docs re: transform-runtime (#197) @gbrassey
|
|
||||||
|
|
||||||
### 🏠 Internal
|
|
||||||
|
|
||||||
- Use eslint and nyc (#321) @danez
|
|
||||||
- Adjust travis config (#320) @danez
|
|
||||||
- Use babel to compile babel-loader (#319) @danez
|
|
||||||
|
|
||||||
## v6.2.7
|
|
||||||
|
|
||||||
### 😢 Regression
|
|
||||||
|
|
||||||
Fallback to `os.tmpdir()` if no cachedir found (#318) (fixes #317) @danez
|
|
||||||
|
|
||||||
Fixes an issue with v6.2.6 when using `babel-loader` as a global package.
|
|
||||||
|
|
||||||
## v6.2.6
|
|
||||||
|
|
||||||
### 🐛 Bug Fix
|
|
||||||
|
|
||||||
- Use standard cache dir as default `cacheDirectory` (#301) @fson
|
|
||||||
|
|
||||||
Use the common cache directory, `./node_modules/.cache/babel-loader`, as the default cache directory (when the cacheDirectory setting is enabled).
|
|
||||||
|
|
||||||
```js
|
|
||||||
query: {
|
|
||||||
cacheDirectory: true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## v6.2.5
|
|
||||||
|
|
||||||
- Don't show the call stack for a Babel error (such as when you have a syntax error)
|
|
||||||
|
|
||||||
<img width="415" alt="screenshot 2016-08-15 15 24 37" src="https://cloud.githubusercontent.com/assets/30594/17664401/727ba098-62fc-11e6-9f12-42da0cf47f14.png">
|
|
||||||
|
|
||||||
- resolve the .babelrc relative to the file path rather than the cwd (current working directory).
|
|
||||||
|
|
||||||
* fix: more concise formatting for Babel errors (#287) (Andrey Popp)
|
|
||||||
* fix(resolve-rc): resolve-rc relative file path (#253) (Luke Page)
|
|
||||||
* add babel-core and preset-2015 to dev dependencies (#273) (timse)
|
|
||||||
* chore(docs): add issue and pr templates (#280) (Joshua Wiens)
|
|
||||||
* chore(docs): fix badge formatting (Joshua Wiens)
|
|
||||||
* chore(ci): expand travis testing (#278) (Joshua Wiens)
|
|
||||||
* Update README: add env vars to cacheIdentifier (#267) (Dominik Ferber)
|
|
||||||
* add npm badge [skip ci] (Henry Zhu)
|
|
||||||
* update [skip ci] (Henry Zhu)
|
|
||||||
* remove jsx references as well [skip ci] (Henry Zhu)
|
|
||||||
* Save the transform to devDependencies (Ray Booysen)
|
|
||||||
* Remove 'react' preset (Jake Rios)
|
|
||||||
* Removed babel-preset-react from README.md (Ben Stephenson)
|
|
||||||
|
|
||||||
## v6.2.4
|
|
||||||
* change allowed peer deps (all webpack 2 beta versions)
|
|
||||||
|
|
||||||
## v6.2.3
|
|
||||||
* change allowed peer deps (2.0.7-beta)
|
|
||||||
|
|
||||||
## v6.2.2
|
|
||||||
* Update peerDependencies to accept webpack 2 [#208](https://github.com/babel/babel-loader/pull/208)
|
|
||||||
* Remove duplicated dependencies
|
|
||||||
|
|
||||||
## v6.2.0
|
|
||||||
* Pass true filenames [#106](https://github.com/babel/babel-loader/issues/106)
|
|
||||||
* Remove babel-core from devDependencies
|
|
||||||
|
|
||||||
## v6.1.0
|
|
||||||
|
|
||||||
* Merge [PR #146](https://github.com/babel/babel-loader/pull/146) Set source file name relative to options.sourceRoot
|
|
||||||
* Merge [PR #136](https://github.com/babel/babel-loader/pull/136) use container-based infrastructure for faster build
|
|
||||||
* Merge [PR #121](https://github.com/babel/babel-loader/pull/121) Make babelrc configurable
|
|
||||||
* Merge [PR #113](https://github.com/babel/babel-loader/pull/113) Include BABEL_ENV || NODE_ENV in cacheIdentifier
|
|
||||||
|
|
||||||
## v6.0.1
|
|
||||||
|
|
||||||
* Update to babel v6.
|
|
||||||
|
|
||||||
## v5.3.1
|
|
||||||
|
|
||||||
* Merge [PR #85](https://github.com/babel/babel-loader/pull/85) - Don't override sourcemap if sourcesContent already exists.
|
|
||||||
|
|
||||||
|
|
||||||
## v5.3.1
|
|
||||||
|
|
||||||
* Merge [PR #82](https://github.com/babel/babel-loader/pull/82) - Fallback global options to empty object to avoid conflicts with object-assign polyfill.
|
|
||||||
|
|
||||||
## v5.3.0
|
|
||||||
|
|
||||||
* Merge [PR #79](https://github.com/babel/babel-loader/pull/79) - This should allow babel-loader to work with [enhanced-require](https://github.com/webpack/enhanced-require).
|
|
||||||
|
|
||||||
## v5.2.0
|
|
||||||
|
|
||||||
* Include `.babelrc` file into the `cacheIdentifier` if it exists
|
|
|
@ -1,22 +0,0 @@
|
||||||
Copyright (c) 2014-2016 Luís Couto <hello@luiscouto.pt>
|
|
||||||
|
|
||||||
MIT License
|
|
||||||
|
|
||||||
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.
|
|
|
@ -1,299 +0,0 @@
|
||||||
> This README is for babel-loader v8 + Babel v7
|
|
||||||
> Check the [7.x branch](https://github.com/babel/babel-loader/tree/7.x) for docs with Babel v6
|
|
||||||
|
|
||||||
[![NPM Status](https://img.shields.io/npm/v/babel-loader.svg?style=flat)](https://www.npmjs.com/package/babel-loader)
|
|
||||||
[![Build Status](https://travis-ci.org/babel/babel-loader.svg?branch=master)](https://travis-ci.org/babel/babel-loader)
|
|
||||||
[![Build Status](https://ci.appveyor.com/api/projects/status/77y5mk6amwqt0q88/branch/master?svg=true)](https://ci.appveyor.com/project/babel/babel-loader/branch/master)
|
|
||||||
[![codecov](https://codecov.io/gh/babel/babel-loader/branch/master/graph/badge.svg)](https://codecov.io/gh/babel/babel-loader)
|
|
||||||
|
|
||||||
<div align="center">
|
|
||||||
<a href="https://github.com/babel/babel">
|
|
||||||
<img src="https://rawgit.com/babel/logo/master/babel.svg" alt="Babel logo" width="200" height="200">
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/webpack/webpack">
|
|
||||||
<img src="https://webpack.js.org/assets/icon-square-big.svg" alt="webpack logo" width="200" height="200">
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h1 align="center">Babel Loader</h1>
|
|
||||||
|
|
||||||
This package allows transpiling JavaScript files using [Babel](https://github.com/babel/babel) and [webpack](https://github.com/webpack/webpack).
|
|
||||||
|
|
||||||
**Note**: Issues with the output should be reported on the Babel [Issues](https://github.com/babel/babel/issues) tracker.
|
|
||||||
|
|
||||||
<h2 align="center">Install</h2>
|
|
||||||
|
|
||||||
> webpack 4.x | babel-loader 8.x | babel 7.x
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install -D babel-loader @babel/core @babel/preset-env webpack
|
|
||||||
```
|
|
||||||
|
|
||||||
> webpack 4.x | babel-loader 7.x | babel 6.x
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install -D babel-loader@7 babel-core babel-preset-env webpack
|
|
||||||
```
|
|
||||||
|
|
||||||
<h2 align="center">Usage</h2>
|
|
||||||
|
|
||||||
webpack documentation: [Loaders](https://webpack.js.org/loaders/)
|
|
||||||
|
|
||||||
Within your webpack configuration object, you'll need to add the babel-loader to the list of modules, like so:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.m?js$/,
|
|
||||||
exclude: /(node_modules|bower_components)/,
|
|
||||||
use: {
|
|
||||||
loader: 'babel-loader',
|
|
||||||
options: {
|
|
||||||
presets: ['@babel/preset-env']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
See the `babel` [options](https://babeljs.io/docs/en/options).
|
|
||||||
|
|
||||||
You can pass options to the loader by using the [`options`](https://webpack.js.org/configuration/module/#rule-options-rule-query) property:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.m?js$/,
|
|
||||||
exclude: /(node_modules|bower_components)/,
|
|
||||||
use: {
|
|
||||||
loader: 'babel-loader',
|
|
||||||
options: {
|
|
||||||
presets: ['@babel/preset-env'],
|
|
||||||
plugins: [require('@babel/plugin-proposal-object-rest-spread')]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
This loader also supports the following loader-specific option:
|
|
||||||
|
|
||||||
* `cacheDirectory`: Default `false`. When set, the given directory will be used to cache the results of the loader. Future webpack builds will attempt to read from the cache to avoid needing to run the potentially expensive Babel recompilation process on each run. If the value is blank (`loader: 'babel-loader?cacheDirectory'`) or `true` (`loader: 'babel-loader?cacheDirectory=true'`), the loader will use the default cache directory in `node_modules/.cache/babel-loader` or fallback to the default OS temporary file directory if no `node_modules` folder could be found in any root directory.
|
|
||||||
|
|
||||||
* `cacheIdentifier`: Default is a string composed by the `babel-core`'s version, the `babel-loader`'s version, the contents of `.babelrc` file if it exists, and the value of the environment variable `BABEL_ENV` with a fallback to the `NODE_ENV` environment variable. This can be set to a custom value to force cache busting if the identifier changes.
|
|
||||||
|
|
||||||
* `cacheCompression`: Default `true`. When set, each Babel transform output will be compressed with Gzip. If you want to opt-out of cache compression, set it to `false` -- your project may benefit from this if it transpiles thousands of files.
|
|
||||||
|
|
||||||
* `customize`: Default `null`. The path of a module that exports a `custom` callback [like the one that you'd pass to `.custom()`](#customized-loader). Since you already have to make a new file to use this, it is recommended that you instead use `.custom` to create a wrapper loader. Only use this is you _must_ continue using `babel-loader` directly, but still want to customize.
|
|
||||||
|
|
||||||
**Note**: The `sourceMap` option is ignored. Instead, source maps are automatically enabled when webpack is configured to use them (via the [`devtool`](https://webpack.js.org/configuration/devtool/#devtool) config option).
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
### babel-loader is slow!
|
|
||||||
|
|
||||||
Make sure you are transforming as few files as possible. Because you are probably matching `/\.m?js$/`, you might be transforming the `node_modules` folder or other unwanted source.
|
|
||||||
|
|
||||||
To exclude `node_modules`, see the `exclude` option in the `loaders` config as documented above.
|
|
||||||
|
|
||||||
You can also speed up babel-loader by as much as 2x by using the `cacheDirectory` option. This will cache transformations to the filesystem.
|
|
||||||
|
|
||||||
### Babel is injecting helpers into each file and bloating my code!
|
|
||||||
|
|
||||||
Babel uses very small helpers for common functions such as `_extend`. By default, this will be added to every file that requires it.
|
|
||||||
|
|
||||||
You can instead require the Babel runtime as a separate module to avoid the duplication.
|
|
||||||
|
|
||||||
The following configuration disables automatic per-file runtime injection in Babel, requiring `babel-plugin-transform-runtime` instead and making all helper references use it.
|
|
||||||
|
|
||||||
See the [docs](https://babeljs.io/docs/plugins/transform-runtime/) for more information.
|
|
||||||
|
|
||||||
**NOTE**: You must run `npm install -D @babel/plugin-transform-runtime` to include this in your project and `babel-runtime` itself as a dependency with `npm install @babel/runtime`.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
rules: [
|
|
||||||
// the 'transform-runtime' plugin tells Babel to
|
|
||||||
// require the runtime instead of inlining it.
|
|
||||||
{
|
|
||||||
test: /\.m?js$/,
|
|
||||||
exclude: /(node_modules|bower_components)/,
|
|
||||||
use: {
|
|
||||||
loader: 'babel-loader',
|
|
||||||
options: {
|
|
||||||
presets: ['@babel/preset-env'],
|
|
||||||
plugins: ['@babel/plugin-transform-runtime']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
```
|
|
||||||
|
|
||||||
#### **NOTE**: transform-runtime & custom polyfills (e.g. Promise library)
|
|
||||||
|
|
||||||
Since [babel-plugin-transform-runtime](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime) includes a polyfill that includes a custom [regenerator-runtime](https://github.com/facebook/regenerator/blob/master/packages/regenerator-runtime/runtime.js) and [core-js](https://github.com/zloirock/core-js), the following usual shimming method using `webpack.ProvidePlugin` will not work:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
// ...
|
|
||||||
new webpack.ProvidePlugin({
|
|
||||||
'Promise': 'bluebird'
|
|
||||||
}),
|
|
||||||
// ...
|
|
||||||
```
|
|
||||||
|
|
||||||
The following approach will not work either:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
require('@babel/runtime/core-js/promise').default = require('bluebird');
|
|
||||||
|
|
||||||
var promise = new Promise;
|
|
||||||
```
|
|
||||||
|
|
||||||
which outputs to (using `runtime`):
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var _Promise = require('@babel/runtime/core-js/promise')['default'];
|
|
||||||
|
|
||||||
require('@babel/runtime/core-js/promise')['default'] = require('bluebird');
|
|
||||||
|
|
||||||
var promise = new _Promise();
|
|
||||||
```
|
|
||||||
|
|
||||||
The previous `Promise` library is referenced and used before it is overridden.
|
|
||||||
|
|
||||||
One approach is to have a "bootstrap" step in your application that would first override the default globals before your application:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
// bootstrap.js
|
|
||||||
|
|
||||||
require('@babel/runtime/core-js/promise').default = require('bluebird');
|
|
||||||
|
|
||||||
// ...
|
|
||||||
|
|
||||||
require('./app');
|
|
||||||
```
|
|
||||||
|
|
||||||
### The Node.js API for `babel` has been moved to `babel-core`.
|
|
||||||
|
|
||||||
If you receive this message, it means that you have the npm package `babel` installed and are using the short notation of the loader in the webpack config (which is not valid anymore as of webpack 2.x):
|
|
||||||
```javascript
|
|
||||||
{
|
|
||||||
test: /\.m?js$/,
|
|
||||||
loader: 'babel',
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
webpack then tries to load the `babel` package instead of the `babel-loader`.
|
|
||||||
|
|
||||||
To fix this, you should uninstall the npm package `babel`, as it is deprecated in Babel v6. (Instead, install `babel-cli` or `babel-core`.)
|
|
||||||
In the case one of your dependencies is installing `babel` and you cannot uninstall it yourself, use the complete name of the loader in the webpack config:
|
|
||||||
```javascript
|
|
||||||
{
|
|
||||||
test: /\.m?js$/,
|
|
||||||
loader: 'babel-loader',
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Customized Loader
|
|
||||||
|
|
||||||
`babel-loader` exposes a loader-builder utility that allows users to add custom handling
|
|
||||||
of Babel's configuration for each file that it processes.
|
|
||||||
|
|
||||||
`.custom` accepts a callback that will be called with the loader's instance of
|
|
||||||
`babel` so that tooling can ensure that it using exactly the same `@babel/core`
|
|
||||||
instance as the loader itself.
|
|
||||||
|
|
||||||
In cases where you want to customize without actually having a file to call `.custom`, you
|
|
||||||
may also pass the `customize` option with a string pointing at a file that exports
|
|
||||||
your `custom` callback function.
|
|
||||||
|
|
||||||
### Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Export from "./my-custom-loader.js" or whatever you want.
|
|
||||||
module.exports = require("babel-loader").custom(babel => {
|
|
||||||
function myPlugin() {
|
|
||||||
return {
|
|
||||||
visitor: {},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
// Passed the loader options.
|
|
||||||
customOptions({ opt1, opt2, ...loader }) {
|
|
||||||
return {
|
|
||||||
// Pull out any custom options that the loader might have.
|
|
||||||
custom: { opt1, opt2 },
|
|
||||||
|
|
||||||
// Pass the options back with the two custom options removed.
|
|
||||||
loader,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
// Passed Babel's 'PartialConfig' object.
|
|
||||||
config(cfg) {
|
|
||||||
if (cfg.hasFilesystemConfig()) {
|
|
||||||
// Use the normal config
|
|
||||||
return cfg.options;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
...cfg.options,
|
|
||||||
plugins: [
|
|
||||||
...(cfg.options.plugins || []),
|
|
||||||
|
|
||||||
// Include a custom plugin in the options.
|
|
||||||
myPlugin,
|
|
||||||
],
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
result(result) {
|
|
||||||
return {
|
|
||||||
...result,
|
|
||||||
code: result.code + "\n// Generated by some custom loader",
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
// And in your Webpack config
|
|
||||||
module.exports = {
|
|
||||||
// ..
|
|
||||||
module: {
|
|
||||||
rules: [{
|
|
||||||
// ...
|
|
||||||
loader: path.join(__dirname, 'my-custom-loader.js'),
|
|
||||||
// ...
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### `customOptions(options: Object): { custom: Object, loader: Object }`
|
|
||||||
|
|
||||||
Given the loader's options, split custom options out of `babel-loader`'s
|
|
||||||
options.
|
|
||||||
|
|
||||||
|
|
||||||
### `config(cfg: PartialConfig): Object`
|
|
||||||
|
|
||||||
Given Babel's `PartialConfig` object, return the `options` object that should
|
|
||||||
be passed to `babel.transform`.
|
|
||||||
|
|
||||||
|
|
||||||
### `result(result: Result): Result`
|
|
||||||
|
|
||||||
Given Babel's result object, allow loaders to make additional tweaks to it.
|
|
||||||
|
|
||||||
|
|
||||||
## [License](https://couto.mit-license.org/)
|
|
|
@ -1,36 +0,0 @@
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const STRIP_FILENAME_RE = /^[^:]+: /;
|
|
||||||
|
|
||||||
const format = err => {
|
|
||||||
if (err instanceof SyntaxError) {
|
|
||||||
err.name = "SyntaxError";
|
|
||||||
err.message = err.message.replace(STRIP_FILENAME_RE, "");
|
|
||||||
err.hideStack = true;
|
|
||||||
} else if (err instanceof TypeError) {
|
|
||||||
err.name = null;
|
|
||||||
err.message = err.message.replace(STRIP_FILENAME_RE, "");
|
|
||||||
err.hideStack = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
};
|
|
||||||
|
|
||||||
class LoaderError extends Error {
|
|
||||||
constructor(err) {
|
|
||||||
super();
|
|
||||||
const {
|
|
||||||
name,
|
|
||||||
message,
|
|
||||||
codeFrame,
|
|
||||||
hideStack
|
|
||||||
} = format(err);
|
|
||||||
this.name = "BabelLoaderError";
|
|
||||||
this.message = `${name ? `${name}: ` : ""}${message}\n\n${codeFrame}\n`;
|
|
||||||
this.hideStack = hideStack;
|
|
||||||
Error.captureStackTrace(this, this.constructor);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = LoaderError;
|
|
|
@ -1,222 +0,0 @@
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
||||||
|
|
||||||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filesystem Cache
|
|
||||||
*
|
|
||||||
* Given a file and a transform function, cache the result into files
|
|
||||||
* or retrieve the previously cached files if the given file is already known.
|
|
||||||
*
|
|
||||||
* @see https://github.com/babel/babel-loader/issues/34
|
|
||||||
* @see https://github.com/babel/babel-loader/pull/41
|
|
||||||
*/
|
|
||||||
const fs = require("fs");
|
|
||||||
|
|
||||||
const os = require("os");
|
|
||||||
|
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
const zlib = require("zlib");
|
|
||||||
|
|
||||||
const crypto = require("crypto");
|
|
||||||
|
|
||||||
const mkdirpOrig = require("mkdirp");
|
|
||||||
|
|
||||||
const findCacheDir = require("find-cache-dir");
|
|
||||||
|
|
||||||
const promisify = require("util.promisify");
|
|
||||||
|
|
||||||
const transform = require("./transform"); // Lazily instantiated when needed
|
|
||||||
|
|
||||||
|
|
||||||
let defaultCacheDirectory = null;
|
|
||||||
const readFile = promisify(fs.readFile);
|
|
||||||
const writeFile = promisify(fs.writeFile);
|
|
||||||
const gunzip = promisify(zlib.gunzip);
|
|
||||||
const gzip = promisify(zlib.gzip);
|
|
||||||
const mkdirp = promisify(mkdirpOrig);
|
|
||||||
/**
|
|
||||||
* Read the contents from the compressed file.
|
|
||||||
*
|
|
||||||
* @async
|
|
||||||
* @params {String} filename
|
|
||||||
*/
|
|
||||||
|
|
||||||
const read =
|
|
||||||
/*#__PURE__*/
|
|
||||||
function () {
|
|
||||||
var _ref = _asyncToGenerator(function* (filename, compress) {
|
|
||||||
const data = yield readFile(filename + (compress ? ".gz" : ""));
|
|
||||||
const content = compress ? yield gunzip(data) : data;
|
|
||||||
return JSON.parse(content.toString());
|
|
||||||
});
|
|
||||||
|
|
||||||
return function read(_x, _x2) {
|
|
||||||
return _ref.apply(this, arguments);
|
|
||||||
};
|
|
||||||
}();
|
|
||||||
/**
|
|
||||||
* Write contents into a compressed file.
|
|
||||||
*
|
|
||||||
* @async
|
|
||||||
* @params {String} filename
|
|
||||||
* @params {String} result
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
const write =
|
|
||||||
/*#__PURE__*/
|
|
||||||
function () {
|
|
||||||
var _ref2 = _asyncToGenerator(function* (filename, compress, result) {
|
|
||||||
const content = JSON.stringify(result);
|
|
||||||
const data = compress ? yield gzip(content) : content;
|
|
||||||
return yield writeFile(filename + (compress ? ".gz" : ""), data);
|
|
||||||
});
|
|
||||||
|
|
||||||
return function write(_x3, _x4, _x5) {
|
|
||||||
return _ref2.apply(this, arguments);
|
|
||||||
};
|
|
||||||
}();
|
|
||||||
/**
|
|
||||||
* Build the filename for the cached file
|
|
||||||
*
|
|
||||||
* @params {String} source File source code
|
|
||||||
* @params {Object} options Options used
|
|
||||||
*
|
|
||||||
* @return {String}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
const filename = function (source, identifier, options) {
|
|
||||||
const hash = crypto.createHash("md4");
|
|
||||||
const contents = JSON.stringify({
|
|
||||||
source,
|
|
||||||
options,
|
|
||||||
identifier
|
|
||||||
});
|
|
||||||
hash.update(contents);
|
|
||||||
return hash.digest("hex") + ".json";
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Handle the cache
|
|
||||||
*
|
|
||||||
* @params {String} directory
|
|
||||||
* @params {Object} params
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
const handleCache =
|
|
||||||
/*#__PURE__*/
|
|
||||||
function () {
|
|
||||||
var _ref3 = _asyncToGenerator(function* (directory, params) {
|
|
||||||
const {
|
|
||||||
source,
|
|
||||||
options = {},
|
|
||||||
cacheIdentifier,
|
|
||||||
cacheDirectory,
|
|
||||||
cacheCompression
|
|
||||||
} = params;
|
|
||||||
const file = path.join(directory, filename(source, cacheIdentifier, options));
|
|
||||||
|
|
||||||
try {
|
|
||||||
// No errors mean that the file was previously cached
|
|
||||||
// we just need to return it
|
|
||||||
return yield read(file, cacheCompression);
|
|
||||||
} catch (err) {}
|
|
||||||
|
|
||||||
const fallback = typeof cacheDirectory !== "string" && directory !== os.tmpdir(); // Make sure the directory exists.
|
|
||||||
|
|
||||||
try {
|
|
||||||
yield mkdirp(directory);
|
|
||||||
} catch (err) {
|
|
||||||
if (fallback) {
|
|
||||||
return handleCache(os.tmpdir(), params);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw err;
|
|
||||||
} // Otherwise just transform the file
|
|
||||||
// return it to the user asap and write it in cache
|
|
||||||
|
|
||||||
|
|
||||||
const result = yield transform(source, options);
|
|
||||||
|
|
||||||
try {
|
|
||||||
yield write(file, cacheCompression, result);
|
|
||||||
} catch (err) {
|
|
||||||
if (fallback) {
|
|
||||||
// Fallback to tmpdir if node_modules folder not writable
|
|
||||||
return handleCache(os.tmpdir(), params);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
|
|
||||||
return function handleCache(_x6, _x7) {
|
|
||||||
return _ref3.apply(this, arguments);
|
|
||||||
};
|
|
||||||
}();
|
|
||||||
/**
|
|
||||||
* Retrieve file from cache, or create a new one for future reads
|
|
||||||
*
|
|
||||||
* @async
|
|
||||||
* @param {Object} params
|
|
||||||
* @param {String} params.directory Directory to store cached files
|
|
||||||
* @param {String} params.identifier Unique identifier to bust cache
|
|
||||||
* @param {String} params.source Original contents of the file to be cached
|
|
||||||
* @param {Object} params.options Options to be given to the transform fn
|
|
||||||
* @param {Function} params.transform Function that will transform the
|
|
||||||
* original file and whose result will be
|
|
||||||
* cached
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* cache({
|
|
||||||
* directory: '.tmp/cache',
|
|
||||||
* identifier: 'babel-loader-cachefile',
|
|
||||||
* cacheCompression: false,
|
|
||||||
* source: *source code from file*,
|
|
||||||
* options: {
|
|
||||||
* experimental: true,
|
|
||||||
* runtime: true
|
|
||||||
* },
|
|
||||||
* transform: function(source, options) {
|
|
||||||
* var content = *do what you need with the source*
|
|
||||||
* return content;
|
|
||||||
* }
|
|
||||||
* }, function(err, result) {
|
|
||||||
*
|
|
||||||
* });
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
module.exports =
|
|
||||||
/*#__PURE__*/
|
|
||||||
function () {
|
|
||||||
var _ref4 = _asyncToGenerator(function* (params) {
|
|
||||||
let directory;
|
|
||||||
|
|
||||||
if (typeof params.cacheDirectory === "string") {
|
|
||||||
directory = params.cacheDirectory;
|
|
||||||
} else {
|
|
||||||
if (defaultCacheDirectory === null) {
|
|
||||||
defaultCacheDirectory = findCacheDir({
|
|
||||||
name: "babel-loader"
|
|
||||||
}) || os.tmpdir();
|
|
||||||
}
|
|
||||||
|
|
||||||
directory = defaultCacheDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
return yield handleCache(directory, params);
|
|
||||||
});
|
|
||||||
|
|
||||||
return function (_x8) {
|
|
||||||
return _ref4.apply(this, arguments);
|
|
||||||
};
|
|
||||||
}();
|
|
|
@ -1,221 +0,0 @@
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
||||||
|
|
||||||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
||||||
|
|
||||||
let babel;
|
|
||||||
|
|
||||||
try {
|
|
||||||
babel = require("@babel/core");
|
|
||||||
} catch (err) {
|
|
||||||
if (err.code === "MODULE_NOT_FOUND") {
|
|
||||||
err.message += "\n babel-loader@8 requires Babel 7.x (the package '@babel/core'). " + "If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'.";
|
|
||||||
}
|
|
||||||
|
|
||||||
throw err;
|
|
||||||
} // Since we've got the reverse bridge package at @babel/core@6.x, give
|
|
||||||
// people useful feedback if they try to use it alongside babel-loader.
|
|
||||||
|
|
||||||
|
|
||||||
if (/^6\./.test(babel.version)) {
|
|
||||||
throw new Error("\n babel-loader@8 will not work with the '@babel/core@6' bridge package. " + "If you want to use Babel 6.x, install 'babel-loader@7'.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const pkg = require("../package.json");
|
|
||||||
|
|
||||||
const cache = require("./cache");
|
|
||||||
|
|
||||||
const transform = require("./transform");
|
|
||||||
|
|
||||||
const injectCaller = require("./injectCaller");
|
|
||||||
|
|
||||||
const path = require("path");
|
|
||||||
|
|
||||||
const loaderUtils = require("loader-utils");
|
|
||||||
|
|
||||||
function subscribe(subscriber, metadata, context) {
|
|
||||||
if (context[subscriber]) {
|
|
||||||
context[subscriber](metadata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = makeLoader();
|
|
||||||
module.exports.custom = makeLoader;
|
|
||||||
|
|
||||||
function makeLoader(callback) {
|
|
||||||
const overrides = callback ? callback(babel) : undefined;
|
|
||||||
return function (source, inputSourceMap) {
|
|
||||||
// Make the loader async
|
|
||||||
const callback = this.async();
|
|
||||||
loader.call(this, source, inputSourceMap, overrides).then(args => callback(null, ...args), err => callback(err));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function loader(_x, _x2, _x3) {
|
|
||||||
return _loader.apply(this, arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
function _loader() {
|
|
||||||
_loader = _asyncToGenerator(function* (source, inputSourceMap, overrides) {
|
|
||||||
const filename = this.resourcePath;
|
|
||||||
let loaderOptions = loaderUtils.getOptions(this) || {};
|
|
||||||
|
|
||||||
if (loaderOptions.customize != null) {
|
|
||||||
if (typeof loaderOptions.customize !== "string") {
|
|
||||||
throw new Error("Customized loaders must be implemented as standalone modules.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!path.isAbsolute(loaderOptions.customize)) {
|
|
||||||
throw new Error("Customized loaders must be passed as absolute paths, since " + "babel-loader has no way to know what they would be relative to.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (overrides) {
|
|
||||||
throw new Error("babel-loader's 'customize' option is not available when already " + "using a customized babel-loader wrapper.");
|
|
||||||
}
|
|
||||||
|
|
||||||
let override = require(loaderOptions.customize);
|
|
||||||
|
|
||||||
if (override.__esModule) override = override.default;
|
|
||||||
|
|
||||||
if (typeof override !== "function") {
|
|
||||||
throw new Error("Custom overrides must be functions.");
|
|
||||||
}
|
|
||||||
|
|
||||||
overrides = override(babel);
|
|
||||||
}
|
|
||||||
|
|
||||||
let customOptions;
|
|
||||||
|
|
||||||
if (overrides && overrides.customOptions) {
|
|
||||||
const result = yield overrides.customOptions.call(this, loaderOptions, {
|
|
||||||
source,
|
|
||||||
map: inputSourceMap
|
|
||||||
});
|
|
||||||
customOptions = result.custom;
|
|
||||||
loaderOptions = result.loader;
|
|
||||||
} // Deprecation handling
|
|
||||||
|
|
||||||
|
|
||||||
if ("forceEnv" in loaderOptions) {
|
|
||||||
console.warn("The option `forceEnv` has been removed in favor of `envName` in Babel 7.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof loaderOptions.babelrc === "string") {
|
|
||||||
console.warn("The option `babelrc` should not be set to a string anymore in the babel-loader config. " + "Please update your configuration and set `babelrc` to true or false.\n" + "If you want to specify a specific babel config file to inherit config from " + "please use the `extends` option.\nFor more information about this options see " + "https://babeljs.io/docs/core-packages/#options");
|
|
||||||
} // Standardize on 'sourceMaps' as the key passed through to Webpack, so that
|
|
||||||
// users may safely use either one alongside our default use of
|
|
||||||
// 'this.sourceMap' below without getting error about conflicting aliases.
|
|
||||||
|
|
||||||
|
|
||||||
if (Object.prototype.hasOwnProperty.call(loaderOptions, "sourceMap") && !Object.prototype.hasOwnProperty.call(loaderOptions, "sourceMaps")) {
|
|
||||||
loaderOptions = Object.assign({}, loaderOptions, {
|
|
||||||
sourceMaps: loaderOptions.sourceMap
|
|
||||||
});
|
|
||||||
delete loaderOptions.sourceMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
const programmaticOptions = Object.assign({}, loaderOptions, {
|
|
||||||
filename,
|
|
||||||
inputSourceMap: inputSourceMap || undefined,
|
|
||||||
// Set the default sourcemap behavior based on Webpack's mapping flag,
|
|
||||||
// but allow users to override if they want.
|
|
||||||
sourceMaps: loaderOptions.sourceMaps === undefined ? this.sourceMap : loaderOptions.sourceMaps,
|
|
||||||
// Ensure that Webpack will get a full absolute path in the sourcemap
|
|
||||||
// so that it can properly map the module back to its internal cached
|
|
||||||
// modules.
|
|
||||||
sourceFileName: filename
|
|
||||||
}); // Remove loader related options
|
|
||||||
|
|
||||||
delete programmaticOptions.customize;
|
|
||||||
delete programmaticOptions.cacheDirectory;
|
|
||||||
delete programmaticOptions.cacheIdentifier;
|
|
||||||
delete programmaticOptions.cacheCompression;
|
|
||||||
delete programmaticOptions.metadataSubscribers;
|
|
||||||
|
|
||||||
if (!babel.loadPartialConfig) {
|
|
||||||
throw new Error(`babel-loader ^8.0.0-beta.3 requires @babel/core@7.0.0-beta.41, but ` + `you appear to be using "${babel.version}". Either update your ` + `@babel/core version, or pin you babel-loader version to 8.0.0-beta.2`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const config = babel.loadPartialConfig(injectCaller(programmaticOptions));
|
|
||||||
|
|
||||||
if (config) {
|
|
||||||
let options = config.options;
|
|
||||||
|
|
||||||
if (overrides && overrides.config) {
|
|
||||||
options = yield overrides.config.call(this, config, {
|
|
||||||
source,
|
|
||||||
map: inputSourceMap,
|
|
||||||
customOptions
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.sourceMaps === "inline") {
|
|
||||||
// Babel has this weird behavior where if you set "inline", we
|
|
||||||
// inline the sourcemap, and set 'result.map = null'. This results
|
|
||||||
// in bad behavior from Babel since the maps get put into the code,
|
|
||||||
// which Webpack does not expect, and because the map we return to
|
|
||||||
// Webpack is null, which is also bad. To avoid that, we override the
|
|
||||||
// behavior here so "inline" just behaves like 'true'.
|
|
||||||
options.sourceMaps = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
|
||||||
cacheDirectory = null,
|
|
||||||
cacheIdentifier = JSON.stringify({
|
|
||||||
options,
|
|
||||||
"@babel/core": transform.version,
|
|
||||||
"@babel/loader": pkg.version
|
|
||||||
}),
|
|
||||||
cacheCompression = true,
|
|
||||||
metadataSubscribers = []
|
|
||||||
} = loaderOptions;
|
|
||||||
let result;
|
|
||||||
|
|
||||||
if (cacheDirectory) {
|
|
||||||
result = yield cache({
|
|
||||||
source,
|
|
||||||
options,
|
|
||||||
transform,
|
|
||||||
cacheDirectory,
|
|
||||||
cacheIdentifier,
|
|
||||||
cacheCompression
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
result = yield transform(source, options);
|
|
||||||
} // TODO: Babel should really provide the full list of config files that
|
|
||||||
// were used so that this can also handle files loaded with 'extends'.
|
|
||||||
|
|
||||||
|
|
||||||
if (typeof config.babelrc === "string") {
|
|
||||||
this.addDependency(config.babelrc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
if (overrides && overrides.result) {
|
|
||||||
result = yield overrides.result.call(this, result, {
|
|
||||||
source,
|
|
||||||
map: inputSourceMap,
|
|
||||||
customOptions,
|
|
||||||
config,
|
|
||||||
options
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
|
||||||
code,
|
|
||||||
map,
|
|
||||||
metadata
|
|
||||||
} = result;
|
|
||||||
metadataSubscribers.forEach(subscriber => {
|
|
||||||
subscribe(subscriber, metadata, this);
|
|
||||||
});
|
|
||||||
return [code, map];
|
|
||||||
}
|
|
||||||
} // If the file was ignored, pass through the original content.
|
|
||||||
|
|
||||||
|
|
||||||
return [source, inputSourceMap];
|
|
||||||
});
|
|
||||||
return _loader.apply(this, arguments);
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const babel = require("@babel/core");
|
|
||||||
|
|
||||||
module.exports = function injectCaller(opts) {
|
|
||||||
if (!supportsCallerOption()) return opts;
|
|
||||||
return Object.assign({}, opts, {
|
|
||||||
caller: Object.assign({
|
|
||||||
name: "babel-loader",
|
|
||||||
// Webpack >= 2 supports ESM and dynamic import.
|
|
||||||
supportsStaticESM: true,
|
|
||||||
supportsDynamicImport: true
|
|
||||||
}, opts.caller)
|
|
||||||
});
|
|
||||||
}; // TODO: We can remove this eventually, I'm just adding it so that people have
|
|
||||||
// a little time to migrate to the newer RCs of @babel/core without getting
|
|
||||||
// hard-to-diagnose errors about unknown 'caller' options.
|
|
||||||
|
|
||||||
|
|
||||||
let supportsCallerOptionFlag = undefined;
|
|
||||||
|
|
||||||
function supportsCallerOption() {
|
|
||||||
if (supportsCallerOptionFlag === undefined) {
|
|
||||||
try {
|
|
||||||
// Rather than try to match the Babel version, we just see if it throws
|
|
||||||
// when passed a 'caller' flag, and use that to decide if it is supported.
|
|
||||||
babel.loadPartialConfig({
|
|
||||||
caller: undefined,
|
|
||||||
babelrc: false,
|
|
||||||
configFile: false
|
|
||||||
});
|
|
||||||
supportsCallerOptionFlag = true;
|
|
||||||
} catch (err) {
|
|
||||||
supportsCallerOptionFlag = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return supportsCallerOptionFlag;
|
|
||||||
}
|
|
|
@ -1,59 +0,0 @@
|
||||||
"use strict";
|
|
||||||
|
|
||||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
||||||
|
|
||||||
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
||||||
|
|
||||||
const babel = require("@babel/core");
|
|
||||||
|
|
||||||
const promisify = require("util.promisify");
|
|
||||||
|
|
||||||
const LoaderError = require("./Error");
|
|
||||||
|
|
||||||
const transform = promisify(babel.transform);
|
|
||||||
|
|
||||||
module.exports =
|
|
||||||
/*#__PURE__*/
|
|
||||||
function () {
|
|
||||||
var _ref = _asyncToGenerator(function* (source, options) {
|
|
||||||
let result;
|
|
||||||
|
|
||||||
try {
|
|
||||||
result = yield transform(source, options);
|
|
||||||
} catch (err) {
|
|
||||||
throw err.message && err.codeFrame ? new LoaderError(err) : err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!result) return null; // We don't return the full result here because some entries are not
|
|
||||||
// really serializable. For a full list of properties see here:
|
|
||||||
// https://github.com/babel/babel/blob/master/packages/babel-core/src/transformation/index.js
|
|
||||||
// For discussion on this topic see here:
|
|
||||||
// https://github.com/babel/babel-loader/pull/629
|
|
||||||
|
|
||||||
const {
|
|
||||||
ast,
|
|
||||||
code,
|
|
||||||
map,
|
|
||||||
metadata,
|
|
||||||
sourceType
|
|
||||||
} = result;
|
|
||||||
|
|
||||||
if (map && (!map.sourcesContent || !map.sourcesContent.length)) {
|
|
||||||
map.sourcesContent = [source];
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
ast,
|
|
||||||
code,
|
|
||||||
map,
|
|
||||||
metadata,
|
|
||||||
sourceType
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return function (_x, _x2) {
|
|
||||||
return _ref.apply(this, arguments);
|
|
||||||
};
|
|
||||||
}();
|
|
||||||
|
|
||||||
module.exports.version = babel.version;
|
|
|
@ -1,118 +0,0 @@
|
||||||
{
|
|
||||||
"name": "babel-loader",
|
|
||||||
"version": "8.0.4",
|
|
||||||
"description": "babel module loader for webpack",
|
|
||||||
"files": [
|
|
||||||
"lib"
|
|
||||||
],
|
|
||||||
"main": "lib/index.js",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 6.9"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"find-cache-dir": "^1.0.0",
|
|
||||||
"loader-utils": "^1.0.2",
|
|
||||||
"mkdirp": "^0.5.1",
|
|
||||||
"util.promisify": "^1.0.0"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"@babel/core": "^7.0.0",
|
|
||||||
"webpack": ">=2"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@babel/cli": "^7.0.0",
|
|
||||||
"@babel/core": "^7.0.0",
|
|
||||||
"@babel/preset-env": "^7.0.0",
|
|
||||||
"ava": "0.25.0",
|
|
||||||
"babel-eslint": "^8.0.0",
|
|
||||||
"babel-plugin-istanbul": "^4.0.0",
|
|
||||||
"babel-plugin-react-intl": "^2.1.3",
|
|
||||||
"cross-env": "^5.0.0",
|
|
||||||
"eslint": "^4.1.0",
|
|
||||||
"eslint-config-babel": "^8.0.0",
|
|
||||||
"eslint-plugin-flowtype": "^2.25.0",
|
|
||||||
"eslint-plugin-prettier": "^2.1.2",
|
|
||||||
"husky": "^0.14.0",
|
|
||||||
"lint-staged": "^7.1.0",
|
|
||||||
"nyc": "^11.0.1",
|
|
||||||
"prettier": "^1.2.2",
|
|
||||||
"react": "^16.0.0",
|
|
||||||
"react-intl": "^2.1.2",
|
|
||||||
"react-intl-webpack-plugin": "^0.0.3",
|
|
||||||
"rimraf": "^2.4.3",
|
|
||||||
"webpack": "^4.0.0"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"clean": "rimraf lib/",
|
|
||||||
"build": "babel src/ --out-dir lib/",
|
|
||||||
"format": "prettier --write --trailing-comma all 'src/**/*.js' 'test/**/*.test.js' 'test/helpers/*.js' && prettier --write --trailing-comma es5 'scripts/*.js'",
|
|
||||||
"lint": "eslint src test",
|
|
||||||
"precommit": "lint-staged",
|
|
||||||
"prepublish": "yarn run clean && yarn run build",
|
|
||||||
"preversion": "yarn run test",
|
|
||||||
"test": "yarn run lint && cross-env BABEL_ENV=test yarn run build && yarn run test-only",
|
|
||||||
"test-only": "nyc ava"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/babel/babel-loader.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"webpack",
|
|
||||||
"loader",
|
|
||||||
"babel",
|
|
||||||
"es6",
|
|
||||||
"transpiler",
|
|
||||||
"module"
|
|
||||||
],
|
|
||||||
"author": "Luis Couto <hello@luiscouto.pt>",
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/babel/babel-loader/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/babel/babel-loader",
|
|
||||||
"nyc": {
|
|
||||||
"all": true,
|
|
||||||
"include": [
|
|
||||||
"src/**/*.js"
|
|
||||||
],
|
|
||||||
"reporter": [
|
|
||||||
"text",
|
|
||||||
"json"
|
|
||||||
],
|
|
||||||
"sourceMap": false,
|
|
||||||
"instrument": false
|
|
||||||
},
|
|
||||||
"ava": {
|
|
||||||
"files": [
|
|
||||||
"test/**/*.test.js",
|
|
||||||
"!test/fixtures/**/*",
|
|
||||||
"!test/helpers/**/*"
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"src/**/*.js"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"lint-staged": {
|
|
||||||
"scripts/*.js": [
|
|
||||||
"prettier --trailing-comma es5 --write",
|
|
||||||
"git add"
|
|
||||||
],
|
|
||||||
"src/**/*.js": [
|
|
||||||
"prettier --trailing-comma all --write",
|
|
||||||
"git add"
|
|
||||||
],
|
|
||||||
"test/**/*.test.js": [
|
|
||||||
"prettier --trailing-comma all --write",
|
|
||||||
"git add"
|
|
||||||
],
|
|
||||||
"test/helpers/*.js": [
|
|
||||||
"prettier --trailing-comma all --write",
|
|
||||||
"git add"
|
|
||||||
],
|
|
||||||
"package.json": [
|
|
||||||
"node ./scripts/yarn-install.js",
|
|
||||||
"git add yarn.lock"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
../prettier/bin-prettier.js
|
|
|
@ -1 +1 @@
|
||||||
../ansi-html/bin/ansi-html
|
../ansi-html-community/bin/ansi-html
|
|
@ -1 +0,0 @@
|
||||||
../atob/bin/atob.js
|
|
|
@ -1 +0,0 @@
|
||||||
../babylon/bin/babylon.js
|
|
|
@ -0,0 +1 @@
|
||||||
|
../css-blank-pseudo/dist/cli.cjs
|
|
@ -0,0 +1 @@
|
||||||
|
../css-has-pseudo/dist/cli.cjs
|
|
@ -0,0 +1 @@
|
||||||
|
../css-prefers-color-scheme/dist/cli.cjs
|
|
@ -0,0 +1 @@
|
||||||
|
../detective/bin/detective.js
|
|
@ -0,0 +1 @@
|
||||||
|
../ejs/bin/cli.js
|
|
@ -1 +0,0 @@
|
||||||
../errno/cli.js
|
|
|
@ -1 +0,0 @@
|
||||||
../handlebars/bin/handlebars
|
|
|
@ -1 +0,0 @@
|
||||||
../html-minifier/cli.js
|
|
|
@ -0,0 +1 @@
|
||||||
|
../html-minifier-terser/cli.js
|
|
@ -1 +0,0 @@
|
||||||
../is-ci/bin.js
|
|
|
@ -0,0 +1 @@
|
||||||
|
../is-docker/cli.js
|
|
@ -0,0 +1 @@
|
||||||
|
../jake/bin/cli.js
|
|
@ -1 +0,0 @@
|
||||||
../jest-runtime/bin/jest-runtime.js
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue