@tb-dev/vue 0.1.4 → 0.1.6

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/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { defineComponent, createBlock, openBlock, unref, withCtx, createElementBlock, renderSlot, toDisplayString, toRef, effectScope, toValue, computed } from 'vue';
1
+ import { defineComponent, createBlock, openBlock, unref, withCtx, createElementBlock, renderSlot, toDisplayString, toRef, effectScope, toValue, computed, inject as inject$1 } from 'vue';
2
2
  import { RouterLink } from 'vue-router';
3
3
  import { computedAsync, useAsyncState, useElementSize as useElementSize$1, tryOnScopeDispose, onKeyStroke, useLocalStorage, useWindowSize } from '@vueuse/core';
4
- import { isNil } from '@tb-dev/utils';
4
+ import { unwrap, isNil } from '@tb-dev/utils';
5
5
 
6
6
  const _hoisted_1 = { key: 0 };
7
7
  const _sfc_main = /* @__PURE__ */ defineComponent({
@@ -24,7 +24,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
24
24
  }
25
25
  });
26
26
 
27
- function create() {
27
+ function create$1() {
28
28
  let ERROR_HANDLER_FN = null;
29
29
  function get() {
30
30
  return ERROR_HANDLER_FN;
@@ -46,7 +46,7 @@ function create() {
46
46
  }
47
47
  return { get, set, handle };
48
48
  }
49
- const { get: getErrorHandler, set: setErrorHandler, handle: handleError } = create();
49
+ const { get: getErrorHandler, set: setErrorHandler, handle: handleError } = create$1();
50
50
 
51
51
  function asyncComputed(initial, callback, options) {
52
52
  const state = computedAsync(callback, initial, {
@@ -165,9 +165,37 @@ function useWindowWidth() {
165
165
  return useWindowSize().width;
166
166
  }
167
167
 
168
+ function create() {
169
+ let APP = null;
170
+ function get() {
171
+ return unwrap(APP, "no active app");
172
+ }
173
+ function set(app) {
174
+ APP = app;
175
+ }
176
+ return { get, set };
177
+ }
178
+ const { get: getCurrentApp, set: setCurrentApp } = create();
179
+ function runWithContext(fn) {
180
+ return getCurrentApp().runWithContext(fn);
181
+ }
182
+ function provide(key, value) {
183
+ getCurrentApp().provide(key, value);
184
+ }
185
+ function inject(key) {
186
+ const value = fallibleInject(key);
187
+ if (typeof value === "undefined") {
188
+ throw new TypeError("injection failed: value not provided");
189
+ }
190
+ return value;
191
+ }
192
+ function fallibleInject(key) {
193
+ return runWithContext(() => inject$1(key));
194
+ }
195
+
168
196
  function maybe(value, fn) {
169
197
  const _value = toValue(value);
170
198
  return isNil(_value) ? null : fn(_value);
171
199
  }
172
200
 
173
- export { _sfc_main as Link, asyncComputed, asyncRef, getErrorHandler, handleError, localRef, maybe, onAltKeyDown, onCtrlKeyDown, onCtrlShiftKeyDown, onKeyDown, onShiftKeyDown, setErrorHandler, useElementSize, useHeight, useWidth, useWindowHeight, useWindowWidth };
201
+ export { _sfc_main as Link, asyncComputed, asyncRef, fallibleInject, getCurrentApp, getErrorHandler, handleError, inject, localRef, maybe, onAltKeyDown, onCtrlKeyDown, onCtrlShiftKeyDown, onKeyDown, onShiftKeyDown, provide, runWithContext, setCurrentApp, setErrorHandler, useElementSize, useHeight, useWidth, useWindowHeight, useWindowWidth };
@@ -0,0 +1,6 @@
1
+ import { App, InjectionKey } from 'vue';
2
+ export declare const getCurrentApp: () => App<any>, setCurrentApp: (app: App) => void;
3
+ export declare function runWithContext<T>(fn: () => T): T;
4
+ export declare function provide<T>(key: InjectionKey<T>, value: T): void;
5
+ export declare function inject<T>(key: InjectionKey<T>): T;
6
+ export declare function fallibleInject<T>(key: InjectionKey<T>): T | undefined;
@@ -1,2 +1,3 @@
1
+ export * from './app';
1
2
  export * from './error';
2
3
  export * from './maybe';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/vue",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Vue utilities",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,22 +25,22 @@
25
25
  "composables"
26
26
  ],
27
27
  "dependencies": {
28
- "@tb-dev/utils": "^5.1.4",
28
+ "@tb-dev/utils": "^6.0.0",
29
29
  "@vueuse/core": "^13.0.0",
30
30
  "lucide-vue-next": "^0.484.0",
31
31
  "vue": "^3.5.13",
32
32
  "vue-router": "^4.5.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@tailwindcss/vite": "^4.0.15",
36
- "@tb-dev/eslint-config": "^6.7.1",
35
+ "@tailwindcss/vite": "^4.0.17",
36
+ "@tb-dev/eslint-config": "^6.7.2",
37
37
  "@types/node": "^22.13.14",
38
38
  "@vitejs/plugin-vue": "^5.2.3",
39
39
  "eslint": "^9.23.0",
40
40
  "prettier": "^3.5.3",
41
41
  "prettier-plugin-css-order": "^2.1.2",
42
42
  "prettier-plugin-tailwindcss": "^0.6.11",
43
- "tailwindcss": "^4.0.15",
43
+ "tailwindcss": "^4.0.17",
44
44
  "tslib": "^2.8.1",
45
45
  "typescript": "~5.8.2",
46
46
  "vite": "^6.2.3",