Skip to content

Commit 65fc7ca

Browse files
committed
Migrate to ESM
1 parent d787033 commit 65fc7ca

35 files changed

+146
-102
lines changed

extension/command/help.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
class HelpCommand extends Command {
1+
import { c } from "../core/index.js";
2+
import Command from "../core/command/base.js";
3+
4+
export default class HelpCommand extends Command {
25
constructor() {
36
super("help", "Show the help messages.")
47
}
@@ -22,4 +25,4 @@ class HelpCommand extends Command {
2225
return { content: key, description };
2326
});
2427
}
25-
}
28+
};

extension/command/label.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
class LabelCommand extends Command {
1+
import { c } from "../core/index.js";
2+
import Command from "../core/command/base.js";
3+
4+
export default class LabelCommand extends Command {
25
constructor(index) {
36
super("label", "Search issue labels of rust-lang repository.");
47
this.labels = index.map(([name, description]) => {
5-
return {name, description};
8+
return { name, description };
69
});
710
}
811

@@ -32,4 +35,4 @@ class LabelCommand extends Command {
3235
}
3336
});
3437
}
35-
}
38+
};

extension/command/rfc.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
class RfcCommand extends Command {
1+
import { c } from "../core/index.js";
2+
import Command from "../core/command/base.js";
3+
4+
export default class RfcCommand extends Command {
25
constructor(index) {
36
super("rfc", "Search Rust RFCs.");
47
this.rfcs = index.map(([number, name, date, title]) => {
@@ -38,4 +41,4 @@ class RfcCommand extends Command {
3841
}
3942
});
4043
}
41-
}
44+
};

extension/command/rustc.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
class RustcCommand extends Command {
1+
import { c } from "../core/index.js";
2+
import Command from "../core/command/base.js";
3+
4+
export default class RustcCommand extends Command {
25
constructor(index) {
36
super("rustc", "Search rustc codegen options and lints.");
47
this.docs = [];
@@ -23,4 +26,4 @@ class RustcCommand extends Command {
2326
};
2427
});
2528
}
26-
}
29+
};

extension/command/stable.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
class StableCommand extends Command {
1+
import { c } from "../core/index.js";
2+
import Command from "../core/command/base.js";
3+
import { getScheduledVersions } from "../rust-version.js";
4+
5+
export default class StableCommand extends Command {
26
constructor() {
37
super("stable", "Show stable Rust scheduled release date.")
48
}
@@ -8,4 +12,4 @@ class StableCommand extends Command {
812
.map(version => `Version ${c.match(version.number)} scheduled release on ${c.match(c.normalizeDate(version.date))}`)
913
return this.wrap(versions);
1014
}
11-
}
15+
};

extension/command/target.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
class TargetCommand extends Command {
1+
import { c } from "../core/index.js";
2+
import Command from "../core/command/base.js";
3+
4+
export default class TargetCommand extends Command {
25
constructor(index) {
36
super("target", "Search rust target for three tiers.");
47
this.targets = [];
@@ -24,4 +27,4 @@ class TargetCommand extends Command {
2427
};
2528
});
2629
}
27-
}
30+
};

extension/crate-manager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
class CrateDocManager {
1+
import storage from "./core/storage.js";
2+
3+
export class CrateDocManager {
24
static async getCrates() {
35
return await storage.getItem("crates") || {};
46
}
@@ -63,4 +65,4 @@ class CrateDocManager {
6365
await storage.setItem("crates", crates);
6466
await storage.removeItem(`@${name}`);
6567
}
66-
}
68+
};

extension/deminifier.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Deminifier {
1+
export default class Deminifier {
22
constructor(mapping) {
33
this.mapping = mapping;
44
}
@@ -15,4 +15,4 @@ class Deminifier {
1515
setMapping(mapping) {
1616
this.mapping = mapping;
1717
}
18-
}
18+
};

extension/index-manager.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1+
import caniuseIndex from "./index/caniuse.js";
2+
import booksIndex from "./index/books.js";
3+
import commandsIndex from "./index/commands.js";
4+
import labelsIndex from "./index/labels.js";
5+
import lintsIndex from "./index/lints.js";
6+
import rfcsIndex from "./index/rfcs.js";
7+
import rustcIndex from "./index/rustc.js";
8+
import targetsIndex from "./index/targets.js";
9+
import searchIndex from "./index/std-docs.js";
10+
import { mapping, crateIndex } from "./index/crates.js";
11+
import storage from "./core/storage.js";
12+
113
// Query all storage by this method:
214
// chrome.storage.local.get(null, function(result) {
315
// console.log('Value currently is ', result);
416
// });
517

6-
class IndexManager {
18+
export default class IndexManager {
719
static async getStdStableIndex() {
820
// Convert default map searchIndex to Object since rust 1.76.0
921
return await storage.getItem('index-std-stable') || Object.fromEntries(searchIndex);
@@ -125,4 +137,4 @@ class IndexManager {
125137
IndexManager.setStdStableIndex(searchIndex);
126138
IndexManager.setTargetIndex(targetsIndex);
127139
}
128-
}
140+
};

extension/index/attributes.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/index/books.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/index/caniuse.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/index/commands.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var commandsIndex = {
1+
export default {
22
"book": [
33
["The Rust Programming Language", "https://doc.rust-lang.org/stable/book/"],
44
["Rust Async Book", "https://rust-lang.github.io/async-book/"],

extension/index/crates.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/index/labels.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/index/lints.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extension/index/rfcs.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)