@vibes.diy/vibe-runtime 2.2.13-dev.5 → 2.2.13
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/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/use-viewer.d.ts +12 -0
- package/use-viewer.js +23 -0
- package/use-viewer.js.map +1 -0
package/index.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export * from "./call-ai.js";
|
|
|
8
8
|
export * from "./img-gen.js";
|
|
9
9
|
export { resizeImageToBase64 } from "./resize-image.js";
|
|
10
10
|
export { useFireproof, fireproof, listDbNames } from "./use-firefly.js";
|
|
11
|
+
export { useViewer, type UseViewerResult } from "./use-viewer.js";
|
|
11
12
|
export { FireflyDatabase, FireflyDatabase as Database, type DocTypes, type DocWithId, type DocResponse, type ListenerFn, type IndexRow, type QueryResponse, } from "./firefly-database.js";
|
|
12
13
|
export type { FireflyTransport } from "./firefly-database.js";
|
package/index.js
CHANGED
|
@@ -8,5 +8,6 @@ export * from "./call-ai.js";
|
|
|
8
8
|
export * from "./img-gen.js";
|
|
9
9
|
export { resizeImageToBase64 } from "./resize-image.js";
|
|
10
10
|
export { useFireproof, fireproof, listDbNames } from "./use-firefly.js";
|
|
11
|
+
export { useViewer } from "./use-viewer.js";
|
|
11
12
|
export { FireflyDatabase, FireflyDatabase as Database, } from "./firefly-database.js";
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../jsr/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACxF,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EACL,eAAe,EACf,eAAe,IAAI,QAAQ,GAO5B,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../jsr/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACxF,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAwB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EACL,eAAe,EACf,eAAe,IAAI,QAAQ,GAO5B,MAAM,uBAAuB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibes.diy/vibe-runtime",
|
|
3
|
-
"version": "2.2.13
|
|
3
|
+
"version": "2.2.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@adviser/cement": "~0.5.34",
|
|
11
|
-
"@vibes.diy/base": "2.2.13
|
|
12
|
-
"@vibes.diy/vibe-types": "2.2.13
|
|
11
|
+
"@vibes.diy/base": "2.2.13",
|
|
12
|
+
"@vibes.diy/vibe-types": "2.2.13",
|
|
13
13
|
"arktype": "~2.2.0",
|
|
14
14
|
"charwise": "~3.0.1",
|
|
15
15
|
"react": "~19.2.5",
|
package/use-viewer.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type DbAcl } from "./db-acl-allows.js";
|
|
2
|
+
import type { ViewerEnv } from "./vibe.js";
|
|
3
|
+
type ViewerPayload = NonNullable<ViewerEnv["viewer"]>;
|
|
4
|
+
type DocAccessLevel = ViewerEnv["access"];
|
|
5
|
+
export interface UseViewerResult {
|
|
6
|
+
readonly viewer: ViewerPayload | null;
|
|
7
|
+
readonly access: DocAccessLevel;
|
|
8
|
+
readonly dbAcls: Record<string, DbAcl>;
|
|
9
|
+
readonly can: (action: "read" | "write" | "delete", dbName?: string) => boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function useViewer(): UseViewerResult;
|
|
12
|
+
export {};
|
package/use-viewer.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { aclAllows } from "./db-acl-allows.js";
|
|
2
|
+
import { useVibeContext } from "./VibeContext.js";
|
|
3
|
+
export function useViewer() {
|
|
4
|
+
const { mountParams } = useVibeContext();
|
|
5
|
+
const env = mountParams.viewerEnv;
|
|
6
|
+
const viewer = env?.viewer ?? null;
|
|
7
|
+
const access = env?.access ?? "none";
|
|
8
|
+
const dbAcls = env?.dbAcls ?? {};
|
|
9
|
+
function can(action, dbName) {
|
|
10
|
+
if (dbName !== undefined) {
|
|
11
|
+
return aclAllows(dbAcls[dbName], action, access);
|
|
12
|
+
}
|
|
13
|
+
if (!aclAllows(undefined, action, access))
|
|
14
|
+
return false;
|
|
15
|
+
for (const acl of Object.values(dbAcls)) {
|
|
16
|
+
if (!aclAllows(acl, action, access))
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return { viewer, access, dbAcls, can };
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=use-viewer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-viewer.js","sourceRoot":"","sources":["../jsr/use-viewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAalD,MAAM,UAAU,SAAS;IACvB,MAAM,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,CAAC;IACzC,MAAM,GAAG,GAAG,WAAW,CAAC,SAAS,CAAC;IAClC,MAAM,MAAM,GAAG,GAAG,EAAE,MAAM,IAAI,IAAI,CAAC;IACnC,MAAM,MAAM,GAAmB,GAAG,EAAE,MAAM,IAAI,MAAM,CAAC;IACrD,MAAM,MAAM,GAA0B,GAAG,EAAE,MAAM,IAAI,EAAE,CAAC;IAExD,SAAS,GAAG,CAAC,MAAmC,EAAE,MAAe;QAC/D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC;YAAE,OAAO,KAAK,CAAC;QACxD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC;gBAAE,OAAO,KAAK,CAAC;QACpD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACzC,CAAC"}
|