@askrjs/askr 0.0.41 → 0.0.42

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/benchmark.js CHANGED
@@ -10,8 +10,8 @@ import { BenchmarkTable } from "./bench/components/benchmark-table.js";
10
10
  installRendererBridge();
11
11
  const benchmarkMetadata = {
12
12
  packageName: "@askrjs/askr",
13
- packageVersion: "0.0.41",
14
- buildLabel: "0.0.41-local"
13
+ packageVersion: "0.0.42",
14
+ buildLabel: "0.0.42-local"
15
15
  };
16
16
  function getBenchmarkMetadata() {
17
17
  return { ...benchmarkMetadata };
@@ -1221,6 +1221,7 @@ function resolveNestedComponentResult(result, snapshot, parentInstance) {
1221
1221
  const nestedSnapshot = getVNodeContextFrame(currentResult) ?? activeSnapshot;
1222
1222
  const nestedInstance = createComponentInstance(nextComponentInstanceId(), currentResult.type, currentResult.props ?? {}, null);
1223
1223
  nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);
1224
+ nestedInstance.parentInstance = parentInstance;
1224
1225
  nestedInstance.portalScope = parentInstance?.portalScope ?? nestedInstance.portalScope;
1225
1226
  inheritComponentCleanupStrict(nestedInstance);
1226
1227
  if (nestedSnapshot) nestedInstance.ownerFrame = nestedSnapshot;
@@ -1233,11 +1234,12 @@ function resolveNestedComponentResult(result, snapshot, parentInstance) {
1233
1234
  }
1234
1235
  return currentResult;
1235
1236
  }
