@lytjs/component 6.7.0 → 6.8.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/dist/index.cjs +76 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +841 -0
- package/dist/index.d.ts +841 -0
- package/dist/index.mjs +73 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -1322,6 +1322,73 @@ function abortSuspense(boundary) {
|
|
|
1322
1322
|
boundary.onPending.length = 0;
|
|
1323
1323
|
boundary.onError.length = 0;
|
|
1324
1324
|
}
|
|
1325
|
+
function useSuspense(promise, _key) {
|
|
1326
|
+
const instance = getCurrentInstance();
|
|
1327
|
+
if (!instance) {
|
|
1328
|
+
throw new Error("useSuspense must be called within a component setup function");
|
|
1329
|
+
}
|
|
1330
|
+
let boundary = findNearestSuspenseBoundary(instance);
|
|
1331
|
+
if (!boundary) {
|
|
1332
|
+
boundary = createSuspenseBoundary();
|
|
1333
|
+
}
|
|
1334
|
+
registerAsyncChild(boundary, promise);
|
|
1335
|
+
return void 0;
|
|
1336
|
+
}
|
|
1337
|
+
function findNearestSuspenseBoundary(instance) {
|
|
1338
|
+
let current = instance;
|
|
1339
|
+
while (current) {
|
|
1340
|
+
if (current.type === Suspense) {
|
|
1341
|
+
const setupState = current.setupState;
|
|
1342
|
+
if (setupState?.boundary) {
|
|
1343
|
+
return setupState.boundary;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
current = current.parent;
|
|
1347
|
+
}
|
|
1348
|
+
return null;
|
|
1349
|
+
}
|
|
1350
|
+
function startTransition(callback) {
|
|
1351
|
+
try {
|
|
1352
|
+
callback();
|
|
1353
|
+
} finally {
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
var SuspenseResource = class {
|
|
1357
|
+
constructor(factory) {
|
|
1358
|
+
this.status = "pending";
|
|
1359
|
+
this.value = null;
|
|
1360
|
+
this.error = null;
|
|
1361
|
+
this.promise = null;
|
|
1362
|
+
this.load(factory);
|
|
1363
|
+
}
|
|
1364
|
+
load(factory) {
|
|
1365
|
+
this.status = "pending";
|
|
1366
|
+
this.promise = factory().then((result) => {
|
|
1367
|
+
this.value = result;
|
|
1368
|
+
this.status = "success";
|
|
1369
|
+
return result;
|
|
1370
|
+
}).catch((err) => {
|
|
1371
|
+
this.error = err instanceof Error ? err : new Error(String(err));
|
|
1372
|
+
this.status = "error";
|
|
1373
|
+
throw this.error;
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
read() {
|
|
1377
|
+
if (this.status === "success") {
|
|
1378
|
+
return this.value;
|
|
1379
|
+
}
|
|
1380
|
+
if (this.status === "error") {
|
|
1381
|
+
throw this.error;
|
|
1382
|
+
}
|
|
1383
|
+
throw this.promise;
|
|
1384
|
+
}
|
|
1385
|
+
refresh(factory) {
|
|
1386
|
+
this.load(factory);
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1389
|
+
function createSuspenseResource(factory) {
|
|
1390
|
+
return new SuspenseResource(factory);
|
|
1391
|
+
}
|
|
1325
1392
|
|
|
1326
1393
|
// src/transition.ts
|
|
1327
1394
|
var Transition = {
|
|
@@ -1757,7 +1824,11 @@ function inject2(key, options) {
|
|
|
1757
1824
|
const actualKey = isInjectionToken(key) ? key.__token : key;
|
|
1758
1825
|
const lookupKey = actualKey;
|
|
1759
1826
|
if (instance) {
|
|
1760
|
-
const result = injectFromInstance(
|
|
1827
|
+
const result = injectFromInstance(
|
|
1828
|
+
instance,
|
|
1829
|
+
lookupKey,
|
|
1830
|
+
options
|
|
1831
|
+
);
|
|
1761
1832
|
if (result !== void 0) {
|
|
1762
1833
|
return result;
|
|
1763
1834
|
}
|
|
@@ -1868,6 +1939,7 @@ exports.InjectionToken = InjectionToken;
|
|
|
1868
1939
|
exports.KeepAlive = KeepAlive;
|
|
1869
1940
|
exports.PUBLIC_PROPERTIES_MAP = PUBLIC_PROPERTIES_MAP;
|
|
1870
1941
|
exports.Suspense = Suspense;
|
|
1942
|
+
exports.SuspenseResource = SuspenseResource;
|
|
1871
1943
|
exports.Teleport = Teleport;
|
|
1872
1944
|
exports.Transition = Transition;
|
|
1873
1945
|
exports.TransitionGroup = TransitionGroup;
|
|
@@ -1888,6 +1960,7 @@ exports.createKeepAliveInstance = createKeepAliveInstance;
|
|
|
1888
1960
|
exports.createSignalState = createSignalState;
|
|
1889
1961
|
exports.createSuspenseBoundary = createSuspenseBoundary;
|
|
1890
1962
|
exports.createSuspenseInstance = createSuspenseInstance;
|
|
1963
|
+
exports.createSuspenseResource = createSuspenseResource;
|
|
1891
1964
|
exports.deactivateInstance = deactivateInstance;
|
|
1892
1965
|
exports.defineAsyncComponent = defineAsyncComponent;
|
|
1893
1966
|
exports.defineComponent = defineComponent;
|
|
@@ -1939,6 +2012,8 @@ exports.resolvePropValue = resolvePropValue;
|
|
|
1939
2012
|
exports.resolveSuspense = resolveSuspense;
|
|
1940
2013
|
exports.setCurrentInstance = setCurrentInstance;
|
|
1941
2014
|
exports.setupComponent = setupComponent;
|
|
2015
|
+
exports.startTransition = startTransition;
|
|
2016
|
+
exports.useSuspense = useSuspense;
|
|
1942
2017
|
exports.validateType = validateType;
|
|
1943
2018
|
exports.withProviderScope = withProviderScope;
|
|
1944
2019
|
//# sourceMappingURL=index.cjs.map
|