note-connector 0.1.0

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/dist/util.js ADDED
@@ -0,0 +1,30 @@
1
+ import { spawn } from "node:child_process";
2
+ export function copyToClipboard(text) {
3
+ return new Promise((resolve) => {
4
+ const cmd = process.platform === "darwin" ? "pbcopy" : process.platform === "win32" ? "clip" : "xclip";
5
+ const args = process.platform === "linux" ? ["-selection", "clipboard"] : [];
6
+ try {
7
+ const child = spawn(cmd, args, { stdio: ["pipe", "ignore", "ignore"] });
8
+ child.on("error", () => resolve(false));
9
+ child.on("close", (code) => resolve(code === 0));
10
+ child.stdin.write(text);
11
+ child.stdin.end();
12
+ }
13
+ catch {
14
+ resolve(false);
15
+ }
16
+ });
17
+ }
18
+ export function openBrowser(url) {
19
+ const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
20
+ try {
21
+ spawn(cmd, [url], {
22
+ stdio: "ignore",
23
+ detached: true,
24
+ shell: process.platform === "win32",
25
+ }).unref();
26
+ }
27
+ catch {
28
+ /* ignore */
29
+ }
30
+ }
@@ -0,0 +1,4 @@
1
+ /** Resolve version from the published `note-connector` package.json. */
2
+ export declare function resolveAppVersion(): string;
3
+ export declare const APP_VERSION: string;
4
+ export declare function isNewerVersion(candidate: string, current: string): boolean;
@@ -0,0 +1,41 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ /** Resolve version from the published `note-connector` package.json. */
5
+ export function resolveAppVersion() {
6
+ try {
7
+ let dir = dirname(fileURLToPath(import.meta.url));
8
+ for (let i = 0; i < 10; i++) {
9
+ try {
10
+ const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
11
+ if (pkg.name === "note-connector" && typeof pkg.version === "string") {
12
+ return pkg.version;
13
+ }
14
+ }
15
+ catch {
16
+ /* keep walking */
17
+ }
18
+ const parent = dirname(dir);
19
+ if (parent === dir)
20
+ break;
21
+ dir = parent;
22
+ }
23
+ }
24
+ catch {
25
+ /* fall through */
26
+ }
27
+ return "0.0.0";
28
+ }
29
+ export const APP_VERSION = resolveAppVersion();
30
+ export function isNewerVersion(candidate, current) {
31
+ const parse = (v) => v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
32
+ const a = parse(candidate);
33
+ const b = parse(current);
34
+ const len = Math.max(a.length, b.length);
35
+ for (let i = 0; i < len; i++) {
36
+ const diff = (a[i] ?? 0) - (b[i] ?? 0);
37
+ if (diff !== 0)
38
+ return diff > 0;
39
+ }
40
+ return false;
41
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+ import { APP_VERSION, isNewerVersion, resolveAppVersion } from "./version.js";
4
+ test("APP_VERSION matches package.json", () => {
5
+ assert.equal(APP_VERSION, resolveAppVersion());
6
+ assert.match(APP_VERSION, /^\d+\.\d+\.\d+/);
7
+ });
8
+ test("isNewerVersion", () => {
9
+ assert.equal(isNewerVersion("1.0.1", "1.0.0"), true);
10
+ assert.equal(isNewerVersion("1.0.0", "1.0.1"), false);
11
+ assert.equal(isNewerVersion("2.0.0", "1.9.9"), true);
12
+ });
@@ -0,0 +1 @@
1
+ export declare function parseWidgetData(payload: unknown): Record<string, unknown>;
@@ -0,0 +1,16 @@
1
+ export function parseWidgetData(payload) {
2
+ if (!payload || typeof payload !== "object")
3
+ return {};
4
+ const obj = payload;
5
+ if (typeof obj.result === "string") {
6
+ try {
7
+ const inner = JSON.parse(obj.result);
8
+ if (inner && typeof inner === "object")
9
+ return inner;
10
+ }
11
+ catch {
12
+ /* ignore */
13
+ }
14
+ }
15
+ return obj;
16
+ }
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "note-connector",
3
+ "version": "0.1.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "note-connector \u2014 ChatGPT connector for note.com (MCP + Apps SDK UI)",
8
+ "license": "MIT",
9
+ "type": "module",
10
+ "bin": {
11
+ "note-connector": "dist/bin.js"
12
+ },
13
+ "files": [
14
+ "dist/**",
15
+ "README.md"
16
+ ],
17
+ "engines": {
18
+ "node": ">=20.10"
19
+ },
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.json",
22
+ "test": "npm run build && node --test dist/net.test.js dist/version.test.js dist/config.test.js",
23
+ "prepublishOnly": "npm run build"
24
+ },
25
+ "dependencies": {
26
+ "commander": "^13.1.0"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^22.10.0",
30
+ "typescript": "^5.7.0",
31
+ "vitest": "^3.0.0"
32
+ },
33
+ "keywords": [
34
+ "chatgpt",
35
+ "mcp",
36
+ "note.com",
37
+ "note-connector",
38
+ "apps-sdk"
39
+ ],
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/drillan/note-mcp.git"
43
+ },
44
+ "homepage": "https://github.com/drillan/note-mcp#readme"
45
+ }