Skip to content

Commit

Permalink
Migrate to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
Folyd committed May 26, 2024
1 parent d787033 commit 65fc7ca
Show file tree
Hide file tree
Showing 35 changed files with 146 additions and 102 deletions.
7 changes: 5 additions & 2 deletions extension/command/help.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class HelpCommand extends Command {
import { c } from "../core/index.js";
import Command from "../core/command/base.js";

export default class HelpCommand extends Command {
constructor() {
super("help", "Show the help messages.")
}
Expand All @@ -22,4 +25,4 @@ class HelpCommand extends Command {
return { content: key, description };
});
}
}
};
9 changes: 6 additions & 3 deletions extension/command/label.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
class LabelCommand extends Command {
import { c } from "../core/index.js";
import Command from "../core/command/base.js";

export default class LabelCommand extends Command {
constructor(index) {
super("label", "Search issue labels of rust-lang repository.");
this.labels = index.map(([name, description]) => {
return {name, description};
return { name, description };
});
}

Expand Down Expand Up @@ -32,4 +35,4 @@ class LabelCommand extends Command {
}
});
}
}
};
7 changes: 5 additions & 2 deletions extension/command/rfc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class RfcCommand extends Command {
import { c } from "../core/index.js";
import Command from "../core/command/base.js";

export default class RfcCommand extends Command {
constructor(index) {
super("rfc", "Search Rust RFCs.");
this.rfcs = index.map(([number, name, date, title]) => {
Expand Down Expand Up @@ -38,4 +41,4 @@ class RfcCommand extends Command {
}
});
}
}
};
7 changes: 5 additions & 2 deletions extension/command/rustc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class RustcCommand extends Command {
import { c } from "../core/index.js";
import Command from "../core/command/base.js";

export default class RustcCommand extends Command {
constructor(index) {
super("rustc", "Search rustc codegen options and lints.");
this.docs = [];
Expand All @@ -23,4 +26,4 @@ class RustcCommand extends Command {
};
});
}
}
};
8 changes: 6 additions & 2 deletions extension/command/stable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
class StableCommand extends Command {
import { c } from "../core/index.js";
import Command from "../core/command/base.js";
import { getScheduledVersions } from "../rust-version.js";

export default class StableCommand extends Command {
constructor() {
super("stable", "Show stable Rust scheduled release date.")
}
Expand All @@ -8,4 +12,4 @@ class StableCommand extends Command {
.map(version => `Version ${c.match(version.number)} scheduled release on ${c.match(c.normalizeDate(version.date))}`)
return this.wrap(versions);
}
}
};
7 changes: 5 additions & 2 deletions extension/command/target.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class TargetCommand extends Command {
import { c } from "../core/index.js";
import Command from "../core/command/base.js";

export default class TargetCommand extends Command {
constructor(index) {
super("target", "Search rust target for three tiers.");
this.targets = [];
Expand All @@ -24,4 +27,4 @@ class TargetCommand extends Command {
};
});
}
}
};
6 changes: 4 additions & 2 deletions extension/crate-manager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class CrateDocManager {
import storage from "./core/storage.js";

export class CrateDocManager {
static async getCrates() {
return await storage.getItem("crates") || {};
}
Expand Down Expand Up @@ -63,4 +65,4 @@ class CrateDocManager {
await storage.setItem("crates", crates);
await storage.removeItem(`@${name}`);
}
}
};
4 changes: 2 additions & 2 deletions extension/deminifier.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Deminifier {
export default class Deminifier {
constructor(mapping) {
this.mapping = mapping;
}
Expand All @@ -15,4 +15,4 @@ class Deminifier {
setMapping(mapping) {
this.mapping = mapping;
}
}
};
16 changes: 14 additions & 2 deletions extension/index-manager.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import caniuseIndex from "./index/caniuse.js";
import booksIndex from "./index/books.js";
import commandsIndex from "./index/commands.js";
import labelsIndex from "./index/labels.js";
import lintsIndex from "./index/lints.js";
import rfcsIndex from "./index/rfcs.js";
import rustcIndex from "./index/rustc.js";
import targetsIndex from "./index/targets.js";
import searchIndex from "./index/std-docs.js";
import { mapping, crateIndex } from "./index/crates.js";
import storage from "./core/storage.js";

// Query all storage by this method:
// chrome.storage.local.get(null, function(result) {
// console.log('Value currently is ', result);
// });

class IndexManager {
export default class IndexManager {
static async getStdStableIndex() {
// Convert default map searchIndex to Object since rust 1.76.0
return await storage.getItem('index-std-stable') || Object.fromEntries(searchIndex);
Expand Down Expand Up @@ -125,4 +137,4 @@ class IndexManager {
IndexManager.setStdStableIndex(searchIndex);
IndexManager.setTargetIndex(targetsIndex);
}
}
};
3 changes: 2 additions & 1 deletion extension/index/attributes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion extension/index/books.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion extension/index/caniuse.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion extension/index/commands.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var commandsIndex = {
export default {
"book": [
["The Rust Programming Language", "https://doc.rust-lang.org/stable/book/"],
["Rust Async Book", "https://rust-lang.github.io/async-book/"],
Expand Down
3 changes: 2 additions & 1 deletion extension/index/crates.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion extension/index/labels.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion extension/index/lints.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion extension/index/rfcs.js

Large diffs are not rendered by default.

Loading

0 comments on commit 65fc7ca

Please sign in to comment.