@veolab/discoverylab 1.3.4 → 1.4.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/dist/chunk-34KRJWZL.js +477 -0
- package/dist/chunk-4VNS5WPM.js +42 -0
- package/dist/{chunk-FIL7IWEL.js → chunk-DGXAP477.js} +1 -1
- package/dist/{chunk-HGWEHWKJ.js → chunk-DKAX5RCX.js} +1 -1
- package/dist/{chunk-7EDIUVIO.js → chunk-EU63HPKT.js} +1 -1
- package/dist/chunk-QMUEC6B5.js +288 -0
- package/dist/{chunk-FNUN7EPB.js → chunk-RCY26WEK.js} +2 -2
- package/dist/{chunk-ZLHIHMSL.js → chunk-SWZIBO2R.js} +1 -1
- package/dist/chunk-VYYAP5G5.js +265 -0
- package/dist/{chunk-VVIOB362.js → chunk-XAMA3JJG.js} +18 -1
- package/dist/{chunk-BE7BFMYC.js → chunk-XWBFSSNB.js} +10224 -393
- package/dist/{chunk-AHVBE25Y.js → chunk-YNLUOZSZ.js} +274 -667
- package/dist/cli.js +33 -31
- package/dist/{db-6WLEVKUV.js → db-745LC5YC.js} +2 -2
- package/dist/document-AE4XI2CP.js +104 -0
- package/dist/{esvp-KVOWYW6G.js → esvp-4LIAU76K.js} +3 -3
- package/dist/{esvp-mobile-GZ5EMYPG.js → esvp-mobile-FKFHDS5Q.js} +4 -4
- package/dist/frames-RCNLSDD6.js +24 -0
- package/dist/{gridCompositor-M3K3LCLZ.js → gridCompositor-VUWBZXYL.js} +262 -3
- package/dist/index.d.ts +32 -0
- package/dist/index.html +1197 -9
- package/dist/index.js +15 -10
- package/dist/notion-api-OXSWOJPZ.js +190 -0
- package/dist/{ocr-QDYNCSPE.js → ocr-FXRLEP66.js} +1 -1
- package/dist/{playwright-VZ7PXDC5.js → playwright-GYKUH34L.js} +3 -3
- package/dist/renderer-D22GCMMD.js +17 -0
- package/dist/{server-6N3KIEGP.js → server-NTT2XGCC.js} +1 -1
- package/dist/server-TKYRIYJ6.js +24 -0
- package/dist/{setup-2SQC5UHJ.js → setup-O6WQQAGP.js} +3 -3
- package/dist/templates/bundle/bundle.js +4 -2
- package/dist/{tools-YGM5HRIB.js → tools-FVVWKEGC.js} +15 -7
- package/package.json +2 -2
- package/skills/knowledge-brain/SKILL.md +64 -0
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/server-QKZXPZRC.js +0 -22
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"name": "discoverylab",
|
|
13
13
|
"source": ".",
|
|
14
14
|
"description": "AI-powered app testing & marketing asset generator. Record mobile/web apps, run automated tests with Maestro & Playwright, and generate professional screenshots, GIFs, and test reports.",
|
|
15
|
-
"version": "1.
|
|
15
|
+
"version": "1.4.0",
|
|
16
16
|
"author": {
|
|
17
17
|
"name": "Anderson Melo"
|
|
18
18
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discoverylab",
|
|
3
3
|
"description": "AI-powered app testing & marketing asset generator. Record mobile/web apps, run automated tests with Maestro & Playwright, and generate professional screenshots, GIFs, and test reports.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Anderson Melo",
|
|
7
7
|
"email": "anderson.90@gmail.com"
|
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DATA_DIR
|
|
3
|
+
} from "./chunk-XAMA3JJG.js";
|
|
4
|
+
|
|
5
|
+
// src/integrations/notion.ts
|
|
6
|
+
import { exec } from "child_process";
|
|
7
|
+
import { promisify } from "util";
|
|
8
|
+
import * as fs from "fs";
|
|
9
|
+
import * as path from "path";
|
|
10
|
+
var execAsync = promisify(exec);
|
|
11
|
+
var SESSION_DIR = path.join(DATA_DIR, "sessions", "notion");
|
|
12
|
+
async function getNotionSessionPath() {
|
|
13
|
+
await fs.promises.mkdir(SESSION_DIR, { recursive: true });
|
|
14
|
+
return SESSION_DIR;
|
|
15
|
+
}
|
|
16
|
+
async function checkNotionAuth() {
|
|
17
|
+
const sessionPath = await getNotionSessionPath();
|
|
18
|
+
const cookiesPath = path.join(sessionPath, "cookies.json");
|
|
19
|
+
if (!fs.existsSync(cookiesPath)) {
|
|
20
|
+
return { authenticated: false, sessionPath };
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const cookies = JSON.parse(await fs.promises.readFile(cookiesPath, "utf-8"));
|
|
24
|
+
const notionCookies = cookies.filter((c) => c.domain?.includes("notion"));
|
|
25
|
+
if (notionCookies.length > 0) {
|
|
26
|
+
return {
|
|
27
|
+
authenticated: true,
|
|
28
|
+
sessionPath
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
return { authenticated: false, sessionPath };
|
|
34
|
+
}
|
|
35
|
+
function generateNotionLoginScript() {
|
|
36
|
+
return `
|
|
37
|
+
import { chromium } from 'playwright';
|
|
38
|
+
import * as fs from 'fs';
|
|
39
|
+
import * as path from 'path';
|
|
40
|
+
|
|
41
|
+
const SESSION_DIR = '${SESSION_DIR}';
|
|
42
|
+
|
|
43
|
+
async function login() {
|
|
44
|
+
const browser = await chromium.launchPersistentContext(SESSION_DIR, {
|
|
45
|
+
headless: false,
|
|
46
|
+
viewport: { width: 1280, height: 800 },
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const page = browser.pages()[0] || await browser.newPage();
|
|
50
|
+
|
|
51
|
+
// Navigate to Notion login
|
|
52
|
+
await page.goto('https://www.notion.so/login');
|
|
53
|
+
|
|
54
|
+
console.log('Please log in to Notion in the browser window...');
|
|
55
|
+
console.log('The browser will close automatically once logged in.');
|
|
56
|
+
|
|
57
|
+
// Wait for successful login (redirect to workspace)
|
|
58
|
+
await page.waitForURL(/notion\\.so\\/[^login]/, { timeout: 300000 });
|
|
59
|
+
|
|
60
|
+
// Save cookies
|
|
61
|
+
const cookies = await browser.cookies();
|
|
62
|
+
await fs.promises.writeFile(
|
|
63
|
+
path.join(SESSION_DIR, 'cookies.json'),
|
|
64
|
+
JSON.stringify(cookies, null, 2)
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
console.log('Login successful! Session saved.');
|
|
68
|
+
await browser.close();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
login().catch(console.error);
|
|
72
|
+
`;
|
|
73
|
+
}
|
|
74
|
+
function generateNotionUploadScript(options) {
|
|
75
|
+
const { title, content, parentPageId, files = [] } = options;
|
|
76
|
+
return `
|
|
77
|
+
import { chromium } from 'playwright';
|
|
78
|
+
import * as fs from 'fs';
|
|
79
|
+
import * as path from 'path';
|
|
80
|
+
|
|
81
|
+
const SESSION_DIR = '${SESSION_DIR}';
|
|
82
|
+
const TITLE = ${JSON.stringify(title)};
|
|
83
|
+
const CONTENT = ${JSON.stringify(content)};
|
|
84
|
+
const FILES = ${JSON.stringify(files)};
|
|
85
|
+
const PARENT_PAGE_ID = ${JSON.stringify(parentPageId || null)};
|
|
86
|
+
|
|
87
|
+
async function createPage() {
|
|
88
|
+
const browser = await chromium.launchPersistentContext(SESSION_DIR, {
|
|
89
|
+
headless: false,
|
|
90
|
+
viewport: { width: 1280, height: 800 },
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const page = browser.pages()[0] || await browser.newPage();
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
// Navigate to parent page or workspace
|
|
97
|
+
if (PARENT_PAGE_ID) {
|
|
98
|
+
await page.goto(\`https://www.notion.so/\${PARENT_PAGE_ID}\`);
|
|
99
|
+
} else {
|
|
100
|
+
await page.goto('https://www.notion.so');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
await page.waitForLoadState('networkidle');
|
|
104
|
+
|
|
105
|
+
// Create new page
|
|
106
|
+
await page.keyboard.press('Control+N');
|
|
107
|
+
await page.waitForTimeout(1000);
|
|
108
|
+
|
|
109
|
+
// Set title
|
|
110
|
+
await page.keyboard.type(TITLE);
|
|
111
|
+
await page.keyboard.press('Enter');
|
|
112
|
+
await page.waitForTimeout(500);
|
|
113
|
+
|
|
114
|
+
// Add content blocks
|
|
115
|
+
for (const block of CONTENT) {
|
|
116
|
+
await addBlock(page, block);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Upload files
|
|
120
|
+
for (const filePath of FILES) {
|
|
121
|
+
if (fs.existsSync(filePath)) {
|
|
122
|
+
await uploadFile(page, filePath);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Get page URL
|
|
127
|
+
const url = page.url();
|
|
128
|
+
console.log(JSON.stringify({ success: true, pageUrl: url }));
|
|
129
|
+
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.log(JSON.stringify({ success: false, error: error.message }));
|
|
132
|
+
} finally {
|
|
133
|
+
await browser.close();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function addBlock(page, block) {
|
|
138
|
+
switch (block.type) {
|
|
139
|
+
case 'heading1':
|
|
140
|
+
await page.keyboard.type('/h1');
|
|
141
|
+
await page.keyboard.press('Enter');
|
|
142
|
+
await page.keyboard.type(block.content || '');
|
|
143
|
+
await page.keyboard.press('Enter');
|
|
144
|
+
break;
|
|
145
|
+
|
|
146
|
+
case 'heading2':
|
|
147
|
+
await page.keyboard.type('/h2');
|
|
148
|
+
await page.keyboard.press('Enter');
|
|
149
|
+
await page.keyboard.type(block.content || '');
|
|
150
|
+
await page.keyboard.press('Enter');
|
|
151
|
+
break;
|
|
152
|
+
|
|
153
|
+
case 'heading3':
|
|
154
|
+
await page.keyboard.type('/h3');
|
|
155
|
+
await page.keyboard.press('Enter');
|
|
156
|
+
await page.keyboard.type(block.content || '');
|
|
157
|
+
await page.keyboard.press('Enter');
|
|
158
|
+
break;
|
|
159
|
+
|
|
160
|
+
case 'paragraph':
|
|
161
|
+
await page.keyboard.type(block.content || '');
|
|
162
|
+
await page.keyboard.press('Enter');
|
|
163
|
+
break;
|
|
164
|
+
|
|
165
|
+
case 'bulletList':
|
|
166
|
+
for (const item of block.items || []) {
|
|
167
|
+
await page.keyboard.type('/bullet');
|
|
168
|
+
await page.keyboard.press('Enter');
|
|
169
|
+
await page.keyboard.type(item);
|
|
170
|
+
await page.keyboard.press('Enter');
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
|
|
174
|
+
case 'numberedList':
|
|
175
|
+
for (const item of block.items || []) {
|
|
176
|
+
await page.keyboard.type('/numbered');
|
|
177
|
+
await page.keyboard.press('Enter');
|
|
178
|
+
await page.keyboard.type(item);
|
|
179
|
+
await page.keyboard.press('Enter');
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
|
|
183
|
+
case 'quote':
|
|
184
|
+
await page.keyboard.type('/quote');
|
|
185
|
+
await page.keyboard.press('Enter');
|
|
186
|
+
await page.keyboard.type(block.content || '');
|
|
187
|
+
await page.keyboard.press('Enter');
|
|
188
|
+
break;
|
|
189
|
+
|
|
190
|
+
case 'callout':
|
|
191
|
+
await page.keyboard.type('/callout');
|
|
192
|
+
await page.keyboard.press('Enter');
|
|
193
|
+
await page.keyboard.type(block.content || '');
|
|
194
|
+
await page.keyboard.press('Enter');
|
|
195
|
+
break;
|
|
196
|
+
|
|
197
|
+
case 'divider':
|
|
198
|
+
await page.keyboard.type('/divider');
|
|
199
|
+
await page.keyboard.press('Enter');
|
|
200
|
+
break;
|
|
201
|
+
|
|
202
|
+
case 'code':
|
|
203
|
+
await page.keyboard.type('/code');
|
|
204
|
+
await page.keyboard.press('Enter');
|
|
205
|
+
await page.keyboard.type(block.content || '');
|
|
206
|
+
await page.keyboard.press('Enter');
|
|
207
|
+
await page.keyboard.press('Escape');
|
|
208
|
+
break;
|
|
209
|
+
|
|
210
|
+
case 'image':
|
|
211
|
+
if (block.url) {
|
|
212
|
+
await page.keyboard.type('/image');
|
|
213
|
+
await page.keyboard.press('Enter');
|
|
214
|
+
await page.waitForTimeout(500);
|
|
215
|
+
// Click "Embed link"
|
|
216
|
+
await page.click('text=Embed link');
|
|
217
|
+
await page.keyboard.type(block.url);
|
|
218
|
+
await page.keyboard.press('Enter');
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
|
|
222
|
+
case 'gallery':
|
|
223
|
+
await page.keyboard.type('/gallery');
|
|
224
|
+
await page.keyboard.press('Enter');
|
|
225
|
+
await page.waitForTimeout(500);
|
|
226
|
+
// Upload images to gallery
|
|
227
|
+
for (const imagePath of block.paths || []) {
|
|
228
|
+
if (fs.existsSync(imagePath)) {
|
|
229
|
+
await uploadFile(page, imagePath);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
await page.waitForTimeout(300);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
async function uploadFile(page, filePath) {
|
|
239
|
+
await page.keyboard.type('/file');
|
|
240
|
+
await page.keyboard.press('Enter');
|
|
241
|
+
await page.waitForTimeout(500);
|
|
242
|
+
|
|
243
|
+
const fileInput = await page.waitForSelector('input[type="file"]', { timeout: 5000 });
|
|
244
|
+
await fileInput.setInputFiles(filePath);
|
|
245
|
+
await page.waitForTimeout(2000);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
createPage().catch(console.error);
|
|
249
|
+
`;
|
|
250
|
+
}
|
|
251
|
+
async function loginToNotion() {
|
|
252
|
+
const script = generateNotionLoginScript();
|
|
253
|
+
const scriptPath = path.join(SESSION_DIR, "login.mjs");
|
|
254
|
+
await fs.promises.mkdir(SESSION_DIR, { recursive: true });
|
|
255
|
+
await fs.promises.writeFile(scriptPath, script);
|
|
256
|
+
try {
|
|
257
|
+
await execAsync(`npx playwright install chromium`);
|
|
258
|
+
await execAsync(`node "${scriptPath}"`, { timeout: 3e5 });
|
|
259
|
+
const auth = await checkNotionAuth();
|
|
260
|
+
if (auth.authenticated) {
|
|
261
|
+
return { success: true };
|
|
262
|
+
}
|
|
263
|
+
return { success: false, error: "Login was not completed" };
|
|
264
|
+
} catch (error) {
|
|
265
|
+
return {
|
|
266
|
+
success: false,
|
|
267
|
+
error: error instanceof Error ? error.message : String(error)
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
async function createNotionPage(options) {
|
|
272
|
+
const auth = await checkNotionAuth();
|
|
273
|
+
if (!auth.authenticated) {
|
|
274
|
+
return { success: false, error: "Not authenticated. Run dlab.notion.login first." };
|
|
275
|
+
}
|
|
276
|
+
const content = buildPageContent(options);
|
|
277
|
+
const files = [...options.screenshots || [], ...options.videos || []];
|
|
278
|
+
const script = generateNotionUploadScript({
|
|
279
|
+
title: options.title,
|
|
280
|
+
content,
|
|
281
|
+
parentPageId: options.parentPageId,
|
|
282
|
+
files
|
|
283
|
+
});
|
|
284
|
+
const scriptPath = path.join(SESSION_DIR, "upload.mjs");
|
|
285
|
+
await fs.promises.writeFile(scriptPath, script);
|
|
286
|
+
try {
|
|
287
|
+
const { stdout } = await execAsync(`node "${scriptPath}"`, { timeout: 12e4 });
|
|
288
|
+
const lines = stdout.trim().split("\n");
|
|
289
|
+
const lastLine = lines[lines.length - 1];
|
|
290
|
+
const result = JSON.parse(lastLine);
|
|
291
|
+
return result;
|
|
292
|
+
} catch (error) {
|
|
293
|
+
return {
|
|
294
|
+
success: false,
|
|
295
|
+
error: error instanceof Error ? error.message : String(error)
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function buildPageContent(options) {
|
|
300
|
+
const { template = "evidence", description, notes, tags, screenshots, videos } = options;
|
|
301
|
+
const blocks = [];
|
|
302
|
+
switch (template) {
|
|
303
|
+
case "evidence":
|
|
304
|
+
if (description) {
|
|
305
|
+
blocks.push({ type: "paragraph", content: description });
|
|
306
|
+
}
|
|
307
|
+
if (tags && tags.length > 0) {
|
|
308
|
+
blocks.push({ type: "paragraph", content: `Tags: ${tags.join(", ")}` });
|
|
309
|
+
}
|
|
310
|
+
blocks.push({ type: "divider" });
|
|
311
|
+
if (screenshots && screenshots.length > 0) {
|
|
312
|
+
blocks.push({ type: "heading2", content: "Screenshots" });
|
|
313
|
+
blocks.push({ type: "gallery", paths: screenshots });
|
|
314
|
+
}
|
|
315
|
+
if (videos && videos.length > 0) {
|
|
316
|
+
blocks.push({ type: "heading2", content: "Videos" });
|
|
317
|
+
for (const video of videos) {
|
|
318
|
+
blocks.push({ type: "file", url: video });
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (notes) {
|
|
322
|
+
blocks.push({ type: "heading2", content: "Notes" });
|
|
323
|
+
blocks.push({ type: "paragraph", content: notes });
|
|
324
|
+
}
|
|
325
|
+
break;
|
|
326
|
+
case "testReport":
|
|
327
|
+
blocks.push({ type: "callout", content: "Test Report", color: "blue" });
|
|
328
|
+
if (description) {
|
|
329
|
+
blocks.push({ type: "heading2", content: "Summary" });
|
|
330
|
+
blocks.push({ type: "paragraph", content: description });
|
|
331
|
+
}
|
|
332
|
+
if (screenshots && screenshots.length > 0) {
|
|
333
|
+
blocks.push({ type: "heading2", content: "Evidence" });
|
|
334
|
+
blocks.push({ type: "gallery", paths: screenshots });
|
|
335
|
+
}
|
|
336
|
+
if (notes) {
|
|
337
|
+
blocks.push({ type: "heading2", content: "Details" });
|
|
338
|
+
blocks.push({ type: "paragraph", content: notes });
|
|
339
|
+
}
|
|
340
|
+
break;
|
|
341
|
+
case "gallery":
|
|
342
|
+
if (description) {
|
|
343
|
+
blocks.push({ type: "paragraph", content: description });
|
|
344
|
+
}
|
|
345
|
+
if (screenshots && screenshots.length > 0) {
|
|
346
|
+
blocks.push({ type: "gallery", paths: screenshots });
|
|
347
|
+
}
|
|
348
|
+
break;
|
|
349
|
+
case "marketing":
|
|
350
|
+
blocks.push({
|
|
351
|
+
type: "callout",
|
|
352
|
+
content: `${options.title || "App Review"}`,
|
|
353
|
+
color: "purple"
|
|
354
|
+
});
|
|
355
|
+
if (description) {
|
|
356
|
+
blocks.push({ type: "paragraph", content: description });
|
|
357
|
+
}
|
|
358
|
+
blocks.push({ type: "divider" });
|
|
359
|
+
if (screenshots && screenshots.length > 0) {
|
|
360
|
+
blocks.push({ type: "image", url: screenshots[0] });
|
|
361
|
+
if (screenshots.length > 1) {
|
|
362
|
+
blocks.push({ type: "heading2", content: "Screenshots" });
|
|
363
|
+
blocks.push({ type: "gallery", paths: screenshots.slice(1) });
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (videos && videos.length > 0) {
|
|
367
|
+
blocks.push({ type: "heading2", content: "Preview" });
|
|
368
|
+
for (const video of videos) {
|
|
369
|
+
if (video.endsWith(".gif")) {
|
|
370
|
+
blocks.push({ type: "image", url: video });
|
|
371
|
+
} else {
|
|
372
|
+
blocks.push({ type: "file", url: video });
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (notes) {
|
|
377
|
+
blocks.push({ type: "divider" });
|
|
378
|
+
blocks.push({ type: "heading2", content: "Analysis" });
|
|
379
|
+
const analysisBlocks = markdownToNotionBlocks(notes);
|
|
380
|
+
if (analysisBlocks.length > 0) {
|
|
381
|
+
blocks.push(...analysisBlocks);
|
|
382
|
+
} else {
|
|
383
|
+
blocks.push({ type: "paragraph", content: notes });
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (tags && tags.length > 0) {
|
|
387
|
+
blocks.push({ type: "divider" });
|
|
388
|
+
blocks.push({ type: "paragraph", content: `Tags: ${tags.join(", ")}` });
|
|
389
|
+
}
|
|
390
|
+
break;
|
|
391
|
+
case "custom":
|
|
392
|
+
default:
|
|
393
|
+
if (description) {
|
|
394
|
+
blocks.push({ type: "paragraph", content: description });
|
|
395
|
+
}
|
|
396
|
+
if (screenshots && screenshots.length > 0) {
|
|
397
|
+
for (const img of screenshots) {
|
|
398
|
+
blocks.push({ type: "image", url: img });
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (notes) {
|
|
402
|
+
blocks.push({ type: "paragraph", content: notes });
|
|
403
|
+
}
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
return blocks;
|
|
407
|
+
}
|
|
408
|
+
function markdownToNotionBlocks(markdown) {
|
|
409
|
+
const blocks = [];
|
|
410
|
+
const lines = markdown.split("\n");
|
|
411
|
+
let i = 0;
|
|
412
|
+
while (i < lines.length) {
|
|
413
|
+
const line = lines[i];
|
|
414
|
+
if (line.startsWith("### ")) {
|
|
415
|
+
blocks.push({ type: "heading3", content: line.slice(4) });
|
|
416
|
+
} else if (line.startsWith("## ")) {
|
|
417
|
+
blocks.push({ type: "heading2", content: line.slice(3) });
|
|
418
|
+
} else if (line.startsWith("# ")) {
|
|
419
|
+
blocks.push({ type: "heading1", content: line.slice(2) });
|
|
420
|
+
} else if (line.match(/^[-*]\s/)) {
|
|
421
|
+
const items = [line.slice(2)];
|
|
422
|
+
while (i + 1 < lines.length && lines[i + 1].match(/^[-*]\s/)) {
|
|
423
|
+
i++;
|
|
424
|
+
items.push(lines[i].slice(2));
|
|
425
|
+
}
|
|
426
|
+
blocks.push({ type: "bulletList", items });
|
|
427
|
+
} else if (line.match(/^\d+\.\s/)) {
|
|
428
|
+
const items = [line.replace(/^\d+\.\s/, "")];
|
|
429
|
+
while (i + 1 < lines.length && lines[i + 1].match(/^\d+\.\s/)) {
|
|
430
|
+
i++;
|
|
431
|
+
items.push(lines[i].replace(/^\d+\.\s/, ""));
|
|
432
|
+
}
|
|
433
|
+
blocks.push({ type: "numberedList", items });
|
|
434
|
+
} else if (line.startsWith("> ")) {
|
|
435
|
+
blocks.push({ type: "quote", content: line.slice(2) });
|
|
436
|
+
} else if (line.match(/^(-{3,}|_{3,}|\*{3,})$/)) {
|
|
437
|
+
blocks.push({ type: "divider" });
|
|
438
|
+
} else if (line.startsWith("```")) {
|
|
439
|
+
const language = line.slice(3).trim();
|
|
440
|
+
const codeLines = [];
|
|
441
|
+
i++;
|
|
442
|
+
while (i < lines.length && !lines[i].startsWith("```")) {
|
|
443
|
+
codeLines.push(lines[i]);
|
|
444
|
+
i++;
|
|
445
|
+
}
|
|
446
|
+
blocks.push({ type: "code", content: codeLines.join("\n"), language });
|
|
447
|
+
} else if (line.match(/^!\[.*\]\(.*\)$/)) {
|
|
448
|
+
const match = line.match(/^!\[.*\]\((.*)\)$/);
|
|
449
|
+
if (match) {
|
|
450
|
+
blocks.push({ type: "image", url: match[1] });
|
|
451
|
+
}
|
|
452
|
+
} else if (line.trim()) {
|
|
453
|
+
blocks.push({ type: "paragraph", content: line });
|
|
454
|
+
}
|
|
455
|
+
i++;
|
|
456
|
+
}
|
|
457
|
+
return blocks;
|
|
458
|
+
}
|
|
459
|
+
async function quickExportToNotion(title, files, notes) {
|
|
460
|
+
const screenshots = files.filter((f) => /\.(png|jpg|jpeg|gif|webp)$/i.test(f));
|
|
461
|
+
const videos = files.filter((f) => /\.(mp4|mov|webm|gif)$/i.test(f));
|
|
462
|
+
return createNotionPage({
|
|
463
|
+
projectId: "quick-export",
|
|
464
|
+
title,
|
|
465
|
+
screenshots,
|
|
466
|
+
videos,
|
|
467
|
+
notes,
|
|
468
|
+
template: screenshots.length > 3 ? "gallery" : "evidence"
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
export {
|
|
473
|
+
checkNotionAuth,
|
|
474
|
+
loginToNotion,
|
|
475
|
+
createNotionPage,
|
|
476
|
+
quickExportToNotion
|
|
477
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
__require,
|
|
39
|
+
__commonJS,
|
|
40
|
+
__export,
|
|
41
|
+
__toESM
|
|
42
|
+
};
|