@plures/pluresdb 2.9.6 → 2.9.7
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/.tsbuildinfo +1 -0
- package/dist/better-sqlite3-shared.d.ts +12 -0
- package/dist/better-sqlite3-shared.d.ts.map +1 -0
- package/dist/better-sqlite3-shared.js +143 -0
- package/dist/better-sqlite3-shared.js.map +1 -0
- package/dist/better-sqlite3.d.ts +4 -0
- package/dist/better-sqlite3.d.ts.map +1 -0
- package/dist/better-sqlite3.js +8 -0
- package/dist/better-sqlite3.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js.map +1 -0
- package/dist/local-first/unified-api.d.ts +110 -0
- package/dist/local-first/unified-api.d.ts.map +1 -0
- package/dist/local-first/unified-api.js +348 -0
- package/dist/local-first/unified-api.js.map +1 -0
- package/dist/napi/index.d.ts +38 -0
- package/dist/napi/index.d.ts.map +1 -0
- package/dist/napi/index.js.map +1 -0
- package/dist/node-index.d.ts +182 -0
- package/dist/node-index.d.ts.map +1 -0
- package/dist/node-index.js +720 -0
- package/dist/node-index.js.map +1 -0
- package/dist/node-wrapper.d.ts +44 -0
- package/dist/node-wrapper.d.ts.map +1 -0
- package/dist/node-wrapper.js +296 -0
- package/dist/node-wrapper.js.map +1 -0
- package/dist/types/index.d.ts +28 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/node-types.d.ts +71 -0
- package/dist/types/node-types.d.ts.map +1 -0
- package/dist/types/node-types.js +6 -0
- package/dist/types/node-types.js.map +1 -0
- package/dist/util/debug.d.ts +3 -0
- package/dist/util/debug.d.ts.map +1 -0
- package/dist/util/debug.js +34 -0
- package/dist/util/debug.js.map +1 -0
- package/dist/vscode/extension.d.ts +81 -0
- package/dist/vscode/extension.d.ts.map +1 -0
- package/dist/vscode/extension.js +309 -0
- package/dist/vscode/extension.js.map +1 -0
- package/package.json +3 -1
- package/scripts/postinstall.js +156 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { PluresNode, SQLiteCompatibleAPI } from "../node-index";
|
|
2
|
+
import type { PluresDBConfig } from "../types/node-types";
|
|
3
|
+
type DisposableLike = {
|
|
4
|
+
dispose(): void;
|
|
5
|
+
};
|
|
6
|
+
type InputBoxOptions = {
|
|
7
|
+
prompt: string;
|
|
8
|
+
placeHolder?: string;
|
|
9
|
+
};
|
|
10
|
+
type TextDocumentInit = {
|
|
11
|
+
content: string;
|
|
12
|
+
language: string;
|
|
13
|
+
};
|
|
14
|
+
type UriLike = {
|
|
15
|
+
toString(): string;
|
|
16
|
+
} | string;
|
|
17
|
+
export type VSCodeWindow = {
|
|
18
|
+
showInformationMessage(message: string): void | Promise<unknown>;
|
|
19
|
+
showErrorMessage(message: string): void | Promise<unknown>;
|
|
20
|
+
showInputBox(options: InputBoxOptions): Promise<string | undefined>;
|
|
21
|
+
showTextDocument(document: unknown): Promise<unknown>;
|
|
22
|
+
};
|
|
23
|
+
export type VSCodeCommands = {
|
|
24
|
+
registerCommand(command: string, callback: (...args: unknown[]) => unknown): DisposableLike;
|
|
25
|
+
};
|
|
26
|
+
export type VSCodeWorkspace = {
|
|
27
|
+
openTextDocument(init: TextDocumentInit): Promise<unknown>;
|
|
28
|
+
};
|
|
29
|
+
export type VSCodeEnv = {
|
|
30
|
+
openExternal(target: UriLike): Promise<unknown> | unknown;
|
|
31
|
+
};
|
|
32
|
+
export type VSCodeUri = {
|
|
33
|
+
parse(target: string): UriLike;
|
|
34
|
+
};
|
|
35
|
+
export type VSCodeAPI = {
|
|
36
|
+
window: VSCodeWindow;
|
|
37
|
+
commands: VSCodeCommands;
|
|
38
|
+
workspace: VSCodeWorkspace;
|
|
39
|
+
env: VSCodeEnv;
|
|
40
|
+
Uri: VSCodeUri;
|
|
41
|
+
};
|
|
42
|
+
export type ExtensionContextLike = {
|
|
43
|
+
subscriptions: DisposableLike[];
|
|
44
|
+
globalStorageUri: {
|
|
45
|
+
fsPath: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export type ExtensionOptions = {
|
|
49
|
+
config?: PluresDBConfig;
|
|
50
|
+
commandPrefix?: string;
|
|
51
|
+
pluresInstance?: PluresNode;
|
|
52
|
+
sqliteInstance?: SQLiteCompatibleAPI;
|
|
53
|
+
};
|
|
54
|
+
export declare class PluresVSCodeExtension {
|
|
55
|
+
private readonly vscode;
|
|
56
|
+
private readonly context;
|
|
57
|
+
private readonly plures;
|
|
58
|
+
private readonly sqlite;
|
|
59
|
+
private readonly commandPrefix;
|
|
60
|
+
private readonly disposables;
|
|
61
|
+
private activated;
|
|
62
|
+
constructor(vscodeApi: VSCodeAPI, context: ExtensionContextLike, options?: ExtensionOptions);
|
|
63
|
+
activate(): Promise<void>;
|
|
64
|
+
deactivate(): Promise<void>;
|
|
65
|
+
getWebUrl(): string;
|
|
66
|
+
storeSetting(key: string, value: unknown): Promise<void>;
|
|
67
|
+
getSetting(key: string): Promise<any>;
|
|
68
|
+
storeDocument(id: string, content: string, language: string, filePath: string): Promise<void>;
|
|
69
|
+
searchDocuments(query: string, limit?: number): Promise<any[]>;
|
|
70
|
+
executeSQL(sql: string, params?: unknown[]): Promise<any>;
|
|
71
|
+
private setupEventHandlers;
|
|
72
|
+
private registerCommands;
|
|
73
|
+
private setupDatabase;
|
|
74
|
+
private disposeAll;
|
|
75
|
+
private safeInfo;
|
|
76
|
+
private safeError;
|
|
77
|
+
private errorMessage;
|
|
78
|
+
}
|
|
79
|
+
export declare function createPluresExtension(vscodeApi: VSCodeAPI, context: ExtensionContextLike, options?: ExtensionOptions): PluresVSCodeExtension;
|
|
80
|
+
export {};
|
|
81
|
+
//# sourceMappingURL=extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../legacy/vscode/extension.ts"],"names":[],"mappings":"AACA,OAAO,EA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AAG,EAAE,MAAM;IAItB,aAAa,CACjB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM;IAUZ,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAK;IAIzC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,OAAO,EAAO;IAIpD,OAAO,CAAC,kBAAkB;IA4B1B,OAAO,CAAC,gBAAgB;YA8GV,aAAa;IAmC3B,OAAO,CAAC,UAAU;YAUJ,QAAQ;YAQR,SAAS;IAQvB,OAAO,CAAC,YAAY;CAMrB;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,oBAAoB,EAC7B,OAAO,GAAE,gBAAqB,yBAG/B"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.PluresVSCodeExtension = void 0;
|
|
37
|
+
exports.createPluresExtension = createPluresExtension;
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const node_index_1 = require("../node-index");
|
|
40
|
+
const DEFAULT_CONFIG = {
|
|
41
|
+
port: 34567,
|
|
42
|
+
host: "localhost",
|
|
43
|
+
webPort: 34568,
|
|
44
|
+
logLevel: "info",
|
|
45
|
+
};
|
|
46
|
+
class PluresVSCodeExtension {
|
|
47
|
+
vscode;
|
|
48
|
+
context;
|
|
49
|
+
plures;
|
|
50
|
+
sqlite;
|
|
51
|
+
commandPrefix;
|
|
52
|
+
disposables = [];
|
|
53
|
+
activated = false;
|
|
54
|
+
constructor(vscodeApi, context, options = {}) {
|
|
55
|
+
this.vscode = vscodeApi;
|
|
56
|
+
this.context = context;
|
|
57
|
+
this.commandPrefix = options.commandPrefix ?? "pluresdb";
|
|
58
|
+
const mergedConfig = {
|
|
59
|
+
...DEFAULT_CONFIG,
|
|
60
|
+
dataDir: path.join(context.globalStorageUri.fsPath, "pluresdb"),
|
|
61
|
+
...options.config,
|
|
62
|
+
};
|
|
63
|
+
this.plures = options.pluresInstance ??
|
|
64
|
+
new node_index_1.PluresNode({ config: mergedConfig, autoStart: false });
|
|
65
|
+
this.sqlite = options.sqliteInstance ??
|
|
66
|
+
new node_index_1.SQLiteCompatibleAPI({ config: mergedConfig, autoStart: false });
|
|
67
|
+
this.setupEventHandlers();
|
|
68
|
+
}
|
|
69
|
+
async activate() {
|
|
70
|
+
if (this.activated) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
await this.plures.start();
|
|
75
|
+
await this.sqlite.start();
|
|
76
|
+
this.registerCommands();
|
|
77
|
+
await this.setupDatabase();
|
|
78
|
+
this.activated = true;
|
|
79
|
+
await this.safeInfo("PluresDB extension activated");
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
await this.safeError(`Failed to activate PluresDB: ${this.errorMessage(error)}`);
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async deactivate() {
|
|
87
|
+
if (!this.activated) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
await this.sqlite.stop();
|
|
92
|
+
await this.plures.stop();
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
this.disposeAll();
|
|
96
|
+
this.activated = false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
getWebUrl() {
|
|
100
|
+
return this.plures.getWebUrl();
|
|
101
|
+
}
|
|
102
|
+
async storeSetting(key, value) {
|
|
103
|
+
return this.sqlite.put(`settings:${key}`, value);
|
|
104
|
+
}
|
|
105
|
+
async getSetting(key) {
|
|
106
|
+
return this.sqlite.getValue(`settings:${key}`);
|
|
107
|
+
}
|
|
108
|
+
async storeDocument(id, content, language, filePath) {
|
|
109
|
+
return this.sqlite.put(`documents:${id}`, {
|
|
110
|
+
content,
|
|
111
|
+
language,
|
|
112
|
+
filePath,
|
|
113
|
+
updatedAt: new Date().toISOString(),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async searchDocuments(query, limit = 20) {
|
|
117
|
+
return this.sqlite.vectorSearch(query, limit);
|
|
118
|
+
}
|
|
119
|
+
async executeSQL(sql, params = []) {
|
|
120
|
+
return this.sqlite.all(sql, params);
|
|
121
|
+
}
|
|
122
|
+
setupEventHandlers() {
|
|
123
|
+
this.plures.on("started", () => {
|
|
124
|
+
this.safeInfo("PluresDB database started");
|
|
125
|
+
});
|
|
126
|
+
this.plures.on("stopped", () => {
|
|
127
|
+
this.safeInfo("PluresDB database stopped");
|
|
128
|
+
});
|
|
129
|
+
this.plures.on("error", (error) => {
|
|
130
|
+
this.safeError(`PluresDB error: ${this.errorMessage(error)}`);
|
|
131
|
+
});
|
|
132
|
+
this.plures.on("stderr", (output) => {
|
|
133
|
+
const trimmed = output.trim();
|
|
134
|
+
if (trimmed.length > 0) {
|
|
135
|
+
this.safeError(trimmed);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
this.plures.on("stdout", (output) => {
|
|
139
|
+
const trimmed = output.trim();
|
|
140
|
+
if (trimmed.length > 0) {
|
|
141
|
+
this.safeInfo(trimmed);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
registerCommands() {
|
|
146
|
+
const register = (name, factory) => {
|
|
147
|
+
const disposable = this.vscode.commands.registerCommand(`${this.commandPrefix}.${name}`, () => factory());
|
|
148
|
+
this.context.subscriptions.push(disposable);
|
|
149
|
+
this.disposables.push(disposable);
|
|
150
|
+
};
|
|
151
|
+
register("openWebUI", async () => {
|
|
152
|
+
const webUrl = this.getWebUrl();
|
|
153
|
+
await this.vscode.env.openExternal(this.vscode.Uri.parse(webUrl));
|
|
154
|
+
});
|
|
155
|
+
register("executeQuery", async () => {
|
|
156
|
+
const sql = await this.vscode.window.showInputBox({
|
|
157
|
+
prompt: "Enter SQL query",
|
|
158
|
+
placeHolder: "SELECT * FROM users",
|
|
159
|
+
});
|
|
160
|
+
if (!sql)
|
|
161
|
+
return;
|
|
162
|
+
try {
|
|
163
|
+
const result = await this.sqlite.all(sql);
|
|
164
|
+
const doc = await this.vscode.workspace.openTextDocument({
|
|
165
|
+
content: JSON.stringify(result, null, 2),
|
|
166
|
+
language: "json",
|
|
167
|
+
});
|
|
168
|
+
await this.vscode.window.showTextDocument(doc);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
await this.safeError(`Query failed: ${this.errorMessage(error)}`);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
register("vectorSearch", async () => {
|
|
175
|
+
const query = await this.vscode.window.showInputBox({
|
|
176
|
+
prompt: "Enter search query",
|
|
177
|
+
placeHolder: "machine learning",
|
|
178
|
+
});
|
|
179
|
+
if (!query)
|
|
180
|
+
return;
|
|
181
|
+
try {
|
|
182
|
+
const results = await this.sqlite.vectorSearch(query, 10);
|
|
183
|
+
const doc = await this.vscode.workspace.openTextDocument({
|
|
184
|
+
content: JSON.stringify(results, null, 2),
|
|
185
|
+
language: "json",
|
|
186
|
+
});
|
|
187
|
+
await this.vscode.window.showTextDocument(doc);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
await this.safeError(`Vector search failed: ${this.errorMessage(error)}`);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
register("storeData", async () => {
|
|
194
|
+
const key = await this.vscode.window.showInputBox({
|
|
195
|
+
prompt: "Enter key",
|
|
196
|
+
placeHolder: "user:123",
|
|
197
|
+
});
|
|
198
|
+
if (!key)
|
|
199
|
+
return;
|
|
200
|
+
const json = await this.vscode.window.showInputBox({
|
|
201
|
+
prompt: "Enter value (JSON)",
|
|
202
|
+
placeHolder: '{"name": "Ada", "email": "ada@example.com"}',
|
|
203
|
+
});
|
|
204
|
+
if (!json)
|
|
205
|
+
return;
|
|
206
|
+
try {
|
|
207
|
+
const value = JSON.parse(json);
|
|
208
|
+
await this.sqlite.put(key, value);
|
|
209
|
+
await this.safeInfo(`Stored data for key: ${key}`);
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
await this.safeError(`Failed to store data: ${this.errorMessage(error)}`);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
register("retrieveData", async () => {
|
|
216
|
+
const key = await this.vscode.window.showInputBox({
|
|
217
|
+
prompt: "Enter key to retrieve",
|
|
218
|
+
placeHolder: "user:123",
|
|
219
|
+
});
|
|
220
|
+
if (!key)
|
|
221
|
+
return;
|
|
222
|
+
try {
|
|
223
|
+
const value = await this.sqlite.getValue(key);
|
|
224
|
+
if (value) {
|
|
225
|
+
const doc = await this.vscode.workspace.openTextDocument({
|
|
226
|
+
content: JSON.stringify(value, null, 2),
|
|
227
|
+
language: "json",
|
|
228
|
+
});
|
|
229
|
+
await this.vscode.window.showTextDocument(doc);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
await this.safeInfo("Key not found");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
await this.safeError(`Failed to retrieve data: ${this.errorMessage(error)}`);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
async setupDatabase() {
|
|
241
|
+
const statements = [
|
|
242
|
+
`CREATE TABLE IF NOT EXISTS settings (
|
|
243
|
+
key TEXT PRIMARY KEY,
|
|
244
|
+
value TEXT,
|
|
245
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
246
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
247
|
+
)`,
|
|
248
|
+
`CREATE TABLE IF NOT EXISTS documents (
|
|
249
|
+
id TEXT PRIMARY KEY,
|
|
250
|
+
content TEXT,
|
|
251
|
+
language TEXT,
|
|
252
|
+
file_path TEXT,
|
|
253
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
254
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
255
|
+
)`,
|
|
256
|
+
`CREATE TABLE IF NOT EXISTS search_history (
|
|
257
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
258
|
+
query TEXT,
|
|
259
|
+
results_count INTEGER,
|
|
260
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
261
|
+
)`,
|
|
262
|
+
];
|
|
263
|
+
for (const sql of statements) {
|
|
264
|
+
try {
|
|
265
|
+
await this.sqlite.exec(sql);
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
await this.safeError(`Failed to initialize database: ${this.errorMessage(error)}`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
disposeAll() {
|
|
273
|
+
for (const disposable of this.disposables.splice(0)) {
|
|
274
|
+
try {
|
|
275
|
+
disposable.dispose();
|
|
276
|
+
}
|
|
277
|
+
catch (_error) {
|
|
278
|
+
// ignore
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
async safeInfo(message) {
|
|
283
|
+
try {
|
|
284
|
+
await this.vscode.window.showInformationMessage(message);
|
|
285
|
+
}
|
|
286
|
+
catch (_error) {
|
|
287
|
+
// ignore message failures in headless tests
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
async safeError(message) {
|
|
291
|
+
try {
|
|
292
|
+
await this.vscode.window.showErrorMessage(message);
|
|
293
|
+
}
|
|
294
|
+
catch (_error) {
|
|
295
|
+
// ignore message failures in headless tests
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
errorMessage(error) {
|
|
299
|
+
if (error instanceof Error) {
|
|
300
|
+
return error.message;
|
|
301
|
+
}
|
|
302
|
+
return String(error);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
exports.PluresVSCodeExtension = PluresVSCodeExtension;
|
|
306
|
+
function createPluresExtension(vscodeApi, context, options = {}) {
|
|
307
|
+
return new PluresVSCodeExtension(vscodeApi, context, options);
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../legacy/vscode/extension.ts"],"names":[],"mappings":";;;;;;;;;;;;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AAE,CAAC;YACvB,CAAC;YAAC,OAAO,MAAM,EAAE,CAAC;gBAChB,SAAS;YACX,CAAC;QACH,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,OAAe;QACpC,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,4CAA4C;QAC9C,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,SAAS,CAAC,OAAe;QACrC,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACrD,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,4CAA4C;QAC9C,CAAC;IACH,CAAC;IAEO,YAAY,CAAC,KAAc;QACjC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC,OAAO,CAAC;QACvB,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;CACF;AAjTD,sDAiTC;AAED,SAAgB,qBAAqB,CACnC,SAAoB,EACpB,OAA6B,EAC7B,UAA4B,EAAE;IAE9B,OAAO,IAAI,qBAAqB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAChE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plures/pluresdb",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.7",
|
|
4
4
|
"description": "P2P Graph Database with SQLite Compatibility - Local-first, offline-first database for modern applications",
|
|
5
5
|
"main": "dist/napi/index.js",
|
|
6
6
|
"types": "dist/napi/index.d.ts",
|
|
@@ -107,11 +107,13 @@
|
|
|
107
107
|
"npm": ">=8.0.0"
|
|
108
108
|
},
|
|
109
109
|
"files": [
|
|
110
|
+
"dist/",
|
|
110
111
|
"embedded.js",
|
|
111
112
|
"embedded.d.ts",
|
|
112
113
|
"crates/pluresdb-node/index.d.ts",
|
|
113
114
|
"crates/pluresdb-node/index.js",
|
|
114
115
|
"crates/pluresdb-node/*.node",
|
|
116
|
+
"scripts/postinstall.js",
|
|
115
117
|
"README.md",
|
|
116
118
|
"LICENSE",
|
|
117
119
|
"package.json"
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post-install script for PluresDB npm package
|
|
3
|
+
* This script ensures Deno is available and sets up the environment
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { spawn, exec } = require("child_process");
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const os = require("os");
|
|
10
|
+
|
|
11
|
+
const DENO_VERSION = "1.40.0";
|
|
12
|
+
|
|
13
|
+
function log(message) {
|
|
14
|
+
console.log(`[pluresdb] ${message}`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function logError(message) {
|
|
18
|
+
console.error(`[pluresdb] ERROR: ${message}`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function isDenoInstalled() {
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
exec("deno --version", (error) => {
|
|
24
|
+
resolve(!error);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function installDeno() {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
const platform = os.platform();
|
|
32
|
+
const arch = os.arch();
|
|
33
|
+
|
|
34
|
+
log("Installing Deno...");
|
|
35
|
+
|
|
36
|
+
let installCommand;
|
|
37
|
+
|
|
38
|
+
if (platform === "win32") {
|
|
39
|
+
// Windows - use PowerShell
|
|
40
|
+
installCommand =
|
|
41
|
+
`powershell -c "iwr https://deno.land/install.ps1 -useb | iex"`;
|
|
42
|
+
} else if (platform === "darwin") {
|
|
43
|
+
// macOS - use Homebrew or curl
|
|
44
|
+
installCommand = "curl -fsSL https://deno.land/install.sh | sh";
|
|
45
|
+
} else {
|
|
46
|
+
// Linux - use curl
|
|
47
|
+
installCommand = "curl -fsSL https://deno.land/install.sh | sh";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
exec(installCommand, (error, stdout, stderr) => {
|
|
51
|
+
if (error) {
|
|
52
|
+
logError(`Failed to install Deno: ${error.message}`);
|
|
53
|
+
logError("Please install Deno manually from https://deno.land/");
|
|
54
|
+
reject(error);
|
|
55
|
+
} else {
|
|
56
|
+
log("Deno installed successfully");
|
|
57
|
+
resolve();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function createStartScript() {
|
|
64
|
+
const scriptContent = `#!/bin/bash
|
|
65
|
+
# PluresDB start script
|
|
66
|
+
export DENO_INSTALL="$HOME/.deno"
|
|
67
|
+
export PATH="$DENO_INSTALL/bin:$PATH"
|
|
68
|
+
|
|
69
|
+
# Start PluresDB
|
|
70
|
+
deno run -A "${path.join(__dirname, "../src/main.ts")}" serve "$@"
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
const scriptPath = path.join(__dirname, "../bin/pluresdb.sh");
|
|
74
|
+
const scriptDir = path.dirname(scriptPath);
|
|
75
|
+
|
|
76
|
+
if (!fs.existsSync(scriptDir)) {
|
|
77
|
+
fs.mkdirSync(scriptDir, { recursive: true });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fs.writeFileSync(scriptPath, scriptContent);
|
|
81
|
+
fs.chmodSync(scriptPath, "755");
|
|
82
|
+
|
|
83
|
+
log("Created start script");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function createWindowsStartScript() {
|
|
87
|
+
const scriptContent = `@echo off
|
|
88
|
+
REM PluresDB start script for Windows
|
|
89
|
+
set DENO_INSTALL=%USERPROFILE%\\.deno
|
|
90
|
+
set PATH=%DENO_INSTALL%\\bin;%PATH%
|
|
91
|
+
|
|
92
|
+
REM Start PluresDB
|
|
93
|
+
deno run -A "${path.join(__dirname, "../src/main.ts")}" serve %*
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
const scriptPath = path.join(__dirname, "../bin/pluresdb.bat");
|
|
97
|
+
const scriptDir = path.dirname(scriptPath);
|
|
98
|
+
|
|
99
|
+
if (!fs.existsSync(scriptDir)) {
|
|
100
|
+
fs.mkdirSync(scriptDir, { recursive: true });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
fs.writeFileSync(scriptPath, scriptContent);
|
|
104
|
+
|
|
105
|
+
log("Created Windows start script");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function main() {
|
|
109
|
+
try {
|
|
110
|
+
log("Setting up PluresDB...");
|
|
111
|
+
|
|
112
|
+
// Check if Deno is installed
|
|
113
|
+
const denoInstalled = await isDenoInstalled();
|
|
114
|
+
|
|
115
|
+
if (!denoInstalled) {
|
|
116
|
+
log("Deno not found, attempting to install...");
|
|
117
|
+
try {
|
|
118
|
+
await installDeno();
|
|
119
|
+
} catch {
|
|
120
|
+
logError("Failed to install Deno automatically");
|
|
121
|
+
logError("Please install Deno manually:");
|
|
122
|
+
logError(" Windows: iwr https://deno.land/install.ps1 -useb | iex");
|
|
123
|
+
logError(" macOS/Linux: curl -fsSL https://deno.land/install.sh | sh");
|
|
124
|
+
logError(" Or visit: https://deno.land/");
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
log("Deno is already installed");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Create start scripts
|
|
132
|
+
createStartScript();
|
|
133
|
+
if (os.platform() === "win32") {
|
|
134
|
+
createWindowsStartScript();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Create data directory
|
|
138
|
+
const dataDir = path.join(os.homedir(), ".pluresdb");
|
|
139
|
+
if (!fs.existsSync(dataDir)) {
|
|
140
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
141
|
+
log(`Created data directory: ${dataDir}`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
log("Setup complete!");
|
|
145
|
+
log("Usage:");
|
|
146
|
+
log(" npx pluresdb serve");
|
|
147
|
+
log(" or");
|
|
148
|
+
log(" node node_modules/pluresdb/dist/cli.js serve");
|
|
149
|
+
} catch (error) {
|
|
150
|
+
logError(`Setup failed: ${error.message}`);
|
|
151
|
+
Deno.exit(1);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Run the setup
|
|
156
|
+
main();
|