aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--loader.js15
-rw-r--r--package.json4
-rw-r--r--pirc.js (renamed from index.js)6
4 files changed, 22 insertions, 6 deletions
diff --git a/README.md b/README.md
index 1fbf22d..295e7d0 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,8 @@ client. You need a relay of your own; PiRC's self-hosting guide covers
running one.
This repository holds releases only: the extension built into one file
-(`index.js`). Its source is in PiRC's repository.
+(`pirc.js`), and `loader.js`, which loads it. Its source is in PiRC's
+repository.
## Install
diff --git a/loader.js b/loader.js
new file mode 100644
index 0000000..247724f
--- /dev/null
+++ b/loader.js
@@ -0,0 +1,15 @@
+// The published extension's entry point. pi's /reload imports the
+// extension again, but Node keeps every JavaScript module it has imported,
+// so a bundle updated in place would not run until pi restarted. This file
+// imports the bundle beside it by a URL that changes when the file does,
+// so a reload after an update runs the new code, and is the same in every
+// version, so that its own copy, which Node keeps, is never stale. Not
+// index.js: versions before it had their bundle there, which Node would
+// still hold after updating from one of them.
+import { statSync } from "node:fs";
+
+export default async function (pi) {
+ const bundle = new URL("./pirc.js", import.meta.url);
+ const { default: factory } = await import(`${bundle.href}?t=${statSync(bundle).mtimeMs}`);
+ return factory(pi);
+}
diff --git a/package.json b/package.json
index 6e3d708..1b03009 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "pirc-extension",
- "version": "0.1.9-dev+3bc256ad5274",
+ "version": "0.1.9-dev+69800ee67711",
"description": "PiRC: puts every interactive pi session on a PiRC relay",
"license": "MIT",
"homepage": "https://pirc.dev",
@@ -10,7 +10,7 @@
],
"pi": {
"extensions": [
- "./index.js"
+ "./loader.js"
]
},
"peerDependencies": {
diff --git a/index.js b/pirc.js
index b9758d6..be18709 100644
--- a/index.js
+++ b/pirc.js
@@ -1,4 +1,4 @@
-// PiRC extension 0.1.9-dev+3bc256ad5274. Third-party code in this file: @bufbuild/protobuf@2.16.0, ws@8.22.0; see NOTICE.
+// PiRC extension 0.1.9-dev+69800ee67711. Third-party code in this file: @bufbuild/protobuf@2.16.0, ws@8.22.0; see NOTICE.
import { createRequire as __pircCreateRequire } from "node:module";
const require = __pircCreateRequire(import.meta.url);
var __create = Object.create;
@@ -8717,7 +8717,7 @@ function requestIdOf(m) {
}
// extension/src/index.ts
-var EXTENSION_VERSION = true ? "0.1.9-dev+3bc256ad5274" : "dev";
+var EXTENSION_VERSION = true ? "0.1.9-dev+69800ee67711" : "dev";
function piVersion() {
try {
let dir = dirname3(realpathSync(process.argv[1]));
@@ -8732,7 +8732,7 @@ function piVersion() {
}
return "unknown";
}
-var LOAD = true ? "0.1.9-dev+3bc256ad5274" : `dev ${randomBytes3(4).toString("hex")}`;
+var LOAD = true ? "0.1.9-dev+69800ee67711" : `dev ${randomBytes3(4).toString("hex")}`;
var KEY = /* @__PURE__ */ Symbol.for("pirc.extension");
var proc = globalThis[KEY] ??= {};
if (!proc.host || proc.load !== LOAD) {