@korajs/vue 0.5.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/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # @korajs/vue
2
+
3
+ Experimental Vue 3 bindings stub for [Kora.js](https://github.com/korajs/kora). Production React apps should use `@korajs/react` until reactive query composables land here.
4
+
5
+ ## Usage
6
+
7
+ ```typescript
8
+ import { createApp as createKoraApp } from 'korajs'
9
+ import { createApp as createVueApp } from 'vue'
10
+ import { installKora } from '@korajs/vue'
11
+ import schema from './schema'
12
+
13
+ const kora = createKoraApp({ schema, store: { workerUrl: '/sqlite-wasm-worker.js' } })
14
+ const vue = createVueApp(App)
15
+ installKora(vue, kora)
16
+ await kora.ready
17
+ vue.mount('#app')
18
+ ```
19
+
20
+ In components, use `useKoraApp()` then `app.todos.where({}).exec()` or wire your own `watch` on `app.events`.
package/dist/index.cjs ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ installKora: () => installKora,
24
+ koraAppInjectionKey: () => koraAppInjectionKey,
25
+ useKoraApp: () => useKoraApp
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+ var import_core = require("@korajs/core");
29
+ var import_vue = require("vue");
30
+ var koraAppInjectionKey = /* @__PURE__ */ Symbol("korajs-app");
31
+ function installKora(vueApp, koraApp) {
32
+ vueApp.provide(koraAppInjectionKey, koraApp);
33
+ }
34
+ function useKoraApp() {
35
+ const app = (0, import_vue.inject)(koraAppInjectionKey);
36
+ if (!app) {
37
+ throw new import_core.KoraError(
38
+ "useKoraApp() requires installKora(vueApp, koraApp) on the Vue application.",
39
+ "KORA_NOT_PROVIDED",
40
+ {
41
+ fix: "In main.ts: const kora = createApp({ schema }); installKora(vueApp, kora); await kora.ready"
42
+ }
43
+ );
44
+ }
45
+ return app;
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ installKora,
50
+ koraAppInjectionKey,
51
+ useKoraApp
52
+ });
53
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { KoraError } from '@korajs/core'\nimport { type App, type InjectionKey, inject } from 'vue'\nimport type { KoraAppHandle } from './types'\n\nexport type { KoraAppHandle } from './types'\n\n/** Vue injection key for the root Kora app instance. */\nexport const koraAppInjectionKey: InjectionKey<KoraAppHandle> = Symbol('korajs-app')\n\n/**\n * Register a Kora app on a Vue application instance.\n * Call once after `createApp()` from korajs, typically in `main.ts`.\n */\nexport function installKora(vueApp: App, koraApp: KoraAppHandle): void {\n\tvueApp.provide(koraAppInjectionKey, koraApp)\n}\n\n/**\n * Access the Kora app from a component setup function.\n * Pair with {@link installKora} and `app.ready` before running queries.\n */\nexport function useKoraApp(): KoraAppHandle {\n\tconst app = inject(koraAppInjectionKey)\n\tif (!app) {\n\t\tthrow new KoraError(\n\t\t\t'useKoraApp() requires installKora(vueApp, koraApp) on the Vue application.',\n\t\t\t'KORA_NOT_PROVIDED',\n\t\t\t{\n\t\t\t\tfix: 'In main.ts: const kora = createApp({ schema }); installKora(vueApp, kora); await kora.ready',\n\t\t\t},\n\t\t)\n\t}\n\treturn app\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA0B;AAC1B,iBAAoD;AAM7C,IAAM,sBAAmD,uBAAO,YAAY;AAM5E,SAAS,YAAY,QAAa,SAA8B;AACtE,SAAO,QAAQ,qBAAqB,OAAO;AAC5C;AAMO,SAAS,aAA4B;AAC3C,QAAM,UAAM,mBAAO,mBAAmB;AACtC,MAAI,CAAC,KAAK;AACT,UAAM,IAAI;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,QACC,KAAK;AAAA,MACN;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;","names":[]}
@@ -0,0 +1,31 @@
1
+ import { App, InjectionKey } from 'vue';
2
+ import { KoraEventEmitter } from '@korajs/core';
3
+ import { Store } from '@korajs/store';
4
+
5
+ /**
6
+ * Minimal app handle type for Vue provide/inject (matches `createApp()` from korajs).
7
+ * Use the full `KoraApp` / `TypedKoraApp` types from korajs in application code when available.
8
+ */
9
+ interface KoraAppHandle {
10
+ readonly ready: Promise<void>;
11
+ readonly events: KoraEventEmitter;
12
+ readonly sync: unknown;
13
+ close(): Promise<void>;
14
+ getStore(): Store;
15
+ [collection: string]: unknown;
16
+ }
17
+
18
+ /** Vue injection key for the root Kora app instance. */
19
+ declare const koraAppInjectionKey: InjectionKey<KoraAppHandle>;
20
+ /**
21
+ * Register a Kora app on a Vue application instance.
22
+ * Call once after `createApp()` from korajs, typically in `main.ts`.
23
+ */
24
+ declare function installKora(vueApp: App, koraApp: KoraAppHandle): void;
25
+ /**
26
+ * Access the Kora app from a component setup function.
27
+ * Pair with {@link installKora} and `app.ready` before running queries.
28
+ */
29
+ declare function useKoraApp(): KoraAppHandle;
30
+
31
+ export { type KoraAppHandle, installKora, koraAppInjectionKey, useKoraApp };
@@ -0,0 +1,31 @@
1
+ import { App, InjectionKey } from 'vue';
2
+ import { KoraEventEmitter } from '@korajs/core';
3
+ import { Store } from '@korajs/store';
4
+
5
+ /**
6
+ * Minimal app handle type for Vue provide/inject (matches `createApp()` from korajs).
7
+ * Use the full `KoraApp` / `TypedKoraApp` types from korajs in application code when available.
8
+ */
9
+ interface KoraAppHandle {
10
+ readonly ready: Promise<void>;
11
+ readonly events: KoraEventEmitter;
12
+ readonly sync: unknown;
13
+ close(): Promise<void>;
14
+ getStore(): Store;
15
+ [collection: string]: unknown;
16
+ }
17
+
18
+ /** Vue injection key for the root Kora app instance. */
19
+ declare const koraAppInjectionKey: InjectionKey<KoraAppHandle>;
20
+ /**
21
+ * Register a Kora app on a Vue application instance.
22
+ * Call once after `createApp()` from korajs, typically in `main.ts`.
23
+ */
24
+ declare function installKora(vueApp: App, koraApp: KoraAppHandle): void;
25
+ /**
26
+ * Access the Kora app from a component setup function.
27
+ * Pair with {@link installKora} and `app.ready` before running queries.
28
+ */
29
+ declare function useKoraApp(): KoraAppHandle;
30
+
31
+ export { type KoraAppHandle, installKora, koraAppInjectionKey, useKoraApp };
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ // src/index.ts
2
+ import { KoraError } from "@korajs/core";
3
+ import { inject } from "vue";
4
+ var koraAppInjectionKey = /* @__PURE__ */ Symbol("korajs-app");
5
+ function installKora(vueApp, koraApp) {
6
+ vueApp.provide(koraAppInjectionKey, koraApp);
7
+ }
8
+ function useKoraApp() {
9
+ const app = inject(koraAppInjectionKey);
10
+ if (!app) {
11
+ throw new KoraError(
12
+ "useKoraApp() requires installKora(vueApp, koraApp) on the Vue application.",
13
+ "KORA_NOT_PROVIDED",
14
+ {
15
+ fix: "In main.ts: const kora = createApp({ schema }); installKora(vueApp, kora); await kora.ready"
16
+ }
17
+ );
18
+ }
19
+ return app;
20
+ }
21
+ export {
22
+ installKora,
23
+ koraAppInjectionKey,
24
+ useKoraApp
25
+ };
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { KoraError } from '@korajs/core'\nimport { type App, type InjectionKey, inject } from 'vue'\nimport type { KoraAppHandle } from './types'\n\nexport type { KoraAppHandle } from './types'\n\n/** Vue injection key for the root Kora app instance. */\nexport const koraAppInjectionKey: InjectionKey<KoraAppHandle> = Symbol('korajs-app')\n\n/**\n * Register a Kora app on a Vue application instance.\n * Call once after `createApp()` from korajs, typically in `main.ts`.\n */\nexport function installKora(vueApp: App, koraApp: KoraAppHandle): void {\n\tvueApp.provide(koraAppInjectionKey, koraApp)\n}\n\n/**\n * Access the Kora app from a component setup function.\n * Pair with {@link installKora} and `app.ready` before running queries.\n */\nexport function useKoraApp(): KoraAppHandle {\n\tconst app = inject(koraAppInjectionKey)\n\tif (!app) {\n\t\tthrow new KoraError(\n\t\t\t'useKoraApp() requires installKora(vueApp, koraApp) on the Vue application.',\n\t\t\t'KORA_NOT_PROVIDED',\n\t\t\t{\n\t\t\t\tfix: 'In main.ts: const kora = createApp({ schema }); installKora(vueApp, kora); await kora.ready',\n\t\t\t},\n\t\t)\n\t}\n\treturn app\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAsC,cAAc;AAM7C,IAAM,sBAAmD,uBAAO,YAAY;AAM5E,SAAS,YAAY,QAAa,SAA8B;AACtE,SAAO,QAAQ,qBAAqB,OAAO;AAC5C;AAMO,SAAS,aAA4B;AAC3C,QAAM,MAAM,OAAO,mBAAmB;AACtC,MAAI,CAAC,KAAK;AACT,UAAM,IAAI;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,QACC,KAAK;AAAA,MACN;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;","names":[]}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@korajs/vue",
3
+ "version": "0.5.0",
4
+ "description": "Experimental Vue bindings stub for Kora.js (provide/inject app context)",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "peerDependencies": {
25
+ "vue": "^3.4.0"
26
+ },
27
+ "dependencies": {
28
+ "@korajs/store": "0.5.0",
29
+ "@korajs/core": "0.5.0"
30
+ },
31
+ "devDependencies": {
32
+ "tsup": "^8.3.6",
33
+ "typescript": "^5.7.3",
34
+ "vue": "^3.5.13"
35
+ },
36
+ "license": "MIT",
37
+ "scripts": {
38
+ "build": "tsup",
39
+ "dev": "tsup --watch",
40
+ "typecheck": "tsc --noEmit",
41
+ "lint": "biome check src/",
42
+ "clean": "rm -rf dist .turbo"
43
+ }
44
+ }