revojs 0.0.65 → 0.0.67
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 +12 -4
- package/dist/runtime/index.d.ts +4 -1
- package/dist/signals/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -358,6 +358,14 @@ function fromValue(value) {
|
|
|
358
358
|
if (value instanceof Function) return fromValue(value());
|
|
359
359
|
return value;
|
|
360
360
|
}
|
|
361
|
+
function untrack(invoke) {
|
|
362
|
+
let previous = activeCompute;
|
|
363
|
+
activeCompute = void 0;
|
|
364
|
+
const result = invoke();
|
|
365
|
+
if (result instanceof Promise) return result.finally(() => activeCompute = previous);
|
|
366
|
+
activeCompute = previous;
|
|
367
|
+
return result;
|
|
368
|
+
}
|
|
361
369
|
function defineContext(key) {
|
|
362
370
|
return key;
|
|
363
371
|
}
|
|
@@ -413,11 +421,11 @@ const $fetch = async (scope, input, options) => {
|
|
|
413
421
|
default: return response;
|
|
414
422
|
}
|
|
415
423
|
};
|
|
416
|
-
const useAsync = (scope, invoke) => {
|
|
424
|
+
const useAsync = (scope, invoke, options) => {
|
|
417
425
|
const { tasks } = useRuntime(scope);
|
|
418
426
|
const state = createState();
|
|
419
427
|
const isLoading = createState(true);
|
|
420
|
-
const task = invoke().then((value) => state.value = value).finally(() => isLoading.value = false);
|
|
428
|
+
const task = invoke().then((value) => state.value = value).catch(options?.catch).finally(() => isLoading.value = false);
|
|
421
429
|
if (isServer()) tasks.push(task);
|
|
422
430
|
return {
|
|
423
431
|
state,
|
|
@@ -704,7 +712,7 @@ const toCustomElement = (Component) => {
|
|
|
704
712
|
detail: value
|
|
705
713
|
}));
|
|
706
714
|
});
|
|
707
|
-
hydrate(this.component.scope, rootNode, this.component.setup
|
|
715
|
+
hydrate(this.component.scope, rootNode, untrack(this.component.setup), 0);
|
|
708
716
|
requestAnimationFrame(() => this.dispatchEvent(new MountedEvent()));
|
|
709
717
|
}
|
|
710
718
|
attributeChangedCallback(name, oldValue, value) {
|
|
@@ -893,4 +901,4 @@ const useLocale = (scope, context) => {
|
|
|
893
901
|
const LOCALE_CONTEXT = defineContext("LOCALE_CONTEXT");
|
|
894
902
|
|
|
895
903
|
//#endregion
|
|
896
|
-
export { $fetch, AfterNavigateEvent, CLIENT, Compute, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, ROUTE_CONTEXT, RUNTIME_CONTEXT, Radix, SERVER, Scope, StopEvent, activeCompute, components, createApp, createCompute, createElement, createMemo, createRuntime, createState, defineComponent, defineContext, defineMiddleware, defineRoute, fileName, fromValue, hydrate, isClient, isComponent, isCustomElement, isRoute, isServer, isTemplate, mimeType, onMounted, preventDefault, provideLocaleContext, provideRouterContext, registerComponent, renderToString, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, startViewTransition, stopImmediatePropagation, stopPropagation, targets, toArray, toCustomElement, toFragment, toPath, toRange, toString, useAsync, useCookies, useEvent, useHost, useLocale, useRequestUrl, useRoute, useRouter, useRuntime, useSetCookies };
|
|
904
|
+
export { $fetch, AfterNavigateEvent, CLIENT, Compute, HOST_CONTEXT, Handler, LOCALE_CONTEXT, MountedEvent, NavigateEvent, Page, ROUTER_CONTEXT, ROUTE_CONTEXT, RUNTIME_CONTEXT, Radix, SERVER, Scope, StopEvent, activeCompute, components, createApp, createCompute, createElement, createMemo, createRuntime, createState, defineComponent, defineContext, defineMiddleware, defineRoute, fileName, fromValue, hydrate, isClient, isComponent, isCustomElement, isRoute, isServer, isTemplate, mimeType, onMounted, preventDefault, provideLocaleContext, provideRouterContext, registerComponent, renderToString, sendBadRequest, sendHtml, sendJson, sendRedirect, sendText, sendUnauthorized, setCookie, startViewTransition, stopImmediatePropagation, stopPropagation, targets, toArray, toCustomElement, toFragment, toPath, toRange, toString, untrack, useAsync, useCookies, useEvent, useHost, useLocale, useRequestUrl, useRoute, useRouter, useRuntime, useSetCookies };
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -21,6 +21,9 @@ export type RuntimeContext<T = Record<string, unknown>> = {
|
|
|
21
21
|
export type RouteContext = {
|
|
22
22
|
inputs: State<Record<string, string>>;
|
|
23
23
|
};
|
|
24
|
+
export type AsyncOptions = {
|
|
25
|
+
catch?: (error: Error) => void | Promise<void>;
|
|
26
|
+
};
|
|
24
27
|
export declare const isRoute: <T>(value?: T) => value is Route & T;
|
|
25
28
|
export declare const useRuntime: <T = Record<string, unknown>>(scope: Scope) => RuntimeContext<T>;
|
|
26
29
|
export declare const useRoute: (scope: Scope) => RouteContext;
|
|
@@ -29,7 +32,7 @@ export declare const defineMiddleware: (middleware: Middleware) => Middleware;
|
|
|
29
32
|
export declare const fileName: (path: string) => string | undefined;
|
|
30
33
|
export declare const toPath: (value: string) => (string | undefined)[];
|
|
31
34
|
export declare const $fetch: <T>(scope: Scope, input: string | URL, options?: RequestInit) => Promise<T>;
|
|
32
|
-
export declare const useAsync: <T>(scope: Scope, invoke: () => Promise<T
|
|
35
|
+
export declare const useAsync: <T>(scope: Scope, invoke: () => Promise<T>, options?: AsyncOptions) => {
|
|
33
36
|
state: State<T | undefined>;
|
|
34
37
|
isLoading: State<boolean>;
|
|
35
38
|
};
|
package/dist/signals/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare function createState<T>(value: T): State<T>;
|
|
|
32
32
|
export declare function createCompute<T>(scope: Scope, invoke: (scope: Scope) => T): T;
|
|
33
33
|
export declare function createMemo<T>(scope: Scope, invoke: (scope: Scope) => T): State<T>;
|
|
34
34
|
export declare function fromValue<T>(value: Value<T>): T;
|
|
35
|
+
export declare function untrack<T>(invoke: () => T): T;
|
|
35
36
|
export declare function defineContext<T>(key: string): Descriptor<T>;
|
|
36
37
|
export declare let activeCompute: Compute | undefined;
|
|
37
38
|
export declare const targets: WeakMap<object, Map<string | symbol, Set<Compute<void>>>>;
|