@burger-editor/local 4.0.0-alpha.55 → 4.0.0-alpha.57

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/client.js CHANGED
@@ -1296,7 +1296,7 @@ var style$b = "/* No Styling */\n";
1296
1296
  var template$b = "<a href=\"\" data-kind=\"primary\" data-before-icon=\"none\" data-after-icon=\"none\" data-bge=\"link:href, target:target, kind:data-kind, before-icon:data-before-icon, after-icon:data-after-icon\">\n\t<div>\n\t\t<span data-bge=\"text\">ボタン</span>\n\t\t<span data-bge=\"subtext\">サブテキスト</span>\n\t</div>\n</a>\n";
1297
1297
 
1298
1298
  var button = createItem$1({
1299
- version: "4.0.0-alpha.54",
1299
+ version: "4.0.0-alpha.56",
1300
1300
  name: "button",
1301
1301
  template: template$b,
1302
1302
  style: style$b,
@@ -1352,7 +1352,7 @@ var style$a = "/* No Styling */\n";
1352
1352
  var template$a = "<details data-bge=\"open:open\">\n\t<summary data-bge=\"summary\">折りたたみコンテンツ</summary>\n\t<div data-bge=\"content\"><p>内容を入力してください</p></div>\n</details>\n";
1353
1353
 
1354
1354
  var details = createItem$1({
1355
- version: "4.0.0-alpha.54",
1355
+ version: "4.0.0-alpha.56",
1356
1356
  name: "details",
1357
1357
  template: template$a,
1358
1358
  style: style$a,
@@ -1366,7 +1366,7 @@ var style$9 = "[data-bgi='download-file'] {\n\t[data-bge*='size'] {\n\t\t&::befo
1366
1366
  var template$9 = "<a href=\"./files/bgeditor/bg-sample.pdf\" target=\"_blank\" data-bge=\"path:href, download:download\">\n\t<div>\n\t\t<span data-bge=\"name\">サンプルダウンロードファイル</span>\n\t\t<span data-bge=\"formated-size, size:data-size\" data-size=\"138158\">134.92kB</span>\n\t</div>\n</a>\n";
1367
1367
 
1368
1368
  var downloadFile = createItem$1({
1369
- version: "4.0.0-alpha.54",
1369
+ version: "4.0.0-alpha.56",
1370
1370
  name: "download-file",
1371
1371
  template: template$9,
1372
1372
  style: style$9,
@@ -1405,7 +1405,7 @@ var style$8 = "[data-bgi='google-maps'] {\n\tdiv {\n\t\tinline-size: 100%;\n\t\t
1405
1405
  var template$8 = "<div data-lat=\"35.681382\" data-lng=\"139.766084\" data-zoom=\"16\" data-bge=\"lat:data-lat, lng:data-lng, zoom:data-zoom\">\n\t<img data-bge=\"img:src\" src=\"https://maps.google.com/maps/api/staticmap?center=35.681382,139.766084&amp;zoom=16&amp;size=640x400&amp;markers=color:red|color:red|35.681382,139.766084&amp;scale=2&amp;key=%googleMapsApiKey%\" width=\"8\" height=\"5\" alt=\"Google Maps\" />\n</div>\n<a href=\"https://maps.apple.com/?q=35.681382,139.766084\" data-bge=\"url:href\" target=\"_blank\"><span>アプリで開く</span></a>\n";
1406
1406
 
1407
1407
  var googleMaps = createItem$1({
1408
- version: "4.0.0-alpha.54",
1408
+ version: "4.0.0-alpha.56",
1409
1409
  name: "google-maps",
1410
1410
  template: template$8,
1411
1411
  style: style$8,
@@ -1540,7 +1540,7 @@ var style$7 = "[data-bgi='hr'] {\n\t--inline-size: 100%;\n\t--border-color: #000
1540
1540
  var template$7 = "<div data-bgi-hr-kind=\"primary\" data-bge=\"kind:data-bgi-hr-kind\">\n\t<hr />\n</div>\n";
1541
1541
 
1542
1542
  var hr = createItem$1({
1543
- version: "4.0.0-alpha.54",
1543
+ version: "4.0.0-alpha.56",
1544
1544
  name: "hr",
1545
1545
  template: template$7,
1546
1546
  style: style$7,
@@ -1630,7 +1630,7 @@ function createWidthState() {
1630
1630
 
1631
1631
  const ORIGIN = "__org";
1632
1632
  var image = createItem$1({
1633
- version: "4.0.0-alpha.54",
1633
+ version: "4.0.0-alpha.56",
1634
1634
  name: "image",
1635
1635
  template: template$6,
1636
1636
  style: style$6,
@@ -1828,7 +1828,7 @@ var style$5 = "[data-bgi='import'] {\n\tbge-import {\n\t\t&::before {\n\t\t\tfon
1828
1828
  var template$5 = "<bge-import data-bge=\":src\" src=\"\"></bge-import>\n";
1829
1829
 
1830
1830
  var importItem = createItem$1({
1831
- version: "4.0.0-alpha.54",
1831
+ version: "4.0.0-alpha.56",
1832
1832
  name: "import",
1833
1833
  template: template$5,
1834
1834
  style: style$5,
@@ -1842,7 +1842,7 @@ var style$4 = "/* No Styling */\n";
1842
1842
  var template$4 = "<div data-bge=\":scrollable\" data-bge-scrollable=\"false\">\n\t<table>\n\t\t<caption data-bge=\"caption\">\n\t\t\tキャプションを入力してください\n\t\t</caption>\n\t\t<tbody data-bge-list>\n\t\t\t<tr>\n\t\t\t\t<th data-bge=\"th\">表組の見出し</th>\n\t\t\t\t<td data-bge=\"td\">表組の内容を入力してください</td>\n\t\t\t</tr>\n\t\t</tbody>\n\t</table>\n</div>\n";
1843
1843
 
1844
1844
  var table = createItem$1({
1845
- version: "4.0.0-alpha.54",
1845
+ version: "4.0.0-alpha.56",
1846
1846
  name: "table",
1847
1847
  template: template$4,
1848
1848
  style: style$4,
@@ -1870,7 +1870,7 @@ var style$3 = "/* No Styling */\n";
1870
1870
  var template$3 = "<h2 data-bge=\"title-h2\">見出しを入力してください</h2>\n";
1871
1871
 
1872
1872
  var titleH2 = createItem$1({
1873
- version: "4.0.0-alpha.54",
1873
+ version: "4.0.0-alpha.56",
1874
1874
  name: "title-h2",
1875
1875
  template: template$3,
1876
1876
  style: style$3,
@@ -1884,7 +1884,7 @@ var style$2 = "/* No Styling */\n";
1884
1884
  var template$2 = "<h3 data-bge=\"title-h3\">見出しを入力してください</h3>\n";
1885
1885
 
1886
1886
  var titleH3 = createItem$1({
1887
- version: "4.0.0-alpha.54",
1887
+ version: "4.0.0-alpha.56",
1888
1888
  name: "title-h3",
1889
1889
  template: template$2,
1890
1890
  style: style$2,
@@ -1898,7 +1898,7 @@ var style$1 = "/* No Styling */\n";
1898
1898
  var template$1 = "<div data-bge=\"wysiwyg\"><p>本文を入力してください</p></div>\n";
1899
1899
 
1900
1900
  var wysiwyg = createItem$1({
1901
- version: "4.0.0-alpha.54",
1901
+ version: "4.0.0-alpha.56",
1902
1902
  name: "wysiwyg",
1903
1903
  template: template$1,
1904
1904
  style: style$1,
@@ -1913,7 +1913,7 @@ var template = "<div data-id=\"3KtWfp0UopM\" data-title=\"YouTube動画\" data-w
1913
1913
 
1914
1914
  const FALLBACK_TITLE = "YouTube\u52D5\u753B";
1915
1915
  var youtube = createItem$1({
1916
- version: "4.0.0-alpha.54",
1916
+ version: "4.0.0-alpha.56",
1917
1917
  name: "youtube",
1918
1918
  template,
1919
1919
  style: style$c,
@@ -4220,6 +4220,10 @@ function set$1(el, prefix, name, datum, xssSanitize = true) {
4220
4220
  el.removeAttribute(name);
4221
4221
  return;
4222
4222
  }
4223
+ if (el.localName.includes("-")) {
4224
+ el.setAttribute(name, `${datum}`);
4225
+ return;
4226
+ }
4223
4227
  if (!name.startsWith("data-") && !propInElement(el, name)) {
4224
4228
  const dataAttr = `data-${prefix}-${kebabCase(name)}`;
4225
4229
  if (el.hasAttribute(dataAttr)) {
@@ -11960,6 +11964,27 @@ class Transform {
11960
11964
  return this.steps.length > 0;
11961
11965
  }
11962
11966
  /**
11967
+ Return a single range, in post-transform document positions,
11968
+ that covers all content changed by this transform. Returns null
11969
+ if no replacements are made. Note that this will ignore changes
11970
+ that add/remove marks without replacing the underlying content.
11971
+ */
11972
+ changedRange() {
11973
+ let from2 = 1e9, to = -1e9;
11974
+ for (let i = 0; i < this.mapping.maps.length; i++) {
11975
+ let map2 = this.mapping.maps[i];
11976
+ if (i) {
11977
+ from2 = map2.map(from2, 1);
11978
+ to = map2.map(to, -1);
11979
+ }
11980
+ map2.forEach((_f, _t, fromB, toB) => {
11981
+ from2 = Math.min(from2, fromB);
11982
+ to = Math.max(to, toB);
11983
+ });
11984
+ }
11985
+ return from2 == 1e9 ? null : { from: from2, to };
11986
+ }
11987
+ /**
11963
11988
  @internal
11964
11989
  */
11965
11990
  addStep(step, doc2) {
@@ -19576,8 +19601,12 @@ var focus = (position = null, options = {}) => ({ editor, view, tr: tr2, dispatc
19576
19601
  }
19577
19602
  });
19578
19603
  };
19579
- if (view.hasFocus() && position === null || position === false) {
19580
- return true;
19604
+ try {
19605
+ if (view.hasFocus() && position === null || position === false) {
19606
+ return true;
19607
+ }
19608
+ } catch {
19609
+ return false;
19581
19610
  }
19582
19611
  if (dispatch && position === null && !isTextSelection(editor.state.selection)) {
19583
19612
  delayedFocus();
@@ -22864,19 +22893,20 @@ var NodePos = class _NodePos {
22864
22893
  this.node.content.forEach((node, offset) => {
22865
22894
  const isBlock = node.isBlock && !node.isTextblock;
22866
22895
  const isNonTextAtom = node.isAtom && !node.isText;
22896
+ const isInline2 = node.isInline;
22867
22897
  const targetPos = this.pos + offset + (isNonTextAtom ? 0 : 1);
22868
22898
  if (targetPos < 0 || targetPos > this.resolvedPos.doc.nodeSize - 2) {
22869
22899
  return;
22870
22900
  }
22871
22901
  const $pos = this.resolvedPos.doc.resolve(targetPos);
22872
- if (!isBlock && $pos.depth <= this.depth) {
22902
+ if (!isBlock && !isInline2 && $pos.depth <= this.depth) {
22873
22903
  return;
22874
22904
  }
22875
- const childNodePos = new _NodePos($pos, this.editor, isBlock, isBlock ? node : null);
22905
+ const childNodePos = new _NodePos($pos, this.editor, isBlock, isBlock || isInline2 ? node : null);
22876
22906
  if (isBlock) {
22877
22907
  childNodePos.actualDepth = this.depth + 1;
22878
22908
  }
22879
- children.push(new _NodePos($pos, this.editor, isBlock, isBlock ? node : null));
22909
+ children.push(childNodePos);
22880
22910
  });
22881
22911
  return children;
22882
22912
  }
@@ -23839,7 +23869,8 @@ var ResizableNodeView = class {
23839
23869
  return this.container;
23840
23870
  }
23841
23871
  get contentDOM() {
23842
- return this.contentElement;
23872
+ var _a2;
23873
+ return (_a2 = this.contentElement) != null ? _a2 : null;
23843
23874
  }
23844
23875
  handleEditorUpdate() {
23845
23876
  const isEditable = this.editor.isEditable;
@@ -27370,11 +27401,13 @@ var ListItem = Node3.create({
27370
27401
  node,
27371
27402
  h2,
27372
27403
  (context) => {
27404
+ var _a2, _b;
27373
27405
  if (context.parentType === "bulletList") {
27374
27406
  return "- ";
27375
27407
  }
27376
27408
  if (context.parentType === "orderedList") {
27377
- return `${context.index + 1}. `;
27409
+ const start = ((_b = (_a2 = context.meta) == null ? void 0 : _a2.parentAttrs) == null ? void 0 : _b.start) || 1;
27410
+ return `${start + context.index}. `;
27378
27411
  }
27379
27412
  return "- ";
27380
27413
  },
@@ -28240,6 +28273,8 @@ Extension.create({
28240
28273
  return extensions;
28241
28274
  }
28242
28275
  });
28276
+ var EMPTY_PARAGRAPH_MARKDOWN = "&nbsp;";
28277
+ var NBSP_CHAR = " ";
28243
28278
  var Paragraph = Node3.create({
28244
28279
  name: "paragraph",
28245
28280
  priority: 1e3,
@@ -28261,18 +28296,21 @@ var Paragraph = Node3.create({
28261
28296
  if (tokens.length === 1 && tokens[0].type === "image") {
28262
28297
  return helpers.parseChildren([tokens[0]]);
28263
28298
  }
28264
- return helpers.createNode(
28265
- "paragraph",
28266
- void 0,
28267
- // no attributes for paragraph
28268
- helpers.parseInline(tokens)
28269
- );
28299
+ const content = helpers.parseInline(tokens);
28300
+ if (content.length === 1 && content[0].type === "text" && (content[0].text === EMPTY_PARAGRAPH_MARKDOWN || content[0].text === NBSP_CHAR)) {
28301
+ return helpers.createNode("paragraph", void 0, []);
28302
+ }
28303
+ return helpers.createNode("paragraph", void 0, content);
28270
28304
  },
28271
28305
  renderMarkdown: (node, h2) => {
28272
- if (!node || !Array.isArray(node.content)) {
28306
+ if (!node) {
28273
28307
  return "";
28274
28308
  }
28275
- return h2.renderChildren(node.content);
28309
+ const content = Array.isArray(node.content) ? node.content : [];
28310
+ if (content.length === 0) {
28311
+ return EMPTY_PARAGRAPH_MARKDOWN;
28312
+ }
28313
+ return h2.renderChildren(content);
28276
28314
  },
28277
28315
  addCommands() {
28278
28316
  return {
@@ -29496,12 +29534,17 @@ var Gapcursor = Extension.create({
29496
29534
  };
29497
29535
  }
29498
29536
  });
29537
+ var DEFAULT_DATA_ATTRIBUTE = "placeholder";
29538
+ function preparePlaceholderAttribute(attr) {
29539
+ return attr.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
29540
+ }
29499
29541
  Extension.create({
29500
29542
  name: "placeholder",
29501
29543
  addOptions() {
29502
29544
  return {
29503
29545
  emptyEditorClass: "is-editor-empty",
29504
29546
  emptyNodeClass: "is-empty",
29547
+ dataAttribute: DEFAULT_DATA_ATTRIBUTE,
29505
29548
  placeholder: "Write something …",
29506
29549
  showOnlyWhenEditable: true,
29507
29550
  showOnlyCurrent: true,
@@ -29509,6 +29552,7 @@ Extension.create({
29509
29552
  };
29510
29553
  },
29511
29554
  addProseMirrorPlugins() {
29555
+ const dataAttribute = this.options.dataAttribute ? `data-${preparePlaceholderAttribute(this.options.dataAttribute)}` : `data-${DEFAULT_DATA_ATTRIBUTE}`;
29512
29556
  return [
29513
29557
  new Plugin({
29514
29558
  key: new PluginKey("placeholder"),
@@ -29531,7 +29575,7 @@ Extension.create({
29531
29575
  }
29532
29576
  const decoration = Decoration.node(pos, pos + node.nodeSize, {
29533
29577
  class: classes.join(" "),
29534
- "data-placeholder": typeof this.options.placeholder === "function" ? this.options.placeholder({
29578
+ [dataAttribute]: typeof this.options.placeholder === "function" ? this.options.placeholder({
29535
29579
  editor: this.editor,
29536
29580
  node,
29537
29581
  pos,
@@ -33235,7 +33279,8 @@ activateTextOnlyMode_fn = function() {
33235
33279
  if (!__privateGet$1(this, _textOnlyContainer)) {
33236
33280
  __privateSet$1(this, _textOnlyContainer, document.createElement("div"));
33237
33281
  __privateGet$1(this, _textOnlyContainer).dataset.textOnlyEditor = "";
33238
- this.shadowRoot.querySelector("[data-bge-mode]").append(__privateGet$1(this, _textOnlyContainer));
33282
+ const modeContainer = this.shadowRoot.querySelector("[data-bge-mode]");
33283
+ modeContainer.insertBefore(__privateGet$1(this, _textOnlyContainer), __privateGet$1(this, _structureChangeMessage));
33239
33284
  }
33240
33285
  const textOnlyStyle = document.createElement("style");
33241
33286
  textOnlyStyle.dataset.textOnlyStyle = "";
@@ -33535,6 +33580,16 @@ const _BgeWysiwygEditorElement = class _BgeWysiwygEditorElement2 extends HTMLEle
33535
33580
  updateButtonState(button, event2.detail.state, this);
33536
33581
  }
33537
33582
  });
33583
+ __privateGet(this, _wysiwygElement).addEventListener("bge:structure-change", () => {
33584
+ const currentState = getCurrentEditorState(__privateGet(this, _wysiwygElement));
33585
+ for (const button of buttons) {
33586
+ updateButtonState(button, currentState, this);
33587
+ }
33588
+ });
33589
+ const initialState = getCurrentEditorState(__privateGet(this, _wysiwygElement));
33590
+ for (const button of buttons) {
33591
+ updateButtonState(button, initialState, this);
33592
+ }
33538
33593
  if (_BgeWysiwygEditorElement2.experimentalTextOnlyMode) {
33539
33594
  const modeSelector = this.querySelector(
33540
33595
  "[data-bge-mode-selector]"
@@ -33543,23 +33598,23 @@ const _BgeWysiwygEditorElement = class _BgeWysiwygEditorElement2 extends HTMLEle
33543
33598
  throw new Error("Mode selector not found");
33544
33599
  }
33545
33600
  modeSelector.value = __privateGet(this, _wysiwygElement).mode;
33546
- const initialHasStructureChange = __privateGet(this, _wysiwygElement).hasStructureChange;
33547
33601
  const wysiwygOption = modeSelector.querySelector(
33548
33602
  'option[value="wysiwyg"]'
33549
33603
  );
33550
- if (wysiwygOption) {
33551
- wysiwygOption.disabled = initialHasStructureChange;
33552
- }
33553
33604
  const handleStructureChange = (event2) => {
33554
33605
  const hasStructureChange = event2.detail.hasStructureChange;
33555
33606
  if (wysiwygOption) {
33556
33607
  wysiwygOption.disabled = hasStructureChange;
33557
33608
  }
33609
+ modeSelector.value = __privateGet(this, _wysiwygElement).mode;
33558
33610
  };
33559
33611
  __privateGet(this, _wysiwygElement).addEventListener(
33560
33612
  "bge:structure-change",
33561
33613
  handleStructureChange
33562
33614
  );
33615
+ if (wysiwygOption) {
33616
+ wysiwygOption.disabled = __privateGet(this, _wysiwygElement).hasStructureChange;
33617
+ }
33563
33618
  modeSelector.addEventListener("change", () => {
33564
33619
  if (!__privateGet(this, _wysiwygElement)) {
33565
33620
  throw new ReferenceError("<bge-wysiwyg-editor> is not connected");
@@ -33583,10 +33638,6 @@ const _BgeWysiwygEditorElement = class _BgeWysiwygEditorElement2 extends HTMLEle
33583
33638
  if (!htmlModeButton) {
33584
33639
  throw new Error("HTML mode button not found");
33585
33640
  }
33586
- const initialHasStructureChange = __privateGet(this, _wysiwygElement).hasStructureChange;
33587
- const initialIsHtmlMode = __privateGet(this, _wysiwygElement).mode === "html";
33588
- htmlModeButton.disabled = initialIsHtmlMode && initialHasStructureChange;
33589
- htmlModeButton.ariaPressed = initialIsHtmlMode ? "true" : "false";
33590
33641
  htmlModeButton.addEventListener("click", () => {
33591
33642
  if (!__privateGet(this, _wysiwygElement)) {
33592
33643
  throw new ReferenceError("<bge-wysiwyg-editor> is not connected");
@@ -33608,9 +33659,12 @@ const _BgeWysiwygEditorElement = class _BgeWysiwygEditorElement2 extends HTMLEle
33608
33659
  });
33609
33660
  __privateGet(this, _wysiwygElement).addEventListener("bge:structure-change", (event2) => {
33610
33661
  const hasStructureChange = event2.detail.hasStructureChange;
33611
- const isHtmlMode = __privateGet(this, _wysiwygElement).mode === "html";
33612
- htmlModeButton.disabled = isHtmlMode && hasStructureChange;
33662
+ const isHtmlMode2 = __privateGet(this, _wysiwygElement).mode === "html";
33663
+ htmlModeButton.disabled = isHtmlMode2 && hasStructureChange;
33613
33664
  });
33665
+ const isHtmlMode = __privateGet(this, _wysiwygElement).mode === "html";
33666
+ htmlModeButton.ariaPressed = isHtmlMode ? "true" : "false";
33667
+ htmlModeButton.disabled = isHtmlMode && __privateGet(this, _wysiwygElement).hasStructureChange;
33614
33668
  }
33615
33669
  }
33616
33670
  setStyle(css) {
@@ -33768,6 +33822,9 @@ function bindToggle(button, wysiwygElement) {
33768
33822
  }
33769
33823
  function updateButtonState(button, state2, editorElement) {
33770
33824
  const buttonType = button.dataset.bgeToolbarButton;
33825
+ if (!buttonType) {
33826
+ return;
33827
+ }
33771
33828
  if (buttonType === "html-mode" || buttonType === "text-only-mode") {
33772
33829
  return;
33773
33830
  }
@@ -33813,6 +33870,7 @@ const ATTACHMENT_KEY = "@attach";
33813
33870
  const DEV = false;
33814
33871
  var is_array = Array.isArray;
33815
33872
  var index_of = Array.prototype.indexOf;
33873
+ var includes = Array.prototype.includes;
33816
33874
  var array_from = Array.from;
33817
33875
  var define_property = Object.defineProperty;
33818
33876
  var get_descriptor = Object.getOwnPropertyDescriptor;
@@ -34146,6 +34204,7 @@ class Batch {
34146
34204
  */
34147
34205
  skipped_effects = /* @__PURE__ */ new Set();
34148
34206
  is_fork = false;
34207
+ #decrement_queued = false;
34149
34208
  is_deferred() {
34150
34209
  return this.is_fork || this.#blocking_pending > 0;
34151
34210
  }
@@ -34155,20 +34214,24 @@ class Batch {
34155
34214
  */
34156
34215
  process(root_effects) {
34157
34216
  queued_root_effects = [];
34158
- previous_batch = null;
34159
34217
  this.apply();
34160
34218
  var effects = [];
34161
34219
  var render_effects = [];
34162
34220
  for (const root2 of root_effects) {
34163
34221
  this.#traverse_effect_tree(root2, effects, render_effects);
34164
34222
  }
34165
- if (!this.is_fork) {
34166
- this.#resolve();
34167
- }
34168
34223
  if (this.is_deferred()) {
34169
34224
  this.#defer_effects(render_effects);
34170
34225
  this.#defer_effects(effects);
34226
+ for (const e of this.skipped_effects) {
34227
+ reset_branch(e);
34228
+ }
34171
34229
  } else {
34230
+ for (const fn of this.#commit_callbacks) fn();
34231
+ this.#commit_callbacks.clear();
34232
+ if (this.#pending === 0) {
34233
+ this.#commit();
34234
+ }
34172
34235
  previous_batch = this;
34173
34236
  current_batch = null;
34174
34237
  flush_queued_effects(render_effects);
@@ -34202,7 +34265,7 @@ class Batch {
34202
34265
  } else if ((flags2 & EFFECT) !== 0) {
34203
34266
  effects.push(effect2);
34204
34267
  } else if (is_dirty(effect2)) {
34205
- if ((flags2 & BLOCK_EFFECT) !== 0) this.#dirty_effects.add(effect2);
34268
+ if ((flags2 & BLOCK_EFFECT) !== 0) this.#maybe_dirty_effects.add(effect2);
34206
34269
  update_effect(effect2);
34207
34270
  }
34208
34271
  var child2 = effect2.first;
@@ -34270,15 +34333,6 @@ class Batch {
34270
34333
  for (const fn of this.#discard_callbacks) fn(this);
34271
34334
  this.#discard_callbacks.clear();
34272
34335
  }
34273
- #resolve() {
34274
- if (this.#blocking_pending === 0) {
34275
- for (const fn of this.#commit_callbacks) fn();
34276
- this.#commit_callbacks.clear();
34277
- }
34278
- if (this.#pending === 0) {
34279
- this.#commit();
34280
- }
34281
- }
34282
34336
  #commit() {
34283
34337
  if (batches.size > 1) {
34284
34338
  this.previous.clear();
@@ -34344,7 +34398,16 @@ class Batch {
34344
34398
  decrement(blocking) {
34345
34399
  this.#pending -= 1;
34346
34400
  if (blocking) this.#blocking_pending -= 1;
34347
- this.revive();
34401
+ if (this.#decrement_queued) return;
34402
+ this.#decrement_queued = true;
34403
+ queue_micro_task(() => {
34404
+ this.#decrement_queued = false;
34405
+ if (!this.is_deferred()) {
34406
+ this.revive();
34407
+ } else if (queued_root_effects.length > 0) {
34408
+ this.flush();
34409
+ }
34410
+ });
34348
34411
  }
34349
34412
  revive() {
34350
34413
  for (const e of this.#dirty_effects) {
@@ -34374,7 +34437,7 @@ class Batch {
34374
34437
  const batch = current_batch = new Batch();
34375
34438
  batches.add(current_batch);
34376
34439
  if (!is_flushing_sync) {
34377
- Batch.enqueue(() => {
34440
+ queue_micro_task(() => {
34378
34441
  if (current_batch !== batch) {
34379
34442
  return;
34380
34443
  }
@@ -34384,10 +34447,6 @@ class Batch {
34384
34447
  }
34385
34448
  return current_batch;
34386
34449
  }
34387
- /** @param {() => void} task */
34388
- static enqueue(task) {
34389
- queue_micro_task(task);
34390
- }
34391
34450
  apply() {
34392
34451
  return;
34393
34452
  }
@@ -34417,11 +34476,9 @@ function flushSync(fn) {
34417
34476
  }
34418
34477
  }
34419
34478
  function flush_effects() {
34420
- var was_updating_effect = is_updating_effect;
34421
34479
  is_flushing = true;
34422
34480
  try {
34423
34481
  var flush_count = 0;
34424
- set_is_updating_effect(true);
34425
34482
  while (queued_root_effects.length > 0) {
34426
34483
  var batch = Batch.ensure();
34427
34484
  if (flush_count++ > 1e3) {
@@ -34435,7 +34492,6 @@ function flush_effects() {
34435
34492
  }
34436
34493
  } finally {
34437
34494
  is_flushing = false;
34438
- set_is_updating_effect(was_updating_effect);
34439
34495
  last_scheduled_effect = null;
34440
34496
  }
34441
34497
  }
@@ -34517,7 +34573,7 @@ function depends_on(reaction, sources, checked) {
34517
34573
  if (depends !== void 0) return depends;
34518
34574
  if (reaction.deps !== null) {
34519
34575
  for (const dep of reaction.deps) {
34520
- if (sources.includes(dep)) {
34576
+ if (includes.call(sources, dep)) {
34521
34577
  return true;
34522
34578
  }
34523
34579
  if ((dep.f & DERIVED) !== 0 && depends_on(
@@ -34553,6 +34609,17 @@ function schedule_effect(signal) {
34553
34609
  }
34554
34610
  queued_root_effects.push(effect2);
34555
34611
  }
34612
+ function reset_branch(effect2) {
34613
+ if ((effect2.f & BRANCH_EFFECT) !== 0 && (effect2.f & CLEAN) !== 0) {
34614
+ return;
34615
+ }
34616
+ set_signal_status(effect2, CLEAN);
34617
+ var e = effect2.first;
34618
+ while (e !== null) {
34619
+ reset_branch(e);
34620
+ e = e.next;
34621
+ }
34622
+ }
34556
34623
  function createSubscriber(start) {
34557
34624
  let subscribers = 0;
34558
34625
  let version2 = source(0);
@@ -34609,6 +34676,7 @@ class Boundary {
34609
34676
  #pending_anchor = null;
34610
34677
  #local_pending_count = 0;
34611
34678
  #pending_count = 0;
34679
+ #pending_count_update_queued = false;
34612
34680
  #is_creating_fallback = false;
34613
34681
  /** @type {Set<Effect>} */
34614
34682
  #dirty_effects = /* @__PURE__ */ new Set();
@@ -34669,11 +34737,9 @@ class Boundary {
34669
34737
  }
34670
34738
  #hydrate_pending_content() {
34671
34739
  const pending = this.#props.pending;
34672
- if (!pending) {
34673
- return;
34674
- }
34740
+ if (!pending) return;
34675
34741
  this.#pending_effect = branch(() => pending(this.#anchor));
34676
- Batch.enqueue(() => {
34742
+ queue_micro_task(() => {
34677
34743
  var anchor = this.#get_anchor();
34678
34744
  this.#main_effect = this.#run(() => {
34679
34745
  Batch.ensure();
@@ -34802,9 +34868,14 @@ class Boundary {
34802
34868
  update_pending_count(d2) {
34803
34869
  this.#update_pending_count(d2);
34804
34870
  this.#local_pending_count += d2;
34805
- if (this.#effect_pending) {
34806
- internal_set(this.#effect_pending, this.#local_pending_count);
34807
- }
34871
+ if (!this.#effect_pending || this.#pending_count_update_queued) return;
34872
+ this.#pending_count_update_queued = true;
34873
+ queue_micro_task(() => {
34874
+ this.#pending_count_update_queued = false;
34875
+ if (this.#effect_pending) {
34876
+ internal_set(this.#effect_pending, this.#local_pending_count);
34877
+ }
34878
+ });
34808
34879
  }
34809
34880
  get_effect_pending() {
34810
34881
  this.#effect_pending_subscriber();
@@ -34861,19 +34932,15 @@ class Boundary {
34861
34932
  this.is_pending = false;
34862
34933
  }
34863
34934
  };
34864
- var previous_reaction = active_reaction;
34865
- try {
34866
- set_active_reaction(null);
34867
- calling_on_error = true;
34868
- onerror?.(error, reset2);
34869
- calling_on_error = false;
34870
- } catch (error2) {
34871
- invoke_error_boundary(error2, this.#effect && this.#effect.parent);
34872
- } finally {
34873
- set_active_reaction(previous_reaction);
34874
- }
34875
- if (failed) {
34876
- queue_micro_task(() => {
34935
+ queue_micro_task(() => {
34936
+ try {
34937
+ calling_on_error = true;
34938
+ onerror?.(error, reset2);
34939
+ calling_on_error = false;
34940
+ } catch (error2) {
34941
+ invoke_error_boundary(error2, this.#effect && this.#effect.parent);
34942
+ }
34943
+ if (failed) {
34877
34944
  this.#failed_effect = this.#run(() => {
34878
34945
  Batch.ensure();
34879
34946
  this.#is_creating_fallback = true;
@@ -34896,13 +34963,14 @@ class Boundary {
34896
34963
  this.#is_creating_fallback = false;
34897
34964
  }
34898
34965
  });
34899
- });
34900
- }
34966
+ }
34967
+ });
34901
34968
  }
34902
34969
  }
34903
34970
  function flatten(blockers, sync, async, fn) {
34904
34971
  const d2 = is_runes() ? derived : derived_safe_equal;
34905
- if (async.length === 0 && blockers.length === 0) {
34972
+ var pending = blockers.filter((b2) => !b2.settled);
34973
+ if (async.length === 0 && pending.length === 0) {
34906
34974
  fn(sync.map(d2));
34907
34975
  return;
34908
34976
  }
@@ -34912,32 +34980,29 @@ function flatten(blockers, sync, async, fn) {
34912
34980
  active_effect
34913
34981
  );
34914
34982
  var restore = capture();
34915
- function run3() {
34916
- Promise.all(async.map((expression) => /* @__PURE__ */ async_derived(expression))).then((result) => {
34917
- restore();
34918
- try {
34919
- fn([...sync.map(d2), ...result]);
34920
- } catch (error) {
34921
- if ((parent.f & DESTROYED) === 0) {
34922
- invoke_error_boundary(error, parent);
34923
- }
34983
+ var blocker_promise = pending.length === 1 ? pending[0].promise : pending.length > 1 ? Promise.all(pending.map((b2) => b2.promise)) : null;
34984
+ function finish(values) {
34985
+ restore();
34986
+ try {
34987
+ fn(values);
34988
+ } catch (error) {
34989
+ if ((parent.f & DESTROYED) === 0) {
34990
+ invoke_error_boundary(error, parent);
34924
34991
  }
34925
- batch?.deactivate();
34926
- unset_context();
34927
- }).catch((error) => {
34928
- invoke_error_boundary(error, parent);
34929
- });
34992
+ }
34993
+ batch?.deactivate();
34994
+ unset_context();
34930
34995
  }
34931
- if (blockers.length > 0) {
34932
- Promise.all(blockers).then(() => {
34933
- restore();
34934
- try {
34935
- return run3();
34936
- } finally {
34937
- batch?.deactivate();
34938
- unset_context();
34939
- }
34940
- });
34996
+ if (async.length === 0) {
34997
+ blocker_promise.then(() => finish(sync.map(d2)));
34998
+ return;
34999
+ }
35000
+ function run3() {
35001
+ restore();
35002
+ Promise.all(async.map((expression) => /* @__PURE__ */ async_derived(expression))).then((result) => finish([...sync.map(d2), ...result])).catch((error) => invoke_error_boundary(error, parent));
35003
+ }
35004
+ if (blocker_promise) {
35005
+ blocker_promise.then(run3);
34941
35006
  } else {
34942
35007
  run3();
34943
35008
  }
@@ -35199,7 +35264,7 @@ function mutate(source2, value) {
35199
35264
  function set(source2, value, should_proxy = false) {
35200
35265
  if (active_reaction !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
35201
35266
  // to ensure we error if state is set inside an inspect effect
35202
- (!untracking || (active_reaction.f & EAGER_EFFECT) !== 0) && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | EAGER_EFFECT)) !== 0 && !current_sources?.includes(source2)) {
35267
+ (!untracking || (active_reaction.f & EAGER_EFFECT) !== 0) && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | EAGER_EFFECT)) !== 0 && (current_sources === null || !includes.call(current_sources, source2))) {
35203
35268
  state_unsafe_mutation();
35204
35269
  }
35205
35270
  let new_value = should_proxy ? proxy(value) : value;
@@ -35243,20 +35308,13 @@ function internal_set(source2, value) {
35243
35308
  }
35244
35309
  function flush_eager_effects() {
35245
35310
  eager_effects_deferred = false;
35246
- var prev_is_updating_effect = is_updating_effect;
35247
- set_is_updating_effect(true);
35248
- const inspects = Array.from(eager_effects);
35249
- try {
35250
- for (const effect2 of inspects) {
35251
- if ((effect2.f & CLEAN) !== 0) {
35252
- set_signal_status(effect2, MAYBE_DIRTY);
35253
- }
35254
- if (is_dirty(effect2)) {
35255
- update_effect(effect2);
35256
- }
35311
+ for (const effect2 of eager_effects) {
35312
+ if ((effect2.f & CLEAN) !== 0) {
35313
+ set_signal_status(effect2, MAYBE_DIRTY);
35314
+ }
35315
+ if (is_dirty(effect2)) {
35316
+ update_effect(effect2);
35257
35317
  }
35258
- } finally {
35259
- set_is_updating_effect(prev_is_updating_effect);
35260
35318
  }
35261
35319
  eager_effects.clear();
35262
35320
  }
@@ -36007,9 +36065,6 @@ function invalidate_inner_signals(fn) {
36007
36065
  }
36008
36066
  }
36009
36067
  let is_updating_effect = false;
36010
- function set_is_updating_effect(value) {
36011
- is_updating_effect = value;
36012
- }
36013
36068
  let is_destroying_effect = false;
36014
36069
  function set_is_destroying_effect(value) {
36015
36070
  is_destroying_effect = value;
@@ -36088,7 +36143,7 @@ function is_dirty(reaction) {
36088
36143
  function schedule_possible_effect_self_invalidation(signal, effect2, root2 = true) {
36089
36144
  var reactions = signal.reactions;
36090
36145
  if (reactions === null) return;
36091
- if (current_sources?.includes(signal)) {
36146
+ if (current_sources !== null && includes.call(current_sources, signal)) {
36092
36147
  return;
36093
36148
  }
36094
36149
  for (var i = 0; i < reactions.length; i++) {
@@ -36146,9 +36201,12 @@ function update_reaction(reaction) {
36146
36201
  );
36147
36202
  var result = fn();
36148
36203
  var deps = reaction.deps;
36204
+ var is_fork = current_batch?.is_fork;
36149
36205
  if (new_deps !== null) {
36150
36206
  var i;
36151
- remove_reactions(reaction, skipped_deps);
36207
+ if (!is_fork) {
36208
+ remove_reactions(reaction, skipped_deps);
36209
+ }
36152
36210
  if (deps !== null && skipped_deps > 0) {
36153
36211
  deps.length = skipped_deps + new_deps.length;
36154
36212
  for (i = 0; i < new_deps.length; i++) {
@@ -36162,7 +36220,7 @@ function update_reaction(reaction) {
36162
36220
  (deps[i].reactions ??= []).push(reaction);
36163
36221
  }
36164
36222
  }
36165
- } else if (deps !== null && skipped_deps < deps.length) {
36223
+ } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
36166
36224
  remove_reactions(reaction, skipped_deps);
36167
36225
  deps.length = skipped_deps;
36168
36226
  }
@@ -36232,7 +36290,7 @@ function remove_reaction(signal, dependency) {
36232
36290
  if (reactions === null && (dependency.f & DERIVED) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
36233
36291
  // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
36234
36292
  // allows us to skip the expensive work of disconnecting and immediately reconnecting it
36235
- (new_deps === null || !new_deps.includes(dependency))) {
36293
+ (new_deps === null || !includes.call(new_deps, dependency))) {
36236
36294
  var derived2 = (
36237
36295
  /** @type {Derived} */
36238
36296
  dependency
@@ -36290,7 +36348,7 @@ function get2(signal) {
36290
36348
  captured_signals?.add(signal);
36291
36349
  if (active_reaction !== null && !untracking) {
36292
36350
  var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0;
36293
- if (!destroyed && !current_sources?.includes(signal)) {
36351
+ if (!destroyed && (current_sources === null || !includes.call(current_sources, signal))) {
36294
36352
  var deps = active_reaction.deps;
36295
36353
  if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) {
36296
36354
  if (signal.rv < read_version) {
@@ -36308,7 +36366,7 @@ function get2(signal) {
36308
36366
  var reactions = signal.reactions;
36309
36367
  if (reactions === null) {
36310
36368
  signal.reactions = [active_reaction];
36311
- } else if (!reactions.includes(active_reaction)) {
36369
+ } else if (!includes.call(reactions, active_reaction)) {
36312
36370
  reactions.push(active_reaction);
36313
36371
  }
36314
36372
  }
@@ -37146,11 +37204,17 @@ function each(node, flags2, get_collection, get_key, render_fn, fallback_fn = nu
37146
37204
  var state2 = { effect: effect2, items, outrogroups: null, fallback };
37147
37205
  first_run = false;
37148
37206
  }
37207
+ function skip_to_branch(effect2) {
37208
+ while (effect2 !== null && (effect2.f & BRANCH_EFFECT) === 0) {
37209
+ effect2 = effect2.next;
37210
+ }
37211
+ return effect2;
37212
+ }
37149
37213
  function reconcile(state2, array, anchor, flags2, get_key) {
37150
37214
  var is_animated = (flags2 & EACH_IS_ANIMATED) !== 0;
37151
37215
  var length = array.length;
37152
37216
  var items = state2.items;
37153
- var current = state2.effect.first;
37217
+ var current = skip_to_branch(state2.effect.first);
37154
37218
  var seen;
37155
37219
  var prev = null;
37156
37220
  var to_animate;
@@ -37200,7 +37264,7 @@ function reconcile(state2, array, anchor, flags2, get_key) {
37200
37264
  prev = effect2;
37201
37265
  matched = [];
37202
37266
  stashed = [];
37203
- current = prev.next;
37267
+ current = skip_to_branch(prev.next);
37204
37268
  continue;
37205
37269
  }
37206
37270
  }
@@ -37248,7 +37312,7 @@ function reconcile(state2, array, anchor, flags2, get_key) {
37248
37312
  while (current !== null && current !== effect2) {
37249
37313
  (seen ??= /* @__PURE__ */ new Set()).add(current);
37250
37314
  stashed.push(current);
37251
- current = current.next;
37315
+ current = skip_to_branch(current.next);
37252
37316
  }
37253
37317
  if (current === null) {
37254
37318
  continue;
@@ -37258,7 +37322,7 @@ function reconcile(state2, array, anchor, flags2, get_key) {
37258
37322
  matched.push(effect2);
37259
37323
  }
37260
37324
  prev = effect2;
37261
- current = effect2.next;
37325
+ current = skip_to_branch(effect2.next);
37262
37326
  }
37263
37327
  if (state2.outrogroups !== null) {
37264
37328
  for (const group of state2.outrogroups) {
@@ -37284,7 +37348,7 @@ function reconcile(state2, array, anchor, flags2, get_key) {
37284
37348
  if ((current.f & INERT) === 0 && current !== state2.fallback) {
37285
37349
  to_destroy.push(current);
37286
37350
  }
37287
- current = current.next;
37351
+ current = skip_to_branch(current.next);
37288
37352
  }
37289
37353
  var destroy_length = to_destroy.length;
37290
37354
  if (destroy_length > 0) {