v1.0 with SW PWA enabled

This commit is contained in:
Blomios
2026-01-01 17:40:53 +01:00
parent 1c0e22aac1
commit 3c8bebb2ad
29775 changed files with 2197201 additions and 119080 deletions

View File

@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
exports.default = void 0;
var _renamer = require("./lib/renamer.js");
var _index = require("../index.js");
var _traverseForScope = require("./traverseForScope.js");
var _binding = require("./binding.js");
var _t = require("@babel/types");
var t = _t;
@ -186,6 +187,9 @@ function resetScope(scope) {
scope.bindings = Object.create(null);
scope.globals = Object.create(null);
}
function isAnonymousFunctionExpression(path) {
return path.isFunctionExpression() && !path.node.id || path.isArrowFunctionExpression();
}
{
var NOT_LOCAL_BINDING = Symbol.for("should not be considered a local binding");
}
@ -677,6 +681,7 @@ class Scope {
}
crawl() {
const path = this.path;
;
resetScope(this);
this.data = Object.create(null);
let scope = this;
@ -699,9 +704,6 @@ class Scope {
}
}, collectorVisitor]));
if (path.type !== "Program") {
for (const visit of scopeVisitor.enter) {
visit.call(state, path, state);
}
const typeVisitors = scopeVisitor[path.type];
if (typeVisitors) {
for (const visit of typeVisitors.enter) {
@ -709,7 +711,9 @@ class Scope {
}
}
}
path.traverse(scopeVisitor, state);
{
path.traverse(scopeVisitor, state);
}
this.crawling = false;
for (const path of state.assignments) {
const ids = path.getAssignmentIdentifiers();
@ -747,7 +751,7 @@ class Scope {
kind = "var",
id
} = opts;
if (!init && !unique && (kind === "var" || kind === "let") && path.isFunction() && !path.node.name && isCallExpression(path.parent, {
if (!init && !unique && (kind === "var" || kind === "let") && isAnonymousFunctionExpression(path) && isCallExpression(path.parent, {
callee: path.node
}) && path.parent.arguments.length <= path.node.params.length && isIdentifier(id)) {
path.pushContainer("params", id);
@ -936,7 +940,7 @@ class Scope {
emit(identifier(name), decl.init != null);
}
}
if (parentPath.parentPath.isFor({
if (parentPath.parentPath.isForXStatement({
left: parent
})) {
parentPath.replaceWith(firstId);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,68 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = traverseForScope;
var _t = require("@babel/types");
var _index = require("../index.js");
var _visitors = require("../visitors.js");
var _context = require("../path/context.js");
const {
VISITOR_KEYS
} = _t;
function traverseForScope(path, visitors, state) {
const exploded = (0, _visitors.explode)(visitors);
if (exploded.enter || exploded.exit) {
throw new Error("Should not be used with enter/exit visitors.");
}
_traverse(path.parentPath, path.parent, path.node, path.container, path.key, path.listKey, path.hub, path);
function _traverse(parentPath, parent, node, container, key, listKey, hub, inPath) {
if (!node) {
return;
}
const path = inPath || _index.NodePath.get({
hub,
parentPath,
parent,
container,
listKey,
key
});
_context.setScope.call(path);
const visitor = exploded[node.type];
if (visitor) {
if (visitor.enter) {
for (const visit of visitor.enter) {
visit.call(state, path, state);
}
}
if (visitor.exit) {
for (const visit of visitor.exit) {
visit.call(state, path, state);
}
}
}
if (path.shouldSkip) {
return;
}
const keys = VISITOR_KEYS[node.type];
if (!(keys != null && keys.length)) {
return;
}
for (const key of keys) {
const prop = node[key];
if (!prop) continue;
if (Array.isArray(prop)) {
for (let i = 0; i < prop.length; i++) {
const value = prop[i];
_traverse(path, node, value, prop, i, key);
}
} else {
_traverse(path, node, prop, node, key, null);
}
}
}
}
//# sourceMappingURL=traverseForScope.js.map

View File

@ -0,0 +1 @@
{"version":3,"names":["_t","require","_index","_visitors","_context","VISITOR_KEYS","traverseForScope","path","visitors","state","exploded","explode","enter","exit","Error","_traverse","parentPath","parent","node","container","key","listKey","hub","inPath","NodePath","get","setScope","call","visitor","type","visit","shouldSkip","keys","length","prop","Array","isArray","i","value"],"sources":["../../src/scope/traverseForScope.ts"],"sourcesContent":["import { VISITOR_KEYS } from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type { HubInterface, Visitor } from \"../index.ts\";\nimport { NodePath } from \"../index.ts\";\nimport { explode } from \"../visitors.ts\";\nimport { setScope } from \"../path/context.ts\";\n\nexport default function traverseForScope(\n path: NodePath,\n visitors: Visitor,\n state: any,\n) {\n const exploded = explode(visitors);\n\n if (exploded.enter || exploded.exit) {\n throw new Error(\"Should not be used with enter/exit visitors.\");\n }\n\n _traverse(\n path.parentPath,\n path.parent,\n path.node,\n path.container!,\n path.key!,\n path.listKey,\n path.hub,\n path,\n );\n\n function _traverse(\n parentPath: NodePath,\n parent: t.Node,\n node: t.Node,\n container: t.Node | t.Node[],\n key: string | number,\n listKey: string | null | undefined,\n hub?: HubInterface,\n inPath?: NodePath,\n ) {\n if (!node) {\n return;\n }\n\n const path =\n inPath ||\n NodePath.get({\n hub,\n parentPath,\n parent,\n container,\n listKey,\n key,\n });\n\n setScope.call(path);\n\n const visitor = exploded[node.type];\n if (visitor) {\n if (visitor.enter) {\n for (const visit of visitor.enter) {\n visit.call(state, path, state);\n }\n }\n if (visitor.exit) {\n for (const visit of visitor.exit) {\n visit.call(state, path, state);\n }\n }\n }\n if (path.shouldSkip) {\n return;\n }\n\n const keys = VISITOR_KEYS[node.type];\n if (!keys?.length) {\n return;\n }\n\n for (const key of keys) {\n // @ts-expect-error key must present in node\n const prop = node[key];\n if (!prop) continue;\n if (Array.isArray(prop)) {\n for (let i = 0; i < prop.length; i++) {\n const value = prop[i];\n _traverse(path, node, value, prop, i, key);\n }\n } else {\n _traverse(path, node, prop, node, key, null);\n }\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,EAAA,GAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAA8C;EALrCI;AAAY,IAAAL,EAAA;AAON,SAASM,gBAAgBA,CACtCC,IAAc,EACdC,QAAiB,EACjBC,KAAU,EACV;EACA,MAAMC,QAAQ,GAAG,IAAAC,iBAAO,EAACH,QAAQ,CAAC;EAElC,IAAIE,QAAQ,CAACE,KAAK,IAAIF,QAAQ,CAACG,IAAI,EAAE;IACnC,MAAM,IAAIC,KAAK,CAAC,8CAA8C,CAAC;EACjE;EAE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