@oldboydev/sheldon-darwin-arm64 0.2.0 → 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/SHA256SUMS +69 -18
- package/inventory.json +291 -36
- package/node_modules/@sheldon/cli/dist/commands/agents.js +85 -69
- package/node_modules/@sheldon/cli/dist/commands/mcp.js +1 -1
- package/node_modules/@sheldon/cli/dist/help/fonts/NunitoSans-VariableFont_YTLC_opsz_wdth_wght.ttf +0 -0
- package/node_modules/@sheldon/cli/dist/help/index.html +97 -0
- package/node_modules/@sheldon/cli/dist/help/manifest.json +121 -0
- package/node_modules/@sheldon/cli/dist/help/pages/agent.html +101 -0
- package/node_modules/@sheldon/cli/dist/help/pages/answer.html +110 -0
- package/node_modules/@sheldon/cli/dist/help/pages/bundle.html +124 -0
- package/node_modules/@sheldon/cli/dist/help/pages/compile.html +120 -0
- package/node_modules/@sheldon/cli/dist/help/pages/doctor.html +102 -0
- package/node_modules/@sheldon/cli/dist/help/pages/flow-compile-review.html +125 -0
- package/node_modules/@sheldon/cli/dist/help/pages/flow-end-to-end.html +147 -0
- package/node_modules/@sheldon/cli/dist/help/pages/flow-first-vault.html +100 -0
- package/node_modules/@sheldon/cli/dist/help/pages/image.html +107 -0
- package/node_modules/@sheldon/cli/dist/help/pages/ingest.html +156 -0
- package/node_modules/@sheldon/cli/dist/help/pages/init.html +98 -0
- package/node_modules/@sheldon/cli/dist/help/pages/mcp.html +135 -0
- package/node_modules/@sheldon/cli/dist/help/pages/migrate-state.html +100 -0
- package/node_modules/@sheldon/cli/dist/help/pages/plugin.html +120 -0
- package/node_modules/@sheldon/cli/dist/help/pages/project.html +110 -0
- package/node_modules/@sheldon/cli/dist/help/pages/query.html +110 -0
- package/node_modules/@sheldon/cli/dist/help/pages/review.html +114 -0
- package/node_modules/@sheldon/cli/dist/help/pages/search.html +103 -0
- package/node_modules/@sheldon/cli/dist/help/pages/topic.html +112 -0
- package/node_modules/@sheldon/cli/dist/help/pages/web.html +102 -0
- package/node_modules/@sheldon/cli/dist/help/styles.css +368 -0
- package/node_modules/@sheldon/cli/dist/help.js +84 -0
- package/node_modules/@sheldon/cli/dist/main.js +38 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/agent-runtime/dist/command-executor.js +1 -1
- package/node_modules/@sheldon/cli/node_modules/@sheldon/agent-runtime/dist/index.js +1 -1
- package/node_modules/@sheldon/cli/node_modules/@sheldon/agent-runtime/dist/profiles.js +1 -5
- package/node_modules/@sheldon/cli/node_modules/@sheldon/plugin-host/dist/official-catalog.js +4 -3
- package/node_modules/@sheldon/cli/node_modules/@sheldon/plugin-source-image/node_modules/@sheldon/plugin-host/dist/official-catalog.js +4 -3
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/dist/client/assets/index-B8MAXTxb.js +13 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/dist/client/assets/{index-BB6UWWie.css → index-DZRX97IO.css} +1 -1
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/dist/client/index.html +2 -2
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/dist/contract.js +18 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/dist/server.js +26 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/dist/wiki-markdown.js +75 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/dist/wiki.js +175 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel-react-native.d.ts.map +1 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel-react-native.js.map +1 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel.d.ts +5 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/react-native/diagnostics-channel.js +7 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/react-native/index.d.ts +1400 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/react-native/index.d.ts.map +1 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/react-native/index.js +1733 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/react-native/index.js.map +1 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/react-native/perf.d.ts +12 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/react-native/perf.d.ts.map +1 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/react-native/perf.js +10 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/react-native/perf.js.map +1 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel-react-native.d.ts.map +1 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel-react-native.js.map +1 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel.d.ts +5 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/esm/react-native/diagnostics-channel.js +4 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/esm/react-native/index.d.ts +1400 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/esm/react-native/index.d.ts.map +1 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/esm/react-native/index.js +1729 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/esm/react-native/index.js.map +1 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/esm/react-native/perf.d.ts +12 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/esm/react-native/perf.d.ts.map +1 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/esm/react-native/perf.js +7 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/dist/esm/react-native/perf.js.map +1 -0
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@fastify/static/node_modules/glob/node_modules/path-scurry/node_modules/lru-cache/package.json +17 -1
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@sheldon/agent-runtime/dist/command-executor.js +1 -1
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@sheldon/agent-runtime/dist/index.js +1 -1
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/node_modules/@sheldon/agent-runtime/dist/profiles.js +1 -5
- package/package.json +1 -1
- package/sbom.spdx.json +1 -1
- package/node_modules/@sheldon/cli/node_modules/@sheldon/web/dist/client/assets/index-FrWwJl0U.js +0 -9
|
@@ -9,6 +9,7 @@ import { OperationsDatabase } from '@sheldon/persistence';
|
|
|
9
9
|
import { VaultService, vaultPaths } from '@sheldon/vault';
|
|
10
10
|
import { webOpenApi } from './contract.js';
|
|
11
11
|
import { InvalidWebJobRequestError, WebJobService } from './jobs.js';
|
|
12
|
+
import { listWikiPaths, readRawFile, readWikiPage, WikiNotFoundError } from './wiki.js';
|
|
12
13
|
export async function createWebServer(options) {
|
|
13
14
|
const root = resolve(options.vaultRoot);
|
|
14
15
|
const server = fastify({
|
|
@@ -55,6 +56,21 @@ export async function createWebServer(options) {
|
|
|
55
56
|
const params = request.params;
|
|
56
57
|
return options.application.showEntity(entityKind(params.kind), params.slug);
|
|
57
58
|
});
|
|
59
|
+
server.get('/api/v1/entities/:kind/:slug/wiki', async (request, reply)=>{
|
|
60
|
+
const params = request.params;
|
|
61
|
+
return sendWiki(reply, ()=>listWikiPaths(root, entityKind(params.kind), params.slug));
|
|
62
|
+
});
|
|
63
|
+
server.get('/api/v1/entities/:kind/:slug/wiki/*', async (request, reply)=>{
|
|
64
|
+
const params = request.params;
|
|
65
|
+
return sendWiki(reply, ()=>readWikiPage(root, entityKind(params.kind), params.slug, params['*']));
|
|
66
|
+
});
|
|
67
|
+
server.get('/api/v1/entities/:kind/:slug/raw/*', async (request, reply)=>{
|
|
68
|
+
const params = request.params;
|
|
69
|
+
return sendWiki(reply, async ()=>{
|
|
70
|
+
const text = await readRawFile(root, entityKind(params.kind), params.slug, params['*']);
|
|
71
|
+
return reply.type('text/plain; charset=utf-8').send(text);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
58
74
|
server.post('/api/v1/entities/:kind/:slug/archive', async (request)=>{
|
|
59
75
|
const params = request.params;
|
|
60
76
|
requireConfirmation(request.body, `${params.kind}:${params.slug}`);
|
|
@@ -224,6 +240,16 @@ async function dashboard(root) {
|
|
|
224
240
|
database.close();
|
|
225
241
|
}
|
|
226
242
|
}
|
|
243
|
+
async function sendWiki(reply, run) {
|
|
244
|
+
try {
|
|
245
|
+
return await run();
|
|
246
|
+
} catch (error) {
|
|
247
|
+
if (error instanceof WikiNotFoundError) {
|
|
248
|
+
return reply.status(404).send(problem(error.code, error.message, error.target, error.recovery));
|
|
249
|
+
}
|
|
250
|
+
throw error;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
227
253
|
function entityKind(value) {
|
|
228
254
|
if (value === 'topic' || value === 'project') return value;
|
|
229
255
|
throw badRequest('A entidade deve ser topic ou project.');
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export function parseWikiMarkdown(markdown) {
|
|
2
|
+
const blocks = [];
|
|
3
|
+
let paragraph = [];
|
|
4
|
+
const flush = ()=>{
|
|
5
|
+
if (paragraph.length === 0) return;
|
|
6
|
+
blocks.push({
|
|
7
|
+
type: 'paragraph',
|
|
8
|
+
children: parseInlines(paragraph.join('\n'))
|
|
9
|
+
});
|
|
10
|
+
paragraph = [];
|
|
11
|
+
};
|
|
12
|
+
for (const line of markdown.replaceAll('\r\n', '\n').split('\n')){
|
|
13
|
+
const heading = /^(#{1,6})[ \t]+(.+)$/u.exec(line);
|
|
14
|
+
if (heading) {
|
|
15
|
+
flush();
|
|
16
|
+
blocks.push({
|
|
17
|
+
type: 'heading',
|
|
18
|
+
level: heading[1].length,
|
|
19
|
+
children: parseInlines(heading[2])
|
|
20
|
+
});
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (line.trim() === '') {
|
|
24
|
+
flush();
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
paragraph.push(line);
|
|
28
|
+
}
|
|
29
|
+
flush();
|
|
30
|
+
return blocks;
|
|
31
|
+
}
|
|
32
|
+
export function resolveWikiHref(currentPath, href) {
|
|
33
|
+
const trimmed = href.split('#', 1)[0] ?? href;
|
|
34
|
+
if (trimmed.startsWith('/') || /^[A-Za-z]:[\\/]/u.test(trimmed) || trimmed.includes('..')) {
|
|
35
|
+
return trimmed;
|
|
36
|
+
}
|
|
37
|
+
const slash = currentPath.replaceAll('\\', '/').lastIndexOf('/');
|
|
38
|
+
const directory = slash === -1 ? '' : currentPath.slice(0, slash + 1);
|
|
39
|
+
return `${directory}${trimmed}`.replaceAll(/\/{2,}/gu, '/');
|
|
40
|
+
}
|
|
41
|
+
function parseInlines(text) {
|
|
42
|
+
const result = [];
|
|
43
|
+
const expression = /\[([^\]]+)\]\(([^)]+)\)/gu;
|
|
44
|
+
let last = 0;
|
|
45
|
+
for (const match of text.matchAll(expression)){
|
|
46
|
+
const index = match.index ?? 0;
|
|
47
|
+
if (index > last) result.push({
|
|
48
|
+
type: 'text',
|
|
49
|
+
value: text.slice(last, index)
|
|
50
|
+
});
|
|
51
|
+
const href = match[2];
|
|
52
|
+
result.push({
|
|
53
|
+
type: 'link',
|
|
54
|
+
href,
|
|
55
|
+
text: match[1],
|
|
56
|
+
wiki: isWikiHref(href)
|
|
57
|
+
});
|
|
58
|
+
last = index + match[0].length;
|
|
59
|
+
}
|
|
60
|
+
if (last < text.length) result.push({
|
|
61
|
+
type: 'text',
|
|
62
|
+
value: text.slice(last)
|
|
63
|
+
});
|
|
64
|
+
return result.length === 0 ? [
|
|
65
|
+
{
|
|
66
|
+
type: 'text',
|
|
67
|
+
value: text
|
|
68
|
+
}
|
|
69
|
+
] : result;
|
|
70
|
+
}
|
|
71
|
+
function isWikiHref(href) {
|
|
72
|
+
if (href.length === 0 || href.startsWith('#') || href.startsWith('//')) return false;
|
|
73
|
+
if (/^[A-Za-z][A-Za-z0-9+.-]*:/u.test(href)) return false;
|
|
74
|
+
return (href.split('#', 1)[0] ?? href).endsWith('.md');
|
|
75
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { readdir, readFile, realpath, stat } from 'node:fs/promises';
|
|
2
|
+
import { isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { SearchIndex } from '@sheldon/search';
|
|
4
|
+
import { entityDirectory, VaultService } from '@sheldon/vault';
|
|
5
|
+
import { parse } from 'yaml';
|
|
6
|
+
export class WikiNotFoundError extends Error {
|
|
7
|
+
code = 'WEB_NOT_FOUND';
|
|
8
|
+
recovery;
|
|
9
|
+
target;
|
|
10
|
+
constructor(message, recovery, target){
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'WikiNotFoundError';
|
|
13
|
+
this.recovery = recovery;
|
|
14
|
+
this.target = target;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export async function listWikiPaths(vaultRoot, kind, slug) {
|
|
18
|
+
const entityRoot = await requireEntityRoot(vaultRoot, kind, slug);
|
|
19
|
+
const wikiRoot = join(entityRoot, 'wiki');
|
|
20
|
+
const files = await findMarkdownFiles(wikiRoot);
|
|
21
|
+
return files.map((file)=>({
|
|
22
|
+
path: toPosix(join('wiki', relative(wikiRoot, file)))
|
|
23
|
+
})).sort((left, right)=>comparePaths(left.path, right.path));
|
|
24
|
+
}
|
|
25
|
+
export async function readWikiPage(vaultRoot, kind, slug, requestedPath) {
|
|
26
|
+
const entityRoot = await requireEntityRoot(vaultRoot, kind, slug);
|
|
27
|
+
const wikiRoot = join(entityRoot, 'wiki');
|
|
28
|
+
const relativePath = stripPrefix(requestedPath, 'wiki/');
|
|
29
|
+
const file = await confinedExistingFile(wikiRoot, relativePath);
|
|
30
|
+
const content = await readFile(file, 'utf8');
|
|
31
|
+
const concept = parseConcept(content);
|
|
32
|
+
const realWikiRoot = await realpath(wikiRoot);
|
|
33
|
+
const path = toPosix(join('wiki', relative(realWikiRoot, file)));
|
|
34
|
+
return {
|
|
35
|
+
...concept,
|
|
36
|
+
path,
|
|
37
|
+
neighbours: await readNeighbours(vaultRoot, kind, slug, path)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export async function readRawFile(vaultRoot, kind, slug, requestedPath) {
|
|
41
|
+
const entityRoot = await requireEntityRoot(vaultRoot, kind, slug);
|
|
42
|
+
const rawRoot = join(entityRoot, 'raw');
|
|
43
|
+
const relativePath = stripPrefix(requestedPath, 'raw/');
|
|
44
|
+
const file = await confinedExistingFile(rawRoot, relativePath);
|
|
45
|
+
return readFile(file, 'utf8');
|
|
46
|
+
}
|
|
47
|
+
async function requireEntityRoot(vaultRoot, kind, slug) {
|
|
48
|
+
const vault = await VaultService.discover(vaultRoot);
|
|
49
|
+
try {
|
|
50
|
+
await vault.inspectEntity(kind, slug);
|
|
51
|
+
} catch {
|
|
52
|
+
throw new WikiNotFoundError('Entidade não encontrada.', 'Atualize a lista e tente novamente.', `${kind}/${slug}`);
|
|
53
|
+
}
|
|
54
|
+
return entityDirectory(vaultRoot, kind, slug);
|
|
55
|
+
}
|
|
56
|
+
async function confinedExistingFile(root, requestedPath) {
|
|
57
|
+
const target = confinedPath(root, requestedPath);
|
|
58
|
+
let realRoot;
|
|
59
|
+
let realTarget;
|
|
60
|
+
try {
|
|
61
|
+
realRoot = await realpath(root);
|
|
62
|
+
realTarget = await realpath(target);
|
|
63
|
+
} catch {
|
|
64
|
+
throw wikiMissing();
|
|
65
|
+
}
|
|
66
|
+
if (!isInside(realRoot, realTarget)) throw wikiMissing();
|
|
67
|
+
const info = await stat(realTarget);
|
|
68
|
+
if (!info.isFile()) throw wikiMissing();
|
|
69
|
+
return realTarget;
|
|
70
|
+
}
|
|
71
|
+
function confinedPath(root, requestedPath) {
|
|
72
|
+
const trimmed = requestedPath.trim();
|
|
73
|
+
if (trimmed.length === 0 || trimmed.includes('\0') || isAbsolute(trimmed)) {
|
|
74
|
+
throw wikiMissing();
|
|
75
|
+
}
|
|
76
|
+
const target = resolve(root, trimmed);
|
|
77
|
+
if (!isInside(root, target)) throw wikiMissing();
|
|
78
|
+
return target;
|
|
79
|
+
}
|
|
80
|
+
function isInside(root, target) {
|
|
81
|
+
const relativePath = relative(resolve(root), resolve(target));
|
|
82
|
+
return relativePath !== '' && relativePath !== '..' && !relativePath.startsWith(`..${sep}`) && !isAbsolute(relativePath);
|
|
83
|
+
}
|
|
84
|
+
async function findMarkdownFiles(root) {
|
|
85
|
+
const found = [];
|
|
86
|
+
const visit = async (directory)=>{
|
|
87
|
+
let entries;
|
|
88
|
+
try {
|
|
89
|
+
entries = await readdir(directory, {
|
|
90
|
+
withFileTypes: true
|
|
91
|
+
});
|
|
92
|
+
} catch (error) {
|
|
93
|
+
if (isMissing(error)) return;
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
for (const entry of entries){
|
|
97
|
+
const path = join(directory, entry.name);
|
|
98
|
+
if (entry.isDirectory()) await visit(path);
|
|
99
|
+
else if (entry.isFile() && entry.name.endsWith('.md')) found.push(path);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
await visit(root);
|
|
103
|
+
return found;
|
|
104
|
+
}
|
|
105
|
+
function parseConcept(content) {
|
|
106
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/u.exec(content);
|
|
107
|
+
let data = {};
|
|
108
|
+
let body = content;
|
|
109
|
+
if (match) {
|
|
110
|
+
const value = parse(match[1]);
|
|
111
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
112
|
+
data = value;
|
|
113
|
+
}
|
|
114
|
+
body = content.slice(match[0].length).replace(/^\r?\n/u, '');
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
id: typeof data.id === 'string' ? data.id : '',
|
|
118
|
+
title: typeof data.title === 'string' ? data.title : '',
|
|
119
|
+
sources: Array.isArray(data.sources) ? data.sources.filter((item)=>typeof item === 'string') : [],
|
|
120
|
+
body
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async function readNeighbours(vaultRoot, kind, slug, path) {
|
|
124
|
+
let index;
|
|
125
|
+
try {
|
|
126
|
+
index = SearchIndex.open(vaultRoot);
|
|
127
|
+
} catch {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const neighbours = [];
|
|
132
|
+
for (const relation of index.findRelatedConcepts({
|
|
133
|
+
kind,
|
|
134
|
+
slug
|
|
135
|
+
}, path)){
|
|
136
|
+
for (const mapped of mapRelation(relation.relation)){
|
|
137
|
+
neighbours.push({
|
|
138
|
+
path: relation.path,
|
|
139
|
+
relation: mapped
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return neighbours;
|
|
144
|
+
} finally{
|
|
145
|
+
index.close();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function mapRelation(relation) {
|
|
149
|
+
if (relation === 'outgoing') return [
|
|
150
|
+
'outgoing'
|
|
151
|
+
];
|
|
152
|
+
if (relation === 'backlink') return [
|
|
153
|
+
'incoming'
|
|
154
|
+
];
|
|
155
|
+
return [
|
|
156
|
+
'outgoing',
|
|
157
|
+
'incoming'
|
|
158
|
+
];
|
|
159
|
+
}
|
|
160
|
+
function stripPrefix(path, prefix) {
|
|
161
|
+
const normalized = path.replaceAll('\\', '/');
|
|
162
|
+
return normalized.startsWith(prefix) ? normalized.slice(prefix.length) : normalized;
|
|
163
|
+
}
|
|
164
|
+
function toPosix(path) {
|
|
165
|
+
return path.replaceAll('\\', '/');
|
|
166
|
+
}
|
|
167
|
+
function comparePaths(left, right) {
|
|
168
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
169
|
+
}
|
|
170
|
+
function wikiMissing() {
|
|
171
|
+
return new WikiNotFoundError('Wiki não encontrado.', 'Atualize a lista e tente novamente.', 'Wiki');
|
|
172
|
+
}
|
|
173
|
+
function isMissing(error) {
|
|
174
|
+
return error instanceof Error && 'code' in error && error.code === 'ENOENT';
|
|
175
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics-channel-react-native.d.ts","sourceRoot":"","sources":["../../../src/diagnostics-channel-react-native.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,cAAc,EACpB,MAAM,0BAA0B,CAAA;AACjC,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,CAAA;AAGvC,eAAO,MAAM,OAAO,EAAY,OAAO,CAAC,OAAO,CAAC,CAAA;AAChD,eAAO,MAAM,OAAO,EAAY,cAAc,CAAC,OAAO,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics-channel-react-native.js","sourceRoot":"","sources":["../../../src/diagnostics-channel-react-native.ts"],"names":[],"mappings":";;;AAQA,MAAM,KAAK,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,CAAA;AAC1B,QAAA,OAAO,GAAG,KAAyB,CAAA;AACnC,QAAA,OAAO,GAAG,KAAgC,CAAA","sourcesContent":["// this is used in ESM environments that follow the 'react-native' import\n// condition, to avoid even trying to load node:diagnostics_channel\nimport {\n type Channel,\n type TracingChannel,\n} from 'node:diagnostics_channel'\nexport type { TracingChannel, Channel }\n\nconst dummy = { hasSubscribers: false }\nexport const metrics = dummy as Channel<unknown>\nexport const tracing = dummy as TracingChannel<unknown>\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Channel, type TracingChannel } from 'node:diagnostics_channel';
|
|
2
|
+
export type { TracingChannel, Channel };
|
|
3
|
+
export declare const metrics: Channel<unknown>;
|
|
4
|
+
export declare const tracing: TracingChannel<unknown>;
|
|
5
|
+
//# sourceMappingURL=diagnostics-channel-react-native.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tracing = exports.metrics = void 0;
|
|
4
|
+
const dummy = { hasSubscribers: false };
|
|
5
|
+
exports.metrics = dummy;
|
|
6
|
+
exports.tracing = dummy;
|
|
7
|
+
//# sourceMappingURL=diagnostics-channel-react-native.js.map
|