defuss 3.4.4 → 3.4.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/dom-C679BHZu.cjs +2616 -0
- package/dist/dom-DUPOK7Hs.mjs +2543 -0
- package/dist/index.cjs +22 -28
- package/dist/index.d.ts +18 -18
- package/dist/index.mjs +23 -29
- package/dist/mount-DNlJN8xI.mjs +26 -0
- package/dist/mount-DcLKJdyY.cjs +29 -0
- package/dist/render/client.cjs +2 -2
- package/dist/render/client.mjs +3 -3
- package/dist/render/dev/index.cjs +1 -1
- package/dist/render/dev/index.mjs +1 -1
- package/dist/render/index.cjs +2 -2
- package/dist/render/index.mjs +2 -2
- package/dist/render/server.cjs +2 -2
- package/dist/render/server.mjs +3 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var dom = require('./dom-
|
|
3
|
+
var dom = require('./dom-C679BHZu.cjs');
|
|
4
4
|
require('defuss-runtime');
|
|
5
|
-
var mount = require('./mount-
|
|
5
|
+
var mount = require('./mount-DcLKJdyY.cjs');
|
|
6
6
|
|
|
7
7
|
const inDevMode = typeof process !== "undefined" && process.env ? process.env.NODE_ENV !== "production" : false;
|
|
8
8
|
|
|
@@ -832,10 +832,7 @@ function createDomFromChild(child, globals) {
|
|
|
832
832
|
}
|
|
833
833
|
function shouldPreserveFormStateAttribute(el, attrName, vnode) {
|
|
834
834
|
const tag = el.tagName.toLowerCase();
|
|
835
|
-
const hasExplicit = Object.
|
|
836
|
-
vnode.attributes ?? {},
|
|
837
|
-
attrName
|
|
838
|
-
);
|
|
835
|
+
const hasExplicit = Object.hasOwn(vnode.attributes ?? {}, attrName);
|
|
839
836
|
if (hasExplicit) return false;
|
|
840
837
|
if (tag === "input") return attrName === "value" || attrName === "checked";
|
|
841
838
|
if (tag === "textarea") return attrName === "value";
|
|
@@ -850,10 +847,10 @@ function patchElementInPlace(el, vnode, globals) {
|
|
|
850
847
|
const { name } = attr;
|
|
851
848
|
if (name === "key") continue;
|
|
852
849
|
if (name.startsWith("on")) continue;
|
|
853
|
-
if (name === "class" && (Object.
|
|
850
|
+
if (name === "class" && (Object.hasOwn(nextAttrs, "class") || Object.hasOwn(nextAttrs, "className"))) {
|
|
854
851
|
continue;
|
|
855
852
|
}
|
|
856
|
-
if (!Object.
|
|
853
|
+
if (!Object.hasOwn(nextAttrs, name)) {
|
|
857
854
|
if (shouldPreserveFormStateAttribute(el, name, vnode)) continue;
|
|
858
855
|
el.removeAttribute(name);
|
|
859
856
|
}
|
|
@@ -886,10 +883,7 @@ function patchElementInPlace(el, vnode, globals) {
|
|
|
886
883
|
}
|
|
887
884
|
const tag = el.tagName.toLowerCase();
|
|
888
885
|
if (tag === "textarea") {
|
|
889
|
-
const isControlled = Object.
|
|
890
|
-
nextAttrs,
|
|
891
|
-
"value"
|
|
892
|
-
);
|
|
886
|
+
const isControlled = Object.hasOwn(nextAttrs, "value");
|
|
893
887
|
const isActive = el.ownerDocument?.activeElement === el;
|
|
894
888
|
if (isActive && !isControlled) return;
|
|
895
889
|
}
|
|
@@ -1163,10 +1157,10 @@ const setupRouter = (config = {
|
|
|
1163
1157
|
pendingResolvers: [],
|
|
1164
1158
|
currentPath: "",
|
|
1165
1159
|
popAttached: false,
|
|
1166
|
-
lifecycleHooks: {
|
|
1160
|
+
lifecycleHooks: { beforeLeave: [], leave: [] }
|
|
1167
1161
|
};
|
|
1168
1162
|
if (!state.lifecycleHooks) {
|
|
1169
|
-
state.lifecycleHooks = {
|
|
1163
|
+
state.lifecycleHooks = { beforeLeave: [], leave: [] };
|
|
1170
1164
|
}
|
|
1171
1165
|
const routeRegistrations = state.routeRegistrations;
|
|
1172
1166
|
if (typeof window !== "undefined" && !windowImpl) {
|
|
@@ -1295,30 +1289,30 @@ const setupRouter = (config = {
|
|
|
1295
1289
|
return {
|
|
1296
1290
|
request,
|
|
1297
1291
|
onBeforeLeave(fn) {
|
|
1298
|
-
state.lifecycleHooks.
|
|
1292
|
+
state.lifecycleHooks.beforeLeave.push(fn);
|
|
1299
1293
|
},
|
|
1300
1294
|
onLeave(fn) {
|
|
1301
|
-
state.lifecycleHooks.
|
|
1295
|
+
state.lifecycleHooks.leave.push(fn);
|
|
1302
1296
|
}
|
|
1303
1297
|
};
|
|
1304
1298
|
},
|
|
1305
|
-
async
|
|
1306
|
-
for (const fn of state.lifecycleHooks.
|
|
1299
|
+
async runBeforeLeaveHooks() {
|
|
1300
|
+
for (const fn of state.lifecycleHooks.beforeLeave) {
|
|
1307
1301
|
const result = await fn();
|
|
1308
1302
|
if (result === false) return false;
|
|
1309
1303
|
}
|
|
1310
1304
|
return true;
|
|
1311
1305
|
},
|
|
1312
|
-
|
|
1313
|
-
for (const fn of state.lifecycleHooks.
|
|
1306
|
+
runLeaveHooks() {
|
|
1307
|
+
for (const fn of state.lifecycleHooks.leave) {
|
|
1314
1308
|
fn();
|
|
1315
1309
|
}
|
|
1316
1310
|
},
|
|
1317
1311
|
clearRouteLifecycle() {
|
|
1318
|
-
const
|
|
1319
|
-
state.lifecycleHooks.
|
|
1320
|
-
state.lifecycleHooks.
|
|
1321
|
-
return {
|
|
1312
|
+
const oldLeaveHooks = [...state.lifecycleHooks.leave];
|
|
1313
|
+
state.lifecycleHooks.beforeLeave = [];
|
|
1314
|
+
state.lifecycleHooks.leave = [];
|
|
1315
|
+
return { leaveHooks: oldLeaveHooks };
|
|
1322
1316
|
}
|
|
1323
1317
|
};
|
|
1324
1318
|
const handlePopState = (event) => {
|
|
@@ -1349,7 +1343,7 @@ if (!globalThis[ROUTER_STATE_KEY]) {
|
|
|
1349
1343
|
pendingResolvers: [],
|
|
1350
1344
|
currentPath: "",
|
|
1351
1345
|
popAttached: false,
|
|
1352
|
-
lifecycleHooks: {
|
|
1346
|
+
lifecycleHooks: { beforeLeave: [], leave: [] }
|
|
1353
1347
|
};
|
|
1354
1348
|
}
|
|
1355
1349
|
const getRouterState = () => globalThis[ROUTER_STATE_KEY];
|
|
@@ -1422,18 +1416,18 @@ const RouterSlot = ({
|
|
|
1422
1416
|
const currentPath = router.getRequest().path;
|
|
1423
1417
|
const isSamePath = currentPath === lastPath;
|
|
1424
1418
|
if (!isSamePath) {
|
|
1425
|
-
const allowed = await router.
|
|
1419
|
+
const allowed = await router.runBeforeLeaveHooks();
|
|
1426
1420
|
if (!allowed) {
|
|
1427
1421
|
window.history.pushState({}, "", lastPath);
|
|
1428
1422
|
router.resolve(lastPath);
|
|
1429
1423
|
return;
|
|
1430
1424
|
}
|
|
1431
|
-
const {
|
|
1425
|
+
const { leaveHooks } = router.clearRouteLifecycle();
|
|
1432
1426
|
await dom.$(ref).update(
|
|
1433
1427
|
typeof RouterOutlet === "function" ? RouterOutlet() : [],
|
|
1434
1428
|
transitionConfig
|
|
1435
1429
|
);
|
|
1436
|
-
for (const fn of
|
|
1430
|
+
for (const fn of leaveHooks) {
|
|
1437
1431
|
fn();
|
|
1438
1432
|
}
|
|
1439
1433
|
} else {
|
package/dist/index.d.ts
CHANGED
|
@@ -137,8 +137,8 @@ declare const T: ({ key, values, tag, ref, ...attrs }: TransProps<string>) => VN
|
|
|
137
137
|
type OnHandleRouteChangeFn = (newRoute: string, oldRoute: string) => void;
|
|
138
138
|
type OnRouteChangeFn = (cb: OnHandleRouteChangeFn) => void;
|
|
139
139
|
type RouterStrategy = "page-refresh" | "slot-refresh";
|
|
140
|
-
type
|
|
141
|
-
type
|
|
140
|
+
type BeforeLeaveHookFn = () => boolean | void | Promise<boolean | void>;
|
|
141
|
+
type LeaveHookFn = () => void;
|
|
142
142
|
/**
|
|
143
143
|
* Context object passed to components rendered via Route's `component` prop.
|
|
144
144
|
* Provides access to the current route request and lifecycle hooks.
|
|
@@ -161,30 +161,30 @@ interface RouteContext {
|
|
|
161
161
|
/** The matched RouteRequest for the current route */
|
|
162
162
|
request: RouteRequest;
|
|
163
163
|
/**
|
|
164
|
-
* Register a hook that fires before
|
|
164
|
+
* Register a hook that fires before the route is unmounted.
|
|
165
165
|
* Returning `false` (or a Promise resolving to `false`) blocks navigation,
|
|
166
166
|
* allowing implementation of confirmation dialogs.
|
|
167
167
|
*/
|
|
168
|
-
onBeforeLeave(fn:
|
|
168
|
+
onBeforeLeave(fn: BeforeLeaveHookFn): void;
|
|
169
169
|
/**
|
|
170
|
-
* Register a hook that fires after the route has been
|
|
170
|
+
* Register a hook that fires after the route has been unmounted
|
|
171
171
|
* (navigation completed, new route is rendered).
|
|
172
172
|
*/
|
|
173
|
-
onLeave(fn:
|
|
173
|
+
onLeave(fn: LeaveHookFn): void;
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
|
-
* Props
|
|
177
|
-
* Extend your component props with this to
|
|
176
|
+
* Props interface for components rendered via Route's `component` prop.
|
|
177
|
+
* Extend your component's props with this to receive the `route` context.
|
|
178
178
|
*
|
|
179
179
|
* @example
|
|
180
180
|
* ```tsx
|
|
181
|
-
* import {
|
|
181
|
+
* import { type Props, type RouteProps } from "defuss";
|
|
182
182
|
*
|
|
183
|
-
*
|
|
183
|
+
* interface MyScreenProps extends Props, RouteProps {}
|
|
184
184
|
*
|
|
185
|
-
*
|
|
186
|
-
* const {
|
|
187
|
-
* return <h1>
|
|
185
|
+
* function MyScreen({ route }: MyScreenProps) {
|
|
186
|
+
* const { userId } = route.request.params;
|
|
187
|
+
* return <h1>User #{userId}</h1>;
|
|
188
188
|
* }
|
|
189
189
|
* ```
|
|
190
190
|
*/
|
|
@@ -323,8 +323,8 @@ interface RouterState {
|
|
|
323
323
|
currentPath: string;
|
|
324
324
|
popAttached: boolean;
|
|
325
325
|
lifecycleHooks: {
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
beforeLeave: Array<BeforeLeaveHookFn>;
|
|
327
|
+
leave: Array<LeaveHookFn>;
|
|
328
328
|
};
|
|
329
329
|
}
|
|
330
330
|
declare global {
|
|
@@ -381,8 +381,8 @@ interface RouteComponentProps extends Props {
|
|
|
381
381
|
*
|
|
382
382
|
* The component receives a `route` prop (RouteContext) with:
|
|
383
383
|
* - `route.request` — the matched RouteRequest with params, query, etc.
|
|
384
|
-
* - `route.
|
|
385
|
-
* - `route.
|
|
384
|
+
* - `route.onBeforeUnmount(fn)` — register a hook before route leaves; return `false` to block
|
|
385
|
+
* - `route.onUnmount(fn)` — register a hook after route has been left
|
|
386
386
|
*
|
|
387
387
|
* When the component is async and Route has children, the children are
|
|
388
388
|
* shown as a loading fallback until the async component resolves.
|
|
@@ -486,4 +486,4 @@ declare const Suspense: ({ fallback, ref, children, class: _class, className, id
|
|
|
486
486
|
};
|
|
487
487
|
|
|
488
488
|
export { Async, AsyncDefussChild, DOMElement, FC, Globals, NodeType, PersistenceProviderImpl, PersistenceProviderOptions, PersistenceProviderType, Props, Redirect, Ref, RenderInput, Route, Router, RouterSlot, RouterSlotId, Suspense, T, Trans, TransitionConfig, VNode, VNodeAttributes, VNodeChild, addElementEvent, areDomNodesEqual, changeLanguage, checkElementVisibility, clearElementEvents, createI18n, createTrans, domNodeToVNode, getEventMap, getLanguage, getMimeType, getRouterState, htmlStringToVNodes, i18n, inDevMode, isHTML, isMarkup, isSVG, loadLanguage, matchRouteRegistrations, parseDOM, processAllFormElements, queueCallback, removeElementEvent, renderMarkup, replaceDomWithVdom, setupRouter, t, tokenizePath, updateDomWithVdom, waitForDOM, webstorage };
|
|
489
|
-
export type { AsyncProps, AsyncState, AsyncStateRef,
|
|
489
|
+
export type { AsyncProps, AsyncState, AsyncStateRef, BeforeLeaveHookFn, I18nStore, LeaveHookFn, MatchRouteRegistrationsOpts, OnHandleRouteChangeFn, OnLanguageChangeListener, OnRouteChangeFn, RedirectProps, Replacements, Resolve, RouteComponentProps, RouteContext, RouteHandler, RouteParams, RouteProps, RouteRegistration, RouteRequest, RouterConfig, RouterSlotProps, RouterStrategy, TokenizedPath, TransProps, TransRef, TranslationKeys, TranslationObject, Translations, ValidChild };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { M as createStore, h as createRef, $, r as isRef } from './dom-
|
|
2
|
-
export { C as CAPTURE_ONLY_EVENTS, a as CLASS_ATTRIBUTE_NAME, N as CallChainImpl, D as DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE, b as DEFAULT_TRANSITION_CONFIG, F as Fragment, R as REF_ATTRIBUTE_NAME, X as XLINK_ATTRIBUTE_NAME, c as XMLNS_ATTRIBUTE_NAME, O as addElementEvent, d as applyStyles, P as areDomNodesEqual, Q as checkElementVisibility, e as clearDelegatedEvents, f as clearDelegatedEventsDeep, S as clearElementEvents, g as createInPlaceErrorMessageVNode, T as deepEquals, U as dequery, V as domNodeToVNode, W as emptyImpl, Y as getAllFormValues, i as getComponentInstance, Z as getDefaultDequeryOptions, _ as getEventMap, a0 as getMimeType, j as getRegisteredEventKeys, k as getRegisteredEventTypes, l as getRenderer, m as getTransitionStyles, n as globalScopeDomApis, o as handleLifecycleEventsForOnMount, a1 as htmlStringToVNodes, p as isComponentRoot, a2 as isDequery, a3 as isDequeryOptionsObject, a4 as isHTML, q as isJSX, a5 as isMarkup, a6 as isSVG, s as jsx, t as jsxDEV, u as jsxs, v as nsMap, w as observeUnmount, a7 as parseDOM, x as parseEventPropName, y as performTransition, a8 as processAllFormElements, a9 as queueCallback, z as registerComponent, A as registerDelegatedEvent, B as removeDelegatedEvent, E as removeDelegatedEventByKey, aa as removeElementEvent, G as render, H as renderInto, I as renderIsomorphicAsync, J as renderIsomorphicSync, ab as renderMarkup, ac as replaceDomWithVdom, ad as scrollHelper, ae as shallowEquals, K as unregisterComponent, L as updateDom, af as updateDomWithVdom, ag as waitForDOM, ah as webstorage } from './dom-
|
|
1
|
+
import { M as createStore, h as createRef, $, r as isRef } from './dom-DUPOK7Hs.mjs';
|
|
2
|
+
export { C as CAPTURE_ONLY_EVENTS, a as CLASS_ATTRIBUTE_NAME, N as CallChainImpl, D as DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE, b as DEFAULT_TRANSITION_CONFIG, F as Fragment, R as REF_ATTRIBUTE_NAME, X as XLINK_ATTRIBUTE_NAME, c as XMLNS_ATTRIBUTE_NAME, O as addElementEvent, d as applyStyles, P as areDomNodesEqual, Q as checkElementVisibility, e as clearDelegatedEvents, f as clearDelegatedEventsDeep, S as clearElementEvents, g as createInPlaceErrorMessageVNode, T as deepEquals, U as dequery, V as domNodeToVNode, W as emptyImpl, Y as getAllFormValues, i as getComponentInstance, Z as getDefaultDequeryOptions, _ as getEventMap, a0 as getMimeType, j as getRegisteredEventKeys, k as getRegisteredEventTypes, l as getRenderer, m as getTransitionStyles, n as globalScopeDomApis, o as handleLifecycleEventsForOnMount, a1 as htmlStringToVNodes, p as isComponentRoot, a2 as isDequery, a3 as isDequeryOptionsObject, a4 as isHTML, q as isJSX, a5 as isMarkup, a6 as isSVG, s as jsx, t as jsxDEV, u as jsxs, v as nsMap, w as observeUnmount, a7 as parseDOM, x as parseEventPropName, y as performTransition, a8 as processAllFormElements, a9 as queueCallback, z as registerComponent, A as registerDelegatedEvent, B as removeDelegatedEvent, E as removeDelegatedEventByKey, aa as removeElementEvent, G as render, H as renderInto, I as renderIsomorphicAsync, J as renderIsomorphicSync, ab as renderMarkup, ac as replaceDomWithVdom, ad as scrollHelper, ae as shallowEquals, K as unregisterComponent, L as updateDom, af as updateDomWithVdom, ag as waitForDOM, ah as webstorage } from './dom-DUPOK7Hs.mjs';
|
|
3
3
|
import 'defuss-runtime';
|
|
4
|
-
export { m as mount, u as unmount } from './mount-
|
|
4
|
+
export { m as mount, u as unmount } from './mount-DNlJN8xI.mjs';
|
|
5
5
|
|
|
6
6
|
const inDevMode = typeof process !== "undefined" && process.env ? process.env.NODE_ENV !== "production" : false;
|
|
7
7
|
|
|
@@ -831,10 +831,7 @@ function createDomFromChild(child, globals) {
|
|
|
831
831
|
}
|
|
832
832
|
function shouldPreserveFormStateAttribute(el, attrName, vnode) {
|
|
833
833
|
const tag = el.tagName.toLowerCase();
|
|
834
|
-
const hasExplicit = Object.
|
|
835
|
-
vnode.attributes ?? {},
|
|
836
|
-
attrName
|
|
837
|
-
);
|
|
834
|
+
const hasExplicit = Object.hasOwn(vnode.attributes ?? {}, attrName);
|
|
838
835
|
if (hasExplicit) return false;
|
|
839
836
|
if (tag === "input") return attrName === "value" || attrName === "checked";
|
|
840
837
|
if (tag === "textarea") return attrName === "value";
|
|
@@ -849,10 +846,10 @@ function patchElementInPlace(el, vnode, globals) {
|
|
|
849
846
|
const { name } = attr;
|
|
850
847
|
if (name === "key") continue;
|
|
851
848
|
if (name.startsWith("on")) continue;
|
|
852
|
-
if (name === "class" && (Object.
|
|
849
|
+
if (name === "class" && (Object.hasOwn(nextAttrs, "class") || Object.hasOwn(nextAttrs, "className"))) {
|
|
853
850
|
continue;
|
|
854
851
|
}
|
|
855
|
-
if (!Object.
|
|
852
|
+
if (!Object.hasOwn(nextAttrs, name)) {
|
|
856
853
|
if (shouldPreserveFormStateAttribute(el, name, vnode)) continue;
|
|
857
854
|
el.removeAttribute(name);
|
|
858
855
|
}
|
|
@@ -885,10 +882,7 @@ function patchElementInPlace(el, vnode, globals) {
|
|
|
885
882
|
}
|
|
886
883
|
const tag = el.tagName.toLowerCase();
|
|
887
884
|
if (tag === "textarea") {
|
|
888
|
-
const isControlled = Object.
|
|
889
|
-
nextAttrs,
|
|
890
|
-
"value"
|
|
891
|
-
);
|
|
885
|
+
const isControlled = Object.hasOwn(nextAttrs, "value");
|
|
892
886
|
const isActive = el.ownerDocument?.activeElement === el;
|
|
893
887
|
if (isActive && !isControlled) return;
|
|
894
888
|
}
|
|
@@ -1162,10 +1156,10 @@ const setupRouter = (config = {
|
|
|
1162
1156
|
pendingResolvers: [],
|
|
1163
1157
|
currentPath: "",
|
|
1164
1158
|
popAttached: false,
|
|
1165
|
-
lifecycleHooks: {
|
|
1159
|
+
lifecycleHooks: { beforeLeave: [], leave: [] }
|
|
1166
1160
|
};
|
|
1167
1161
|
if (!state.lifecycleHooks) {
|
|
1168
|
-
state.lifecycleHooks = {
|
|
1162
|
+
state.lifecycleHooks = { beforeLeave: [], leave: [] };
|
|
1169
1163
|
}
|
|
1170
1164
|
const routeRegistrations = state.routeRegistrations;
|
|
1171
1165
|
if (typeof window !== "undefined" && !windowImpl) {
|
|
@@ -1294,30 +1288,30 @@ const setupRouter = (config = {
|
|
|
1294
1288
|
return {
|
|
1295
1289
|
request,
|
|
1296
1290
|
onBeforeLeave(fn) {
|
|
1297
|
-
state.lifecycleHooks.
|
|
1291
|
+
state.lifecycleHooks.beforeLeave.push(fn);
|
|
1298
1292
|
},
|
|
1299
1293
|
onLeave(fn) {
|
|
1300
|
-
state.lifecycleHooks.
|
|
1294
|
+
state.lifecycleHooks.leave.push(fn);
|
|
1301
1295
|
}
|
|
1302
1296
|
};
|
|
1303
1297
|
},
|
|
1304
|
-
async
|
|
1305
|
-
for (const fn of state.lifecycleHooks.
|
|
1298
|
+
async runBeforeLeaveHooks() {
|
|
1299
|
+
for (const fn of state.lifecycleHooks.beforeLeave) {
|
|
1306
1300
|
const result = await fn();
|
|
1307
1301
|
if (result === false) return false;
|
|
1308
1302
|
}
|
|
1309
1303
|
return true;
|
|
1310
1304
|
},
|
|
1311
|
-
|
|
1312
|
-
for (const fn of state.lifecycleHooks.
|
|
1305
|
+
runLeaveHooks() {
|
|
1306
|
+
for (const fn of state.lifecycleHooks.leave) {
|
|
1313
1307
|
fn();
|
|
1314
1308
|
}
|
|
1315
1309
|
},
|
|
1316
1310
|
clearRouteLifecycle() {
|
|
1317
|
-
const
|
|
1318
|
-
state.lifecycleHooks.
|
|
1319
|
-
state.lifecycleHooks.
|
|
1320
|
-
return {
|
|
1311
|
+
const oldLeaveHooks = [...state.lifecycleHooks.leave];
|
|
1312
|
+
state.lifecycleHooks.beforeLeave = [];
|
|
1313
|
+
state.lifecycleHooks.leave = [];
|
|
1314
|
+
return { leaveHooks: oldLeaveHooks };
|
|
1321
1315
|
}
|
|
1322
1316
|
};
|
|
1323
1317
|
const handlePopState = (event) => {
|
|
@@ -1348,7 +1342,7 @@ if (!globalThis[ROUTER_STATE_KEY]) {
|
|
|
1348
1342
|
pendingResolvers: [],
|
|
1349
1343
|
currentPath: "",
|
|
1350
1344
|
popAttached: false,
|
|
1351
|
-
lifecycleHooks: {
|
|
1345
|
+
lifecycleHooks: { beforeLeave: [], leave: [] }
|
|
1352
1346
|
};
|
|
1353
1347
|
}
|
|
1354
1348
|
const getRouterState = () => globalThis[ROUTER_STATE_KEY];
|
|
@@ -1421,18 +1415,18 @@ const RouterSlot = ({
|
|
|
1421
1415
|
const currentPath = router.getRequest().path;
|
|
1422
1416
|
const isSamePath = currentPath === lastPath;
|
|
1423
1417
|
if (!isSamePath) {
|
|
1424
|
-
const allowed = await router.
|
|
1418
|
+
const allowed = await router.runBeforeLeaveHooks();
|
|
1425
1419
|
if (!allowed) {
|
|
1426
1420
|
window.history.pushState({}, "", lastPath);
|
|
1427
1421
|
router.resolve(lastPath);
|
|
1428
1422
|
return;
|
|
1429
1423
|
}
|
|
1430
|
-
const {
|
|
1424
|
+
const { leaveHooks } = router.clearRouteLifecycle();
|
|
1431
1425
|
await $(ref).update(
|
|
1432
1426
|
typeof RouterOutlet === "function" ? RouterOutlet() : [],
|
|
1433
1427
|
transitionConfig
|
|
1434
1428
|
);
|
|
1435
|
-
for (const fn of
|
|
1429
|
+
for (const fn of leaveHooks) {
|
|
1436
1430
|
fn();
|
|
1437
1431
|
}
|
|
1438
1432
|
} else {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { J as renderIsomorphicSync, z as registerComponent, w as observeUnmount, K as unregisterComponent } from './dom-DUPOK7Hs.mjs';
|
|
2
|
+
|
|
3
|
+
function mount(container, Component, initialProps) {
|
|
4
|
+
while (container.firstChild) {
|
|
5
|
+
container.removeChild(container.firstChild);
|
|
6
|
+
}
|
|
7
|
+
const vnode = Component(initialProps);
|
|
8
|
+
renderIsomorphicSync(vnode, container, globalThis);
|
|
9
|
+
registerComponent(
|
|
10
|
+
container,
|
|
11
|
+
Component,
|
|
12
|
+
{ ...initialProps }
|
|
13
|
+
);
|
|
14
|
+
if (container.parentNode) {
|
|
15
|
+
observeUnmount(container, () => unregisterComponent(container));
|
|
16
|
+
}
|
|
17
|
+
return container;
|
|
18
|
+
}
|
|
19
|
+
function unmount(container) {
|
|
20
|
+
unregisterComponent(container);
|
|
21
|
+
while (container.firstChild) {
|
|
22
|
+
container.removeChild(container.firstChild);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { mount as m, unmount as u };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var dom = require('./dom-C679BHZu.cjs');
|
|
4
|
+
|
|
5
|
+
function mount(container, Component, initialProps) {
|
|
6
|
+
while (container.firstChild) {
|
|
7
|
+
container.removeChild(container.firstChild);
|
|
8
|
+
}
|
|
9
|
+
const vnode = Component(initialProps);
|
|
10
|
+
dom.renderIsomorphicSync(vnode, container, globalThis);
|
|
11
|
+
dom.registerComponent(
|
|
12
|
+
container,
|
|
13
|
+
Component,
|
|
14
|
+
{ ...initialProps }
|
|
15
|
+
);
|
|
16
|
+
if (container.parentNode) {
|
|
17
|
+
dom.observeUnmount(container, () => dom.unregisterComponent(container));
|
|
18
|
+
}
|
|
19
|
+
return container;
|
|
20
|
+
}
|
|
21
|
+
function unmount(container) {
|
|
22
|
+
dom.unregisterComponent(container);
|
|
23
|
+
while (container.firstChild) {
|
|
24
|
+
container.removeChild(container.firstChild);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.mount = mount;
|
|
29
|
+
exports.unmount = unmount;
|
package/dist/render/client.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var dom = require('../dom-
|
|
4
|
-
var mount = require('../mount-
|
|
3
|
+
var dom = require('../dom-C679BHZu.cjs');
|
|
4
|
+
var mount = require('../mount-DcLKJdyY.cjs');
|
|
5
5
|
require('defuss-runtime');
|
|
6
6
|
|
|
7
7
|
const renderSync = (virtualNode, parentDomElement = document.documentElement) => {
|
package/dist/render/client.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { x as parseEventPropName, A as registerDelegatedEvent, w as observeUnmount, n as globalScopeDomApis, I as renderIsomorphicAsync, J as renderIsomorphicSync } from '../dom-
|
|
2
|
-
export { C as CAPTURE_ONLY_EVENTS, a as CLASS_ATTRIBUTE_NAME, D as DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE, b as DEFAULT_TRANSITION_CONFIG, F as Fragment, R as REF_ATTRIBUTE_NAME, X as XLINK_ATTRIBUTE_NAME, c as XMLNS_ATTRIBUTE_NAME, d as applyStyles, e as clearDelegatedEvents, f as clearDelegatedEventsDeep, g as createInPlaceErrorMessageVNode, h as createRef, i as getComponentInstance, j as getRegisteredEventKeys, k as getRegisteredEventTypes, l as getRenderer, m as getTransitionStyles, o as handleLifecycleEventsForOnMount, p as isComponentRoot, q as isJSX, r as isRef, s as jsx, t as jsxDEV, u as jsxs, v as nsMap, y as performTransition, z as registerComponent, B as removeDelegatedEvent, E as removeDelegatedEventByKey, H as renderInto, K as unregisterComponent, L as updateDom } from '../dom-
|
|
3
|
-
export { m as mount, u as unmount } from '../mount-
|
|
1
|
+
import { x as parseEventPropName, A as registerDelegatedEvent, w as observeUnmount, n as globalScopeDomApis, I as renderIsomorphicAsync, J as renderIsomorphicSync } from '../dom-DUPOK7Hs.mjs';
|
|
2
|
+
export { C as CAPTURE_ONLY_EVENTS, a as CLASS_ATTRIBUTE_NAME, D as DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE, b as DEFAULT_TRANSITION_CONFIG, F as Fragment, R as REF_ATTRIBUTE_NAME, X as XLINK_ATTRIBUTE_NAME, c as XMLNS_ATTRIBUTE_NAME, d as applyStyles, e as clearDelegatedEvents, f as clearDelegatedEventsDeep, g as createInPlaceErrorMessageVNode, h as createRef, i as getComponentInstance, j as getRegisteredEventKeys, k as getRegisteredEventTypes, l as getRenderer, m as getTransitionStyles, o as handleLifecycleEventsForOnMount, p as isComponentRoot, q as isJSX, r as isRef, s as jsx, t as jsxDEV, u as jsxs, v as nsMap, y as performTransition, z as registerComponent, B as removeDelegatedEvent, E as removeDelegatedEventByKey, H as renderInto, K as unregisterComponent, L as updateDom } from '../dom-DUPOK7Hs.mjs';
|
|
3
|
+
export { m as mount, u as unmount } from '../mount-DNlJN8xI.mjs';
|
|
4
4
|
import 'defuss-runtime';
|
|
5
5
|
|
|
6
6
|
const renderSync = (virtualNode, parentDomElement = document.documentElement) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a as CLASS_ATTRIBUTE_NAME, D as DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE, b as DEFAULT_TRANSITION_CONFIG, F as Fragment, R as REF_ATTRIBUTE_NAME, X as XLINK_ATTRIBUTE_NAME, c as XMLNS_ATTRIBUTE_NAME, d as applyStyles, g as createInPlaceErrorMessageVNode, h as createRef, l as getRenderer, m as getTransitionStyles, n as globalScopeDomApis, o as handleLifecycleEventsForOnMount, q as isJSX, r as isRef, s as jsx, t as jsxDEV, u as jsxs, v as nsMap, w as observeUnmount, y as performTransition, G as render, H as renderInto, I as renderIsomorphicAsync, J as renderIsomorphicSync, L as updateDom } from '../../dom-
|
|
1
|
+
export { a as CLASS_ATTRIBUTE_NAME, D as DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE, b as DEFAULT_TRANSITION_CONFIG, F as Fragment, R as REF_ATTRIBUTE_NAME, X as XLINK_ATTRIBUTE_NAME, c as XMLNS_ATTRIBUTE_NAME, d as applyStyles, g as createInPlaceErrorMessageVNode, h as createRef, l as getRenderer, m as getTransitionStyles, n as globalScopeDomApis, o as handleLifecycleEventsForOnMount, q as isJSX, r as isRef, s as jsx, t as jsxDEV, u as jsxs, v as nsMap, w as observeUnmount, y as performTransition, G as render, H as renderInto, I as renderIsomorphicAsync, J as renderIsomorphicSync, L as updateDom } from '../../dom-DUPOK7Hs.mjs';
|
|
2
2
|
import 'defuss-runtime';
|
package/dist/render/index.cjs
CHANGED
package/dist/render/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { C as CAPTURE_ONLY_EVENTS, a as CLASS_ATTRIBUTE_NAME, D as DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE, b as DEFAULT_TRANSITION_CONFIG, F as Fragment, R as REF_ATTRIBUTE_NAME, X as XLINK_ATTRIBUTE_NAME, c as XMLNS_ATTRIBUTE_NAME, d as applyStyles, e as clearDelegatedEvents, f as clearDelegatedEventsDeep, g as createInPlaceErrorMessageVNode, h as createRef, i as getComponentInstance, j as getRegisteredEventKeys, k as getRegisteredEventTypes, l as getRenderer, m as getTransitionStyles, n as globalScopeDomApis, o as handleLifecycleEventsForOnMount, p as isComponentRoot, q as isJSX, r as isRef, s as jsx, t as jsxDEV, u as jsxs, v as nsMap, w as observeUnmount, x as parseEventPropName, y as performTransition, z as registerComponent, A as registerDelegatedEvent, B as removeDelegatedEvent, E as removeDelegatedEventByKey, G as render, H as renderInto, I as renderIsomorphicAsync, J as renderIsomorphicSync, K as unregisterComponent, L as updateDom } from '../dom-
|
|
2
|
-
export { m as mount, u as unmount } from '../mount-
|
|
1
|
+
export { C as CAPTURE_ONLY_EVENTS, a as CLASS_ATTRIBUTE_NAME, D as DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE, b as DEFAULT_TRANSITION_CONFIG, F as Fragment, R as REF_ATTRIBUTE_NAME, X as XLINK_ATTRIBUTE_NAME, c as XMLNS_ATTRIBUTE_NAME, d as applyStyles, e as clearDelegatedEvents, f as clearDelegatedEventsDeep, g as createInPlaceErrorMessageVNode, h as createRef, i as getComponentInstance, j as getRegisteredEventKeys, k as getRegisteredEventTypes, l as getRenderer, m as getTransitionStyles, n as globalScopeDomApis, o as handleLifecycleEventsForOnMount, p as isComponentRoot, q as isJSX, r as isRef, s as jsx, t as jsxDEV, u as jsxs, v as nsMap, w as observeUnmount, x as parseEventPropName, y as performTransition, z as registerComponent, A as registerDelegatedEvent, B as removeDelegatedEvent, E as removeDelegatedEventByKey, G as render, H as renderInto, I as renderIsomorphicAsync, J as renderIsomorphicSync, K as unregisterComponent, L as updateDom } from '../dom-DUPOK7Hs.mjs';
|
|
2
|
+
export { m as mount, u as unmount } from '../mount-DNlJN8xI.mjs';
|
|
3
3
|
import 'defuss-runtime';
|
package/dist/render/server.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var HappyDom = require('happy-dom');
|
|
4
|
-
var dom = require('../dom-
|
|
4
|
+
var dom = require('../dom-C679BHZu.cjs');
|
|
5
5
|
var serializeHtml = require('w3c-xmlserializer');
|
|
6
|
-
var mount = require('../mount-
|
|
6
|
+
var mount = require('../mount-DcLKJdyY.cjs');
|
|
7
7
|
require('defuss-runtime');
|
|
8
8
|
|
|
9
9
|
function _interopNamespaceDefault(e) {
|
package/dist/render/server.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as HappyDom from 'happy-dom';
|
|
2
|
-
import { I as renderIsomorphicAsync, J as renderIsomorphicSync, n as globalScopeDomApis } from '../dom-
|
|
3
|
-
export { C as CAPTURE_ONLY_EVENTS, a as CLASS_ATTRIBUTE_NAME, D as DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE, b as DEFAULT_TRANSITION_CONFIG, F as Fragment, R as REF_ATTRIBUTE_NAME, X as XLINK_ATTRIBUTE_NAME, c as XMLNS_ATTRIBUTE_NAME, d as applyStyles, e as clearDelegatedEvents, f as clearDelegatedEventsDeep, g as createInPlaceErrorMessageVNode, h as createRef, i as getComponentInstance, j as getRegisteredEventKeys, k as getRegisteredEventTypes, l as getRenderer, m as getTransitionStyles, o as handleLifecycleEventsForOnMount, p as isComponentRoot, q as isJSX, r as isRef, s as jsx, t as jsxDEV, u as jsxs, v as nsMap, w as observeUnmount, x as parseEventPropName, y as performTransition, z as registerComponent, A as registerDelegatedEvent, B as removeDelegatedEvent, E as removeDelegatedEventByKey, H as renderInto, K as unregisterComponent, L as updateDom } from '../dom-
|
|
2
|
+
import { I as renderIsomorphicAsync, J as renderIsomorphicSync, n as globalScopeDomApis } from '../dom-DUPOK7Hs.mjs';
|
|
3
|
+
export { C as CAPTURE_ONLY_EVENTS, a as CLASS_ATTRIBUTE_NAME, D as DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE, b as DEFAULT_TRANSITION_CONFIG, F as Fragment, R as REF_ATTRIBUTE_NAME, X as XLINK_ATTRIBUTE_NAME, c as XMLNS_ATTRIBUTE_NAME, d as applyStyles, e as clearDelegatedEvents, f as clearDelegatedEventsDeep, g as createInPlaceErrorMessageVNode, h as createRef, i as getComponentInstance, j as getRegisteredEventKeys, k as getRegisteredEventTypes, l as getRenderer, m as getTransitionStyles, o as handleLifecycleEventsForOnMount, p as isComponentRoot, q as isJSX, r as isRef, s as jsx, t as jsxDEV, u as jsxs, v as nsMap, w as observeUnmount, x as parseEventPropName, y as performTransition, z as registerComponent, A as registerDelegatedEvent, B as removeDelegatedEvent, E as removeDelegatedEventByKey, H as renderInto, K as unregisterComponent, L as updateDom } from '../dom-DUPOK7Hs.mjs';
|
|
4
4
|
import serializeHtml from 'w3c-xmlserializer';
|
|
5
|
-
export { m as mount, u as unmount } from '../mount-
|
|
5
|
+
export { m as mount, u as unmount } from '../mount-DNlJN8xI.mjs';
|
|
6
6
|
import 'defuss-runtime';
|
|
7
7
|
|
|
8
8
|
const setupDomApis = (options = {}) => {
|