Spaces:
Running
Running
Upload 5037 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Fragment.d.ts +8 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Fragment.js +11 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Language.d.ts +5 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Language.js +1 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Match.d.ts +1 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Match.js +1 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Parser.d.ts +25 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Parser.js +154 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/README.md +160 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Rule.d.ts +19 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Rule.js +1 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/index.d.ts +9 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/index.js +9 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/c.d.ts +6 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/c.js +19 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/cpp.d.ts +6 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/cpp.js +19 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/css.d.ts +6 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/css.js +19 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/es.d.ts +10 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/es.js +65 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/index.d.ts +22 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/index.js +21 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/nim.d.ts +6 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/nim.js +19 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/py.d.ts +6 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/py.js +23 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/rs.d.ts +6 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/rs.js +19 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/sass.d.ts +6 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/sass.js +23 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/scss.d.ts +6 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/scss.js +23 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/package.json +57 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/utilities/addJsExtensions.d.ts +4 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/utilities/addJsExtensions.js +22 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/utilities/patchJsImports.d.ts +10 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/utilities/patchJsImports.js +55 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/utilities/resolveAliases.d.ts +5 -0
- node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/utilities/resolveAliases.js +13 -0
- node_modules/.pnpm/@[email protected]/node_modules/@esbuild/win32-x64/README.md +3 -0
- node_modules/.pnpm/@[email protected]/node_modules/@esbuild/win32-x64/esbuild.exe +3 -0
- node_modules/.pnpm/@[email protected]/node_modules/@esbuild/win32-x64/package.json +17 -0
- node_modules/.pnpm/@[email protected]/node_modules/@silentbot1/nat-api/.github/dependabot.yml +8 -0
- node_modules/.pnpm/@[email protected]/node_modules/@silentbot1/nat-api/.github/workflows/ci.yml +20 -0
- node_modules/.pnpm/@[email protected]/node_modules/@silentbot1/nat-api/.idea/aws.xml +17 -0
- node_modules/.pnpm/@[email protected]/node_modules/@silentbot1/nat-api/.idea/codeStyles/Project.xml +31 -0
- node_modules/.pnpm/@[email protected]/node_modules/@silentbot1/nat-api/.idea/codeStyles/codeStyleConfig.xml +5 -0
- node_modules/.pnpm/@[email protected]/node_modules/@silentbot1/nat-api/.idea/inspectionProfiles/Project_Default.xml +6 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
node_modules/.pnpm/@[email protected]/node_modules/@esbuild/win32-x64/esbuild.exe filter=lfs diff=lfs merge=lfs -text
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Fragment.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default class Fragment {
|
2 |
+
start: number;
|
3 |
+
end: number;
|
4 |
+
groups: string[];
|
5 |
+
slice: string;
|
6 |
+
constructor(source: string, start: number, end: number, groups?: string[]);
|
7 |
+
get length(): number;
|
8 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Fragment.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default class Fragment {
|
2 |
+
constructor(source, start, end, groups = []) {
|
3 |
+
this.start = start;
|
4 |
+
this.end = end;
|
5 |
+
this.groups = groups;
|
6 |
+
this.slice = source.slice(start, end);
|
7 |
+
}
|
8 |
+
get length() {
|
9 |
+
return this.slice.length;
|
10 |
+
}
|
11 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Language.d.ts
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Rule from "./Rule.js";
|
2 |
+
declare type Language = {
|
3 |
+
readonly rules: Rule[];
|
4 |
+
};
|
5 |
+
export default Language;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Language.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export {};
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Match.d.ts
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export declare type Match = RegExpExecArray | RegExpMatchArray;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Match.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export {};
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Parser.d.ts
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Rule from "./Rule.js";
|
2 |
+
import Fragment from "./Fragment.js";
|
3 |
+
import { LanguageName } from "./languages/index.js";
|
4 |
+
export declare type FromTo = {
|
5 |
+
from: string | RegExp;
|
6 |
+
to: string | RegExp;
|
7 |
+
};
|
8 |
+
export default class Parser {
|
9 |
+
content: string;
|
10 |
+
private stopExpressionCache;
|
11 |
+
private _rules;
|
12 |
+
private language?;
|
13 |
+
get rules(): Rule[];
|
14 |
+
constructor(content: string, rules: LanguageName | Rule[]);
|
15 |
+
find(...expressions: Array<string | RegExp>): Fragment[];
|
16 |
+
replace(...fromTos: FromTo[]): string;
|
17 |
+
findDependencies(): Fragment[];
|
18 |
+
replaceDependencies(to: string): string;
|
19 |
+
private parse;
|
20 |
+
private getRuleExpression;
|
21 |
+
private getRuleStopExpression;
|
22 |
+
private getNextMatchExpression;
|
23 |
+
private getMatchingRule;
|
24 |
+
private resolveFragment;
|
25 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Parser.js
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Fragment from "./Fragment.js";
|
2 |
+
import languages from "./languages/index.js";
|
3 |
+
export default class Parser {
|
4 |
+
constructor(content, rules) {
|
5 |
+
this.content = content;
|
6 |
+
this.stopExpressionCache = new Map();
|
7 |
+
this._rules = [];
|
8 |
+
if (typeof rules === "string")
|
9 |
+
this.language = rules;
|
10 |
+
else
|
11 |
+
this._rules = rules;
|
12 |
+
}
|
13 |
+
get rules() {
|
14 |
+
if (this.language)
|
15 |
+
return new languages[this.language]().rules;
|
16 |
+
return this._rules;
|
17 |
+
}
|
18 |
+
find(...expressions) {
|
19 |
+
const result = [];
|
20 |
+
const rules = [
|
21 |
+
...expressions.map((expression) => ({ type: "match", expression })),
|
22 |
+
...this.rules,
|
23 |
+
];
|
24 |
+
this.parse(rules, (fragment) => result.push(fragment));
|
25 |
+
return result;
|
26 |
+
}
|
27 |
+
replace(...fromTos) {
|
28 |
+
let result = "";
|
29 |
+
let offset = 0;
|
30 |
+
const rules = [
|
31 |
+
...fromTos.map(({ from, to }) => ({
|
32 |
+
type: "match",
|
33 |
+
expression: from,
|
34 |
+
from: new RegExp(`^${typeof from === "string" ? from : from.source}$`),
|
35 |
+
to,
|
36 |
+
})),
|
37 |
+
...this.rules,
|
38 |
+
];
|
39 |
+
this.parse(rules, (fragment, rule) => {
|
40 |
+
result += this.content.slice(offset, fragment.start);
|
41 |
+
if (rule.from !== undefined && rule.to !== undefined) {
|
42 |
+
result += fragment.slice.replace(rule.from, rule.to);
|
43 |
+
}
|
44 |
+
else {
|
45 |
+
result += fragment.slice;
|
46 |
+
}
|
47 |
+
offset = fragment.end;
|
48 |
+
});
|
49 |
+
result += this.content.slice(offset);
|
50 |
+
return result;
|
51 |
+
}
|
52 |
+
findDependencies() {
|
53 |
+
if (!this.language)
|
54 |
+
throw "[findDependencies] No language specified";
|
55 |
+
const importExpression = languages[this.language].importExpression;
|
56 |
+
if (!importExpression)
|
57 |
+
throw `[findDependencies] No importExpression for language ${this.language}`;
|
58 |
+
return this.find(importExpression);
|
59 |
+
}
|
60 |
+
replaceDependencies(to) {
|
61 |
+
if (!this.language)
|
62 |
+
throw "[findDependencies] No language specified";
|
63 |
+
const importExpression = languages[this.language].importExpression;
|
64 |
+
if (!importExpression)
|
65 |
+
throw `[findDependencies] No importExpression for language ${this.language}`;
|
66 |
+
return this.replace({ from: importExpression, to });
|
67 |
+
}
|
68 |
+
parse(rules, onMatch) {
|
69 |
+
const nextMatch = this.getNextMatchExpression(rules);
|
70 |
+
let match;
|
71 |
+
while ((match = nextMatch.exec(this.content))) {
|
72 |
+
const matchingRule = this.getMatchingRule(rules, match);
|
73 |
+
if (matchingRule == null)
|
74 |
+
continue;
|
75 |
+
const [rule, ruleMatch] = matchingRule;
|
76 |
+
const fragment = this.resolveFragment(rule, match, ruleMatch.slice(1));
|
77 |
+
if (!fragment) {
|
78 |
+
// the fragment has no end (good chances it is a syntax error)
|
79 |
+
console.warn("No stop found for rule", rule);
|
80 |
+
break;
|
81 |
+
}
|
82 |
+
// console.log("fragment:", fragment.slice)
|
83 |
+
nextMatch.lastIndex = fragment.end;
|
84 |
+
if (rule.type === "match")
|
85 |
+
onMatch(fragment, rule);
|
86 |
+
}
|
87 |
+
}
|
88 |
+
getRuleExpression(rule) {
|
89 |
+
const expression = "expression" in rule ? rule.expression : rule.startAt;
|
90 |
+
return typeof expression === "string" ? expression : expression.source;
|
91 |
+
}
|
92 |
+
getRuleStopExpression(rule) {
|
93 |
+
let expression = this.stopExpressionCache.get(rule);
|
94 |
+
if (expression)
|
95 |
+
return expression;
|
96 |
+
if ("expression" in rule)
|
97 |
+
throw "A standalone expression has no stop delimiter";
|
98 |
+
expression = new RegExp(typeof rule.stopAt === "string" ? rule.stopAt : rule.stopAt.source, "gm");
|
99 |
+
this.stopExpressionCache.set(rule, expression);
|
100 |
+
return expression;
|
101 |
+
}
|
102 |
+
getNextMatchExpression(rules) {
|
103 |
+
return new RegExp(rules.map((rule) => `(?:${this.getRuleExpression(rule)})`).join("|"), "gm");
|
104 |
+
}
|
105 |
+
getMatchingRule(rules, match) {
|
106 |
+
const [input] = match;
|
107 |
+
let noMatch = true;
|
108 |
+
// console.log(`Get matching rule of: '${input}'`)
|
109 |
+
for (const rule of rules) {
|
110 |
+
const ruleExpression = this.getRuleExpression(rule);
|
111 |
+
const ruleMatch = input.match(ruleExpression);
|
112 |
+
if (ruleMatch &&
|
113 |
+
ruleMatch.index === 0 &&
|
114 |
+
ruleMatch[0].length === input.length) {
|
115 |
+
noMatch = false;
|
116 |
+
if ("expression" in rule) {
|
117 |
+
if ("onExpressionMatch" in rule &&
|
118 |
+
rule.onExpressionMatch &&
|
119 |
+
rule.onExpressionMatch(ruleMatch) === false) {
|
120 |
+
continue;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
else {
|
124 |
+
if (rule.onStartMatch && rule.onStartMatch(ruleMatch) === false)
|
125 |
+
continue;
|
126 |
+
}
|
127 |
+
return [rule, ruleMatch];
|
128 |
+
}
|
129 |
+
}
|
130 |
+
if (noMatch) {
|
131 |
+
console.log("[getMatchingRule] No rules matched with match:", match);
|
132 |
+
throw "[getMatchingRule] No rules matched";
|
133 |
+
}
|
134 |
+
return null;
|
135 |
+
}
|
136 |
+
resolveFragment(rule, match, groups = []) {
|
137 |
+
const start = match.index;
|
138 |
+
const input = match[0];
|
139 |
+
const offset = start + input.length;
|
140 |
+
if ("expression" in rule)
|
141 |
+
return new Fragment(this.content, start, offset, groups);
|
142 |
+
else {
|
143 |
+
const nextStop = this.getRuleStopExpression(rule);
|
144 |
+
nextStop.lastIndex = offset - 1;
|
145 |
+
let stop;
|
146 |
+
while ((stop = nextStop.exec(this.content))) {
|
147 |
+
if (!rule.onStopMatch || rule.onStopMatch(stop) !== false) {
|
148 |
+
return new Fragment(this.content, start, stop.index + stop[0].length, groups);
|
149 |
+
}
|
150 |
+
}
|
151 |
+
return null;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/README.md
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
**_Grubber_** is a lightweight and friendly utility to parse code with regular expressions in a 100% safe way - without having to use an AST 🐛
|
2 |
+
|
3 |
+
In a higher level, Grubber also exposes helper functions to parse the dependencies of a file in many languages (Javascript, Typescript, Css, Scss, Python, Rust, C / C++, Nim, ...).
|
4 |
+
|
5 |
+
## How?
|
6 |
+
|
7 |
+
The problem with parsing a source file with regular expressions is that you cannot be sure your match is not commented or inside a string.
|
8 |
+
|
9 |
+
For example, let's say you are looking for all `const` statements in a Javascript file - you would use a regular expression similar to:
|
10 |
+
|
11 |
+
```ts
|
12 |
+
/\bconst\s+/g;
|
13 |
+
```
|
14 |
+
|
15 |
+
But what if the file you want to parse is something like:
|
16 |
+
|
17 |
+
```ts
|
18 |
+
const x = 12;
|
19 |
+
// const y = 13;
|
20 |
+
let z = "const ";
|
21 |
+
```
|
22 |
+
|
23 |
+
Then you would match three `const` when only one should be matched.
|
24 |
+
|
25 |
+
Grubber understands what is a string, what is a comment and what is code so that you can overcome the issue very easily:
|
26 |
+
|
27 |
+
```ts
|
28 |
+
import { grub } from "@digitak/grubber";
|
29 |
+
|
30 |
+
const content = `
|
31 |
+
const x = 12
|
32 |
+
// const y = 13
|
33 |
+
let z = "const "
|
34 |
+
`;
|
35 |
+
|
36 |
+
const results = grub(content).find(/\bconst\s+/);
|
37 |
+
console.log(results.length); // will print 1 as expected
|
38 |
+
```
|
39 |
+
|
40 |
+
> For the sake of the demonstration we used a simple regex, but remember that Ecmascript is a tricky language! Effectively finding all `const` statements would require a more refined regex. Ex: `foo.const = 12` would be matched. Languages that use semi-colon at the end of every statement or strict indentation are much easier to parse in a 100% safe way.
|
41 |
+
|
42 |
+
## Installation
|
43 |
+
|
44 |
+
Use your favorite package manager:
|
45 |
+
|
46 |
+
```
|
47 |
+
npm install @digitak/grubber
|
48 |
+
```
|
49 |
+
|
50 |
+
## Grubber API
|
51 |
+
|
52 |
+
Grubber exports one main function `grub`:
|
53 |
+
|
54 |
+
```ts
|
55 |
+
export function grub(
|
56 |
+
source: string,
|
57 |
+
languageOrRules: LanguageName | Rule[] = "es",
|
58 |
+
): {
|
59 |
+
// find one or more expressions and return an array of fragments
|
60 |
+
find: (...expressions: Array<string | RegExp>) => Fragment[];
|
61 |
+
|
62 |
+
// replace one or more expressions and return the patched string
|
63 |
+
replace: (
|
64 |
+
...fromTos: Array<{
|
65 |
+
from: string | RegExp;
|
66 |
+
to: string | RegExp;
|
67 |
+
}>
|
68 |
+
) => string;
|
69 |
+
|
70 |
+
// find all dependencies (ex: `imports` in Typescript, `use` in Rust)
|
71 |
+
findDependencies: () => Fragment[];
|
72 |
+
|
73 |
+
// replace all dependencies by the given value
|
74 |
+
// you can use special replace patterns like "$1" to replace
|
75 |
+
// with the first captured group
|
76 |
+
replaceDependencies: (to: string) => string;
|
77 |
+
};
|
78 |
+
```
|
79 |
+
|
80 |
+
The `find` and `findDependencies` methods both return an array of fragments:
|
81 |
+
|
82 |
+
```ts
|
83 |
+
export type Fragment = {
|
84 |
+
slice: string; // the matched substring
|
85 |
+
start: number; // start of the matched substring
|
86 |
+
end: number; // end of the matched substring
|
87 |
+
groups: string[] = []; // the captured groups
|
88 |
+
};
|
89 |
+
```
|
90 |
+
|
91 |
+
### Using grubber with one of the preset languages
|
92 |
+
|
93 |
+
You can use any of the preset languages:
|
94 |
+
|
95 |
+
```ts
|
96 |
+
export type LanguageName =
|
97 |
+
| "es" // Ecmascript (Javascript / Typescript / Haxe): the default
|
98 |
+
| "rs" // Rust
|
99 |
+
| "css"
|
100 |
+
| "scss"
|
101 |
+
| "sass"
|
102 |
+
| "c"
|
103 |
+
| "cpp"
|
104 |
+
| "py" // Python
|
105 |
+
| "nim";
|
106 |
+
```
|
107 |
+
|
108 |
+
Example:
|
109 |
+
|
110 |
+
```ts
|
111 |
+
// find all semi-colons inside the rust source code
|
112 |
+
grub(rustCodeToParse, "rs").find(";");
|
113 |
+
```
|
114 |
+
|
115 |
+
### Using grubber with custom rules
|
116 |
+
|
117 |
+
You may define custom rules for the grubber parser, ie. what should be ignored an treated as "not code".
|
118 |
+
|
119 |
+
A `Rule` has the following type:
|
120 |
+
|
121 |
+
```ts
|
122 |
+
export type Rule =
|
123 |
+
| {
|
124 |
+
expression: string | RegExp; // the expression to ignore
|
125 |
+
|
126 |
+
// if returns false, the match is ignored
|
127 |
+
onExpressionMatch?: (match: RegExpExecArray) => boolean | void;
|
128 |
+
}
|
129 |
+
| {
|
130 |
+
startAt: string | RegExp; // start of the expression to ignore
|
131 |
+
stopAt: string | RegExp; // stop of the expression to ignore
|
132 |
+
|
133 |
+
// if returns false, the match is ignored
|
134 |
+
onStartMatch?: (match: RegExpExecArray) => boolean | void;
|
135 |
+
onStopMatch?: (match: RegExpExecArray) => boolean | void;
|
136 |
+
};
|
137 |
+
```
|
138 |
+
|
139 |
+
For example, the rules used for the `C` language are:
|
140 |
+
|
141 |
+
```ts
|
142 |
+
const rules: Rule[] = [
|
143 |
+
{
|
144 |
+
// string
|
145 |
+
expression: /".*?[^\\](?:\\\\)*"/,
|
146 |
+
},
|
147 |
+
{
|
148 |
+
// single line comment
|
149 |
+
expression: /\/\/.*/,
|
150 |
+
},
|
151 |
+
{
|
152 |
+
// multiline comment
|
153 |
+
expression: /\/\*((?:.|\s)*?)\*\//,
|
154 |
+
},
|
155 |
+
];
|
156 |
+
```
|
157 |
+
|
158 |
+
> Rules are quite simple for most languages but get complicated for Ecmascript because of the `${...}` syntax. Hopefully the job is already done for you!
|
159 |
+
|
160 |
+
🌿 🐛 🌿
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Rule.d.ts
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Match } from "./Match.js";
|
2 |
+
export declare type MatchRule = {
|
3 |
+
type: "match";
|
4 |
+
expression: string | RegExp;
|
5 |
+
from?: RegExp;
|
6 |
+
to?: string;
|
7 |
+
};
|
8 |
+
declare type Rule = MatchRule | {
|
9 |
+
type?: undefined;
|
10 |
+
expression: string | RegExp;
|
11 |
+
onExpressionMatch?: (match: Match) => boolean | void;
|
12 |
+
} | {
|
13 |
+
type?: undefined;
|
14 |
+
startAt: string | RegExp;
|
15 |
+
stopAt: string | RegExp;
|
16 |
+
onStartMatch?: (match: Match) => boolean | void;
|
17 |
+
onStopMatch?: (match: Match) => boolean | void;
|
18 |
+
};
|
19 |
+
export default Rule;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/Rule.js
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
export {};
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/index.d.ts
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Rule from "./Rule.js";
|
2 |
+
import Parser from "./Parser.js";
|
3 |
+
import Fragment from "./Fragment.js";
|
4 |
+
import { LanguageName } from "./languages/index.js";
|
5 |
+
/**
|
6 |
+
* @return a Parser instance with which the user can execute find and replace operations
|
7 |
+
*/
|
8 |
+
export declare function grub(content: string, rules?: Rule[] | LanguageName): Parser;
|
9 |
+
export { Rule, LanguageName, Fragment, Parser };
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/index.js
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Parser from "./Parser.js";
|
2 |
+
import Fragment from "./Fragment.js";
|
3 |
+
/**
|
4 |
+
* @return a Parser instance with which the user can execute find and replace operations
|
5 |
+
*/
|
6 |
+
export function grub(content, rules = "es") {
|
7 |
+
return new Parser(content, rules);
|
8 |
+
}
|
9 |
+
export { Fragment, Parser };
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/c.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Language from "../Language.js";
|
2 |
+
import Rule from "../Rule.js";
|
3 |
+
export default class implements Language {
|
4 |
+
static readonly importExpression: RegExp;
|
5 |
+
readonly rules: Rule[];
|
6 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/c.js
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default class default_1 {
|
2 |
+
constructor() {
|
3 |
+
this.rules = [
|
4 |
+
{
|
5 |
+
// string
|
6 |
+
expression: /".*?[^\\](?:\\\\)*"/,
|
7 |
+
},
|
8 |
+
{
|
9 |
+
// single line comment
|
10 |
+
expression: /\/\/.*/,
|
11 |
+
},
|
12 |
+
{
|
13 |
+
// multiline comment
|
14 |
+
expression: /\/\*((?:.|\s)*?)\*\//,
|
15 |
+
},
|
16 |
+
];
|
17 |
+
}
|
18 |
+
}
|
19 |
+
default_1.importExpression = /#include\s*"(.+?)"/g;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/cpp.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Language from "../Language.js";
|
2 |
+
import Rule from "../Rule.js";
|
3 |
+
export default class implements Language {
|
4 |
+
static readonly importExpression: RegExp;
|
5 |
+
readonly rules: Rule[];
|
6 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/cpp.js
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default class default_1 {
|
2 |
+
constructor() {
|
3 |
+
this.rules = [
|
4 |
+
{
|
5 |
+
// string
|
6 |
+
expression: /".*?[^\\](?:\\\\)*"/,
|
7 |
+
},
|
8 |
+
{
|
9 |
+
// single line comment
|
10 |
+
expression: /\/\/.*/,
|
11 |
+
},
|
12 |
+
{
|
13 |
+
// multiline comment
|
14 |
+
expression: /\/\*((?:.|\s)*?)\*\//,
|
15 |
+
},
|
16 |
+
];
|
17 |
+
}
|
18 |
+
}
|
19 |
+
default_1.importExpression = /#include\s*((?:".+?")|(?:<.+?>))/g;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/css.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Language from "../Language.js";
|
2 |
+
import Rule from "../Rule.js";
|
3 |
+
export default class implements Language {
|
4 |
+
static readonly importExpression: RegExp;
|
5 |
+
readonly rules: Rule[];
|
6 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/css.js
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default class default_1 {
|
2 |
+
constructor() {
|
3 |
+
this.rules = [
|
4 |
+
{
|
5 |
+
// string
|
6 |
+
expression: /".*?[^\\](?:\\\\)*"/,
|
7 |
+
},
|
8 |
+
{
|
9 |
+
// string
|
10 |
+
expression: /'.*?[^\\](?:\\\\)*'/,
|
11 |
+
},
|
12 |
+
{
|
13 |
+
// comment
|
14 |
+
expression: /\/\*((?:.|\s)*?)\*\//,
|
15 |
+
},
|
16 |
+
];
|
17 |
+
}
|
18 |
+
}
|
19 |
+
default_1.importExpression = /@import\s+("|')(.+?)\1/g;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/es.d.ts
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Language from "../Language.js";
|
2 |
+
import Rule from "../Rule.js";
|
3 |
+
export default class implements Language {
|
4 |
+
private backtickScope;
|
5 |
+
private get backtickLevel();
|
6 |
+
private get currentScope();
|
7 |
+
private set currentScope(value);
|
8 |
+
static readonly importExpression: RegExp;
|
9 |
+
readonly rules: Rule[];
|
10 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/es.js
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default class default_1 {
|
2 |
+
constructor() {
|
3 |
+
this.backtickScope = [];
|
4 |
+
this.rules = [
|
5 |
+
{
|
6 |
+
// single quote string
|
7 |
+
expression: /'.*?[^\\](?:\\\\)*'/,
|
8 |
+
},
|
9 |
+
{
|
10 |
+
// double quote string
|
11 |
+
expression: /".*?[^\\](?:\\\\)*"/,
|
12 |
+
},
|
13 |
+
{
|
14 |
+
// backtick string
|
15 |
+
startAt: /`|{|}/,
|
16 |
+
onStartMatch: (match) => {
|
17 |
+
if (match[0] === "{") {
|
18 |
+
if (this.backtickLevel)
|
19 |
+
this.currentScope++;
|
20 |
+
return false;
|
21 |
+
}
|
22 |
+
else if (match[0] === "}") {
|
23 |
+
if (this.backtickLevel) {
|
24 |
+
if (this.currentScope === 0) {
|
25 |
+
this.backtickScope.pop();
|
26 |
+
return true;
|
27 |
+
}
|
28 |
+
this.currentScope--;
|
29 |
+
}
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
return true;
|
33 |
+
},
|
34 |
+
stopAt: /[^\\](?:\\\\)*(\${|`)/,
|
35 |
+
onStopMatch: (match) => {
|
36 |
+
if (match[1] === "${")
|
37 |
+
this.backtickScope.push(0);
|
38 |
+
return true;
|
39 |
+
},
|
40 |
+
},
|
41 |
+
{
|
42 |
+
// single line comment
|
43 |
+
expression: /\/\/.*/,
|
44 |
+
},
|
45 |
+
{
|
46 |
+
// multiline comment
|
47 |
+
expression: /\/\*((?:.|\s)*?)\*\//,
|
48 |
+
},
|
49 |
+
{
|
50 |
+
// regular expression
|
51 |
+
expression: /[=,;?(\n]\s*\/[^/*].*?[^\\](?:\\\\)*\//,
|
52 |
+
},
|
53 |
+
];
|
54 |
+
}
|
55 |
+
get backtickLevel() {
|
56 |
+
return this.backtickScope.length;
|
57 |
+
}
|
58 |
+
get currentScope() {
|
59 |
+
return this.backtickScope[this.backtickScope.length - 1];
|
60 |
+
}
|
61 |
+
set currentScope(value) {
|
62 |
+
this.backtickScope[this.backtickScope.length - 1] = value;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
default_1.importExpression = /\b(?:import|export)(?:\s+([^;()[\]=/'"`+\-:.]+?)\s+from)?\s+('|")(.+?)\2/g;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/index.d.ts
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import es from "./es.js";
|
2 |
+
import c from "./c.js";
|
3 |
+
import cpp from "./cpp.js";
|
4 |
+
import css from "./css.js";
|
5 |
+
import scss from "./scss.js";
|
6 |
+
import sass from "./sass.js";
|
7 |
+
import nim from "./nim.js";
|
8 |
+
import py from "./py.js";
|
9 |
+
import rs from "./rs.js";
|
10 |
+
declare const languages: {
|
11 |
+
es: typeof es;
|
12 |
+
c: typeof c;
|
13 |
+
cpp: typeof cpp;
|
14 |
+
css: typeof css;
|
15 |
+
scss: typeof scss;
|
16 |
+
sass: typeof sass;
|
17 |
+
nim: typeof nim;
|
18 |
+
py: typeof py;
|
19 |
+
rs: typeof rs;
|
20 |
+
};
|
21 |
+
export default languages;
|
22 |
+
export declare type LanguageName = keyof typeof languages;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/index.js
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import es from "./es.js";
|
2 |
+
import c from "./c.js";
|
3 |
+
import cpp from "./cpp.js";
|
4 |
+
import css from "./css.js";
|
5 |
+
import scss from "./scss.js";
|
6 |
+
import sass from "./sass.js";
|
7 |
+
import nim from "./nim.js";
|
8 |
+
import py from "./py.js";
|
9 |
+
import rs from "./rs.js";
|
10 |
+
const languages = {
|
11 |
+
es,
|
12 |
+
c,
|
13 |
+
cpp,
|
14 |
+
css,
|
15 |
+
scss,
|
16 |
+
sass,
|
17 |
+
nim,
|
18 |
+
py,
|
19 |
+
rs,
|
20 |
+
};
|
21 |
+
export default languages;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/nim.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Language from "../Language.js";
|
2 |
+
import Rule from "../Rule.js";
|
3 |
+
export default class implements Language {
|
4 |
+
static readonly importExpression: RegExp;
|
5 |
+
readonly rules: Rule[];
|
6 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/nim.js
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default class default_1 {
|
2 |
+
constructor() {
|
3 |
+
this.rules = [
|
4 |
+
{
|
5 |
+
// string
|
6 |
+
expression: /".*?[^\\](?:\\\\)*"/,
|
7 |
+
},
|
8 |
+
{
|
9 |
+
// multiline comment
|
10 |
+
expression: /#\[((?:.|\s)*?)\]#/,
|
11 |
+
},
|
12 |
+
{
|
13 |
+
// comment
|
14 |
+
expression: /#.*/,
|
15 |
+
},
|
16 |
+
];
|
17 |
+
}
|
18 |
+
}
|
19 |
+
default_1.importExpression = /^(?:(?:(\bfrom +(.*?) +)?(\bimport) +(.*?))|(?:(\binclude) +(.*?))) *$/gm;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/py.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Language from "../Language.js";
|
2 |
+
import Rule from "../Rule.js";
|
3 |
+
export default class implements Language {
|
4 |
+
static readonly importExpression: RegExp;
|
5 |
+
readonly rules: Rule[];
|
6 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/py.js
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default class default_1 {
|
2 |
+
constructor() {
|
3 |
+
this.rules = [
|
4 |
+
{
|
5 |
+
// multi line string
|
6 |
+
expression: /"""((?:.|\s)*?)[^\\](?:\\\\)*"""/,
|
7 |
+
},
|
8 |
+
{
|
9 |
+
// single quote string
|
10 |
+
expression: /'.*?[^\\](?:\\\\)*'/,
|
11 |
+
},
|
12 |
+
{
|
13 |
+
// double quote string
|
14 |
+
expression: /".*?[^\\](?:\\\\)*"/,
|
15 |
+
},
|
16 |
+
{
|
17 |
+
// comment
|
18 |
+
expression: /#.*/,
|
19 |
+
},
|
20 |
+
];
|
21 |
+
}
|
22 |
+
}
|
23 |
+
default_1.importExpression = /^(?:(?:\bfrom +(.*?) +)?(\bimport) +(.*?)) *(?:\bas +(.*?))? *$/gm;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/rs.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Language from "../Language.js";
|
2 |
+
import Rule from "../Rule.js";
|
3 |
+
export default class implements Language {
|
4 |
+
static readonly importExpression: RegExp;
|
5 |
+
readonly rules: Rule[];
|
6 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/rs.js
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default class default_1 {
|
2 |
+
constructor() {
|
3 |
+
this.rules = [
|
4 |
+
{
|
5 |
+
// string
|
6 |
+
expression: /".*?[^\\](?:\\\\)*"/,
|
7 |
+
},
|
8 |
+
{
|
9 |
+
// single line comment
|
10 |
+
expression: /\/\/.*/,
|
11 |
+
},
|
12 |
+
{
|
13 |
+
// multiline comment
|
14 |
+
expression: /\/\*((?:.|\s)*?)\*\//,
|
15 |
+
},
|
16 |
+
];
|
17 |
+
}
|
18 |
+
}
|
19 |
+
default_1.importExpression = /\buse\s+(.+?)\s*;/g;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/sass.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Language from "../Language.js";
|
2 |
+
import Rule from "../Rule.js";
|
3 |
+
export default class implements Language {
|
4 |
+
static readonly importExpression: RegExp;
|
5 |
+
readonly rules: Rule[];
|
6 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/sass.js
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default class default_1 {
|
2 |
+
constructor() {
|
3 |
+
this.rules = [
|
4 |
+
{
|
5 |
+
// string
|
6 |
+
expression: /".*?[^\\](?:\\\\)*"/,
|
7 |
+
},
|
8 |
+
{
|
9 |
+
// string
|
10 |
+
expression: /'.*?[^\\](?:\\\\)*'/,
|
11 |
+
},
|
12 |
+
{
|
13 |
+
// single line comment
|
14 |
+
expression: /\/\/.*/,
|
15 |
+
},
|
16 |
+
{
|
17 |
+
// multiline comment
|
18 |
+
expression: /\/\*((?:.|\s)*?)\*\//,
|
19 |
+
},
|
20 |
+
];
|
21 |
+
}
|
22 |
+
}
|
23 |
+
default_1.importExpression = /@(import|use)[ \t]+([^ \t]+?)[ \t]*(?:\n|$|;)/gm;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/scss.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Language from "../Language.js";
|
2 |
+
import Rule from "../Rule.js";
|
3 |
+
export default class implements Language {
|
4 |
+
static readonly importExpression: RegExp;
|
5 |
+
readonly rules: Rule[];
|
6 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/languages/scss.js
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default class default_1 {
|
2 |
+
constructor() {
|
3 |
+
this.rules = [
|
4 |
+
{
|
5 |
+
// string
|
6 |
+
expression: /".*?[^\\](?:\\\\)*"/,
|
7 |
+
},
|
8 |
+
{
|
9 |
+
// string
|
10 |
+
expression: /'.*?[^\\](?:\\\\)*'/,
|
11 |
+
},
|
12 |
+
{
|
13 |
+
// single line comment
|
14 |
+
expression: /\/\/.*/,
|
15 |
+
},
|
16 |
+
{
|
17 |
+
// multiline comment
|
18 |
+
expression: /\/\*((?:.|\s)*?)\*\//,
|
19 |
+
},
|
20 |
+
];
|
21 |
+
}
|
22 |
+
}
|
23 |
+
default_1.importExpression = /@(import|use)\s*("|')(.+?)\2/g;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/package.json
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@digitak/grubber",
|
3 |
+
"version": "3.1.4",
|
4 |
+
"description": "Parse code files and patch it without having to use an AST",
|
5 |
+
"type": "module",
|
6 |
+
"main": "index.js",
|
7 |
+
"exports": {
|
8 |
+
".": "./index.js",
|
9 |
+
"./*": "./*"
|
10 |
+
},
|
11 |
+
"scripts": {
|
12 |
+
"test": "esrun test",
|
13 |
+
"test:jsimports": "esrun test/patchJsImports",
|
14 |
+
"build": "esrun scripts/build",
|
15 |
+
"lint": "eslint source",
|
16 |
+
"lint:fix": "eslint source --fix"
|
17 |
+
},
|
18 |
+
"repository": {
|
19 |
+
"type": "git",
|
20 |
+
"url": "git+https://github.com/digital-loukoum/grubber.git"
|
21 |
+
},
|
22 |
+
"keywords": [
|
23 |
+
"dependencies",
|
24 |
+
"parse",
|
25 |
+
"patch",
|
26 |
+
"find",
|
27 |
+
"replace",
|
28 |
+
"code",
|
29 |
+
"typescript",
|
30 |
+
"javascript",
|
31 |
+
"python",
|
32 |
+
"rust",
|
33 |
+
"c",
|
34 |
+
"c++",
|
35 |
+
"css",
|
36 |
+
"scss",
|
37 |
+
"nim"
|
38 |
+
],
|
39 |
+
"author": "Gin Quin",
|
40 |
+
"license": "MIT",
|
41 |
+
"bugs": {
|
42 |
+
"url": "https://github.com/digital-loukoum/grubber/issues"
|
43 |
+
},
|
44 |
+
"homepage": "https://github.com/digital-loukoum/grubber#readme",
|
45 |
+
"devDependencies": {
|
46 |
+
"@digitak/esrun": "^3.1.2",
|
47 |
+
"@types/node": "^17.0.17",
|
48 |
+
"@typescript-eslint/eslint-plugin": "^5.28.0",
|
49 |
+
"@typescript-eslint/parser": "^5.28.0",
|
50 |
+
"eslint": "^8.17.0",
|
51 |
+
"eslint-plugin-import": "^2.26.0",
|
52 |
+
"fartest": "^2.1.8",
|
53 |
+
"ncp": "^2.0.0",
|
54 |
+
"prettier": "^2.7.1",
|
55 |
+
"typescript": "^4.7.3"
|
56 |
+
}
|
57 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/utilities/addJsExtensions.d.ts
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @param resolve callback that take a module endpoint as entry and the right .js file that is imported
|
3 |
+
*/
|
4 |
+
export default function addJsExtensions(content: string, resolve: (imported: string) => string): string;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/utilities/addJsExtensions.js
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import Parser from "../Parser.js";
|
2 |
+
// import { createRequire } from "module"
|
3 |
+
/**
|
4 |
+
* @param resolve callback that take a module endpoint as entry and the right .js file that is imported
|
5 |
+
*/
|
6 |
+
export default function addJsExtensions(content, resolve) {
|
7 |
+
const dependencies = new Parser(content, "es").findDependencies();
|
8 |
+
let result = "";
|
9 |
+
let offset = 0;
|
10 |
+
for (const dependency of dependencies) {
|
11 |
+
const imported = dependency.groups[2].trim();
|
12 |
+
const patchedImport = resolve(imported);
|
13 |
+
if (patchedImport !== imported) {
|
14 |
+
result +=
|
15 |
+
content.slice(offset, dependency.start) +
|
16 |
+
dependency.slice.replace(imported, patchedImport);
|
17 |
+
offset = dependency.end;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
result += content.slice(offset);
|
21 |
+
return result;
|
22 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/utilities/patchJsImports.d.ts
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { AliasResolver } from "./resolveAliases.js";
|
2 |
+
/**
|
3 |
+
* When Typescript compiles dependencies, it adds no '.js' extension at the end of imports.
|
4 |
+
* The problem is: browser, Node and Deno all need this '.js' extension.
|
5 |
+
* (Thanks #TypescriptTeam for not being standard, look at all the additional work you make me do!)
|
6 |
+
* (All this work for three stupid letters!...)
|
7 |
+
* (Love your work though, Typescript is an awesome language <3)
|
8 |
+
* This utility function can be used after a Typescript compilation to add the mandatory '.js'
|
9 |
+
*/
|
10 |
+
export default function patchJsImports(directories: string[], aliases?: Array<AliasResolver>): void;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/utilities/patchJsImports.js
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { readdirSync, statSync, readFileSync, writeFileSync } from "fs";
|
2 |
+
import addJsExtensions from "./addJsExtensions.js";
|
3 |
+
import { relative as relativePath, resolve as resolvePath, sep, posix } from "path";
|
4 |
+
import { createRequire } from "module";
|
5 |
+
import { resolveAliases } from "./resolveAliases.js";
|
6 |
+
const require = createRequire(process.cwd());
|
7 |
+
const resolve = (dependency, directory) => require
|
8 |
+
.resolve(dependency, { paths: [directory] })
|
9 |
+
.split(sep)
|
10 |
+
.join(posix.sep);
|
11 |
+
const relative = (directory, path) => relativePath(directory, path).split(sep).join(posix.sep);
|
12 |
+
const NODE_MODULES_DIR_REGEX = /(^|\/)node_modules(\/|$)/;
|
13 |
+
/**
|
14 |
+
* When Typescript compiles dependencies, it adds no '.js' extension at the end of imports.
|
15 |
+
* The problem is: browser, Node and Deno all need this '.js' extension.
|
16 |
+
* (Thanks #TypescriptTeam for not being standard, look at all the additional work you make me do!)
|
17 |
+
* (All this work for three stupid letters!...)
|
18 |
+
* (Love your work though, Typescript is an awesome language <3)
|
19 |
+
* This utility function can be used after a Typescript compilation to add the mandatory '.js'
|
20 |
+
*/
|
21 |
+
export default function patchJsImports(directories, aliases) {
|
22 |
+
for (let directory of directories) {
|
23 |
+
directory = resolvePath(directory);
|
24 |
+
for (const element of readdirSync(directory)) {
|
25 |
+
const entity = `${directory}/${element}`;
|
26 |
+
if (statSync(entity).isDirectory()) {
|
27 |
+
patchJsImports([entity], aliases);
|
28 |
+
}
|
29 |
+
else {
|
30 |
+
// only patch .js, .cjs and .mjs files
|
31 |
+
if (!element.match(/\.[mc]?js$/))
|
32 |
+
continue;
|
33 |
+
const content = readFileSync(entity, "utf8");
|
34 |
+
const patchedContent = addJsExtensions(content, imported => {
|
35 |
+
const resolvedAlias = resolveAliases(imported, aliases);
|
36 |
+
if (resolvedAlias != null)
|
37 |
+
return resolvedAlias;
|
38 |
+
let path = resolve(imported, directory);
|
39 |
+
if (path !== imported) {
|
40 |
+
const isNodeModulePath = NODE_MODULES_DIR_REGEX.test(path);
|
41 |
+
if (isNodeModulePath)
|
42 |
+
path = imported;
|
43 |
+
else {
|
44 |
+
path = relative(directory, path);
|
45 |
+
if (path[0] !== "." && path[0] !== "/")
|
46 |
+
path = `./${path}`;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
return path;
|
50 |
+
});
|
51 |
+
writeFileSync(entity, patchedContent);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/utilities/resolveAliases.d.ts
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export declare type AliasResolver = {
|
2 |
+
find: RegExp;
|
3 |
+
replacement: string | null;
|
4 |
+
};
|
5 |
+
export declare function resolveAliases(path: string, aliases?: Array<AliasResolver>): string | null;
|
node_modules/.pnpm/@[email protected]/node_modules/@digitak/grubber/utilities/resolveAliases.js
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export function resolveAliases(path, aliases) {
|
2 |
+
if (aliases) {
|
3 |
+
for (const { find, replacement } of aliases) {
|
4 |
+
if (find.test(path)) {
|
5 |
+
if (replacement)
|
6 |
+
return path.replace(find, replacement);
|
7 |
+
else
|
8 |
+
return path;
|
9 |
+
}
|
10 |
+
}
|
11 |
+
}
|
12 |
+
return null;
|
13 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@esbuild/win32-x64/README.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# esbuild
|
2 |
+
|
3 |
+
This is the Windows 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
node_modules/.pnpm/@[email protected]/node_modules/@esbuild/win32-x64/esbuild.exe
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:feeb10cd8033b936130dcd8f9c82c4bf6da66ca9f003c12455e6a94a80ba8753
|
3 |
+
size 9303552
|
node_modules/.pnpm/@[email protected]/node_modules/@esbuild/win32-x64/package.json
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@esbuild/win32-x64",
|
3 |
+
"version": "0.17.19",
|
4 |
+
"description": "The Windows 64-bit binary for esbuild, a JavaScript bundler.",
|
5 |
+
"repository": "https://github.com/evanw/esbuild",
|
6 |
+
"license": "MIT",
|
7 |
+
"preferUnplugged": true,
|
8 |
+
"engines": {
|
9 |
+
"node": ">=12"
|
10 |
+
},
|
11 |
+
"os": [
|
12 |
+
"win32"
|
13 |
+
],
|
14 |
+
"cpu": [
|
15 |
+
"x64"
|
16 |
+
]
|
17 |
+
}
|
node_modules/.pnpm/@[email protected]/node_modules/@silentbot1/nat-api/.github/dependabot.yml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: 2
|
2 |
+
updates:
|
3 |
+
- package-ecosystem: npm
|
4 |
+
directory: "/"
|
5 |
+
schedule:
|
6 |
+
interval: daily
|
7 |
+
time: "04:00"
|
8 |
+
open-pull-requests-limit: 10
|
node_modules/.pnpm/@[email protected]/node_modules/@silentbot1/nat-api/.github/workflows/ci.yml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: ci
|
2 |
+
on: [push,pull_request]
|
3 |
+
jobs:
|
4 |
+
test:
|
5 |
+
name: Node ${{ matrix.node }} / ${{ matrix.os }}
|
6 |
+
runs-on: ${{ matrix.os }}
|
7 |
+
strategy:
|
8 |
+
fail-fast: false
|
9 |
+
matrix:
|
10 |
+
os:
|
11 |
+
- ubuntu-latest
|
12 |
+
node:
|
13 |
+
- '10'
|
14 |
+
steps:
|
15 |
+
- uses: actions/checkout@v2
|
16 |
+
- uses: actions/setup-node@v2
|
17 |
+
with:
|
18 |
+
node-version: ${{ matrix.node }}
|
19 |
+
- run: npm install
|
20 |
+
- run: npm test
|
node_modules/.pnpm/@[email protected]/node_modules/@silentbot1/nat-api/.idea/aws.xml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="accountSettings">
|
4 |
+
<option name="activeProfile" value="profile:default" />
|
5 |
+
<option name="activeRegion" value="us-east-1" />
|
6 |
+
<option name="recentlyUsedProfiles">
|
7 |
+
<list>
|
8 |
+
<option value="profile:default" />
|
9 |
+
</list>
|
10 |
+
</option>
|
11 |
+
<option name="recentlyUsedRegions">
|
12 |
+
<list>
|
13 |
+
<option value="us-east-1" />
|
14 |
+
</list>
|
15 |
+
</option>
|
16 |
+
</component>
|
17 |
+
</project>
|
node_modules/.pnpm/@[email protected]/node_modules/@silentbot1/nat-api/.idea/codeStyles/Project.xml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="ProjectCodeStyleConfiguration">
|
2 |
+
<code_scheme name="Project" version="173">
|
3 |
+
<JSCodeStyleSettings version="0">
|
4 |
+
<option name="USE_SEMICOLON_AFTER_STATEMENT" value="false" />
|
5 |
+
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
6 |
+
<option name="SPACE_BEFORE_GENERATOR_MULT" value="true" />
|
7 |
+
<option name="USE_DOUBLE_QUOTES" value="false" />
|
8 |
+
<option name="FORCE_QUOTE_STYlE" value="true" />
|
9 |
+
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
10 |
+
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
11 |
+
</JSCodeStyleSettings>
|
12 |
+
<TypeScriptCodeStyleSettings version="0">
|
13 |
+
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
14 |
+
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
15 |
+
</TypeScriptCodeStyleSettings>
|
16 |
+
<codeStyleSettings language="JavaScript">
|
17 |
+
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
|
18 |
+
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
19 |
+
<option name="ALIGN_MULTILINE_FOR" value="false" />
|
20 |
+
<option name="SPACE_BEFORE_METHOD_PARENTHESES" value="true" />
|
21 |
+
<option name="TERNARY_OPERATION_SIGNS_ON_NEXT_LINE" value="true" />
|
22 |
+
<option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="true" />
|
23 |
+
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
|
24 |
+
<indentOptions>
|
25 |
+
<option name="INDENT_SIZE" value="2" />
|
26 |
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
27 |
+
<option name="TAB_SIZE" value="2" />
|
28 |
+
</indentOptions>
|
29 |
+
</codeStyleSettings>
|
30 |
+
</code_scheme>
|
31 |
+
</component>
|
node_modules/.pnpm/@[email protected]/node_modules/@silentbot1/nat-api/.idea/codeStyles/codeStyleConfig.xml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="ProjectCodeStyleConfiguration">
|
2 |
+
<state>
|
3 |
+
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
4 |
+
</state>
|
5 |
+
</component>
|
node_modules/.pnpm/@[email protected]/node_modules/@silentbot1/nat-api/.idea/inspectionProfiles/Project_Default.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<profile version="1.0">
|
3 |
+
<option name="myName" value="Project Default" />
|
4 |
+
<inspection_tool class="StandardJS" enabled="true" level="ERROR" enabled_by_default="true" />
|
5 |
+
</profile>
|
6 |
+
</component>
|