octane 0.1.51 → 0.2.1

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # What is octane?
2
2
 
3
- [![status: alpha](https://img.shields.io/badge/status-alpha-orange)](https://www.npmjs.com/package/octane)
3
+ [![status: beta](https://img.shields.io/badge/status-beta-yellow)](https://www.npmjs.com/package/octane)
4
4
  [![npm version](https://img.shields.io/npm/v/octane?logo=npm)](https://www.npmjs.com/package/octane)
5
5
  [![npm downloads](https://img.shields.io/npm/dm/octane?logo=npm&label=downloads)](https://www.npmjs.com/package/octane)
6
6
 
@@ -96,7 +96,8 @@ APIs. Features such as native `inert` may require a polyfill on older supported
96
96
  browsers. Validate text entry with the keyboards, languages, and browser or
97
97
  WebView versions your application supports.
98
98
 
99
- Octane is alpha software. It is ready to try, but not yet ready for production.
99
+ Octane is beta software. It is ready to build with, but its APIs may still
100
+ change before 1.0.
100
101
 
101
102
  ## License
102
103
 
@@ -686,13 +686,12 @@ function ensureTransitionSwapDriver() {
686
686
  }
687
687
  let ACTIVE_TRANSITION_ACTION_BATCH = null;
688
688
  let IN_FLIGHT_TRANSITION_ACTION_BATCH = null;
689
- let ACTIVE_DISCRETE_EVENT_DEPTH = 0;
690
689
  function createTransitionActionBatch() {
691
690
  return { updates: /* @__PURE__ */ new Map(), pendingActions: 0, closed: false, flushed: false };
692
691
  }
693
692
  function transitionActionBatchForUpdate() {
694
693
  if (ACTIVE_TRANSITION_ACTION_BATCH !== null) return ACTIVE_TRANSITION_ACTION_BATCH;
695
- if (syncFlush || ACTIVE_DISCRETE_EVENT_DEPTH > 0) return null;
694
+ if (syncFlush || _dispatchDepth > 0) return null;
696
695
  return IN_FLIGHT_TRANSITION_ACTION_BATCH;
697
696
  }
698
697
  function rebaseTransitionActionUpdate(update) {
@@ -2088,7 +2087,7 @@ function scheduleRender(block) {
2088
2087
  block.crossRenderUpdate = true;
2089
2088
  warnCrossComponentRenderUpdate(block, CURRENT_BLOCK);
2090
2089
  }
2091
- const mode = TRANSITION_DEPTH > 0 || renderPhaseSelf && block.currentRenderMode === "transition" || !syncFlush && ACTIVE_DISCRETE_EVENT_DEPTH === 0 && ASYNC_TRANSITION_COUNT > 0 ? "transition" : "urgent";
2090
+ const mode = TRANSITION_DEPTH > 0 || renderPhaseSelf && block.currentRenderMode === "transition" || !syncFlush && _dispatchDepth === 0 && ASYNC_TRANSITION_COUNT > 0 ? "transition" : "urgent";
2092
2091
  const deferred = DEFERRED_SPAWN || renderPhaseSelf && block.currentRenderDeferred;
2093
2092
  if (block.pending) {
2094
2093
  if (mode === "urgent") {
@@ -2900,6 +2899,11 @@ function queueRefDetach(ref, el) {
2900
2899
  target.push(ref, el, TEARDOWN_HANDLER, TEARDOWN_BLOCK);
2901
2900
  }
2902
2901
  function replaceRef(scope, previous, next, target) {
2902
+ if (TRANSITION_JOURNAL !== null) {
2903
+ journalBag();
2904
+ if (Object.prototype.hasOwnProperty.call(target, "_currentRef"))
2905
+ journalRootProperty(target, "_currentRef");
2906
+ }
2903
2907
  if (previous != null) queueRefDetach(previous, target);
2904
2908
  if (next != null) queueRefAttach(scope, next, target);
2905
2909
  return next;
@@ -4137,6 +4141,7 @@ function unmountSlot(val, detachDom) {
4137
4141
  const childDetach = k === "portalSlotSlot" ? true : detachDom;
4138
4142
  if (val.block) unmountBlock(val.block, childDetach);
4139
4143
  if (k === "portalSlotSlot" && val.target) {
4144
+ unregisterPortalEventRange(val.target, val);
4140
4145
  unregisterDelegationTarget(val.target);
4141
4146
  }
4142
4147
  }
@@ -9776,6 +9781,58 @@ function evtNu(d, fn, args) {
9776
9781
  }
9777
9782
  const _delegated = /* @__PURE__ */ new Set();
9778
9783
  const _delegationTargets = /* @__PURE__ */ new Map();
9784
+ const _portalEventRanges = /* @__PURE__ */ new WeakMap();
9785
+ let portalEventTargetCount = 0;
9786
+ const PORTAL_EVENT_PATH_LENGTH = /* @__PURE__ */ Symbol("octane.portalPathLength");
9787
+ const _eventRoots = /* @__PURE__ */ new WeakMap();
9788
+ let eventRootEpoch = 0;
9789
+ const EVENT_ROOT_EPOCH = /* @__PURE__ */ Symbol("octane.rootEpoch");
9790
+ function changeEventRootMembership(target, delta) {
9791
+ const previous = _eventRoots.get(target);
9792
+ _eventRoots.set(target, {
9793
+ count: (previous?.count || 0) + delta,
9794
+ since: ++eventRootEpoch,
9795
+ previous
9796
+ });
9797
+ if (previous !== void 0) {
9798
+ setTimeout(() => {
9799
+ const current = _eventRoots.get(target);
9800
+ if (current !== void 0) current.previous = void 0;
9801
+ }, 0);
9802
+ }
9803
+ }
9804
+ function isEventRoot(node, epoch) {
9805
+ let membership = _eventRoots.get(node);
9806
+ while (membership !== void 0 && membership.since > epoch) membership = membership.previous;
9807
+ return membership !== void 0 && membership.count > 0;
9808
+ }
9809
+ function prepareDelegatedEvent(event, listener) {
9810
+ const path = event.composedPath();
9811
+ if (_delegationTargets.size === 1) {
9812
+ event[EVENT_ROOT_EPOCH] = eventRootEpoch;
9813
+ if (portalEventTargetCount !== 0) {
9814
+ preparePortalEventOwners(path, eventRootEpoch);
9815
+ event[PORTAL_EVENT_PATH_LENGTH] = path.length;
9816
+ }
9817
+ return path;
9818
+ }
9819
+ for (let i = path.length - 1; i >= 0; i--) {
9820
+ if (_delegationTargets.has(path[i])) {
9821
+ if (path[i] === listener) {
9822
+ event[EVENT_ROOT_EPOCH] = eventRootEpoch;
9823
+ if (portalEventTargetCount !== 0) {
9824
+ preparePortalEventOwners(path, eventRootEpoch);
9825
+ event[PORTAL_EVENT_PATH_LENGTH] = path.length;
9826
+ }
9827
+ } else if (portalEventTargetCount !== 0 && path.length > (event[PORTAL_EVENT_PATH_LENGTH] || 0)) {
9828
+ preparePortalEventOwners(path, event[EVENT_ROOT_EPOCH] ?? eventRootEpoch);
9829
+ event[PORTAL_EVENT_PATH_LENGTH] = path.length;
9830
+ }
9831
+ break;
9832
+ }
9833
+ }
9834
+ return path;
9835
+ }
9779
9836
  const _delegatedCapture = /* @__PURE__ */ new Set();
9780
9837
  const EMULATED_BUBBLING_EVENTS = [
9781
9838
  "abort",
@@ -9850,11 +9907,19 @@ function delegateEvents(eventNames) {
9850
9907
  _delegated.add(name);
9851
9908
  if (canSeed) seedExpando(Element.prototype, "$$" + name);
9852
9909
  for (const target of _delegationTargets.keys()) {
9910
+ if (delegatedCapture(name) && _delegatedCapture.has(name)) continue;
9853
9911
  target.addEventListener(
9854
9912
  name,
9855
9913
  dispatchDelegated,
9856
9914
  delegatedListenerOptions(name, delegatedCapture(name))
9857
9915
  );
9916
+ if (!delegatedCapture(name)) {
9917
+ target.addEventListener(
9918
+ name,
9919
+ dispatchDelegatedCapture,
9920
+ delegatedListenerOptions(name, true)
9921
+ );
9922
+ }
9858
9923
  }
9859
9924
  }
9860
9925
  }
@@ -9866,12 +9931,18 @@ function delegateCaptureEvents(eventNames) {
9866
9931
  _delegatedCapture.add(name);
9867
9932
  if (canSeed) seedExpando(Element.prototype, CAPTURE_PREFIX + name);
9868
9933
  for (const target of _delegationTargets.keys()) {
9869
- target.addEventListener(name, dispatchDelegatedCapture, delegatedListenerOptions(name, true));
9934
+ if (_delegated.has(name)) continue;
9935
+ target.addEventListener(
9936
+ name,
9937
+ delegatedCapture(name) ? dispatchDelegated : dispatchDelegatedCapture,
9938
+ delegatedListenerOptions(name, true)
9939
+ );
9870
9940
  }
9871
9941
  }
9872
9942
  }
9873
- function registerDelegationTarget(target) {
9943
+ function registerDelegationTarget(target, root = false) {
9874
9944
  initDomOperations();
9945
+ if (root) changeEventRootMembership(target, 1);
9875
9946
  const prev = _delegationTargets.get(target) || 0;
9876
9947
  _delegationTargets.set(target, prev + 1);
9877
9948
  if (prev === 0) {
@@ -9884,22 +9955,40 @@ function registerDelegationTarget(target) {
9884
9955
  dispatchDelegated,
9885
9956
  delegatedListenerOptions(name, delegatedCapture(name))
9886
9957
  );
9958
+ if (!delegatedCapture(name)) {
9959
+ target.addEventListener(
9960
+ name,
9961
+ dispatchDelegatedCapture,
9962
+ delegatedListenerOptions(name, true)
9963
+ );
9964
+ }
9887
9965
  }
9888
9966
  for (const name of _delegatedCapture) {
9889
- target.addEventListener(name, dispatchDelegatedCapture, delegatedListenerOptions(name, true));
9967
+ if (_delegated.has(name)) continue;
9968
+ target.addEventListener(
9969
+ name,
9970
+ delegatedCapture(name) ? dispatchDelegated : dispatchDelegatedCapture,
9971
+ delegatedListenerOptions(name, true)
9972
+ );
9890
9973
  }
9891
9974
  }
9892
9975
  }
9893
- function unregisterDelegationTarget(target) {
9976
+ function unregisterDelegationTarget(target, root = false) {
9977
+ if (root) changeEventRootMembership(target, -1);
9894
9978
  const prev = _delegationTargets.get(target);
9895
9979
  if (!prev) return;
9896
9980
  if (prev === 1) {
9897
9981
  _delegationTargets.delete(target);
9898
9982
  for (const name of _delegated) {
9899
9983
  target.removeEventListener(name, dispatchDelegated, delegatedCapture(name));
9984
+ if (!delegatedCapture(name)) target.removeEventListener(name, dispatchDelegatedCapture, true);
9900
9985
  }
9901
9986
  for (const name of _delegatedCapture) {
9902
- target.removeEventListener(name, dispatchDelegatedCapture, true);
9987
+ target.removeEventListener(
9988
+ name,
9989
+ delegatedCapture(name) ? dispatchDelegated : dispatchDelegatedCapture,
9990
+ true
9991
+ );
9903
9992
  }
9904
9993
  } else {
9905
9994
  _delegationTargets.set(target, prev - 1);
@@ -9960,9 +10049,64 @@ const DISCRETE_EVENTS = /* @__PURE__ */ new Set([
9960
10049
  "volumechange"
9961
10050
  ]);
9962
10051
  let _dispatchDepth = 0;
9963
- const CAPTURE_FLUSH_FALLBACK = /* @__PURE__ */ Symbol("octane.capture.flushFallback");
9964
- const DELEGATED_DISPATCHED = /* @__PURE__ */ Symbol("octane.dispatched");
9965
- const CAPTURE_DISPATCHED = /* @__PURE__ */ Symbol("octane.dispatched.capture");
10052
+ const DELEGATED_BUBBLE_VERSION = /* @__PURE__ */ Symbol("octane.bubbleVersion");
10053
+ const PROPAGATION_FLAGS = /* @__PURE__ */ Symbol("octane.propagationFlags");
10054
+ const NATIVE_STOP_PROPAGATION = /* @__PURE__ */ Symbol("octane.stopPropagation");
10055
+ const NATIVE_STOP_IMMEDIATE = /* @__PURE__ */ Symbol("octane.stopImmediatePropagation");
10056
+ function stopDelegatedPropagation() {
10057
+ if (this[PROPAGATION_FLAGS] !== void 0) this[PROPAGATION_FLAGS] |= 1;
10058
+ const stop = this[NATIVE_STOP_PROPAGATION] || this.stopPropagation;
10059
+ (stop === stopDelegatedPropagation ? Event.prototype.stopPropagation : stop).call(this);
10060
+ }
10061
+ function stopImmediateNativePropagation() {
10062
+ if (this[PROPAGATION_FLAGS] !== void 0) this[PROPAGATION_FLAGS] |= 2;
10063
+ const stop = this[NATIVE_STOP_IMMEDIATE] || this.stopImmediatePropagation;
10064
+ (stop === stopImmediateNativePropagation ? Event.prototype.stopImmediatePropagation : stop).call(
10065
+ this
10066
+ );
10067
+ }
10068
+ const STOP_PROPAGATION_DESCRIPTOR = {
10069
+ configurable: true,
10070
+ writable: true,
10071
+ value: stopDelegatedPropagation
10072
+ };
10073
+ const STOP_IMMEDIATE_DESCRIPTOR = {
10074
+ configurable: true,
10075
+ writable: true,
10076
+ value: stopImmediateNativePropagation
10077
+ };
10078
+ function installPropagationMethod(event, name, previous, descriptor) {
10079
+ if (previous?.configurable === false) {
10080
+ if (previous.writable) Object.defineProperty(event, name, { value: descriptor.value });
10081
+ } else {
10082
+ Object.defineProperty(event, name, descriptor);
10083
+ }
10084
+ }
10085
+ function beginDelegatedPropagation(event, stop, immediate) {
10086
+ event[PROPAGATION_FLAGS] = 0;
10087
+ event[NATIVE_STOP_PROPAGATION] = event.stopPropagation;
10088
+ installPropagationMethod(event, "stopPropagation", stop, STOP_PROPAGATION_DESCRIPTOR);
10089
+ if (immediate !== null) {
10090
+ event[NATIVE_STOP_IMMEDIATE] = event.stopImmediatePropagation;
10091
+ installPropagationMethod(
10092
+ event,
10093
+ "stopImmediatePropagation",
10094
+ immediate,
10095
+ STOP_IMMEDIATE_DESCRIPTOR
10096
+ );
10097
+ }
10098
+ }
10099
+ function endDelegatedPropagation(event, stop, immediate) {
10100
+ if (stop === void 0) delete event.stopPropagation;
10101
+ else Object.defineProperty(event, "stopPropagation", stop);
10102
+ if (immediate !== null) {
10103
+ if (immediate === void 0) delete event.stopImmediatePropagation;
10104
+ else Object.defineProperty(event, "stopImmediatePropagation", immediate);
10105
+ delete event[NATIVE_STOP_IMMEDIATE];
10106
+ }
10107
+ delete event[PROPAGATION_FLAGS];
10108
+ delete event[NATIVE_STOP_PROPAGATION];
10109
+ }
9966
10110
  const CURRENT_TARGET_NODE = /* @__PURE__ */ Symbol("octane.currentTarget");
9967
10111
  const CURRENT_TARGET_DESCRIPTOR = {
9968
10112
  configurable: true,
@@ -9971,6 +10115,129 @@ const CURRENT_TARGET_DESCRIPTOR = {
9971
10115
  }
9972
10116
  };
9973
10117
  const CAPTURE_PATH = [];
10118
+ function resolvePortalEventOwner(node) {
10119
+ if (node.$$portalParent != null || node.parentNode === null) return;
10120
+ const target = node.parentNode;
10121
+ const ranges = _portalEventRanges.get(target);
10122
+ if (ranges === void 0) return;
10123
+ let owner;
10124
+ let previous = node.previousSibling;
10125
+ let remainingSkips = ranges.size;
10126
+ while (previous !== null) {
10127
+ const closedStart = previous.$$portalEventStart;
10128
+ const closedRange = closedStart?.$$portalEventRange;
10129
+ if (remainingSkips !== 0 && closedStart !== void 0 && closedRange !== void 0 && ranges.has(closedRange) && closedRange.start === closedStart && closedRange.end === previous && closedStart.parentNode === target) {
10130
+ remainingSkips--;
10131
+ previous = closedStart.previousSibling;
10132
+ continue;
10133
+ }
10134
+ const range = previous.$$portalEventRange;
10135
+ const end = range?.end;
10136
+ if (range !== void 0 && ranges.has(range) && range.start === previous && end != null && end.parentNode === target && (previous.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0 && (node.compareDocumentPosition(end) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0) {
10137
+ owner = range;
10138
+ break;
10139
+ }
10140
+ previous = previous.previousSibling;
10141
+ }
10142
+ if (owner === void 0) return;
10143
+ if (ROOT_RENDER_TRANSACTION !== null) {
10144
+ journalRootProperty(node, "$$portalParent");
10145
+ journalRootProperty(node, "$$portalContainer");
10146
+ }
10147
+ node.$$portalParent = owner.host;
10148
+ node.$$portalContainer = target;
10149
+ }
10150
+ function preparePortalEventOwners(path, epoch) {
10151
+ for (let i = 0; i < path.length; i++) {
10152
+ const node = eventPathNode(path[i]);
10153
+ if (node === null) continue;
10154
+ resolvePortalEventOwner(node);
10155
+ let logical = node.$$portalParent;
10156
+ while (logical != null && !isEventRoot(logical, epoch) && path.indexOf(logical) < 0) {
10157
+ resolvePortalEventOwner(logical);
10158
+ logical = logical.$$portalParent || logical.parentNode;
10159
+ }
10160
+ }
10161
+ }
10162
+ function eventPathNode(target) {
10163
+ return target != null && typeof target.nodeType === "number" ? target : null;
10164
+ }
10165
+ function buildDelegatedPath(event, listener, path = event.composedPath()) {
10166
+ const output = CAPTURE_PATH;
10167
+ const base = output.length;
10168
+ const epoch = event[EVENT_ROOT_EPOCH] ?? eventRootEpoch;
10169
+ const listenerIndex = path.indexOf(listener);
10170
+ if (listenerIndex < 0) return 0;
10171
+ if (_delegationTargets.size === 1 && epoch === eventRootEpoch && isEventRoot(listener, epoch)) {
10172
+ let i = 0;
10173
+ for (; i < listenerIndex; i++) {
10174
+ const node = eventPathNode(path[i]);
10175
+ if (node === null || node.$$portalParent != null) break;
10176
+ output.push(node);
10177
+ }
10178
+ if (i === listenerIndex) return output.length - base;
10179
+ output.length = base;
10180
+ }
10181
+ let start = eventPathNode(path[0]);
10182
+ if (start === null) return 0;
10183
+ let startIndex = 0;
10184
+ let rebaseRootAtStart = false;
10185
+ for (; ; ) {
10186
+ output.length = base;
10187
+ let node = start;
10188
+ let index = startIndex;
10189
+ let firstBoundary = null;
10190
+ let ownsBranch = false;
10191
+ let supersededByNearerPortal = false;
10192
+ while (node !== null) {
10193
+ if (isEventRoot(node, epoch) && !(node === start && rebaseRootAtStart)) {
10194
+ firstBoundary ??= node;
10195
+ if (node === listener) {
10196
+ if (firstBoundary === node) ownsBranch = true;
10197
+ else supersededByNearerPortal = true;
10198
+ }
10199
+ break;
10200
+ }
10201
+ output.push(node);
10202
+ const logicalParent = node.$$portalParent;
10203
+ if (logicalParent != null) {
10204
+ const container = node.$$portalContainer;
10205
+ if (container == null) {
10206
+ output.length = base;
10207
+ return 0;
10208
+ }
10209
+ firstBoundary ??= container;
10210
+ if (container === listener) {
10211
+ if (firstBoundary === container) ownsBranch = true;
10212
+ else supersededByNearerPortal = true;
10213
+ }
10214
+ node = logicalParent;
10215
+ index = path.indexOf(logicalParent);
10216
+ } else if (index >= 0) {
10217
+ node = eventPathNode(path[++index]);
10218
+ } else {
10219
+ node = node.parentNode;
10220
+ }
10221
+ }
10222
+ if (supersededByNearerPortal) {
10223
+ output.length = base;
10224
+ return 0;
10225
+ }
10226
+ if (ownsBranch) return output.length - base;
10227
+ if (firstBoundary === null) {
10228
+ output.length = base;
10229
+ return 0;
10230
+ }
10231
+ const boundaryIndex = path.indexOf(firstBoundary);
10232
+ if (boundaryIndex < startIndex || boundaryIndex >= listenerIndex || boundaryIndex === startIndex && rebaseRootAtStart) {
10233
+ output.length = base;
10234
+ return 0;
10235
+ }
10236
+ start = firstBoundary;
10237
+ startIndex = boundaryIndex;
10238
+ rebaseRootAtStart = true;
10239
+ }
10240
+ }
9974
10241
  function fireEventSlot(slot, event) {
9975
10242
  try {
9976
10243
  if (typeof slot === "function") {
@@ -10029,27 +10296,26 @@ function reportListenerError(err) {
10029
10296
  console.error(err);
10030
10297
  }
10031
10298
  function maybeFlushDiscrete(type) {
10032
- if (_dispatchDepth === 0 && DISCRETE_EVENTS.has(type)) {
10299
+ if (_dispatchDepth === 0 && DISCRETE_EVENTS.has(type) && pendingRestores.length > 0) {
10033
10300
  if (hasPendingWork()) {
10034
10301
  if (VIEW_TRANSITION_DRIVER?.queueAllTransition() === true) flush();
10035
10302
  else flushSync(noop);
10036
10303
  }
10037
- if (pendingRestores.length > 0) restoreControlledStates();
10304
+ restoreControlledStates();
10038
10305
  }
10039
10306
  if (type === "click") activationCheckable = null;
10040
10307
  }
10041
10308
  function finishCaptureDispatch(event) {
10042
10309
  const type = event.type;
10043
10310
  if (!event.bubbles || event.cancelBubble || !_delegated.has(type)) {
10044
- if (event.bubbles && _delegated.has(type) && event[DELEGATED_DISPATCHED] !== true)
10045
- maybeEnqueueRestore(event);
10311
+ if (event.bubbles && _delegated.has(type)) maybeEnqueueRestore(event);
10046
10312
  maybeFlushDiscrete(type);
10047
10313
  return;
10048
10314
  }
10049
- if (!DISCRETE_EVENTS.has(type) || event[CAPTURE_FLUSH_FALLBACK] === true) return;
10050
- event[CAPTURE_FLUSH_FALLBACK] = true;
10315
+ if (!DISCRETE_EVENTS.has(type)) return;
10316
+ const bubbleVersion = event[DELEGATED_BUBBLE_VERSION];
10051
10317
  const fallback = () => {
10052
- if (event[DELEGATED_DISPATCHED] !== true) {
10318
+ if (event[DELEGATED_BUBBLE_VERSION] === bubbleVersion) {
10053
10319
  maybeEnqueueRestore(event);
10054
10320
  maybeFlushDiscrete(type);
10055
10321
  }
@@ -10060,13 +10326,13 @@ function finishCaptureDispatch(event) {
10060
10326
  else queueMicrotask(fallback);
10061
10327
  }
10062
10328
  function dispatchDelegated(event) {
10063
- if (event[DELEGATED_DISPATCHED] === true) return;
10064
- event[DELEGATED_DISPATCHED] = true;
10329
+ if (delegatedCapture(event.type)) prepareDelegatedEvent(event, this);
10330
+ event[DELEGATED_BUBBLE_VERSION] = (event[DELEGATED_BUBBLE_VERSION] || 0) + 1;
10065
10331
  maybeEnqueueRestore(event);
10066
10332
  const key = "$$" + event.type;
10067
10333
  const targetOnly = TARGET_ONLY_DELEGATED.has(event.type);
10068
10334
  _dispatchDepth++;
10069
- let node = event.target;
10335
+ const node = event.target;
10070
10336
  const prevSubmitRec = ACTIVE_SUBMIT_DISPATCH;
10071
10337
  const submitRec = event.type === "submit" && node != null && node.nodeName === "FORM" ? {
10072
10338
  form: node,
@@ -10076,29 +10342,32 @@ function dispatchDelegated(event) {
10076
10342
  intercepted: false
10077
10343
  } : null;
10078
10344
  if (submitRec !== null) ACTIVE_SUBMIT_DISPATCH = submitRec;
10079
- const discrete = DISCRETE_EVENTS.has(event.type);
10080
- if (discrete) ACTIVE_DISCRETE_EVENT_DEPTH++;
10081
10345
  const nativeBatch = (0, import_native_read_events.beginNativeEventBatch)(event);
10346
+ const pathBase = CAPTURE_PATH.length;
10347
+ let stop;
10348
+ let propagationStarted = false;
10082
10349
  try {
10083
- if (delegatedCapture(event.type) && event[CAPTURE_DISPATCHED] !== true && _delegatedCapture.has(event.type)) {
10084
- dispatchDelegatedCapture(event);
10085
- if (event.cancelBubble) return;
10086
- }
10087
- while (node !== null && node !== void 0) {
10088
- const slot = node[key];
10350
+ if (delegatedCapture(event.type) && _delegatedCapture.has(event.type) && dispatchDelegatedCapture.call(this, event))
10351
+ return;
10352
+ if (!_delegated.has(event.type)) return;
10353
+ buildDelegatedPath(event, this);
10354
+ stop = Object.getOwnPropertyDescriptor(event, "stopPropagation");
10355
+ propagationStarted = true;
10356
+ beginDelegatedPropagation(event, stop, null);
10357
+ for (let i = pathBase; i < CAPTURE_PATH.length; i++) {
10358
+ const current = CAPTURE_PATH[i];
10359
+ if (targetOnly && current !== event.target) break;
10360
+ const slot = current[key];
10089
10361
  if (slot != null) {
10090
- setCurrentTarget(event, node);
10362
+ setCurrentTarget(event, current);
10091
10363
  fireEventSlot(slot, event);
10092
- if (event.cancelBubble) return;
10093
- }
10094
- if (targetOnly) return;
10095
- if (node.$$portalParent) {
10096
- node = node.$$portalParent;
10097
- } else {
10098
- node = node.parentNode;
10364
+ if ((event[PROPAGATION_FLAGS] & 1) !== 0) break;
10099
10365
  }
10366
+ if (targetOnly) break;
10100
10367
  }
10101
10368
  } finally {
10369
+ CAPTURE_PATH.length = pathBase;
10370
+ if (propagationStarted) endDelegatedPropagation(event, stop, null);
10102
10371
  if (submitRec !== null) {
10103
10372
  ACTIVE_SUBMIT_DISPATCH = prevSubmitRec;
10104
10373
  publishManualFormPending(submitRec);
@@ -10109,51 +10378,52 @@ function dispatchDelegated(event) {
10109
10378
  } catch (error) {
10110
10379
  reportListenerError(error);
10111
10380
  }
10112
- if (discrete) ACTIVE_DISCRETE_EVENT_DEPTH--;
10113
10381
  _dispatchDepth--;
10114
10382
  maybeFlushDiscrete(event.type);
10115
10383
  }
10116
10384
  }
10117
10385
  function dispatchDelegatedCapture(event) {
10118
- if (event[CAPTURE_DISPATCHED] === true) return;
10119
- event[CAPTURE_DISPATCHED] = true;
10386
+ const path = prepareDelegatedEvent(event, this);
10387
+ if (!_delegatedCapture.has(event.type)) return false;
10120
10388
  if (!event.bubbles || !_delegated.has(event.type)) maybeEnqueueRestore(event);
10121
10389
  const key = CAPTURE_PREFIX + event.type;
10122
10390
  const pathBase = CAPTURE_PATH.length;
10123
- for (let node = event.target; node !== null && node !== void 0; ) {
10124
- CAPTURE_PATH.push(node);
10125
- node = node.$$portalParent ? node.$$portalParent : node.parentNode;
10126
- }
10391
+ buildDelegatedPath(event, this, path);
10392
+ const stop = Object.getOwnPropertyDescriptor(event, "stopPropagation");
10393
+ const immediate = delegatedCapture(event.type) ? Object.getOwnPropertyDescriptor(event, "stopImmediatePropagation") : null;
10394
+ const wasCancelled = event.cancelBubble;
10395
+ let stopped = false;
10127
10396
  _dispatchDepth++;
10128
- const discrete = DISCRETE_EVENTS.has(event.type);
10129
- if (discrete) ACTIVE_DISCRETE_EVENT_DEPTH++;
10130
10397
  const nativeBatch = (0, import_native_read_events.beginNativeEventBatch)(event);
10131
10398
  try {
10399
+ beginDelegatedPropagation(event, stop, immediate);
10132
10400
  for (let i = CAPTURE_PATH.length - 1; i >= pathBase; i--) {
10133
10401
  const slot = CAPTURE_PATH[i][key];
10134
10402
  if (slot != null) {
10135
10403
  setCurrentTarget(event, CAPTURE_PATH[i]);
10136
10404
  fireEventSlot(slot, event);
10137
- if (event.cancelBubble) return;
10405
+ if ((event[PROPAGATION_FLAGS] & 1) !== 0) break;
10138
10406
  }
10139
10407
  }
10140
10408
  } finally {
10409
+ stopped = event[PROPAGATION_FLAGS] !== 0 || !wasCancelled && event.cancelBubble;
10141
10410
  CAPTURE_PATH.length = pathBase;
10411
+ endDelegatedPropagation(event, stop, immediate);
10142
10412
  clearCurrentTarget(event);
10143
10413
  try {
10144
10414
  (0, import_native_read_events.endNativeEventBatch)(
10145
10415
  event,
10146
10416
  nativeBatch,
10147
- event.bubbles && !event.cancelBubble && _delegated.has(event.type) && event[DELEGATED_DISPATCHED] !== true,
10417
+ event.bubbles && !event.cancelBubble && _delegated.has(event.type),
10148
10418
  reportListenerError
10149
10419
  );
10150
10420
  } catch (error) {
10151
10421
  reportListenerError(error);
10152
10422
  }
10153
- if (discrete) ACTIVE_DISCRETE_EVENT_DEPTH--;
10154
10423
  _dispatchDepth--;
10155
10424
  finishCaptureDispatch(event);
10156
10425
  }
10426
+ return stopped;
10157
10427
  }
10158
10428
  function noop() {
10159
10429
  }
@@ -10563,9 +10833,8 @@ function setValue(el, value) {
10563
10833
  const prev = ctrl.v;
10564
10834
  ctrl.v = value;
10565
10835
  if (process.env.NODE_ENV !== "production") queueDevFormDiagnostic(el, CURRENT_SCOPE ?? void 0);
10836
+ if (!(ctrl.composing && Object.is(prev, value)) && valueNeedsWrite(input, value)) input.value = s;
10566
10837
  if (input.defaultValue !== s) input.defaultValue = s;
10567
- if (ctrl.composing && Object.is(prev, value)) return;
10568
- if (valueNeedsWrite(input, value)) input.value = s;
10569
10838
  }
10570
10839
  function setCheckedState(input, value, ctrl) {
10571
10840
  const first = !ctrl.sawC;
@@ -11106,6 +11375,30 @@ function reassertControlledIn(form) {
11106
11375
  }
11107
11376
  }
11108
11377
  }
11378
+ function registerPortalEventRange(target, portal2) {
11379
+ let ranges = _portalEventRanges.get(target);
11380
+ if (ranges === void 0) {
11381
+ ranges = /* @__PURE__ */ new Set();
11382
+ _portalEventRanges.set(target, ranges);
11383
+ portalEventTargetCount++;
11384
+ }
11385
+ ranges.add(portal2);
11386
+ portal2.start.$$portalEventRange = portal2;
11387
+ portal2.end.$$portalEventStart = portal2.start;
11388
+ }
11389
+ function unregisterPortalEventRange(target, portal2) {
11390
+ const start = portal2.start;
11391
+ const end = portal2.end;
11392
+ if (start?.$$portalEventRange === portal2) delete start.$$portalEventRange;
11393
+ if (end?.$$portalEventStart === start) delete end.$$portalEventStart;
11394
+ const ranges = _portalEventRanges.get(target);
11395
+ if (ranges === void 0) return;
11396
+ ranges.delete(portal2);
11397
+ if (ranges.size === 0) {
11398
+ _portalEventRanges.delete(target);
11399
+ portalEventTargetCount--;
11400
+ }
11401
+ }
11109
11402
  function portal(parentScope, slotKey, target, body, props, host, env, fragmentOwners, fragmentAnchor) {
11110
11403
  const prev = parentScope.slots[slotKey];
11111
11404
  if (fragmentAnchor !== void 0 && fragmentOwners === void 0 && prev !== void 0 && prev.target === target) {
@@ -11312,12 +11605,21 @@ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, e
11312
11605
  if (typeof __OCTANE_PROFILE_ENABLED__ !== "undefined" && __OCTANE_PROFILE_ENABLED__) {
11313
11606
  (0, import_profiling.__profileTrackComponent)(block, profilePortalComponent(rawBody));
11314
11607
  }
11315
- state = { __kind: "portalSlotSlot", block, target, start, end };
11608
+ state = { __kind: "portalSlotSlot", block, target, host, start, end };
11609
+ registerPortalEventRange(target, state);
11316
11610
  activityPortalCreated?.(block);
11317
11611
  registerDelegationTarget(target);
11318
- if (ROOT_RENDER_TRANSACTION !== null) journalUndo(() => unregisterDelegationTarget(target));
11612
+ if (ROOT_RENDER_TRANSACTION !== null) {
11613
+ const created = state;
11614
+ journalUndo(() => {
11615
+ unregisterPortalEventRange(target, created);
11616
+ unregisterDelegationTarget(target);
11617
+ });
11618
+ }
11319
11619
  renderBlock(block);
11320
11620
  } else {
11621
+ if (state.host !== host) journalRootProperty(state, "host");
11622
+ state.host = host;
11321
11623
  if (state.block.body !== norm.body) journalRootProperty(state.block, "body");
11322
11624
  if (state.block.props !== norm.props) journalRootProperty(state.block, "props");
11323
11625
  if (state.block.extra !== env) journalRootProperty(state.block, "extra");
@@ -11333,6 +11635,7 @@ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, e
11333
11635
  if (state.interleavedFragment === void 0) {
11334
11636
  while (n !== null && n !== state.end) {
11335
11637
  n.$$portalParent = host;
11638
+ n.$$portalContainer = target;
11336
11639
  n = n.nextSibling;
11337
11640
  }
11338
11641
  } else {
@@ -11343,6 +11646,7 @@ function renderPortalState(prev, parentBlock, target, rawBody, rawProps, host, e
11343
11646
  continue;
11344
11647
  }
11345
11648
  n.$$portalParent = host;
11649
+ n.$$portalContainer = target;
11346
11650
  n = n.nextSibling;
11347
11651
  }
11348
11652
  }
@@ -11359,6 +11663,7 @@ function teardownPortalState(state) {
11359
11663
  state.block = null;
11360
11664
  }
11361
11665
  if (state.target) {
11666
+ unregisterPortalEventRange(state.target, state);
11362
11667
  unregisterDelegationTarget(state.target);
11363
11668
  state.target = null;
11364
11669
  }
@@ -19948,7 +20253,7 @@ function makeRoot(container, rootBlock, currentBody, currentKey, idState, output
19948
20253
  renderOwner.adopt = void 0;
19949
20254
  renderOwner.retryKey = null;
19950
20255
  renderOwner.transaction = null;
19951
- unregisterDelegationTarget(container);
20256
+ unregisterDelegationTarget(container, true);
19952
20257
  releaseRootContainer(container, ownerToken);
19953
20258
  }
19954
20259
  }
@@ -19968,7 +20273,7 @@ function createRootWithOutputHandler(container, options, outputHandler) {
19968
20273
  assertValidRootContainer(container);
19969
20274
  options = warnCreateRootElementOption(options);
19970
20275
  const ownerToken = claimRootContainer(container);
19971
- registerDelegationTarget(container);
20276
+ registerDelegationTarget(container, true);
19972
20277
  return makeRoot(
19973
20278
  container,
19974
20279
  null,
@@ -20023,7 +20328,7 @@ function hydrateRoot(container, bodyOrElement, propsOrOptions, rootOptions) {
20023
20328
  const nativeManifest = nativeSidecar === null ? void 0 : (0, import_native_read_seeds.parseNativeSignalManifest)(nativeSidecar.textContent || "");
20024
20329
  nativeSidecar?.remove();
20025
20330
  const ownerToken = claimRootContainer(container);
20026
- registerDelegationTarget(container);
20331
+ registerDelegationTarget(container, true);
20027
20332
  let rootBlock = createBlock(
20028
20333
  "root",
20029
20334
  null,
@@ -21,7 +21,7 @@ __export(version_exports, {
21
21
  version: () => version
22
22
  });
23
23
  module.exports = __toCommonJS(version_exports);
24
- const version = "0.1.51";
24
+ const version = "0.2.1";
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  version