@omgbase/astro 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/LICENSE +21 -0
- package/README.md +142 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/links.d.ts +75 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +198 -0
- package/dist/links.js.map +1 -0
- package/dist/loader.d.ts +70 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +75 -0
- package/dist/loader.js.map +1 -0
- package/dist/local.d.ts +31 -0
- package/dist/local.d.ts.map +1 -0
- package/dist/local.js +139 -0
- package/dist/local.js.map +1 -0
- package/dist/map.d.ts +41 -0
- package/dist/map.d.ts.map +1 -0
- package/dist/map.js +106 -0
- package/dist/map.js.map +1 -0
- package/dist/remote.d.ts +49 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +155 -0
- package/dist/remote.js.map +1 -0
- package/dist/schema.d.ts +16 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -0
- package/dist/server.d.ts +41 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +115 -0
- package/dist/server.js.map +1 -0
- package/dist/transport.d.ts +74 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +2 -0
- package/dist/transport.js.map +1 -0
- package/dist/watch.d.ts +38 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.js +215 -0
- package/dist/watch.js.map +1 -0
- package/package.json +48 -0
package/dist/local.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Store } from "@omgbase/core";
|
|
2
|
+
import type { ChangesPage, ChangesSinceOptions, DocOutEdge, HydrateOptions, HydratedDoc, OutEdgesOptions, QueryHit, QueryOptions, Transport } from "./transport.js";
|
|
3
|
+
export interface LocalTransportOptions {
|
|
4
|
+
/** Path to the omgbase workspace root (directory containing `.omgbase/`). */
|
|
5
|
+
workspace: string;
|
|
6
|
+
/** Repo slug inside the workspace. When omitted, the sole repo is used. */
|
|
7
|
+
repo?: string;
|
|
8
|
+
/** Skip freshnessSweep before reads (default false). */
|
|
9
|
+
stale?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Local transport: open a workspace via `@omgbase/core`, run OQX, hydrate with docsRead.
|
|
13
|
+
*/
|
|
14
|
+
export declare class LocalTransport implements Transport {
|
|
15
|
+
readonly kind: "local";
|
|
16
|
+
private readonly ws;
|
|
17
|
+
private readonly repo;
|
|
18
|
+
private readonly stale;
|
|
19
|
+
constructor(opts: LocalTransportOptions);
|
|
20
|
+
get store(): Store;
|
|
21
|
+
get repoId(): string;
|
|
22
|
+
get watchRoot(): string | null;
|
|
23
|
+
private ensureFresh;
|
|
24
|
+
query(opts: QueryOptions): Promise<QueryHit[]>;
|
|
25
|
+
hydrate(opts: HydrateOptions): Promise<HydratedDoc[]>;
|
|
26
|
+
outEdges(opts: OutEdgesOptions): Promise<DocOutEdge[]>;
|
|
27
|
+
changesSince(opts?: ChangesSinceOptions): Promise<ChangesPage>;
|
|
28
|
+
close(): void;
|
|
29
|
+
}
|
|
30
|
+
export declare function createLocalTransport(opts: LocalTransportOptions): LocalTransport;
|
|
31
|
+
//# sourceMappingURL=local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../src/local.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,KAAK,EAEX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,WAAW,EACX,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,SAAS,EACV,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,qBAAqB;IACpC,6EAA6E;IAC7E,SAAS,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AA2CD;;GAEG;AACH,qBAAa,cAAe,YAAW,SAAS;IAC9C,QAAQ,CAAC,IAAI,EAAG,OAAO,CAAU;IACjC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAY;IAC/B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAU;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;gBAEpB,IAAI,EAAE,qBAAqB;IAMvC,IAAI,KAAK,IAAI,KAAK,CAEjB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,SAAS,IAAI,MAAM,GAAG,IAAI,CAE7B;IAED,OAAO,CAAC,WAAW;IAOb,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAiB9C,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAWrD,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IA4BtD,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;IAaxE,KAAK,IAAI,IAAI;CAGd;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,qBAAqB,GAAG,cAAc,CAEhF"}
|
package/dist/local.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { Workspace, freshnessSweep, oqxRun, docsRead, changesSince, } from "@omgbase/core";
|
|
4
|
+
import { contentHashOf, stripFrontmatter } from "./map.js";
|
|
5
|
+
function resolveRepo(ws, slug) {
|
|
6
|
+
if (slug) {
|
|
7
|
+
const found = ws.repoBySlug(slug);
|
|
8
|
+
if (!found) {
|
|
9
|
+
throw new Error(`omgbase repo not found: ${slug}`);
|
|
10
|
+
}
|
|
11
|
+
return found;
|
|
12
|
+
}
|
|
13
|
+
const repos = ws.repos();
|
|
14
|
+
if (repos.length === 0) {
|
|
15
|
+
throw new Error(`no omgbase repos in workspace ${ws.root}`);
|
|
16
|
+
}
|
|
17
|
+
if (repos.length > 1) {
|
|
18
|
+
throw new Error(`ambiguous omgbase repo in ${ws.root}; pass repo: one of ${repos.map((r) => r.slug).join(", ")}`);
|
|
19
|
+
}
|
|
20
|
+
return repos[0];
|
|
21
|
+
}
|
|
22
|
+
function openWorkspace(workspacePath) {
|
|
23
|
+
const root = resolve(workspacePath);
|
|
24
|
+
if (existsSync(join(root, ".omgbase"))) {
|
|
25
|
+
return Workspace.open(root);
|
|
26
|
+
}
|
|
27
|
+
const found = Workspace.find(root);
|
|
28
|
+
if (found)
|
|
29
|
+
return found;
|
|
30
|
+
return Workspace.open(root);
|
|
31
|
+
}
|
|
32
|
+
function toHydrated(read) {
|
|
33
|
+
return {
|
|
34
|
+
id: read.docId,
|
|
35
|
+
path: read.path,
|
|
36
|
+
properties: read.properties,
|
|
37
|
+
body: stripFrontmatter(read.content),
|
|
38
|
+
contentHash: contentHashOf(read.properties, read.content),
|
|
39
|
+
rev: read.rev,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Local transport: open a workspace via `@omgbase/core`, run OQX, hydrate with docsRead.
|
|
44
|
+
*/
|
|
45
|
+
export class LocalTransport {
|
|
46
|
+
kind = "local";
|
|
47
|
+
ws;
|
|
48
|
+
repo;
|
|
49
|
+
stale;
|
|
50
|
+
constructor(opts) {
|
|
51
|
+
this.ws = openWorkspace(opts.workspace);
|
|
52
|
+
this.repo = resolveRepo(this.ws, opts.repo);
|
|
53
|
+
this.stale = opts.stale ?? false;
|
|
54
|
+
}
|
|
55
|
+
get store() {
|
|
56
|
+
return this.ws.store;
|
|
57
|
+
}
|
|
58
|
+
get repoId() {
|
|
59
|
+
return this.repo.repoId;
|
|
60
|
+
}
|
|
61
|
+
get watchRoot() {
|
|
62
|
+
return this.repo.rootPath ?? this.ws.root;
|
|
63
|
+
}
|
|
64
|
+
ensureFresh() {
|
|
65
|
+
if (this.stale)
|
|
66
|
+
return;
|
|
67
|
+
if (this.repo.rootPath) {
|
|
68
|
+
freshnessSweep(this.ws.store, this.repo.repoId, this.repo.rootPath);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async query(opts) {
|
|
72
|
+
this.ensureFresh();
|
|
73
|
+
const result = oqxRun(this.ws.store, this.repo.repoId, opts.query, opts.limit !== undefined ? { limit: opts.limit } : {});
|
|
74
|
+
if (result.consumer === "count" || result.consumer === "exists") {
|
|
75
|
+
throw new Error(`omgLoader query must return document hits, got consumer=${result.consumer}`);
|
|
76
|
+
}
|
|
77
|
+
return result.hits.map((h) => {
|
|
78
|
+
const { id, path, ...rest } = h;
|
|
79
|
+
return { id, path, ...rest };
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async hydrate(opts) {
|
|
83
|
+
this.ensureFresh();
|
|
84
|
+
const out = [];
|
|
85
|
+
for (const id of opts.ids) {
|
|
86
|
+
const read = docsRead(this.ws.store, id);
|
|
87
|
+
if (!read)
|
|
88
|
+
continue;
|
|
89
|
+
out.push(toHydrated(read));
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
async outEdges(opts) {
|
|
94
|
+
this.ensureFresh();
|
|
95
|
+
if (opts.ids.length === 0)
|
|
96
|
+
return [];
|
|
97
|
+
const wanted = new Set(opts.ids);
|
|
98
|
+
const result = oqxRun(this.ws.store, this.repo.repoId, `$src, $dst, $dst_path from edges where dst_kind == "document"`);
|
|
99
|
+
const out = [];
|
|
100
|
+
const seen = new Set();
|
|
101
|
+
for (const h of result.hits) {
|
|
102
|
+
const src = typeof h.$src === "string" ? h.$src : null;
|
|
103
|
+
const dst = typeof h.$dst === "string" ? h.$dst : null;
|
|
104
|
+
if (!src || !dst || !wanted.has(src))
|
|
105
|
+
continue;
|
|
106
|
+
if (dst.startsWith("phantom:"))
|
|
107
|
+
continue;
|
|
108
|
+
const key = `${src}\0${dst}`;
|
|
109
|
+
if (seen.has(key))
|
|
110
|
+
continue;
|
|
111
|
+
seen.add(key);
|
|
112
|
+
out.push({
|
|
113
|
+
src,
|
|
114
|
+
dst,
|
|
115
|
+
dstPath: typeof h.$dst_path === "string" ? h.$dst_path : null,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
async changesSince(opts = {}) {
|
|
121
|
+
this.ensureFresh();
|
|
122
|
+
const page = changesSince(this.ws.store, this.repo.repoId, {
|
|
123
|
+
...(opts.cursor !== undefined ? { cursor: opts.cursor } : {}),
|
|
124
|
+
...(opts.limit !== undefined ? { limit: opts.limit } : {}),
|
|
125
|
+
});
|
|
126
|
+
return {
|
|
127
|
+
digests: page.digests.map((d) => ({ seq: d.seq, summary: d.summary })),
|
|
128
|
+
head: page.head,
|
|
129
|
+
truncated: page.truncated,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
close() {
|
|
133
|
+
this.ws.store.close();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export function createLocalTransport(opts) {
|
|
137
|
+
return new LocalTransport(opts);
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../src/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,SAAS,EACT,cAAc,EACd,MAAM,EACN,QAAQ,EACR,YAAY,GAGb,MAAM,eAAe,CAAC;AAYvB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAW3D,SAAS,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;IACb,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,OAA4B,EAAE;QAC/C,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACzD,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7D,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3D,CAAC,CAAC;QACH,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YACtE,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;IAED,KAAK;QACH,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACF;AAED,MAAM,UAAU,oBAAoB,CAAC,IAA2B;IAC9D,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/map.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { HydratedDoc } from "./transport.js";
|
|
2
|
+
export interface SlugContext {
|
|
3
|
+
path: string;
|
|
4
|
+
docId: string;
|
|
5
|
+
properties: Record<string, Record<string, unknown>>;
|
|
6
|
+
}
|
|
7
|
+
/** Default slug: document path with a trailing `.md` removed. */
|
|
8
|
+
export declare function defaultSlug({ path }: SlugContext): string;
|
|
9
|
+
/** Strip a leading YAML frontmatter fence from reconstructed file bytes. */
|
|
10
|
+
export declare function stripFrontmatter(content: string): string;
|
|
11
|
+
/** Prefer computed `$content_hash`, else null (caller may digest the body). */
|
|
12
|
+
export declare function contentHashOf(properties: Record<string, Record<string, unknown>>, fullContent?: string): string | null;
|
|
13
|
+
export interface MappedEntry {
|
|
14
|
+
id: string;
|
|
15
|
+
data: Record<string, unknown>;
|
|
16
|
+
body: string;
|
|
17
|
+
digest: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Fold lean OQX hit projections into entry data (e.g. `$updated_at` from
|
|
21
|
+
* `select …`). Intrinsic `id` / `path` stay on the hit; everything else merges
|
|
22
|
+
* under the hydrated frontmatter so authored fields win on collision.
|
|
23
|
+
* Also aliases `$updated_at` → `updatedAt` and `$title` → `title` when absent.
|
|
24
|
+
*/
|
|
25
|
+
export declare function mergeHitProjections(data: Record<string, unknown>, hit: {
|
|
26
|
+
id: string;
|
|
27
|
+
path: string;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}): Record<string, unknown>;
|
|
30
|
+
/**
|
|
31
|
+
* Stable fingerprint for digest inputs. Order-insensitive for plain objects so
|
|
32
|
+
* frontmatter key reshuffles don't thrash the content store.
|
|
33
|
+
*/
|
|
34
|
+
export declare function digestFingerprint(value: unknown): string;
|
|
35
|
+
/**
|
|
36
|
+
* Map a hydrated omg doc to Astro entry fields.
|
|
37
|
+
* Frontmatter keys are spread into `data`; intrinsic keys are always set.
|
|
38
|
+
* When frontmatter has no `title`, computed `$title` is used.
|
|
39
|
+
*/
|
|
40
|
+
export declare function mapDoc(doc: HydratedDoc, slugFn?: (ctx: SlugContext) => string): MappedEntry;
|
|
41
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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package/dist/map.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** Default slug: document path with a trailing `.md` removed. */
|
|
2
|
+
export function defaultSlug({ path }) {
|
|
3
|
+
return path.replace(/\.md$/i, "");
|
|
4
|
+
}
|
|
5
|
+
/** Strip a leading YAML frontmatter fence from reconstructed file bytes. */
|
|
6
|
+
export function stripFrontmatter(content) {
|
|
7
|
+
if (!content.startsWith("---"))
|
|
8
|
+
return content;
|
|
9
|
+
const nl = content.startsWith("---\r\n") ? "\r\n" : "\n";
|
|
10
|
+
const close = content.indexOf(`${nl}---`, 3);
|
|
11
|
+
if (close === -1)
|
|
12
|
+
return content;
|
|
13
|
+
let rest = content.slice(close + nl.length + 3);
|
|
14
|
+
// Drop the fence's trailing newline and any blank line that conventionally
|
|
15
|
+
// separates frontmatter from the body.
|
|
16
|
+
rest = rest.replace(/^(?:\r?\n)+/, "");
|
|
17
|
+
return rest;
|
|
18
|
+
}
|
|
19
|
+
/** Prefer computed `$content_hash`, else null (caller may digest the body). */
|
|
20
|
+
export function contentHashOf(properties, fullContent) {
|
|
21
|
+
const computed = properties.computed ?? {};
|
|
22
|
+
const hash = computed.$content_hash;
|
|
23
|
+
if (typeof hash === "string" && hash.length > 0)
|
|
24
|
+
return hash;
|
|
25
|
+
// Some workspaces materialize content_hash without the $ prefix.
|
|
26
|
+
const plain = computed.content_hash;
|
|
27
|
+
if (typeof plain === "string" && plain.length > 0)
|
|
28
|
+
return plain;
|
|
29
|
+
void fullContent;
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Fold lean OQX hit projections into entry data (e.g. `$updated_at` from
|
|
34
|
+
* `select …`). Intrinsic `id` / `path` stay on the hit; everything else merges
|
|
35
|
+
* under the hydrated frontmatter so authored fields win on collision.
|
|
36
|
+
* Also aliases `$updated_at` → `updatedAt` and `$title` → `title` when absent.
|
|
37
|
+
*/
|
|
38
|
+
export function mergeHitProjections(data, hit) {
|
|
39
|
+
const extras = {};
|
|
40
|
+
for (const [key, value] of Object.entries(hit)) {
|
|
41
|
+
if (key === "id" || key === "path")
|
|
42
|
+
continue;
|
|
43
|
+
extras[key] = value;
|
|
44
|
+
}
|
|
45
|
+
if (extras.$updated_at !== undefined && data.updatedAt === undefined) {
|
|
46
|
+
extras.updatedAt = extras.$updated_at;
|
|
47
|
+
}
|
|
48
|
+
if (typeof extras.$title === "string" && data.title === undefined) {
|
|
49
|
+
extras.title = extras.$title;
|
|
50
|
+
}
|
|
51
|
+
return { ...extras, ...data };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Stable fingerprint for digest inputs. Order-insensitive for plain objects so
|
|
55
|
+
* frontmatter key reshuffles don't thrash the content store.
|
|
56
|
+
*/
|
|
57
|
+
export function digestFingerprint(value) {
|
|
58
|
+
if (value === null || typeof value !== "object") {
|
|
59
|
+
return JSON.stringify(value) ?? "undefined";
|
|
60
|
+
}
|
|
61
|
+
if (Array.isArray(value)) {
|
|
62
|
+
return `[${value.map((item) => digestFingerprint(item)).join(",")}]`;
|
|
63
|
+
}
|
|
64
|
+
const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b));
|
|
65
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${digestFingerprint(v)}`).join(",")}}`;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Map a hydrated omg doc to Astro entry fields.
|
|
69
|
+
* Frontmatter keys are spread into `data`; intrinsic keys are always set.
|
|
70
|
+
* When frontmatter has no `title`, computed `$title` is used.
|
|
71
|
+
*/
|
|
72
|
+
export function mapDoc(doc, slugFn = defaultSlug) {
|
|
73
|
+
const frontmatter = { ...(doc.properties.frontmatter ?? {}) };
|
|
74
|
+
const computed = doc.properties.computed ?? {};
|
|
75
|
+
if (frontmatter.title === undefined && typeof computed.$title === "string") {
|
|
76
|
+
frontmatter.title = computed.$title;
|
|
77
|
+
}
|
|
78
|
+
const slug = slugFn({
|
|
79
|
+
path: doc.path,
|
|
80
|
+
docId: doc.id,
|
|
81
|
+
properties: doc.properties,
|
|
82
|
+
});
|
|
83
|
+
// Digest must change for path moves, rev bumps, and frontmatter-only edits.
|
|
84
|
+
// `$content_hash` is often absent remotely; falling back to body length alone
|
|
85
|
+
// would skip status/priority/etc. updates in Astro's content store.
|
|
86
|
+
const contentDigest = doc.contentHash ?? `body:${doc.body.length}`;
|
|
87
|
+
const digest = [
|
|
88
|
+
contentDigest,
|
|
89
|
+
`path:${doc.path}`,
|
|
90
|
+
`rev:${doc.rev ?? ""}`,
|
|
91
|
+
`fm:${digestFingerprint(frontmatter)}`,
|
|
92
|
+
].join("|");
|
|
93
|
+
return {
|
|
94
|
+
id: doc.id,
|
|
95
|
+
data: {
|
|
96
|
+
...frontmatter,
|
|
97
|
+
path: doc.path,
|
|
98
|
+
docId: doc.id,
|
|
99
|
+
contentHash: doc.contentHash,
|
|
100
|
+
slug,
|
|
101
|
+
},
|
|
102
|
+
body: doc.body,
|
|
103
|
+
digest,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=map.js.map
|
package/dist/map.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../src/map.ts"],"names":[],"mappings":"AAQA,iEAAiE;AACjE,MAAM,UAAU,WAAW,CAAC,EAAE,IAAI,EAAe;IAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AACpC,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IAC/C,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GA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SinceOptions, DocOutEdge, HydrateOptions, HydratedDoc, OutEdgesOptions, QueryHit, QueryOptions, Transport } from "./transport.js";
|
|
2
|
+
/** Parse a CLI-style `-H "Name: value"` line into a header pair. */
|
|
3
|
+
export declare function parseHeaderLine(line: string): [string, string];
|
|
4
|
+
/**
|
|
5
|
+
* Merge header sources the same way the CLI does for `--server` + `-H`:
|
|
6
|
+
* explicit map, then `-H`-style lines, then optional bearer `token`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveHeaders(opts: {
|
|
9
|
+
headers?: Record<string, string>;
|
|
10
|
+
headerLines?: string[];
|
|
11
|
+
token?: string;
|
|
12
|
+
}): Record<string, string>;
|
|
13
|
+
export interface RemoteTransportOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Streamable HTTP MCP endpoint URL (same as `omg … --server <url>`).
|
|
16
|
+
* Use the full URL including any secret path prefix.
|
|
17
|
+
*/
|
|
18
|
+
url: string;
|
|
19
|
+
/** Extra headers sent on every request (CLI `-H` equivalent as a map). */
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
/** Extra headers as CLI `-H` strings: `["X-Foo: bar", "Authorization: Bearer …"]`. */
|
|
22
|
+
headerLines?: string[];
|
|
23
|
+
/** Convenience: sets `Authorization: Bearer <token>` if Authorization is unset. */
|
|
24
|
+
token?: string;
|
|
25
|
+
/** Default repo slug passed to MCP tools when the call omits `repo`. */
|
|
26
|
+
repo?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Remote transport over Streamable HTTP MCP — the same path as
|
|
30
|
+
* `omg sync --server https://…` / `connectHttpEngine`.
|
|
31
|
+
*
|
|
32
|
+
* Calls `query` then `docs_get_many` for the build-time content load.
|
|
33
|
+
*/
|
|
34
|
+
export declare class RemoteTransport implements Transport {
|
|
35
|
+
readonly kind: "remote";
|
|
36
|
+
private readonly url;
|
|
37
|
+
private readonly headers;
|
|
38
|
+
private readonly repo;
|
|
39
|
+
private client;
|
|
40
|
+
constructor(opts: RemoteTransportOptions);
|
|
41
|
+
private ensureClient;
|
|
42
|
+
query(opts: QueryOptions): Promise<QueryHit[]>;
|
|
43
|
+
hydrate(opts: HydrateOptions): Promise<HydratedDoc[]>;
|
|
44
|
+
outEdges(opts: OutEdgesOptions): Promise<DocOutEdge[]>;
|
|
45
|
+
changesSince(opts?: ChangesSinceOptions): Promise<ChangesPage>;
|
|
46
|
+
close(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export declare function createRemoteTransport(opts: RemoteTransportOptions): RemoteTransport;
|
|
49
|
+
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,WAAW,EACX,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,SAAS,EACV,MAAM,gBAAgB,CAAC;AAGxB,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAS9D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWzB;AAED,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,mFAAmF;IACnF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAqBD;;;;;GAKG;AACH,qBAAa,eAAgB,YAAW,SAAS;IAC/C,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C,OAAO,CAAC,MAAM,CAAgC;gBAElC,IAAI,EAAE,sBAAsB;YAM1B,YAAY;IASpB,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAiB9C,OAAO,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAwBrD,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IA0BtD,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;IAmBlE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAM7B;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,sBAAsB,GAAG,eAAe,CAEnF"}
|
package/dist/remote.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { connectHttpEngine } from "@omgbase/sync";
|
|
2
|
+
import { contentHashOf, stripFrontmatter } from "./map.js";
|
|
3
|
+
/** Parse a CLI-style `-H "Name: value"` line into a header pair. */
|
|
4
|
+
export function parseHeaderLine(line) {
|
|
5
|
+
const i = line.indexOf(":");
|
|
6
|
+
if (i <= 0) {
|
|
7
|
+
throw new Error(`invalid header (expected "Name: value"): ${line}`);
|
|
8
|
+
}
|
|
9
|
+
const name = line.slice(0, i).trim();
|
|
10
|
+
const value = line.slice(i + 1).trim();
|
|
11
|
+
if (!name)
|
|
12
|
+
throw new Error(`invalid header name: ${line}`);
|
|
13
|
+
return [name, value];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Merge header sources the same way the CLI does for `--server` + `-H`:
|
|
17
|
+
* explicit map, then `-H`-style lines, then optional bearer `token`.
|
|
18
|
+
*/
|
|
19
|
+
export function resolveHeaders(opts) {
|
|
20
|
+
const out = { ...(opts.headers ?? {}) };
|
|
21
|
+
for (const line of opts.headerLines ?? []) {
|
|
22
|
+
const [name, value] = parseHeaderLine(line);
|
|
23
|
+
out[name] = value;
|
|
24
|
+
}
|
|
25
|
+
if (opts.token) {
|
|
26
|
+
const hasAuth = Object.keys(out).some((k) => k.toLowerCase() === "authorization");
|
|
27
|
+
if (!hasAuth)
|
|
28
|
+
out.Authorization = `Bearer ${opts.token}`;
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
const HYDRATE_CHUNK = 100;
|
|
33
|
+
/**
|
|
34
|
+
* Remote transport over Streamable HTTP MCP — the same path as
|
|
35
|
+
* `omg sync --server https://…` / `connectHttpEngine`.
|
|
36
|
+
*
|
|
37
|
+
* Calls `query` then `docs_get_many` for the build-time content load.
|
|
38
|
+
*/
|
|
39
|
+
export class RemoteTransport {
|
|
40
|
+
kind = "remote";
|
|
41
|
+
url;
|
|
42
|
+
headers;
|
|
43
|
+
repo;
|
|
44
|
+
client = null;
|
|
45
|
+
constructor(opts) {
|
|
46
|
+
this.url = opts.url;
|
|
47
|
+
this.headers = resolveHeaders(opts);
|
|
48
|
+
this.repo = opts.repo;
|
|
49
|
+
}
|
|
50
|
+
async ensureClient() {
|
|
51
|
+
if (this.client)
|
|
52
|
+
return this.client;
|
|
53
|
+
this.client = await connectHttpEngine({
|
|
54
|
+
url: this.url,
|
|
55
|
+
...(Object.keys(this.headers).length > 0 ? { headers: this.headers } : {}),
|
|
56
|
+
});
|
|
57
|
+
return this.client;
|
|
58
|
+
}
|
|
59
|
+
async query(opts) {
|
|
60
|
+
const client = await this.ensureClient();
|
|
61
|
+
const args = { query: opts.query };
|
|
62
|
+
if (opts.limit !== undefined)
|
|
63
|
+
args.limit = opts.limit;
|
|
64
|
+
const repo = opts.repo ?? this.repo;
|
|
65
|
+
if (repo !== undefined)
|
|
66
|
+
args.repo = repo;
|
|
67
|
+
const result = await client.callTool("query", args);
|
|
68
|
+
if (result.consumer === "count" || result.consumer === "exists") {
|
|
69
|
+
throw new Error(`omgLoader query must return document hits, got consumer=${result.consumer}`);
|
|
70
|
+
}
|
|
71
|
+
return (result.hits ?? []).map((h) => {
|
|
72
|
+
const { id, path, ...rest } = h;
|
|
73
|
+
return { id, path, ...rest };
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async hydrate(opts) {
|
|
77
|
+
const client = await this.ensureClient();
|
|
78
|
+
const repo = opts.repo ?? this.repo;
|
|
79
|
+
const out = [];
|
|
80
|
+
for (let i = 0; i < opts.ids.length; i += HYDRATE_CHUNK) {
|
|
81
|
+
const chunk = opts.ids.slice(i, i + HYDRATE_CHUNK);
|
|
82
|
+
const args = { docs: chunk };
|
|
83
|
+
if (repo !== undefined)
|
|
84
|
+
args.repo = repo;
|
|
85
|
+
const result = await client.callTool("docs_get_many", args);
|
|
86
|
+
for (const item of result.items ?? []) {
|
|
87
|
+
out.push({
|
|
88
|
+
id: item.docId,
|
|
89
|
+
path: item.path,
|
|
90
|
+
properties: item.properties,
|
|
91
|
+
body: stripFrontmatter(item.content),
|
|
92
|
+
contentHash: contentHashOf(item.properties, item.content),
|
|
93
|
+
rev: item.rev,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
async outEdges(opts) {
|
|
100
|
+
if (opts.ids.length === 0)
|
|
101
|
+
return [];
|
|
102
|
+
const wanted = new Set(opts.ids);
|
|
103
|
+
const hits = await this.query({
|
|
104
|
+
query: `$src, $dst, $dst_path from edges where dst_kind == "document"`,
|
|
105
|
+
...(opts.repo !== undefined ? { repo: opts.repo } : {}),
|
|
106
|
+
});
|
|
107
|
+
const out = [];
|
|
108
|
+
const seen = new Set();
|
|
109
|
+
for (const h of hits) {
|
|
110
|
+
const src = typeof h.$src === "string" ? h.$src : null;
|
|
111
|
+
const dst = typeof h.$dst === "string" ? h.$dst : null;
|
|
112
|
+
if (!src || !dst || !wanted.has(src))
|
|
113
|
+
continue;
|
|
114
|
+
if (dst.startsWith("phantom:"))
|
|
115
|
+
continue;
|
|
116
|
+
const key = `${src}\0${dst}`;
|
|
117
|
+
if (seen.has(key))
|
|
118
|
+
continue;
|
|
119
|
+
seen.add(key);
|
|
120
|
+
out.push({
|
|
121
|
+
src,
|
|
122
|
+
dst,
|
|
123
|
+
dstPath: typeof h.$dst_path === "string" ? h.$dst_path : null,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return out;
|
|
127
|
+
}
|
|
128
|
+
async changesSince(opts = {}) {
|
|
129
|
+
const client = await this.ensureClient();
|
|
130
|
+
const args = {};
|
|
131
|
+
if (opts.cursor !== undefined)
|
|
132
|
+
args.cursor = opts.cursor;
|
|
133
|
+
if (opts.limit !== undefined)
|
|
134
|
+
args.limit = opts.limit;
|
|
135
|
+
const repo = opts.repo ?? this.repo;
|
|
136
|
+
if (repo !== undefined)
|
|
137
|
+
args.repo = repo;
|
|
138
|
+
const page = await client.callTool("changes_since", args);
|
|
139
|
+
return {
|
|
140
|
+
digests: page.digests ?? [],
|
|
141
|
+
head: page.head,
|
|
142
|
+
truncated: page.truncated ?? false,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
async close() {
|
|
146
|
+
if (this.client) {
|
|
147
|
+
await this.client.close();
|
|
148
|
+
this.client = null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
export function createRemoteTransport(opts) {
|
|
153
|
+
return new RemoteTransport(opts);
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../src/remote.ts"],"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,GAAG,MAAM,MAAM,CAAC,QAAQ,CAI/B,eAAe,EAAE,IAAI,CAAC,CAAC;QAC1B,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE;YAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,KAAK;SACnC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,qBAAqB,CAAC,IAA4B;IAChE,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intrinsic fields always written by {@link omgLoader} into entry `data`.
|
|
3
|
+
* Site schemas typically `z.object({ title: z.string(), ... }).passthrough()`
|
|
4
|
+
* or explicitly include these keys.
|
|
5
|
+
*/
|
|
6
|
+
export interface OmgEntryIntrinsics {
|
|
7
|
+
/** Repository-relative document path (e.g. `posts/hello.md`). */
|
|
8
|
+
path: string;
|
|
9
|
+
/** Stable omg document id — also the Astro entry id. */
|
|
10
|
+
docId: string;
|
|
11
|
+
/** Content hash when available from omg computed properties. */
|
|
12
|
+
contentHash: string | null;
|
|
13
|
+
/** Routing slug derived from path (or a custom `slug` option). */
|
|
14
|
+
slug: string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;CACd"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":""}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Server } from "node:http";
|
|
2
|
+
export interface McpHttpServerOptions {
|
|
3
|
+
/** Path to the omgbase workspace root. */
|
|
4
|
+
workspace: string;
|
|
5
|
+
/** Default repo slug for tools that omit `repo`. */
|
|
6
|
+
repo?: string;
|
|
7
|
+
/** Optional bearer token required on `Authorization`. */
|
|
8
|
+
token?: string;
|
|
9
|
+
host?: string;
|
|
10
|
+
port?: number;
|
|
11
|
+
/** Skip freshnessSweep before serving (default false). */
|
|
12
|
+
stale?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* URL path of the MCP endpoint (default `/mcp`).
|
|
15
|
+
* The returned `url` includes this path — pass it verbatim to `--server` / `omgLoader({ url })`.
|
|
16
|
+
*/
|
|
17
|
+
path?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface McpHttpServer {
|
|
20
|
+
server: Server;
|
|
21
|
+
/** Full Streamable HTTP MCP URL (including path). */
|
|
22
|
+
url: string;
|
|
23
|
+
host: string;
|
|
24
|
+
port: number;
|
|
25
|
+
close: () => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Demo/CI Streamable HTTP MCP server for a local workspace.
|
|
29
|
+
*
|
|
30
|
+
* Same protocol as `omg … --server https://…` against a stdio-mcp-to-http wrapper
|
|
31
|
+
* or a future `omg serve`. Prefer pointing production builds at your real MCP HTTP
|
|
32
|
+
* endpoint; this helper is for local remote-transport demos without that wrapper.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createMcpHttpServer(opts: McpHttpServerOptions): Promise<McpHttpServer>;
|
|
35
|
+
/** @deprecated Use {@link createMcpHttpServer}. */
|
|
36
|
+
export declare const createPublicationServer: typeof createMcpHttpServer;
|
|
37
|
+
/** @deprecated Use {@link McpHttpServerOptions}. */
|
|
38
|
+
export type PublicationServerOptions = McpHttpServerOptions;
|
|
39
|
+
/** @deprecated Use {@link McpHttpServer}. */
|
|
40
|
+
export type PublicationServer = McpHttpServer;
|
|
41
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAsC,KAAK,MAAM,EAAuB,MAAM,WAAW,CAAC;AAKjG,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAiCD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAyE5F;AAED,mDAAmD;AACnD,eAAO,MAAM,uBAAuB,4BAAsB,CAAC;AAC3D,oDAAoD;AACpD,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAC5D,6CAA6C;AAC7C,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC"}
|