@estjs/template 0.0.17-beta.3 → 0.0.17-beta.5
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/template.cjs +2 -2
- package/dist/template.d.cts +11 -3
- package/dist/template.d.ts +11 -3
- package/dist/template.dev.cjs +71 -53
- package/dist/template.dev.cjs.map +1 -1
- package/dist/template.dev.js +72 -54
- package/dist/template.dev.js.map +1 -1
- package/dist/template.js +2 -2
- package/package.json +4 -4
package/dist/template.dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getActiveScope, runWithScope, onCleanup, __objRest, createScope, disposeScope, __async } from './chunk-PYFF2HI3.dev.js';
|
|
2
|
-
import { normalizeClassName, SPREAD_NAME, isObject, warn, startsWith, isSpecialBooleanAttr, isBooleanAttr, includeBooleanAttr, isSymbol, isString, isArray, kebabCase, camelCase, capitalize, HYDRATION_ANCHOR_ATTR, isBrowser, error, isPromise, isFunction, isOn, coerceArray } from '@estjs/shared';
|
|
2
|
+
import { normalizeClassName, SPREAD_NAME, isObject, warn, startsWith, isSpecialBooleanAttr, isBooleanAttr, includeBooleanAttr, isSymbol, isString, isArray, kebabCase, camelCase, capitalize, HYDRATION_ANCHOR_ATTR, isBrowser, error, isPromise, isFunction, isOn, coerceArray, isNumber } from '@estjs/shared';
|
|
3
3
|
import { effect, shallowReactive, isSignal, isComputed, isReactive, signal } from '@estjs/signals';
|
|
4
4
|
|
|
5
5
|
var REF_KEY = "ref";
|
|
@@ -148,6 +148,7 @@ function patchClass(el, prev, next2, isSVG = false) {
|
|
|
148
148
|
}
|
|
149
149
|
var normalizeClass = normalizeClassName;
|
|
150
150
|
var importantRE = /\s*!important$/;
|
|
151
|
+
var styleDeclRE = /(?:^|;)\s*([a-z][a-z\d-]*)\s*:/gi;
|
|
151
152
|
var prefixes = ["Webkit", "Moz", "ms"];
|
|
152
153
|
var prefixCache = {};
|
|
153
154
|
function patchStyle(el, prev, next2) {
|
|
@@ -172,9 +173,9 @@ function patchStyle(el, prev, next2) {
|
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
} else if (prev && isString(prev)) {
|
|
175
|
-
|
|
176
|
+
styleDeclRE.lastIndex = 0;
|
|
176
177
|
let match;
|
|
177
|
-
while ((match =
|
|
178
|
+
while ((match = styleDeclRE.exec(prev)) !== null) {
|
|
178
179
|
const key = match[1].trim();
|
|
179
180
|
if (key && next2 && isObject(next2) && next2[key] == null) {
|
|
180
181
|
setStyle(style, key, "");
|
|
@@ -369,23 +370,31 @@ function resolveHydrationKey(parent) {
|
|
|
369
370
|
const el = parent;
|
|
370
371
|
return (_c = (_b = el.dataset.hk) != null ? _b : (_a2 = parent.closest("[data-hk]")) == null ? void 0 : _a2.dataset.hk) != null ? _c : null;
|
|
371
372
|
}
|
|
373
|
+
function expectedHydrationSlot(parent, index) {
|
|
374
|
+
if (_isHydrating && parent) {
|
|
375
|
+
const key = resolveHydrationKey(parent);
|
|
376
|
+
if (key) return `${key}-${index}`;
|
|
377
|
+
}
|
|
378
|
+
return String(index);
|
|
379
|
+
}
|
|
372
380
|
function hydrationMarker(parent, index) {
|
|
373
|
-
if (!
|
|
374
|
-
const
|
|
375
|
-
|
|
381
|
+
if (!parent || index < 0) return null;
|
|
382
|
+
const expected = expectedHydrationSlot(parent instanceof Element ? parent : null, index);
|
|
383
|
+
let fallbackIndex = 0;
|
|
376
384
|
let cursor = parent.firstChild;
|
|
377
385
|
while (cursor) {
|
|
378
|
-
if (cursor.nodeType === Node.COMMENT_NODE
|
|
379
|
-
|
|
386
|
+
if (cursor.nodeType === Node.COMMENT_NODE) {
|
|
387
|
+
const comment = cursor;
|
|
388
|
+
if (comment.data === expected) return comment;
|
|
389
|
+
if (!_isHydrating && comment.data === "" && fallbackIndex++ === index) return comment;
|
|
380
390
|
}
|
|
381
391
|
cursor = cursor.nextSibling;
|
|
382
392
|
}
|
|
383
393
|
return null;
|
|
384
394
|
}
|
|
385
395
|
function hydrationAnchor(parent, index) {
|
|
386
|
-
if (!
|
|
387
|
-
const
|
|
388
|
-
const expected = key ? `${key}-${index}` : String(index);
|
|
396
|
+
if (!(parent instanceof Element) || index < 0) return null;
|
|
397
|
+
const expected = expectedHydrationSlot(parent, index);
|
|
389
398
|
let cursor = parent.firstChild;
|
|
390
399
|
while (cursor) {
|
|
391
400
|
if (cursor instanceof Element && cursor.getAttribute(HYDRATION_ANCHOR_ATTR) === expected) {
|
|
@@ -637,7 +646,7 @@ function normalizeNode(node) {
|
|
|
637
646
|
}
|
|
638
647
|
function insert(parent, nodeFactory, before) {
|
|
639
648
|
if (!parent) return;
|
|
640
|
-
|
|
649
|
+
let parentScope = getActiveScope();
|
|
641
650
|
let renderedNodes = [];
|
|
642
651
|
let isFirstRun = true;
|
|
643
652
|
const resolveNodes = (raw) => {
|
|
@@ -679,6 +688,7 @@ function insert(parent, nodeFactory, before) {
|
|
|
679
688
|
effectRunner.stop();
|
|
680
689
|
for (const node of renderedNodes) removeNode(node);
|
|
681
690
|
renderedNodes = [];
|
|
691
|
+
parentScope = null;
|
|
682
692
|
});
|
|
683
693
|
return renderedNodes;
|
|
684
694
|
}
|
|
@@ -816,9 +826,9 @@ function syncDescriptors(target, source, pruneMissing = false) {
|
|
|
816
826
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
817
827
|
}
|
|
818
828
|
if (pruneMissing) {
|
|
819
|
-
const
|
|
829
|
+
const sourceKeySet = new Set(Object.getOwnPropertyNames(source));
|
|
820
830
|
for (const key of Object.getOwnPropertyNames(target)) {
|
|
821
|
-
if (!
|
|
831
|
+
if (!sourceKeySet.has(key)) delete target[key];
|
|
822
832
|
}
|
|
823
833
|
}
|
|
824
834
|
}
|
|
@@ -1380,12 +1390,10 @@ function bindElement(node, prop, getter, setter, modifiers = {}) {
|
|
|
1380
1390
|
onCleanup(() => runner.stop());
|
|
1381
1391
|
}
|
|
1382
1392
|
}
|
|
1383
|
-
|
|
1384
|
-
// src/utils.ts
|
|
1385
1393
|
function unwrapSlotValue(raw) {
|
|
1386
1394
|
let v = raw;
|
|
1387
1395
|
if (Array.isArray(v) && v.length === 1) v = v[0];
|
|
1388
|
-
return
|
|
1396
|
+
return isFunction(v) ? v() : v;
|
|
1389
1397
|
}
|
|
1390
1398
|
function useChildren(props) {
|
|
1391
1399
|
const desc = Object.getOwnPropertyDescriptor(props, "children");
|
|
@@ -1703,49 +1711,50 @@ function createResource(fetcher, options) {
|
|
|
1703
1711
|
const error4 = signal(null);
|
|
1704
1712
|
const state = signal("pending");
|
|
1705
1713
|
let fetchId = 0;
|
|
1706
|
-
let
|
|
1707
|
-
let suspenseRegistered = false;
|
|
1714
|
+
let controller = null;
|
|
1708
1715
|
const suspenseContext = inject(SuspenseContext, null);
|
|
1709
|
-
const
|
|
1710
|
-
const
|
|
1716
|
+
const doFetch = () => __async(null, null, function* () {
|
|
1717
|
+
const id = ++fetchId;
|
|
1718
|
+
controller == null ? void 0 : controller.abort();
|
|
1719
|
+
controller = new AbortController();
|
|
1711
1720
|
loading.value = true;
|
|
1712
1721
|
state.value = "pending";
|
|
1713
1722
|
error4.value = null;
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1723
|
+
let promise;
|
|
1724
|
+
try {
|
|
1725
|
+
promise = Promise.resolve(fetcher(controller.signal));
|
|
1726
|
+
} catch (error_) {
|
|
1727
|
+
error4.value = error_ instanceof Error ? error_ : new Error(String(error_));
|
|
1728
|
+
state.value = "errored";
|
|
1729
|
+
loading.value = false;
|
|
1730
|
+
return;
|
|
1717
1731
|
}
|
|
1732
|
+
suspenseContext == null ? void 0 : suspenseContext.register(promise);
|
|
1718
1733
|
try {
|
|
1719
|
-
const promise = fetcher();
|
|
1720
|
-
currentPromise = promise;
|
|
1721
|
-
promise.catch(() => {
|
|
1722
|
-
});
|
|
1723
1734
|
const result = yield promise;
|
|
1724
|
-
if (
|
|
1735
|
+
if (id === fetchId) {
|
|
1725
1736
|
value.value = result;
|
|
1726
1737
|
state.value = "ready";
|
|
1727
1738
|
loading.value = false;
|
|
1728
1739
|
}
|
|
1729
1740
|
} catch (error_) {
|
|
1730
|
-
if (
|
|
1731
|
-
|
|
1732
|
-
state.value = "errored";
|
|
1741
|
+
if (id !== fetchId) return;
|
|
1742
|
+
if (error_ instanceof DOMException && error_.name === "AbortError") {
|
|
1733
1743
|
loading.value = false;
|
|
1744
|
+
return;
|
|
1734
1745
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
}
|
|
1746
|
+
error4.value = error_ instanceof Error ? error_ : new Error(String(error_));
|
|
1747
|
+
state.value = "errored";
|
|
1748
|
+
loading.value = false;
|
|
1739
1749
|
}
|
|
1740
1750
|
});
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
}
|
|
1747
|
-
return value.value;
|
|
1751
|
+
doFetch();
|
|
1752
|
+
onCleanup(() => {
|
|
1753
|
+
fetchId++;
|
|
1754
|
+
controller == null ? void 0 : controller.abort();
|
|
1755
|
+
controller = null;
|
|
1748
1756
|
});
|
|
1757
|
+
const resource = (() => value.value);
|
|
1749
1758
|
resource.loading = loading;
|
|
1750
1759
|
resource.error = error4;
|
|
1751
1760
|
resource.state = state;
|
|
@@ -1756,9 +1765,7 @@ function createResource(fetcher, options) {
|
|
|
1756
1765
|
loading.value = false;
|
|
1757
1766
|
error4.value = null;
|
|
1758
1767
|
},
|
|
1759
|
-
refetch: () =>
|
|
1760
|
-
yield fetch();
|
|
1761
|
-
})
|
|
1768
|
+
refetch: () => doFetch()
|
|
1762
1769
|
};
|
|
1763
1770
|
return [resource, actions];
|
|
1764
1771
|
}
|
|
@@ -1942,9 +1949,14 @@ function For(props) {
|
|
|
1942
1949
|
const parentScope = (_a2 = getActiveScope()) != null ? _a2 : ownerScope;
|
|
1943
1950
|
const scope = createScope(parentScope);
|
|
1944
1951
|
let mountedNodes = [];
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1952
|
+
try {
|
|
1953
|
+
runWithScope(scope, () => {
|
|
1954
|
+
mountedNodes = mountValue(renderFn(item, index), parent, before);
|
|
1955
|
+
});
|
|
1956
|
+
} catch (error4) {
|
|
1957
|
+
disposeScope(scope);
|
|
1958
|
+
throw error4;
|
|
1959
|
+
}
|
|
1948
1960
|
return { key, item, nodes: mountedNodes, scope };
|
|
1949
1961
|
};
|
|
1950
1962
|
const disposeItem = (entry) => {
|
|
@@ -2145,16 +2157,17 @@ function whenTransitionEnds(el, type, explicit, resolve2) {
|
|
|
2145
2157
|
const finish = () => {
|
|
2146
2158
|
if (done) return;
|
|
2147
2159
|
done = true;
|
|
2160
|
+
clearTimeout(timer);
|
|
2148
2161
|
el.removeEventListener(info.event, onEnd);
|
|
2149
2162
|
resolve2();
|
|
2150
2163
|
};
|
|
2151
2164
|
const onEnd = () => finish();
|
|
2152
2165
|
el.addEventListener(info.event, onEnd);
|
|
2153
|
-
setTimeout(finish, info.timeout + 1);
|
|
2166
|
+
const timer = setTimeout(finish, info.timeout + 1);
|
|
2154
2167
|
}
|
|
2155
2168
|
function resolveDuration(d, dir) {
|
|
2156
2169
|
if (d == null) return null;
|
|
2157
|
-
if (
|
|
2170
|
+
if (isNumber(d)) return d;
|
|
2158
2171
|
return d[dir];
|
|
2159
2172
|
}
|
|
2160
2173
|
function validateSlot(value) {
|
|
@@ -2471,9 +2484,14 @@ function TransitionGroup(props) {
|
|
|
2471
2484
|
const parentScope = getActiveScope();
|
|
2472
2485
|
const scope = createScope(parentScope);
|
|
2473
2486
|
let raw;
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2487
|
+
try {
|
|
2488
|
+
runWithScope(scope, () => {
|
|
2489
|
+
raw = childrenFn(item, index);
|
|
2490
|
+
});
|
|
2491
|
+
} catch (error4) {
|
|
2492
|
+
disposeScope(scope);
|
|
2493
|
+
throw error4;
|
|
2494
|
+
}
|
|
2477
2495
|
const { el, comp } = resolveItemElement(raw, wrapper);
|
|
2478
2496
|
if (!el) {
|
|
2479
2497
|
disposeScope(scope);
|