@vibes.diy/use-vibes-base 2.2.12 → 2.2.13-dev.2
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/README.md +67 -0
- package/firefly-defaults.node.d.ts +4 -0
- package/firefly-defaults.node.js +35 -0
- package/firefly-defaults.node.js.map +1 -0
- package/fireproof-node.d.ts +11 -0
- package/fireproof-node.js +57 -0
- package/fireproof-node.js.map +1 -0
- package/hooks/use-viewer.d.ts +11 -0
- package/hooks/use-viewer.js +22 -0
- package/hooks/use-viewer.js.map +1 -0
- package/index.d.ts +4 -2
- package/index.js +4 -2
- package/index.js.map +1 -1
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -31,6 +31,73 @@ import { base64ToFile } from "use-vibes";
|
|
|
31
31
|
const imageFile = base64ToFile(imageResponse.data[0].b64_json, "my-image.png");
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
## Standalone Fireproof (Node.js / Wrangler)
|
|
35
|
+
|
|
36
|
+
`use-vibes` exposes a standalone `fireproof()` factory for non-React contexts
|
|
37
|
+
— Node scripts, Wrangler workers, anywhere you need to read/write Fireproof
|
|
38
|
+
documents without the React hooks or the in-iframe postMessage bridge.
|
|
39
|
+
|
|
40
|
+
The bare form Just Works if you've authenticated this device with the CLI:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx vibes-diy login
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
import { fireproof } from "use-vibes";
|
|
48
|
+
|
|
49
|
+
const db = fireproof("todos");
|
|
50
|
+
|
|
51
|
+
const ok = await db.put({ text: "hello" });
|
|
52
|
+
const doc = await db.get(ok.id);
|
|
53
|
+
const { docs } = await db.query("type", { key: "todo" });
|
|
54
|
+
|
|
55
|
+
db.subscribe((changes) => {
|
|
56
|
+
console.log("changed:", changes);
|
|
57
|
+
}, true);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### How defaults resolve
|
|
61
|
+
|
|
62
|
+
| Field | Default source (when omitted) |
|
|
63
|
+
| ---------- | ----------------------------------------------------------------------------------- |
|
|
64
|
+
| `apiUrl` | env `VIBES_DIY_API_URL`, then `https://vibes.diy/api` |
|
|
65
|
+
| `appSlug` | env `VIBES_APP_SLUG`, then `basename(process.cwd())` |
|
|
66
|
+
| `getToken` | local device-id cert from the Fireproof keybag (populated by `npx vibes-diy login`) |
|
|
67
|
+
| `userSlug` | lazy — looked up from your `defaultUserSlug` user setting on first request |
|
|
68
|
+
|
|
69
|
+
### Explicit overrides
|
|
70
|
+
|
|
71
|
+
For Wrangler / CI / service-account contexts where the CLI flow doesn't apply:
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
import { fireproof, type FireproofOpts } from "use-vibes";
|
|
75
|
+
|
|
76
|
+
const db = fireproof("todos", {
|
|
77
|
+
apiUrl: "https://vibes.diy/api",
|
|
78
|
+
appSlug: "my-app",
|
|
79
|
+
userSlug: "alice", // optional — auto-derived from token otherwise
|
|
80
|
+
getToken: async () => ({
|
|
81
|
+
isOk: () => true,
|
|
82
|
+
Ok: () => ({ type: "device-id", token: myToken }),
|
|
83
|
+
// …a real @adviser/cement Result
|
|
84
|
+
}),
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Caching semantics
|
|
89
|
+
|
|
90
|
+
Calling `fireproof(name)` repeatedly is the supported pattern:
|
|
91
|
+
|
|
92
|
+
- `fireproof("a") === fireproof("a")` — same name returns the same database instance.
|
|
93
|
+
- `fireproof("a")` and `fireproof("b")` are distinct, but **share one WebSocket connection and one resolved userSlug**.
|
|
94
|
+
- **First call's opts win.** If you need to talk to multiple `(apiUrl, appSlug)` pairs in one process, drop the sugar and construct `VibesDiyApi` + `FireflyApiAdapter` + `FireflyDatabase` directly.
|
|
95
|
+
|
|
96
|
+
### v1 limitations
|
|
97
|
+
|
|
98
|
+
- File uploads (docs with a `_files` field of `File`/`Blob` entries) are **not yet supported** — `db.put({_files: {...}})` will throw. Pure-doc workflows work end-to-end.
|
|
99
|
+
- Inside a vibe iframe the import is rewritten to `@vibes.diy/vibe-runtime`, which has its own `fireproof("name")` form that uses the postMessage bridge instead. You don't need this Node factory in iframe code.
|
|
100
|
+
|
|
34
101
|
## Core Features
|
|
35
102
|
|
|
36
103
|
### Interactive Image Generation
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Result } from "@adviser/cement";
|
|
2
|
+
import type { SuperThis } from "@fireproof/core-types-base";
|
|
3
|
+
import type { DashAuthType } from "@fireproof/core-types-protocols-dashboard";
|
|
4
|
+
export declare function loadDeviceIdGetToken(sthis: SuperThis): Promise<() => Promise<Result<DashAuthType>>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Lazy, Result as CementResult } from "@adviser/cement";
|
|
2
|
+
import { getKeyBag } from "@fireproof/core-keybag";
|
|
3
|
+
import { DeviceIdKey, DeviceIdSignMsg } from "@fireproof/core-device-id";
|
|
4
|
+
export async function loadDeviceIdGetToken(sthis) {
|
|
5
|
+
const kb = await getKeyBag(sthis);
|
|
6
|
+
const devid = await kb.getDeviceId();
|
|
7
|
+
if (devid.cert.IsNone()) {
|
|
8
|
+
throw new Error("Run 'npx vibes-diy login' to authenticate this device");
|
|
9
|
+
}
|
|
10
|
+
const rDevkey = await DeviceIdKey.createFromJWK(devid.deviceId.Unwrap());
|
|
11
|
+
if (rDevkey.isErr()) {
|
|
12
|
+
throw rDevkey.Err();
|
|
13
|
+
}
|
|
14
|
+
const payload = devid.cert.Unwrap().certificatePayload;
|
|
15
|
+
const deviceIdSigner = new DeviceIdSignMsg(sthis.txt.base64, rDevkey.Ok(), payload);
|
|
16
|
+
let seq = 0;
|
|
17
|
+
return Lazy(async () => {
|
|
18
|
+
const now = Math.floor(Date.now() / 1000);
|
|
19
|
+
const token = await deviceIdSigner.sign({
|
|
20
|
+
iss: "use-vibes/standalone",
|
|
21
|
+
sub: "device-id",
|
|
22
|
+
deviceId: await rDevkey.Ok().fingerPrint(),
|
|
23
|
+
seq: ++seq,
|
|
24
|
+
exp: now + 120,
|
|
25
|
+
nbf: now - 2,
|
|
26
|
+
iat: now,
|
|
27
|
+
jti: sthis.nextId().str,
|
|
28
|
+
}, "ES256");
|
|
29
|
+
return CementResult.Ok({
|
|
30
|
+
type: "device-id",
|
|
31
|
+
token,
|
|
32
|
+
});
|
|
33
|
+
}, { resetAfter: 60, skipUnref: true });
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=firefly-defaults.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firefly-defaults.node.js","sourceRoot":"","sources":["../jsr/firefly-defaults.node.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEzE,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAAgB;IACzD,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,WAAW,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACzE,IAAI,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;QACpB,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAG,CAAC,kBAAkB,CAAC;IACxD,MAAM,cAAc,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IACpF,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,OAAO,IAAI,CACT,KAAK,IAAmC,EAAE;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAC1C,MAAM,KAAK,GAAG,MAAM,cAAc,CAAC,IAAI,CACrC;YACE,GAAG,EAAE,sBAAsB;YAC3B,GAAG,EAAE,WAAW;YAChB,QAAQ,EAAE,MAAM,OAAO,CAAC,EAAE,EAAE,CAAC,WAAW,EAAE;YAC1C,GAAG,EAAE,EAAE,GAAG;YACV,GAAG,EAAE,GAAG,GAAG,GAAG;YACd,GAAG,EAAE,GAAG,GAAG,CAAC;YACZ,GAAG,EAAE,GAAG;YACR,GAAG,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG;SACI,EAC7B,OAAO,CACR,CAAC;QACF,OAAO,YAAY,CAAC,EAAE,CAAC;YACrB,IAAI,EAAE,WAAW;YACjB,KAAK;SACN,CAAC,CAAC;IACL,CAAC,EACD,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Result } from "@adviser/cement";
|
|
2
|
+
import { FireflyDatabase } from "@vibes.diy/vibe-runtime";
|
|
3
|
+
import type { DashAuthType } from "@fireproof/core-types-protocols-dashboard";
|
|
4
|
+
export interface FireproofOpts {
|
|
5
|
+
apiUrl?: string;
|
|
6
|
+
appSlug?: string;
|
|
7
|
+
userSlug?: string;
|
|
8
|
+
getToken?: () => Promise<Result<DashAuthType>>;
|
|
9
|
+
}
|
|
10
|
+
export declare function fireproof(name: string, opts?: FireproofOpts): FireflyDatabase;
|
|
11
|
+
export declare function __resetFireproofForTesting(): void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Lazy, KeyedResolvOnce } from "@adviser/cement";
|
|
2
|
+
import { VibesDiyApi, FireflyApiAdapter } from "@vibes.diy/api-impl";
|
|
3
|
+
import { FireflyDatabase } from "@vibes.diy/vibe-runtime";
|
|
4
|
+
import { ensureSuperThis } from "@fireproof/core-runtime";
|
|
5
|
+
const DEFAULT_API_URL = "https://vibes.diy/api";
|
|
6
|
+
const lazyKeybagGetToken = Lazy(async () => {
|
|
7
|
+
const mod = await import("./firefly-defaults.node.js");
|
|
8
|
+
return mod.loadDeviceIdGetToken(ensureSuperThis());
|
|
9
|
+
});
|
|
10
|
+
function defaultAppSlugFromCwd() {
|
|
11
|
+
if (typeof process === "undefined" || typeof process.cwd !== "function")
|
|
12
|
+
return "";
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
const idx = Math.max(cwd.lastIndexOf("/"), cwd.lastIndexOf("\\"));
|
|
15
|
+
return idx >= 0 ? cwd.slice(idx + 1) : cwd;
|
|
16
|
+
}
|
|
17
|
+
function envVar(name) {
|
|
18
|
+
if (typeof process === "undefined" || !process.env)
|
|
19
|
+
return undefined;
|
|
20
|
+
return process.env[name];
|
|
21
|
+
}
|
|
22
|
+
function resolveOptsSync(opts) {
|
|
23
|
+
const apiUrl = opts?.apiUrl ?? envVar("VIBES_DIY_API_URL") ?? DEFAULT_API_URL;
|
|
24
|
+
const appSlug = opts?.appSlug ?? envVar("VIBES_APP_SLUG") ?? defaultAppSlugFromCwd();
|
|
25
|
+
if (appSlug === "") {
|
|
26
|
+
throw new Error("Set VIBES_APP_SLUG or pass {appSlug} to fireproof()");
|
|
27
|
+
}
|
|
28
|
+
const getToken = opts?.getToken ??
|
|
29
|
+
(async () => {
|
|
30
|
+
const inner = await lazyKeybagGetToken();
|
|
31
|
+
return inner();
|
|
32
|
+
});
|
|
33
|
+
return { apiUrl, appSlug, userSlug: opts?.userSlug, getToken };
|
|
34
|
+
}
|
|
35
|
+
let sharedAdapter = Lazy((resolved) => {
|
|
36
|
+
const api = new VibesDiyApi({
|
|
37
|
+
apiUrl: resolved.apiUrl,
|
|
38
|
+
getToken: resolved.getToken,
|
|
39
|
+
});
|
|
40
|
+
return new FireflyApiAdapter(api, resolved.appSlug, resolved.userSlug ? { userSlug: resolved.userSlug } : undefined);
|
|
41
|
+
});
|
|
42
|
+
let databasesByName = new KeyedResolvOnce();
|
|
43
|
+
export function fireproof(name, opts) {
|
|
44
|
+
const resolved = resolveOptsSync(opts);
|
|
45
|
+
return databasesByName.get(name).once(() => new FireflyDatabase(name, sharedAdapter(resolved)));
|
|
46
|
+
}
|
|
47
|
+
export function __resetFireproofForTesting() {
|
|
48
|
+
sharedAdapter = Lazy((resolved) => {
|
|
49
|
+
const api = new VibesDiyApi({
|
|
50
|
+
apiUrl: resolved.apiUrl,
|
|
51
|
+
getToken: resolved.getToken,
|
|
52
|
+
});
|
|
53
|
+
return new FireflyApiAdapter(api, resolved.appSlug, resolved.userSlug ? { userSlug: resolved.userSlug } : undefined);
|
|
54
|
+
});
|
|
55
|
+
databasesByName = new KeyedResolvOnce();
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=fireproof-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fireproof-node.js","sourceRoot":"","sources":["../jsr/fireproof-node.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAe,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAiB1D,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAEhD,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,IAAI,EAAE;IACzC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,4B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AAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACvH,CAAC,CAAC,CAAC;IACH,eAAe,GAAG,IAAI,eAAe,EAAmB,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type DbAcl, type ViewerEnv } from "@vibes.diy/vibe-runtime";
|
|
2
|
+
type ViewerPayload = NonNullable<ViewerEnv["viewer"]>;
|
|
3
|
+
type DocAccessLevel = ViewerEnv["access"];
|
|
4
|
+
export interface UseViewerResult {
|
|
5
|
+
readonly viewer: ViewerPayload | null;
|
|
6
|
+
readonly access: DocAccessLevel;
|
|
7
|
+
readonly dbAcls: Record<string, DbAcl>;
|
|
8
|
+
readonly can: (action: "read" | "write" | "delete", dbName?: string) => boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function useViewer(): UseViewerResult;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { aclAllows, useVibeContext as useRuntimeVibeContext } from "@vibes.diy/vibe-runtime";
|
|
2
|
+
export function useViewer() {
|
|
3
|
+
const { mountParams } = useRuntimeVibeContext();
|
|
4
|
+
const env = mountParams.viewerEnv;
|
|
5
|
+
const viewer = env?.viewer ?? null;
|
|
6
|
+
const access = env?.access ?? "none";
|
|
7
|
+
const dbAcls = env?.dbAcls ?? {};
|
|
8
|
+
function can(action, dbName) {
|
|
9
|
+
if (dbName !== undefined) {
|
|
10
|
+
return aclAllows(dbAcls[dbName], action, access);
|
|
11
|
+
}
|
|
12
|
+
if (!aclAllows(undefined, action, access))
|
|
13
|
+
return false;
|
|
14
|
+
for (const acl of Object.values(dbAcls)) {
|
|
15
|
+
if (!aclAllows(acl, action, access))
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return { viewer, access, dbAcls, can };
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=use-viewer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-viewer.js","sourceRoot":"","sources":["../../jsr/hooks/use-viewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,IAAI,qBAAqB,EAA8B,MAAM,yBAAyB,CAAC;AAazH,MAAM,UAAU,SAAS;IACvB,MAAM,EAAE,WAAW,EAAE,GAAG,qBAAqB,EAAE,CAAC;IAChD,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;QAKD,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"}
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { ToCloudAttachable, TokenStrategie } from "@fireproof/core-types-protocols-cloud";
|
|
2
|
-
import { Attached,
|
|
2
|
+
import { Attached, ImgFile, UseFireproof, UseFPConfig, type Database, type UseFpToCloudParam } from "@fireproof/use-fireproof";
|
|
3
3
|
import { Vibe } from "./contexts/VibeContext.js";
|
|
4
4
|
import { callAI } from "call-ai";
|
|
5
5
|
export * from "./contexts/VibeContext.js";
|
|
6
|
-
export {
|
|
6
|
+
export { ImgFile };
|
|
7
|
+
export { fireproof, type FireproofOpts } from "./fireproof-node.js";
|
|
7
8
|
export type * as Fireproof from "@fireproof/use-fireproof";
|
|
8
9
|
export declare const vibesEnvSchema: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
9
10
|
FPCLOUD_URL: string;
|
|
@@ -63,5 +64,6 @@ export { constructVibesDatabaseName } from "./utils/databaseName.js";
|
|
|
63
64
|
export type { ImageDocument, PartialImageDocument, UseImgVibesOptions, UseImgVibesResult } from "@vibes.diy/use-vibes-types";
|
|
64
65
|
export type { UseVibesOptions, UseVibesResult, VibeDocument } from "@vibes.diy/use-vibes-types";
|
|
65
66
|
export { useVibes } from "./hooks/vibes-gen/index.js";
|
|
67
|
+
export { useViewer, type UseViewerResult } from "./hooks/use-viewer.js";
|
|
66
68
|
export { getAppSlug, getInstanceId, getFullAppIdentifier, isDevelopmentEnvironment, isProductionEnvironment, generateRandomInstanceId, generateFreshDataUrl, generateRemixUrl, generateInstallId, } from "./utils/appSlug.js";
|
|
67
69
|
export { VibeContextProvider, useVibeContext, VibeMetadataValidationError } from "./contexts/VibeContext.js";
|
package/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { ImgFile, isDatabase, toCloud as originalToCloud, useFireproof as originalUseFireproof, } from "@fireproof/use-fireproof";
|
|
3
3
|
import { useVibeContext } from "./contexts/VibeContext.js";
|
|
4
4
|
import { constructVibesDatabaseName } from "./utils/databaseName.js";
|
|
5
5
|
import { callAI } from "call-ai";
|
|
6
6
|
import { ResolveOnce } from "@adviser/cement";
|
|
7
7
|
import { type } from "arktype";
|
|
8
8
|
export * from "./contexts/VibeContext.js";
|
|
9
|
-
export {
|
|
9
|
+
export { ImgFile };
|
|
10
|
+
export { fireproof } from "./fireproof-node.js";
|
|
10
11
|
export const vibesEnvSchema = type({
|
|
11
12
|
FPCLOUD_URL: "string",
|
|
12
13
|
DASHBOARD_URL: "string",
|
|
@@ -118,6 +119,7 @@ export { useMobile } from "./hooks/useMobile.js";
|
|
|
118
119
|
export { base64ToFile } from "./utils/base64.js";
|
|
119
120
|
export { constructVibesDatabaseName } from "./utils/databaseName.js";
|
|
120
121
|
export { useVibes } from "./hooks/vibes-gen/index.js";
|
|
122
|
+
export { useViewer } from "./hooks/use-viewer.js";
|
|
121
123
|
export { getAppSlug, getInstanceId, getFullAppIdentifier, isDevelopmentEnvironment, isProductionEnvironment, generateRandomInstanceId, generateFreshDataUrl, generateRemixUrl, generateInstallId, } from "./utils/appSlug.js";
|
|
122
124
|
export { VibeContextProvider, useVibeContext, VibeMetadataValidationError } from "./contexts/VibeContext.js";
|
|
123
125
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../jsr/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAEL,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../jsr/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAEL,OAAO,EACP,UAAU,EACV,OAAO,IAAI,eAAe,EAC1B,YAAY,IAAI,oBAAoB,GAKrC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAQ,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,SAA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3
|
+
"version": "2.2.13-dev.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"description": "Core components and utilities for use-vibes (internal workspace package)",
|
|
@@ -12,18 +12,21 @@
|
|
|
12
12
|
"@adviser/cement": "~0.5.34",
|
|
13
13
|
"@clerk/react": "~6.6.0",
|
|
14
14
|
"@fireproof/core": "~0.24.19",
|
|
15
|
+
"@fireproof/core-device-id": "~0.24.19",
|
|
15
16
|
"@fireproof/core-keybag": "~0.24.19",
|
|
16
17
|
"@fireproof/core-protocols-dashboard": "~0.24.19",
|
|
17
18
|
"@fireproof/core-runtime": "~0.24.19",
|
|
18
19
|
"@fireproof/core-types-base": "~0.24.19",
|
|
19
20
|
"@fireproof/core-types-protocols-cloud": "~0.24.19",
|
|
21
|
+
"@fireproof/core-types-protocols-dashboard": "~0.24.19",
|
|
20
22
|
"@fireproof/use-fireproof": "~0.24.19",
|
|
21
|
-
"@vibes.diy/
|
|
22
|
-
"@vibes.diy/
|
|
23
|
-
"@vibes.diy/
|
|
24
|
-
"@vibes.diy/
|
|
23
|
+
"@vibes.diy/api-impl": "^2.2.13-dev.2",
|
|
24
|
+
"@vibes.diy/base": "^2.2.13-dev.2",
|
|
25
|
+
"@vibes.diy/prompts": "^2.2.13-dev.2",
|
|
26
|
+
"@vibes.diy/use-vibes-types": "^2.2.13-dev.2",
|
|
27
|
+
"@vibes.diy/vibe-runtime": "^2.2.13-dev.2",
|
|
25
28
|
"arktype": "~2.2.0",
|
|
26
|
-
"call-ai": "^2.2.
|
|
29
|
+
"call-ai": "^2.2.13-dev.2",
|
|
27
30
|
"jose": "~6.2.2",
|
|
28
31
|
"react-dom": "~19.2.5",
|
|
29
32
|
"zod": "~4.3.6"
|