@wcstack/state 1.22.3 → 1.22.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/README.ja.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @wcstack/state
2
2
 
3
+ > 🤖 **AI coding agents**: This README is a package-level reference, not the primary entry point for building a wcstack application. If you have not already done so, first read the repository [README](https://github.com/wcstack/wcstack#readme) and [AGENTS.md](https://github.com/wcstack/wcstack/blob/main/AGENTS.md), then use the [wcstack-app skill](https://github.com/wcstack/wcstack-skill).
4
+
3
5
  **これは便利な既存FWの別実装ではありません。フロントエンド開発の前提を組み替える、別系譜の試みです。**
4
6
 
5
7
  多くのライブラリは、UI・状態・コンポーネントの結合点を JavaScript の中に置きます。`@wcstack/state` はそこを選びません。仮想DOMも、コンパイルも、hook も、selector も前提にせず、HTML とパス文字列だけを契約として UI と状態を結びつけます。
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @wcstack/state
2
2
 
3
+ > 🤖 **AI coding agents**: This README is a package-level reference, not the primary entry point for building a wcstack application. If you have not already done so, first read the repository [README](https://github.com/wcstack/wcstack#readme) and [AGENTS.md](https://github.com/wcstack/wcstack/blob/main/AGENTS.md), then use the [wcstack-app skill](https://github.com/wcstack/wcstack-skill).
4
+
3
5
  **This is not another convenient frontend framework. It is a different lineage that rearranges the premises of frontend development.**
4
6
 
5
7
  Most libraries place the coupling point between UI, state, and components inside JavaScript. `@wcstack/state` does not. It assumes no virtual DOM, no compilation step, no hooks, no selectors. UI and state are connected by HTML and path strings alone.
package/dist/index.esm.js CHANGED
@@ -5316,11 +5316,19 @@ class Content {
5316
5316
  }
5317
5317
  mountAfter(targetNode) {
5318
5318
  const parentNode = targetNode.parentNode;
5319
- const nextSibling = targetNode.nextSibling;
5320
5319
  if (parentNode) {
5320
+ // マウント済み content にも再突入する(if の true→true 再適用・SSR
5321
+ // ハイドレーション産 content 等)。固定の nextSibling へ一括 insertBefore
5322
+ // すると、マウント済みでは nextSibling が自分の先頭ノードを指すため
5323
+ // 先頭ノードが末尾へ回転する。anchor を進めながら位置一致ノードを
5324
+ // スキップすることで冪等にする(mutation record も発生させない)。
5325
+ let anchor = targetNode;
5321
5326
  for (const node of this._childNodeArray) {
5322
- markObserverSkipOnAdd(node);
5323
- parentNode.insertBefore(node, nextSibling);
5327
+ if (anchor.nextSibling !== node) {
5328
+ markObserverSkipOnAdd(node);
5329
+ parentNode.insertBefore(node, anchor.nextSibling);
5330
+ }
5331
+ anchor = node;
5324
5332
  }
5325
5333
  }
5326
5334
  this._mounted = true;
@@ -5728,12 +5736,10 @@ function applyChangeToFor(bindingInfo, context, newValue) {
5728
5736
  }
5729
5737
  }
5730
5738
 
5731
- const lastConnectedByNode = new WeakMap();
5732
5739
  function bindingInfoText(bindingInfo) {
5733
5740
  return `${bindingInfo.bindingType} ${bindingInfo.statePathName} ${bindingInfo.outFilters.map(f => f.filterName).join('|')} ${bindingInfo.node.isConnected ? '(connected)' : '(disconnected)'}`;
5734
5741
  }
5735
5742
  function applyChangeToIf(bindingInfo, context, rawNewValue) {
5736
- const currentConnected = bindingInfo.node.isConnected;
5737
5743
  const newValue = Boolean(rawNewValue);
5738
5744
  let content;
5739
5745
  const contents = getContentSetByNode(bindingInfo.node);
@@ -5746,35 +5752,30 @@ function applyChangeToIf(bindingInfo, context, rawNewValue) {
5746
5752
  const ssrMode = inSsr();
5747
5753
  const uuid = bindingInfo.uuid ?? '';
5748
5754
  const keyword = bindingInfo.bindingType; // if, elseif, else
5749
- try {
5750
- if (!newValue) {
5751
- if (config.debug) {
5752
- console.log(`unmount if content : ${bindingInfoText(bindingInfo)}`);
5753
- }
5754
- deactivateContent(content);
5755
- content.unmount();
5756
- }
5757
- if (newValue) {
5758
- if (config.debug) {
5759
- console.log(`mount if content : ${bindingInfoText(bindingInfo)}`);
5760
- }
5761
- if (ssrMode) {
5762
- const startComment = document.createComment(`@@wcs-${keyword}-start:${uuid}:${bindingInfo.statePathName}`);
5763
- bindingInfo.node.parentNode.insertBefore(startComment, bindingInfo.node.nextSibling);
5764
- content.mountAfter(startComment);
5765
- const endComment = document.createComment(`@@wcs-${keyword}-end:${uuid}:${bindingInfo.statePathName}`);
5766
- const afterNode = content.lastNode ?? startComment;
5767
- afterNode.parentNode.insertBefore(endComment, afterNode.nextSibling);
5768
- }
5769
- else {
5770
- content.mountAfter(bindingInfo.node);
5771
- }
5772
- const loopContext = getLoopContextByNode(bindingInfo.node);
5773
- activateContent(content, loopContext, context);
5755
+ if (!newValue) {
5756
+ if (config.debug) {
5757
+ console.log(`unmount if content : ${bindingInfoText(bindingInfo)}`);
5774
5758
  }
5759
+ deactivateContent(content);
5760
+ content.unmount();
5775
5761
  }
5776
- finally {
5777
- lastConnectedByNode.set(bindingInfo.node, currentConnected);
5762
+ if (newValue) {
5763
+ if (config.debug) {
5764
+ console.log(`mount if content : ${bindingInfoText(bindingInfo)}`);
5765
+ }
5766
+ if (ssrMode) {
5767
+ const startComment = document.createComment(`@@wcs-${keyword}-start:${uuid}:${bindingInfo.statePathName}`);
5768
+ bindingInfo.node.parentNode.insertBefore(startComment, bindingInfo.node.nextSibling);
5769
+ content.mountAfter(startComment);
5770
+ const endComment = document.createComment(`@@wcs-${keyword}-end:${uuid}:${bindingInfo.statePathName}`);
5771
+ const afterNode = content.lastNode ?? startComment;
5772
+ afterNode.parentNode.insertBefore(endComment, afterNode.nextSibling);
5773
+ }
5774
+ else {
5775
+ content.mountAfter(bindingInfo.node);
5776
+ }
5777
+ const loopContext = getLoopContextByNode(bindingInfo.node);
5778
+ activateContent(content, loopContext, context);
5778
5779
  }
5779
5780
  }
5780
5781
 
@@ -6896,7 +6897,7 @@ async function buildBindings(root) {
6896
6897
  }
6897
6898
  }
6898
6899
 
6899
- var version = "1.22.3";
6900
+ var version = "1.22.5";
6900
6901
  var pkg = {
6901
6902
  version: version};
6902
6903