codex-token-tracker-nodejs16 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/LICENSE +21 -0
- package/README.md +111 -0
- package/assets/icon.png +0 -0
- package/assets/tray-win-light.png +0 -0
- package/assets/tray-win.png +0 -0
- package/assets/trayTemplate.png +0 -0
- package/assets/trayTemplate@2x.png +0 -0
- package/bin/codex-tracker.js +18 -0
- package/dist/cli.js +11327 -0
- package/dist/main.js +10042 -0
- package/dist/node16-polyfill.js +97 -0
- package/dist/preload.js +25 -0
- package/dist/renderer/index.html +14 -0
- package/dist/renderer/renderer.js +13863 -0
- package/dist/renderer/styles.css +674 -0
- package/package.json +85 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Node 16 runtime shims for codex-token-tracker-nodejs16.
|
|
4
|
+
*
|
|
5
|
+
* This file is prepended (via an esbuild `banner`) to every Node-side bundle, so it runs before a
|
|
6
|
+
* single line of application or vendored code is evaluated. That ordering matters: libraries we
|
|
7
|
+
* bundle (Convex's HTTP client, `ws`) capture globals at module scope.
|
|
8
|
+
*
|
|
9
|
+
* Everything here is installed **only when missing**, so the exact same bundle runs unchanged on
|
|
10
|
+
* Node 18/20/22 and inside Electron (whose main process already ships a modern Node). On those
|
|
11
|
+
* runtimes this file is a no-op.
|
|
12
|
+
*
|
|
13
|
+
* What Node 16.15 is missing, and where we source the replacement:
|
|
14
|
+
* fetch / Headers / Request / Response / FormData / File → undici (Node 18's fetch *is* undici)
|
|
15
|
+
* Blob → node:buffer (present since 16.7)
|
|
16
|
+
* ReadableStream / WritableStream / TransformStream → node:stream/web (present since 16.5)
|
|
17
|
+
* crypto (WebCrypto global) → node:crypto webcrypto
|
|
18
|
+
* structuredClone → node:v8 serialize/deserialize
|
|
19
|
+
*
|
|
20
|
+
* Deliberately NOT polyfilled: Array.prototype.findLast/findLastIndex and friends. Nothing in the
|
|
21
|
+
* bundle uses them (verified against the built output), and patching Array.prototype is the one
|
|
22
|
+
* change that could perturb unrelated code. If a future dependency needs them, add them here.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** Define a global only if the runtime does not already provide it. */
|
|
26
|
+
function provide(name, factory) {
|
|
27
|
+
if (typeof globalThis[name] !== "undefined") return false;
|
|
28
|
+
let value;
|
|
29
|
+
try {
|
|
30
|
+
value = factory();
|
|
31
|
+
} catch (err) {
|
|
32
|
+
return err;
|
|
33
|
+
}
|
|
34
|
+
if (value === undefined || value === null) return false;
|
|
35
|
+
Object.defineProperty(globalThis, name, { value, writable: true, configurable: true, enumerable: false });
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// fetch and its companion classes
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
if (typeof globalThis.fetch === "undefined") {
|
|
43
|
+
let undici;
|
|
44
|
+
try {
|
|
45
|
+
undici = require("undici");
|
|
46
|
+
} catch (err) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
"codex-token-tracker-nodejs16 needs a `fetch` implementation on Node " +
|
|
49
|
+
process.versions.node +
|
|
50
|
+
", but the bundled `undici` dependency could not be loaded (" +
|
|
51
|
+
(err && err.message ? err.message : String(err)) +
|
|
52
|
+
").\n" +
|
|
53
|
+
"Reinstall the package (`npm install -g codex-token-tracker-nodejs16`), or upgrade to Node 18+ where fetch is built in."
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (typeof undici.fetch !== "function") {
|
|
57
|
+
throw new Error(
|
|
58
|
+
"codex-token-tracker-nodejs16: the installed `undici` does not export fetch. Node >= 16.8 is required; this process is Node " +
|
|
59
|
+
process.versions.node +
|
|
60
|
+
"."
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
// undici's fetch reads `globalThis.fetch`-adjacent classes off its own module, so installing the
|
|
64
|
+
// whole family together keeps instanceof checks (e.g. `res instanceof Response`) coherent.
|
|
65
|
+
Object.defineProperty(globalThis, "fetch", {
|
|
66
|
+
value: function fetch(input, init) {
|
|
67
|
+
return undici.fetch(input, init);
|
|
68
|
+
},
|
|
69
|
+
writable: true,
|
|
70
|
+
configurable: true,
|
|
71
|
+
enumerable: false,
|
|
72
|
+
});
|
|
73
|
+
for (const name of ["Headers", "Request", "Response", "FormData", "File", "FileReader"]) {
|
|
74
|
+
if (undici[name]) provide(name, () => undici[name]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// Web platform globals that Node only exposed later. Present on Node 18+, so these are the
|
|
80
|
+
// difference between "Node 16 behaves like Node 20" and "Node 16 quietly takes a different branch".
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
provide("Blob", () => require("buffer").Blob);
|
|
83
|
+
|
|
84
|
+
for (const name of ["ReadableStream", "WritableStream", "TransformStream", "ByteLengthQueuingStrategy", "CountQueuingStrategy"]) {
|
|
85
|
+
provide(name, () => require("stream/web")[name]);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
provide("crypto", () => require("crypto").webcrypto);
|
|
89
|
+
|
|
90
|
+
provide("structuredClone", () => {
|
|
91
|
+
const v8 = require("v8");
|
|
92
|
+
return function structuredClone(value) {
|
|
93
|
+
return v8.deserialize(v8.serialize(value));
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
module.exports = {};
|
package/dist/preload.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require("./node16-polyfill.js");
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// ../menubar/src/preload.ts
|
|
5
|
+
var import_electron = require("electron");
|
|
6
|
+
var bridge = {
|
|
7
|
+
getSnapshot: () => import_electron.ipcRenderer.invoke("snapshot:get"),
|
|
8
|
+
onSnapshot: (cb) => {
|
|
9
|
+
const listener = (_e, s) => cb(s);
|
|
10
|
+
import_electron.ipcRenderer.on("snapshot", listener);
|
|
11
|
+
return () => import_electron.ipcRenderer.removeListener("snapshot", listener);
|
|
12
|
+
},
|
|
13
|
+
setLanguage: (lang) => import_electron.ipcRenderer.invoke("language:set", lang),
|
|
14
|
+
openDashboard: () => import_electron.ipcRenderer.invoke("dashboard:open"),
|
|
15
|
+
openExternal: (url) => import_electron.ipcRenderer.invoke("external:open", url),
|
|
16
|
+
login: () => import_electron.ipcRenderer.invoke("auth:login"),
|
|
17
|
+
cancelLogin: () => import_electron.ipcRenderer.invoke("auth:cancel"),
|
|
18
|
+
logout: () => import_electron.ipcRenderer.invoke("auth:logout"),
|
|
19
|
+
refresh: () => import_electron.ipcRenderer.invoke("refresh"),
|
|
20
|
+
syncNow: () => import_electron.ipcRenderer.invoke("sync:now"),
|
|
21
|
+
checkUpdate: () => import_electron.ipcRenderer.invoke("update:check"),
|
|
22
|
+
installUpdate: () => import_electron.ipcRenderer.invoke("update:install"),
|
|
23
|
+
quit: () => import_electron.ipcRenderer.invoke("quit")
|
|
24
|
+
};
|
|
25
|
+
import_electron.contextBridge.exposeInMainWorld("codexTracker", bridge);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:;" />
|
|
6
|
+
<meta name="color-scheme" content="light dark" />
|
|
7
|
+
<title>Codex Tracker</title>
|
|
8
|
+
<link rel="stylesheet" href="./styles.css" />
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="root"></div>
|
|
12
|
+
<script src="./renderer.js"></script>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|