steel-frame 5.1.13 → 5.1.15

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/lib/index.js CHANGED
@@ -2,7 +2,7 @@ import { devArrayModel, devAwaited, DevDelay, devEnsure, devExpr, DevFor, devMap
2
2
  import { devModal, devPrompt, devRouterApp, devMount } from "vasille-web/dev";
3
3
  import { devScreen } from "vasille-router/dev";
4
4
  import { Inspector } from "./inspector.js";
5
- export { executionPosition, wrapFn, runFn, registerReference, shareStateById, positionedText } from "vasille/dev";
5
+ export { executionPosition, wrapFn, runFn, registerReference, shareStateById, positionedText, setupPosition, } from "vasille/dev";
6
6
  export { setErrorHandler, earlyInspector } from "vasille-jsx/dev";
7
7
  export { safe, } from "vasille-web";
8
8
  export { setLaptopMaxWidth, setTabletMaxWidth, setMobileMaxWidth } from "vasille-css";
package/lib/inspector.js CHANGED
@@ -88,7 +88,8 @@ class AppHandler {
88
88
  return;
89
89
  }
90
90
  const tags = new Set();
91
- this.iterateFragment(this.app, new Set(ids), tags);
91
+ const texts = new Set();
92
+ this.iterateFragment(this.app, new Set(ids), tags, texts);
92
93
  const canvas = this.canvas;
93
94
  const ctx = canvas?.getContext("2d");
94
95
  if (ctx && canvas) {
@@ -99,6 +100,16 @@ class AppHandler {
99
100
  ctx.fillRect(rect.x, rect.y, rect.width, rect.height);
100
101
  }
101
102
  }
103
+ const sel = window.getSelection();
104
+ if (sel) {
105
+ sel.removeAllRanges();
106
+ for (const text of texts) {
107
+ const range = document.createRange();
108
+ // @ts-expect-error node field is protected
109
+ range.selectNodeContents(text.node);
110
+ sel.addRange(range);
111
+ }
112
+ }
102
113
  }
103
114
  setLookup(active) {
104
115
  this.active.V = active;
@@ -112,13 +123,13 @@ class AppHandler {
112
123
  }
113
124
  }
114
125
  }
115
- iterateFragment(node, ids, set) {
126
+ iterateFragment(node, ids, set, texts) {
116
127
  for (const child of node.children) {
117
128
  if ("id" in child && ids.has(child.id)) {
118
- this.addReactive(child, set);
129
+ this.addReactive(child, set, texts);
119
130
  }
120
131
  else if (child instanceof Fragment) {
121
- this.iterateFragment(child, ids, set);
132
+ this.iterateFragment(child, ids, set, texts);
122
133
  }
123
134
  }
124
135
  }
@@ -134,20 +145,21 @@ class AppHandler {
134
145
  set.add(it);
135
146
  }
136
147
  }
137
- addFragment(node, set) {
148
+ addFragment(node, set, texts) {
138
149
  for (const child of node.children) {
139
- this.addReactive(child, set);
150
+ this.addReactive(child, set, texts);
140
151
  }
141
152
  }
142
- addReactive(node, set) {
153
+ addReactive(node, set, texts) {
143
154
  if (node instanceof DevTag) {
144
155
  this.addTag(node, set);
145
156
  }
146
157
  else if (node instanceof DevTextNode) {
147
158
  this.addText(node, set);
159
+ texts.add(node);
148
160
  }
149
161
  else if (node instanceof DevFragment) {
150
- this.addFragment(node, set);
162
+ this.addFragment(node, set, texts);
151
163
  }
152
164
  }
153
165
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steel-frame",
3
- "version": "5.1.13",
3
+ "version": "5.1.15",
4
4
  "description": "SteelFrame: Build Fault-Tolerant Web Applications Effortlessly.",
5
5
  "main": "index.js",
6
6
  "types": "./index.d.ts",
package/src/index.ts CHANGED
@@ -24,7 +24,15 @@ import { TagOptions } from "vasille/web-runner";
24
24
  import { devScreen } from "vasille-router/dev";
25
25
  import { Inspector } from "./inspector.js";
26
26
 
27
- export { executionPosition, wrapFn, runFn, registerReference, shareStateById, positionedText } from "vasille/dev";
27
+ export {
28
+ executionPosition,
29
+ wrapFn,
30
+ runFn,
31
+ registerReference,
32
+ shareStateById,
33
+ positionedText,
34
+ setupPosition,
35
+ } from "vasille/dev";
28
36
  export { setErrorHandler, earlyInspector } from "vasille-jsx/dev";
29
37
  export { type IdeSide, type AppSide } from "./communication.js";
30
38
 
package/src/inspector.ts CHANGED
@@ -105,8 +105,9 @@ class AppHandler implements AppSide {
105
105
  }
106
106
 
107
107
  const tags = new Set<DevTag>();
108
+ const texts = new Set<DevTextNode>();
108
109
 
109
- this.iterateFragment(this.app as unknown as Fragment<Node, Element, TagOptions>, new Set(ids), tags);
110
+ this.iterateFragment(this.app as unknown as Fragment<Node, Element, TagOptions>, new Set(ids), tags, texts);
110
111
 
111
112
  const canvas = this.canvas;
112
113
  const ctx = canvas?.getContext("2d");
@@ -121,6 +122,19 @@ class AppHandler implements AppSide {
121
122
  ctx.fillRect(rect.x, rect.y, rect.width, rect.height);
122
123
  }
123
124
  }
125
+
126
+ const sel = window.getSelection();
127
+
128
+ if (sel) {
129
+ sel.removeAllRanges();
130
+
131
+ for (const text of texts) {
132
+ const range = document.createRange();
133
+ // @ts-expect-error node field is protected
134
+ range.selectNodeContents(text.node);
135
+ sel.addRange(range);
136
+ }
137
+ }
124
138
  }
