@koderlabs/tasks-sdk-vue 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 ADDED
@@ -0,0 +1,179 @@
1
+ PROPRIETARY SOFTWARE LICENSE — ALL RIGHTS RESERVED
2
+
3
+ Copyright (c) 2026 KoderLabs. All rights reserved.
4
+ Author: Jawaid Gadiwala <jawaidgadiwala@gmail.com>
5
+
6
+ ================================================================================
7
+ 1. NO LICENSE GRANTED BY DEFAULT
8
+ ================================================================================
9
+
10
+ This software, including all source code, object code, documentation,
11
+ configuration files, build artifacts, test fixtures, and any associated
12
+ materials (collectively, the "Software"), is the proprietary and confidential
13
+ property of KoderLabs.
14
+
15
+ NO license, right, title, interest, or permission of any kind — express,
16
+ implied, statutory, by estoppel, by exhaustion, by patent exhaustion, or by
17
+ any other legal theory — is granted to any person or entity by:
18
+
19
+ (a) viewing the Software on any registry, repository, mirror, CDN,
20
+ cache, or other distribution channel (including but not limited to
21
+ npmjs.com, GitHub, GitLab, or any private registry);
22
+ (b) downloading, cloning, or otherwise obtaining a copy of the Software;
23
+ (c) the act of the Software being technically accessible due to a registry
24
+ requirement, mirror, or third-party distribution;
25
+ (d) any prior course of dealing, custom, or industry practice.
26
+
27
+ The ability to access the Software does NOT imply any permission to use it.
28
+ A separate, signed, written license agreement executed by an authorised
29
+ representative of KoderLabs is the ONLY mechanism by which any rights may be
30
+ granted.
31
+
32
+ ================================================================================
33
+ 2. PROHIBITED ACTIVITIES (NON-EXHAUSTIVE)
34
+ ================================================================================
35
+
36
+ Without prior signed written permission from KoderLabs, the following are
37
+ expressly PROHIBITED and constitute infringement, breach of contract, and
38
+ unauthorised use:
39
+
40
+ (a) Copying the Software in whole or in part, in any medium;
41
+ (b) Modifying, adapting, translating, porting, or creating derivative works
42
+ of the Software;
43
+ (c) Distributing, republishing, mirroring, hosting, transmitting,
44
+ sublicensing, leasing, lending, renting, selling, offering for sale,
45
+ bartering, gifting, or otherwise transferring the Software or any
46
+ portion of it;
47
+ (d) Forking the Software's repository, whether on GitHub, GitLab, Bitbucket,
48
+ Codeberg, Sourcehut, or any other version-control hosting service;
49
+ (e) Reverse engineering, decompiling, disassembling, deobfuscating,
50
+ extracting source from compiled or minified artifacts, or attempting to
51
+ derive the source code, algorithms, or trade secrets;
52
+ (f) Removing, altering, or obscuring any copyright, trademark, license,
53
+ attribution, or proprietary notice;
54
+ (g) Using the Software, in whole or in part, to train, fine-tune,
55
+ evaluate, or benchmark any machine-learning model, embedding model, or
56
+ AI system;
57
+ (h) Using the Software to provide a hosted service, SaaS offering,
58
+ managed offering, or any form of public or commercial offering;
59
+ (i) Using the Software in any production, staging, development, evaluation,
60
+ or testing capacity, whether commercial or non-commercial;
61
+ (j) Bypassing, disabling, or attempting to circumvent any technical
62
+ protection measure (license check, telemetry, signature verification,
63
+ etc.) embedded in the Software;
64
+ (k) Combining or integrating the Software with any work licensed under a
65
+ copyleft licence (including but not limited to GPL, AGPL, LGPL, MPL,
66
+ EPL) in a manner that would purport to relicense the Software;
67
+ (l) Filing, prosecuting, or threatening patent litigation against KoderLabs
68
+ or its customers based on any feature, design, or behaviour of the
69
+ Software ("defensive termination" — any such action automatically and
70
+ immediately terminates any rights granted to the litigant elsewhere).
71
+
72
+ ================================================================================
73
+ 3. NO IMPLIED RIGHT TO INTERNAL USE
74
+ ================================================================================
75
+
76
+ The Software is NOT licensed for internal evaluation, internal production,
77
+ internal testing, or any other internal use unless and until a separate
78
+ written commercial licence is executed. Possession of a copy of the Software,
79
+ by whatever means, confers no right to execute, run, deploy, or use it.
80
+
81
+ ================================================================================
82
+ 4. NO PATENT, TRADEMARK, OR OTHER IP GRANT
83
+ ================================================================================
84
+
85
+ No patent licence, trademark licence, trade-secret disclosure, design-right
86
+ licence, or any other intellectual-property licence is granted under this
87
+ notice. KoderLabs retains all such rights.
88
+
89
+ ================================================================================
90
+ 5. CONFIDENTIALITY
91
+ ================================================================================
92
+
93
+ The Software contains trade secrets and confidential information of
94
+ KoderLabs. Any party in possession of the Software shall (a) treat it as
95
+ confidential, (b) take reasonable measures to prevent unauthorised access or
96
+ disclosure, and (c) not disclose, publish, or make available the Software or
97
+ any portion thereof to any third party.
98
+
99
+ ================================================================================
100
+ 6. AUTOMATIC TERMINATION
101
+ ================================================================================
102
+
103
+ Any rights that may exist under a separate written agreement terminate
104
+ AUTOMATICALLY AND IMMEDIATELY upon any breach of this notice, without notice
105
+ and without judicial action. Upon termination, the breaching party shall
106
+ immediately destroy all copies of the Software in its possession or control
107
+ and certify destruction in writing to KoderLabs.
108
+
109
+ ================================================================================
110
+ 7. NO WARRANTY
111
+ ================================================================================
112
+
113
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
114
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
115
+ FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ACCURACY, RELIABILITY,
116
+ TITLE, AVAILABILITY, OR THAT THE SOFTWARE WILL OPERATE UNINTERRUPTED OR
117
+ ERROR-FREE.
118
+
119
+ ================================================================================
120
+ 8. NO LIABILITY
121
+ ================================================================================
122
+
123
+ IN NO EVENT SHALL KODERLABS OR ITS AFFILIATES, OFFICERS, EMPLOYEES, AGENTS,
124
+ LICENSORS, OR CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
125
+ LIABILITY (INCLUDING DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
126
+ CONSEQUENTIAL, PUNITIVE, LOST PROFITS, LOST DATA, OR BUSINESS INTERRUPTION),
127
+ WHETHER IN AN ACTION OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT
128
+ LIABILITY, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE
129
+ SOFTWARE OR THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF ADVISED OF
130
+ THE POSSIBILITY OF SUCH DAMAGE. IN NO EVENT SHALL KODERLABS' TOTAL CUMULATIVE
131
+ LIABILITY EXCEED ONE U.S. DOLLAR (USD 1.00).
132
+
133
+ ================================================================================
134
+ 9. EQUITABLE RELIEF
135
+ ================================================================================
136
+
137
+ The parties acknowledge that any breach of this notice would cause
138
+ irreparable harm to KoderLabs for which monetary damages would be inadequate.
139
+ KoderLabs is therefore entitled, in addition to all other remedies available
140
+ at law, to specific performance and injunctive relief without the need to
141
+ post bond.
142
+
143
+ ================================================================================
144
+ 10. GOVERNING LAW AND VENUE
145
+ ================================================================================
146
+
147
+ This notice shall be governed by and construed in accordance with the laws
148
+ of the Islamic Republic of Pakistan, without regard to its conflict-of-laws
149
+ principles. Any dispute arising out of or in connection with this notice
150
+ shall be subject to the exclusive jurisdiction of the courts of Karachi,
151
+ Pakistan.
152
+
153
+ The United Nations Convention on Contracts for the International Sale of
154
+ Goods shall not apply.
155
+
156
+ ================================================================================
157
+ 11. SEVERABILITY AND ENTIRE NOTICE
158
+ ================================================================================
159
+
160
+ If any provision of this notice is held invalid or unenforceable, the
161
+ remaining provisions shall continue in full force and effect. This notice,
162
+ together with any separate signed written licence executed between KoderLabs
163
+ and a licensee, constitutes the entire agreement concerning the Software and
164
+ supersedes all prior or contemporaneous understandings.
165
+
166
+ ================================================================================
167
+ 12. CONTACT
168
+ ================================================================================
169
+
170
+ For licensing inquiries, audit requests, or notice of suspected
171
+ infringement, contact:
172
+
173
+ KoderLabs
174
+ Attn: Jawaid Gadiwala
175
+ Email: jawaidgadiwala@gmail.com
176
+
177
+ ================================================================================
178
+ END OF LICENCE
179
+ ================================================================================
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Proprietary Software
2
+
3
+ KoderLabs proprietary. All rights reserved.
4
+
5
+ See the bundled `LICENSE` for terms. No grant of any rights, express or
6
+ implied, is conferred by access to or possession of this package. A
7
+ separate signed written licence from KoderLabs is required for any use.
8
+
9
+ Licensing inquiries: jawaidgadiwala@gmail.com
package/dist/index.cjs ADDED
@@ -0,0 +1,96 @@
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
+ INSTANTTASKS_KEY: () => INSTANTTASKS_KEY,
24
+ createInstantTasksPlugin: () => createInstantTasksPlugin,
25
+ injectInstantTasks: () => injectInstantTasks
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+
29
+ // src/install.ts
30
+ var import_tasks_sdk = require("@koderlabs/tasks-sdk");
31
+ var INSTANTTASKS_KEY = /* @__PURE__ */ Symbol("instantTasks");
32
+ function installInstantTasks(app, opts) {
33
+ const client = (0, import_tasks_sdk.init)(opts);
34
+ app.provide(INSTANTTASKS_KEY, client);
35
+ const existingHandler = app.config.errorHandler;
36
+ const wrapped = (err, instance, info) => {
37
+ if (typeof existingHandler === "function") {
38
+ try {
39
+ existingHandler(err, instance, info);
40
+ } catch (e) {
41
+ console.error("[InstantTasks] existing errorHandler threw", e);
42
+ }
43
+ }
44
+ if (typeof client.errors?.notify === "function") {
45
+ client.errors.notify(err instanceof Error ? err : new Error(String(err)), {
46
+ vueComponentInfo: info,
47
+ componentName: instance?.$options?.name ?? "Unknown"
48
+ });
49
+ } else {
50
+ const sendResult = client.send({
51
+ kind: "error",
52
+ message: err instanceof Error ? err.message : String(err),
53
+ stack: err instanceof Error ? err.stack : void 0,
54
+ vueComponentInfo: info
55
+ });
56
+ Promise.resolve(sendResult).catch(() => {
57
+ client.emit("send_error", { error: err });
58
+ });
59
+ }
60
+ };
61
+ app.config.errorHandler = wrapped;
62
+ const uninstall = () => {
63
+ if (app.config.errorHandler === wrapped) {
64
+ app.config.errorHandler = existingHandler;
65
+ }
66
+ };
67
+ return { client, uninstall };
68
+ }
69
+
70
+ // src/inject.ts
71
+ var import_vue = require("vue");
72
+ function injectInstantTasks() {
73
+ const client = (0, import_vue.inject)(INSTANTTASKS_KEY);
74
+ if (!client) {
75
+ throw new Error(
76
+ "[InstantTasks] injectInstantTasks() must be called inside setup() in a component that is a descendant of an app where app.use(createInstantTasksPlugin(...)) was called."
77
+ );
78
+ }
79
+ return client;
80
+ }
81
+
82
+ // src/index.ts
83
+ function createInstantTasksPlugin(opts) {
84
+ return {
85
+ install(app) {
86
+ installInstantTasks(app, opts);
87
+ }
88
+ };
89
+ }
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ INSTANTTASKS_KEY,
93
+ createInstantTasksPlugin,
94
+ injectInstantTasks
95
+ });
96
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/install.ts","../src/inject.ts"],"sourcesContent":["import type { App } from 'vue';\nimport { installInstantTasks } from './install';\nimport type { InitOptions } from '@koderlabs/tasks-sdk';\n\nexport { injectInstantTasks } from './inject';\nexport { INSTANTTASKS_KEY } from './install';\n\n/**\n * Creates a Vue 3 Plugin that initializes the InstantTasks SDK.\n *\n * **Vue 2 is not supported.** Peer dependency is `vue: ^3`.\n *\n * @example\n * ```ts\n * import { createApp } from 'vue';\n * import { createInstantTasksPlugin } from '@koderlabs/tasks-sdk-vue';\n * import App from './App.vue';\n *\n * createApp(App)\n * .use(createInstantTasksPlugin({ projectId: 'proj_xxx', accessKey: 'key_yyy' }))\n * .mount('#app');\n * ```\n */\nexport function createInstantTasksPlugin(opts: InitOptions) {\n return {\n install(app: App) {\n installInstantTasks(app, opts);\n },\n };\n}\n","import type { App } from 'vue';\nimport { init } from '@koderlabs/tasks-sdk';\nimport type { InitOptions, Client } from '@koderlabs/tasks-sdk';\n\n/** Injection key used by injectInstantTasks(). */\nexport const INSTANTTASKS_KEY = Symbol('instantTasks');\n\n/**\n * Installs the InstantTasks SDK into a Vue application.\n *\n * Called by the Plugin's `install(app)` method. Should not be called directly.\n *\n * Error handler chain order: any pre-existing `app.config.errorHandler`\n * runs FIRST, then the SDK observes/reports. This matches the\n * \"framework-first, observability-second\" convention that Pinia / Vue\n * Router / vue-i18n follow — if the host has already attached state-aware\n * error handling, it sees the error before telemetry intercepts.\n *\n * Cleanup: returns an uninstall function. `app.config.errorHandler` is\n * restored on uninstall so multiple install/uninstall cycles (Vite HMR,\n * tests) don't stack wrappers.\n */\nexport function installInstantTasks(app: App, opts: InitOptions): { client: Client; uninstall: () => void } {\n const client = init(opts);\n\n // Provide the client to the entire component tree via Vue's provide/inject.\n app.provide(INSTANTTASKS_KEY, client);\n\n const existingHandler = app.config.errorHandler;\n\n const wrapped: NonNullable<App['config']['errorHandler']> = (err, instance, info) => {\n // 1) Host handler first — matches framework-first convention.\n if (typeof existingHandler === 'function') {\n try {\n existingHandler(err, instance, info);\n } catch (e) {\n // Host handler bug — log once via console.error (NOT through SDK to\n // avoid recursion if SDK itself is the source).\n // eslint-disable-next-line no-console\n console.error('[InstantTasks] existing errorHandler threw', e);\n }\n }\n\n // 2) Observe + ship.\n if (typeof (client as any).errors?.notify === 'function') {\n (client as any).errors.notify(err instanceof Error ? err : new Error(String(err)), {\n vueComponentInfo: info,\n componentName: instance?.$options?.name ?? 'Unknown',\n });\n } else {\n // Fallback: raw send. Wrap in Promise.resolve to defend against sub-clients\n // that return void instead of a Promise.\n const sendResult = client.send({\n kind: 'error',\n message: err instanceof Error ? err.message : String(err),\n stack: err instanceof Error ? err.stack : undefined,\n vueComponentInfo: info,\n } as any);\n Promise.resolve(sendResult).catch(() => {\n // Surface via client emit instead of silent swallow.\n client.emit('send_error', { error: err });\n });\n }\n };\n\n app.config.errorHandler = wrapped;\n\n // Best-effort cleanup hook for Vite HMR / tests. Vue 3 doesn't expose a\n // first-class \"unmount\" event for the App itself; caller must invoke\n // uninstall() during the host app's teardown sequence.\n const uninstall = () => {\n if (app.config.errorHandler === wrapped) {\n app.config.errorHandler = existingHandler;\n }\n };\n\n return { client, uninstall };\n}\n","import { inject } from 'vue';\nimport { INSTANTTASKS_KEY } from './install';\nimport type { Client } from '@koderlabs/tasks-sdk';\n\n/**\n * Composition-API helper: returns the InstantTasks client injected by the plugin.\n *\n * @throws When called outside of a setup() function or when the plugin has not\n * been installed on the application.\n *\n * @example\n * ```ts\n * import { injectInstantTasks } from '@koderlabs/tasks-sdk-vue';\n *\n * const { errors } = injectInstantTasks() as any;\n * errors?.notify(new Error('oops'));\n * ```\n */\nexport function injectInstantTasks(): Client {\n const client = inject<Client>(INSTANTTASKS_KEY);\n if (!client) {\n throw new Error(\n '[InstantTasks] injectInstantTasks() must be called inside setup() in a ' +\n 'component that is a descendant of an app where app.use(createInstantTasksPlugin(...)) ' +\n 'was called.',\n );\n }\n return client;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,uBAAqB;AAId,IAAM,mBAAmB,uBAAO,cAAc;AAiB9C,SAAS,oBAAoB,KAAU,MAA8D;AAC1G,QAAM,aAAS,uBAAK,IAAI;AAGxB,MAAI,QAAQ,kBAAkB,MAAM;AAEpC,QAAM,kBAAkB,IAAI,OAAO;AAEnC,QAAM,UAAsD,CAAC,KAAK,UAAU,SAAS;AAEnF,QAAI,OAAO,oBAAoB,YAAY;AACzC,UAAI;AACF,wBAAgB,KAAK,UAAU,IAAI;AAAA,MACrC,SAAS,GAAG;AAIV,gBAAQ,MAAM,8CAA8C,CAAC;AAAA,MAC/D;AAAA,IACF;AAGA,QAAI,OAAQ,OAAe,QAAQ,WAAW,YAAY;AACxD,MAAC,OAAe,OAAO,OAAO,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC,GAAG;AAAA,QACjF,kBAAkB;AAAA,QAClB,eAAe,UAAU,UAAU,QAAQ;AAAA,MAC7C,CAAC;AAAA,IACH,OAAO;AAGL,YAAM,aAAa,OAAO,KAAK;AAAA,QAC7B,MAAM;AAAA,QACN,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,QACxD,OAAO,eAAe,QAAQ,IAAI,QAAQ;AAAA,QAC1C,kBAAkB;AAAA,MACpB,CAAQ;AACR,cAAQ,QAAQ,UAAU,EAAE,MAAM,MAAM;AAEtC,eAAO,KAAK,cAAc,EAAE,OAAO,IAAI,CAAC;AAAA,MAC1C,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,OAAO,eAAe;AAK1B,QAAM,YAAY,MAAM;AACtB,QAAI,IAAI,OAAO,iBAAiB,SAAS;AACvC,UAAI,OAAO,eAAe;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO,EAAE,QAAQ,UAAU;AAC7B;;;AC7EA,iBAAuB;AAkBhB,SAAS,qBAA6B;AAC3C,QAAM,aAAS,mBAAe,gBAAgB;AAC9C,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IAGF;AAAA,EACF;AACA,SAAO;AACT;;;AFLO,SAAS,yBAAyB,MAAmB;AAC1D,SAAO;AAAA,IACL,QAAQ,KAAU;AAChB,0BAAoB,KAAK,IAAI;AAAA,IAC/B;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,43 @@
1
+ import { App } from 'vue';
2
+ import { Client, InitOptions } from '@koderlabs/tasks-sdk';
3
+
4
+ /**
5
+ * Composition-API helper: returns the InstantTasks client injected by the plugin.
6
+ *
7
+ * @throws When called outside of a setup() function or when the plugin has not
8
+ * been installed on the application.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { injectInstantTasks } from '@koderlabs/tasks-sdk-vue';
13
+ *
14
+ * const { errors } = injectInstantTasks() as any;
15
+ * errors?.notify(new Error('oops'));
16
+ * ```
17
+ */
18
+ declare function injectInstantTasks(): Client;
19
+
20
+ /** Injection key used by injectInstantTasks(). */
21
+ declare const INSTANTTASKS_KEY: unique symbol;
22
+
23
+ /**
24
+ * Creates a Vue 3 Plugin that initializes the InstantTasks SDK.
25
+ *
26
+ * **Vue 2 is not supported.** Peer dependency is `vue: ^3`.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { createApp } from 'vue';
31
+ * import { createInstantTasksPlugin } from '@koderlabs/tasks-sdk-vue';
32
+ * import App from './App.vue';
33
+ *
34
+ * createApp(App)
35
+ * .use(createInstantTasksPlugin({ projectId: 'proj_xxx', accessKey: 'key_yyy' }))
36
+ * .mount('#app');
37
+ * ```
38
+ */
39
+ declare function createInstantTasksPlugin(opts: InitOptions): {
40
+ install(app: App): void;
41
+ };
42
+
43
+ export { INSTANTTASKS_KEY, createInstantTasksPlugin, injectInstantTasks };
@@ -0,0 +1,43 @@
1
+ import { App } from 'vue';
2
+ import { Client, InitOptions } from '@koderlabs/tasks-sdk';
3
+
4
+ /**
5
+ * Composition-API helper: returns the InstantTasks client injected by the plugin.
6
+ *
7
+ * @throws When called outside of a setup() function or when the plugin has not
8
+ * been installed on the application.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { injectInstantTasks } from '@koderlabs/tasks-sdk-vue';
13
+ *
14
+ * const { errors } = injectInstantTasks() as any;
15
+ * errors?.notify(new Error('oops'));
16
+ * ```
17
+ */
18
+ declare function injectInstantTasks(): Client;
19
+
20
+ /** Injection key used by injectInstantTasks(). */
21
+ declare const INSTANTTASKS_KEY: unique symbol;
22
+
23
+ /**
24
+ * Creates a Vue 3 Plugin that initializes the InstantTasks SDK.
25
+ *
26
+ * **Vue 2 is not supported.** Peer dependency is `vue: ^3`.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { createApp } from 'vue';
31
+ * import { createInstantTasksPlugin } from '@koderlabs/tasks-sdk-vue';
32
+ * import App from './App.vue';
33
+ *
34
+ * createApp(App)
35
+ * .use(createInstantTasksPlugin({ projectId: 'proj_xxx', accessKey: 'key_yyy' }))
36
+ * .mount('#app');
37
+ * ```
38
+ */
39
+ declare function createInstantTasksPlugin(opts: InitOptions): {
40
+ install(app: App): void;
41
+ };
42
+
43
+ export { INSTANTTASKS_KEY, createInstantTasksPlugin, injectInstantTasks };
package/dist/index.js ADDED
@@ -0,0 +1,67 @@
1
+ // src/install.ts
2
+ import { init } from "@koderlabs/tasks-sdk";
3
+ var INSTANTTASKS_KEY = /* @__PURE__ */ Symbol("instantTasks");
4
+ function installInstantTasks(app, opts) {
5
+ const client = init(opts);
6
+ app.provide(INSTANTTASKS_KEY, client);
7
+ const existingHandler = app.config.errorHandler;
8
+ const wrapped = (err, instance, info) => {
9
+ if (typeof existingHandler === "function") {
10
+ try {
11
+ existingHandler(err, instance, info);
12
+ } catch (e) {
13
+ console.error("[InstantTasks] existing errorHandler threw", e);
14
+ }
15
+ }
16
+ if (typeof client.errors?.notify === "function") {
17
+ client.errors.notify(err instanceof Error ? err : new Error(String(err)), {
18
+ vueComponentInfo: info,
19
+ componentName: instance?.$options?.name ?? "Unknown"
20
+ });
21
+ } else {
22
+ const sendResult = client.send({
23
+ kind: "error",
24
+ message: err instanceof Error ? err.message : String(err),
25
+ stack: err instanceof Error ? err.stack : void 0,
26
+ vueComponentInfo: info
27
+ });
28
+ Promise.resolve(sendResult).catch(() => {
29
+ client.emit("send_error", { error: err });
30
+ });
31
+ }
32
+ };
33
+ app.config.errorHandler = wrapped;
34
+ const uninstall = () => {
35
+ if (app.config.errorHandler === wrapped) {
36
+ app.config.errorHandler = existingHandler;
37
+ }
38
+ };
39
+ return { client, uninstall };
40
+ }
41
+
42
+ // src/inject.ts
43
+ import { inject } from "vue";
44
+ function injectInstantTasks() {
45
+ const client = inject(INSTANTTASKS_KEY);
46
+ if (!client) {
47
+ throw new Error(
48
+ "[InstantTasks] injectInstantTasks() must be called inside setup() in a component that is a descendant of an app where app.use(createInstantTasksPlugin(...)) was called."
49
+ );
50
+ }
51
+ return client;
52
+ }
53
+
54
+ // src/index.ts
55
+ function createInstantTasksPlugin(opts) {
56
+ return {
57
+ install(app) {
58
+ installInstantTasks(app, opts);
59
+ }
60
+ };
61
+ }
62
+ export {
63
+ INSTANTTASKS_KEY,
64
+ createInstantTasksPlugin,
65
+ injectInstantTasks
66
+ };
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/install.ts","../src/inject.ts","../src/index.ts"],"sourcesContent":["import type { App } from 'vue';\nimport { init } from '@koderlabs/tasks-sdk';\nimport type { InitOptions, Client } from '@koderlabs/tasks-sdk';\n\n/** Injection key used by injectInstantTasks(). */\nexport const INSTANTTASKS_KEY = Symbol('instantTasks');\n\n/**\n * Installs the InstantTasks SDK into a Vue application.\n *\n * Called by the Plugin's `install(app)` method. Should not be called directly.\n *\n * Error handler chain order: any pre-existing `app.config.errorHandler`\n * runs FIRST, then the SDK observes/reports. This matches the\n * \"framework-first, observability-second\" convention that Pinia / Vue\n * Router / vue-i18n follow — if the host has already attached state-aware\n * error handling, it sees the error before telemetry intercepts.\n *\n * Cleanup: returns an uninstall function. `app.config.errorHandler` is\n * restored on uninstall so multiple install/uninstall cycles (Vite HMR,\n * tests) don't stack wrappers.\n */\nexport function installInstantTasks(app: App, opts: InitOptions): { client: Client; uninstall: () => void } {\n const client = init(opts);\n\n // Provide the client to the entire component tree via Vue's provide/inject.\n app.provide(INSTANTTASKS_KEY, client);\n\n const existingHandler = app.config.errorHandler;\n\n const wrapped: NonNullable<App['config']['errorHandler']> = (err, instance, info) => {\n // 1) Host handler first — matches framework-first convention.\n if (typeof existingHandler === 'function') {\n try {\n existingHandler(err, instance, info);\n } catch (e) {\n // Host handler bug — log once via console.error (NOT through SDK to\n // avoid recursion if SDK itself is the source).\n // eslint-disable-next-line no-console\n console.error('[InstantTasks] existing errorHandler threw', e);\n }\n }\n\n // 2) Observe + ship.\n if (typeof (client as any).errors?.notify === 'function') {\n (client as any).errors.notify(err instanceof Error ? err : new Error(String(err)), {\n vueComponentInfo: info,\n componentName: instance?.$options?.name ?? 'Unknown',\n });\n } else {\n // Fallback: raw send. Wrap in Promise.resolve to defend against sub-clients\n // that return void instead of a Promise.\n const sendResult = client.send({\n kind: 'error',\n message: err instanceof Error ? err.message : String(err),\n stack: err instanceof Error ? err.stack : undefined,\n vueComponentInfo: info,\n } as any);\n Promise.resolve(sendResult).catch(() => {\n // Surface via client emit instead of silent swallow.\n client.emit('send_error', { error: err });\n });\n }\n };\n\n app.config.errorHandler = wrapped;\n\n // Best-effort cleanup hook for Vite HMR / tests. Vue 3 doesn't expose a\n // first-class \"unmount\" event for the App itself; caller must invoke\n // uninstall() during the host app's teardown sequence.\n const uninstall = () => {\n if (app.config.errorHandler === wrapped) {\n app.config.errorHandler = existingHandler;\n }\n };\n\n return { client, uninstall };\n}\n","import { inject } from 'vue';\nimport { INSTANTTASKS_KEY } from './install';\nimport type { Client } from '@koderlabs/tasks-sdk';\n\n/**\n * Composition-API helper: returns the InstantTasks client injected by the plugin.\n *\n * @throws When called outside of a setup() function or when the plugin has not\n * been installed on the application.\n *\n * @example\n * ```ts\n * import { injectInstantTasks } from '@koderlabs/tasks-sdk-vue';\n *\n * const { errors } = injectInstantTasks() as any;\n * errors?.notify(new Error('oops'));\n * ```\n */\nexport function injectInstantTasks(): Client {\n const client = inject<Client>(INSTANTTASKS_KEY);\n if (!client) {\n throw new Error(\n '[InstantTasks] injectInstantTasks() must be called inside setup() in a ' +\n 'component that is a descendant of an app where app.use(createInstantTasksPlugin(...)) ' +\n 'was called.',\n );\n }\n return client;\n}\n","import type { App } from 'vue';\nimport { installInstantTasks } from './install';\nimport type { InitOptions } from '@koderlabs/tasks-sdk';\n\nexport { injectInstantTasks } from './inject';\nexport { INSTANTTASKS_KEY } from './install';\n\n/**\n * Creates a Vue 3 Plugin that initializes the InstantTasks SDK.\n *\n * **Vue 2 is not supported.** Peer dependency is `vue: ^3`.\n *\n * @example\n * ```ts\n * import { createApp } from 'vue';\n * import { createInstantTasksPlugin } from '@koderlabs/tasks-sdk-vue';\n * import App from './App.vue';\n *\n * createApp(App)\n * .use(createInstantTasksPlugin({ projectId: 'proj_xxx', accessKey: 'key_yyy' }))\n * .mount('#app');\n * ```\n */\nexport function createInstantTasksPlugin(opts: InitOptions) {\n return {\n install(app: App) {\n installInstantTasks(app, opts);\n },\n };\n}\n"],"mappings":";AACA,SAAS,YAAY;AAId,IAAM,mBAAmB,uBAAO,cAAc;AAiB9C,SAAS,oBAAoB,KAAU,MAA8D;AAC1G,QAAM,SAAS,KAAK,IAAI;AAGxB,MAAI,QAAQ,kBAAkB,MAAM;AAEpC,QAAM,kBAAkB,IAAI,OAAO;AAEnC,QAAM,UAAsD,CAAC,KAAK,UAAU,SAAS;AAEnF,QAAI,OAAO,oBAAoB,YAAY;AACzC,UAAI;AACF,wBAAgB,KAAK,UAAU,IAAI;AAAA,MACrC,SAAS,GAAG;AAIV,gBAAQ,MAAM,8CAA8C,CAAC;AAAA,MAC/D;AAAA,IACF;AAGA,QAAI,OAAQ,OAAe,QAAQ,WAAW,YAAY;AACxD,MAAC,OAAe,OAAO,OAAO,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC,GAAG;AAAA,QACjF,kBAAkB;AAAA,QAClB,eAAe,UAAU,UAAU,QAAQ;AAAA,MAC7C,CAAC;AAAA,IACH,OAAO;AAGL,YAAM,aAAa,OAAO,KAAK;AAAA,QAC7B,MAAM;AAAA,QACN,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAAA,QACxD,OAAO,eAAe,QAAQ,IAAI,QAAQ;AAAA,QAC1C,kBAAkB;AAAA,MACpB,CAAQ;AACR,cAAQ,QAAQ,UAAU,EAAE,MAAM,MAAM;AAEtC,eAAO,KAAK,cAAc,EAAE,OAAO,IAAI,CAAC;AAAA,MAC1C,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,OAAO,eAAe;AAK1B,QAAM,YAAY,MAAM;AACtB,QAAI,IAAI,OAAO,iBAAiB,SAAS;AACvC,UAAI,OAAO,eAAe;AAAA,IAC5B;AAAA,EACF;AAEA,SAAO,EAAE,QAAQ,UAAU;AAC7B;;;AC7EA,SAAS,cAAc;AAkBhB,SAAS,qBAA6B;AAC3C,QAAM,SAAS,OAAe,gBAAgB;AAC9C,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI;AAAA,MACR;AAAA,IAGF;AAAA,EACF;AACA,SAAO;AACT;;;ACLO,SAAS,yBAAyB,MAAmB;AAC1D,SAAO;AAAA,IACL,QAAQ,KAAU;AAChB,0BAAoB,KAAK,IAAI;AAAA,IAC/B;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@koderlabs/tasks-sdk-vue",
3
+ "version": "0.1.0",
4
+ "description": "Vue 3 plugin for the InstantTasks SDK.",
5
+ "keywords": [
6
+ "instanttasks",
7
+ "sdk",
8
+ "vue"
9
+ ],
10
+ "homepage": "https://github.com/jawaidgadiwala/instant-tasks/tree/main/packages/sdk-vue#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/jawaidgadiwala/instant-tasks/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/jawaidgadiwala/instant-tasks.git",
17
+ "directory": "packages/sdk-vue"
18
+ },
19
+ "license": "UNLICENSED",
20
+ "author": {
21
+ "name": "Jawaid Gadiwala",
22
+ "email": "jawaidgadiwala@gmail.com",
23
+ "url": "https://koderlabs.com"
24
+ },
25
+ "type": "module",
26
+ "main": "./dist/index.cjs",
27
+ "module": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js",
33
+ "require": "./dist/index.cjs"
34
+ }
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "LICENSE"
39
+ ],
40
+ "sideEffects": false,
41
+ "dependencies": {
42
+ "@koderlabs/tasks-sdk": "0.1.0"
43
+ },
44
+ "peerDependencies": {
45
+ "vue": "^3"
46
+ },
47
+ "devDependencies": {
48
+ "@vue/test-utils": "^2.4.0",
49
+ "jsdom": "^25.0.0",
50
+ "tsup": "^8.3.0",
51
+ "typescript": "^5.5.0",
52
+ "vitest": "^2.1.0",
53
+ "vue": "^3.5.0"
54
+ },
55
+ "engines": {
56
+ "node": ">=20"
57
+ },
58
+ "publishConfig": {
59
+ "access": "restricted"
60
+ },
61
+ "scripts": {
62
+ "build": "tsup",
63
+ "dev": "tsup --watch",
64
+ "test": "vitest run",
65
+ "test:watch": "vitest"
66
+ }
67
+ }