1236
- function resolveHostNestedComponentResult(host, retainedInstance, result, snapshot) {
1237
+ function resolveHostNestedComponentResult(host, retainedInstance, result, snapshot, retainedHostInstances) {
1237
1238
  let currentResult = result;
1238
1239
  let activeSnapshot = snapshot;
1239
1240
  let depth = 0;
1240
1241
  const retainedInstances = new Set([retainedInstance]);
1242
+ if (retainedHostInstances) for (const instance of retainedHostInstances) retainedInstances.add(instance);
1241
1243
  const createdInstances = [];
1242
1244
  while (_isDOMElement(currentResult) && typeof currentResult.type === "function" && depth < 16) {
1243
1245
  const nestedSnapshot = getVNodeContextFrame(currentResult) ?? activeSnapshot;
@@ -1248,6 +1250,7 @@ function resolveHostNestedComponentResult(host, retainedInstance, result, snapsh
1248
1250
  }
1249
1251
  setVNodeComponentInstance(currentResult, nestedInstance);
1250
1252
  nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);
1253
+ nestedInstance.parentInstance = retainedInstance;
1251
1254
  nestedInstance.portalScope = retainedInstance.portalScope ?? nestedInstance.portalScope;
1252
1255
  inheritComponentCleanupStrict(nestedInstance);
1253
1256
  nestedInstance.props = (currentResult.props ?? {}) || {};
@@ -1262,7 +1265,9 @@ function resolveHostNestedComponentResult(host, retainedInstance, result, snapsh
1262
1265
  }
1263
1266
  const previousInstances = host.__ASKR_INSTANCES ?? [];
1264
1267
  for (const instance of previousInstances) if (!retainedInstances.has(instance)) cleanupComponent(instance);
1265
- host.__ASKR_INSTANCES = previousInstances.filter((instance) => retainedInstances.has(instance));
1268
+ const nextHostInstances = previousInstances.filter((instance) => retainedInstances.has(instance));
1269
+ for (const instance of retainedInstances) if (instance.target === host && !nextHostInstances.includes(instance)) nextHostInstances.push(instance);
1270
+ host.__ASKR_INSTANCES = nextHostInstances;
1266
1271
  host.__ASKR_INSTANCE = host.__ASKR_INSTANCES[0] ?? retainedInstance;
1267
1272
  for (const instance of createdInstances) mountInstanceInline(instance, host);
1268
1273
  return currentResult;
@@ -1276,6 +1281,7 @@ function resolveWrapperHostResult(host, result, snapshot) {
1276
1281
  const nestedInstance = findHostInstanceByType(host, currentResult.type);
1277
1282
  if (!nestedInstance) break;
1278
1283
  nestedInstance.props = (currentResult.props ?? {}) || {};
1284
+ nestedInstance.parentInstance = getCurrentInstance();
1279
1285
  nestedInstance.isRoot = isRouteRootComponentVNode(currentResult);
1280
1286
  nestedInstance.portalScope = getCurrentInstance()?.portalScope ?? nestedInstance.portalScope;
1281
1287
  inheritComponentCleanupStrict(nestedInstance);
@@ -1301,7 +1307,7 @@ function normalizeComponentChildren(result) {
1301
1307
  }
1302
1308
  return [result];
1303
1309
  }
1304
- function syncComponentElement(currentDom, node, type, props, parentNamespace, forceChildrenUpdate = false) {
1310
+ function syncComponentElement(currentDom, node, type, props, parentNamespace, forceChildrenUpdate = false, retainedHostInstances) {
1305
1311
  const existingHost = currentDom instanceof Element ? currentDom : null;
1306
1312
  const existingInstance = existingHost ? findHostInstanceByType(existingHost, type) : null;
1307
1313
  if (!existingHost) return null;
@@ -1326,7 +1332,7 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace, fo
1326
1332
  warnUnusedStateReads(hydrationInstance);
1327
1333
  return existingHost;
1328
1334
  }
1329
- const resolvedResult = resolveHostNestedComponentResult(existingHost, hydrationInstance, scopedResult, snapshot ?? null);
1335
+ const resolvedResult = resolveHostNestedComponentResult(existingHost, hydrationInstance, scopedResult, snapshot ?? null, retainedHostInstances);
1330
1336
  if (_isDOMElement(resolvedResult) && typeof resolvedResult.type === "string" && tagNamesEqualIgnoreCase(existingHost.tagName, resolvedResult.type)) {
1331
1337
  withContext(snapshot, () => {
1332
1338
  updateElementFromVnode(existingHost, inheritComponentKey(resolvedResult, node), true, forceChildrenUpdate || hydrationInstance.mounted === false);
@@ -1368,7 +1374,7 @@ function syncComponentElement(currentDom, node, type, props, parentNamespace, fo
1368
1374
  warnUnusedStateReads(existingInstance);
1369
1375
  return existingHost;
1370
1376
  }
1371
- const resolvedResult = resolveHostNestedComponentResult(existingHost, existingInstance, scopedResult, snapshot ?? null);
1377
+ const resolvedResult = resolveHostNestedComponentResult(existingHost, existingInstance, scopedResult, snapshot ?? null, retainedHostInstances);
1372
1378
  if (_isDOMElement(resolvedResult) && typeof resolvedResult.type === "string" && tagNamesEqualIgnoreCase(existingHost.tagName, resolvedResult.type)) {
1373
1379
  withContext(snapshot, () => {
1374
1380
  updateElementFromVnode(existingHost, inheritComponentKey(resolvedResult, node), true, forceChildrenUpdate || existingInstance.mounted === false);
@@ -1403,6 +1409,7 @@ function createComponentElement(node, type, props, parentNamespace) {
1403
1409
  setVNodeComponentInstance(node, childInstance);
1404
1410
  }
1405
1411
  childInstance.portalScope = getCurrentInstance()?.portalScope ?? childInstance.portalScope;
1412
+ childInstance.parentInstance = getCurrentInstance();
1406
1413
  childInstance.props = props || {};
1407
1414
  childInstance.isRoot = isRouteRootComponentVNode(node);
1408
1415
  inheritComponentCleanupStrict(childInstance);