125
139
  public setLookup(active: boolean): void {
126
140
  this.active.V = active;
@@ -137,12 +151,17 @@ class AppHandler implements AppSide {
137
151
  }
138
152
  }
139
153
 
140
- protected iterateFragment(node: Fragment<Node, Element, TagOptions>, ids: Set<number>, set: Set<DevTag>) {
154
+ protected iterateFragment(
155
+ node: Fragment<Node, Element, TagOptions>,
156
+ ids: Set<number>,
157
+ set: Set<DevTag>,
158
+ texts: Set<DevTextNode>,
159
+ ) {
141
160
  for (const child of node.children) {
142
161
  if ("id" in child && ids.has(child.id as number)) {
143
- this.addReactive(child, set);
162
+ this.addReactive(child, set, texts);
144
163
  } else if (child instanceof Fragment) {
145
- this.iterateFragment(child, ids, set);
164
+ this.iterateFragment(child, ids, set, texts);
146
165
  }
147
166
  }
148
167
  }
@@ -163,19 +182,20 @@ class AppHandler implements AppSide {
163
182
  }
164
183
  }
165
184
 
166
- protected addFragment(node: DevFragment<Node, Element, TagOptions>, set: Set<DevTag>) {
185
+ protected addFragment(node: DevFragment<Node, Element, TagOptions>, set: Set<DevTag>, texts: Set<DevTextNode>) {
167
186
  for (const child of node.children) {
168
- this.addReactive(child, set);
187
+ this.addReactive(child, set, texts);
169
188
  }
170
189
  }
171
190
 
172
- protected addReactive(node: Reactive, set: Set<DevTag>) {
191
+ protected addReactive(node: Reactive, set: Set<DevTag>, texts: Set<DevTextNode>) {
173
192
  if (node instanceof DevTag) {
174
193
  this.addTag(node, set);
175
194
  } else if (node instanceof DevTextNode) {
176
195
  this.addText(node, set);
196
+ texts.add(node);
177
197
  } else if (node instanceof DevFragment) {
178
- this.addFragment(node, set);
198
+ this.addFragment(node, set, texts);
179
199
  }
180
200
  }
181
201
  }
package/types/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { devModal, devPrompt } from "vasille-web/dev";
4
4
  import { App } from "vasille";
5
5
  import { TagOptions } from "vasille/web-runner";
6
6
  import { devScreen } from "vasille-router/dev";
7
- export { executionPosition, wrapFn, runFn, registerReference, shareStateById, positionedText } from "vasille/dev";
7
+ export { executionPosition, wrapFn, runFn, registerReference, shareStateById, positionedText, setupPosition, } from "vasille/dev";
8
8
  export { setErrorHandler, earlyInspector } from "vasille-jsx/dev";
9
9
  export { type IdeSide, type AppSide } from "./communication.js";
10
10
  export { type QueryParams, type ScreenProps, type RouteParameters, type FallbackScreenProps, type ErrorScreenProps, type WebRouterInitialization, type NavigationMode, type Router, safe, } from "vasille-web";