steel-frame 5.1.14 → 5.1.16
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/fake-types/index.d.ts +14 -13
- package/lib/inspector.js +20 -8
- package/package.json +1 -1
- package/src/inspector.ts +28 -8
package/fake-types/index.d.ts
CHANGED
|
@@ -84,6 +84,7 @@ export declare function Slot<Props extends object>(
|
|
|
84
84
|
options: {
|
|
85
85
|
model?: (props: Props) => void;
|
|
86
86
|
slot?: () => void;
|
|
87
|
+
"vasille:slot"?: VasilleSlot;
|
|
87
88
|
} & Props,
|
|
88
89
|
): void;
|
|
89
90
|
|
|
@@ -152,9 +153,9 @@ export declare function model<Input extends object, Return extends object>(
|
|
|
152
153
|
export { QueryParams, ScreenProps, RouteParameters } from "vasille-router";
|
|
153
154
|
export { type Router, NavigationMode } from "vasille-router/web-router";
|
|
154
155
|
|
|
155
|
-
/** Applies the value to theme `name` */
|
|
156
|
+
/** Applies the value to the theme `name` */
|
|
156
157
|
export declare function theme<T>(name: string, value: T): T;
|
|
157
|
-
/** Applies the value to dark theme */
|
|
158
|
+
/** Applies the value to the dark theme */
|
|
158
159
|
export declare function dark<T>($: T): T;
|
|
159
160
|
/** Applies the value to mobile devices */
|
|
160
161
|
export declare function mobile<T>($: T): T;
|
|
@@ -162,9 +163,9 @@ export declare function mobile<T>($: T): T;
|
|
|
162
163
|
export declare function tablet<T>($: T): T;
|
|
163
164
|
/** Applies the value to laptop devices */
|
|
164
165
|
export declare function laptop<T>($: T): T;
|
|
165
|
-
/** Applies the value when user prefers dark theme */
|
|
166
|
+
/** Applies the value when the user prefers the dark theme */
|
|
166
167
|
export declare function prefersDark<T>($: T): T;
|
|
167
|
-
/** Applies the value when user prefers light theme */
|
|
168
|
+
/** Applies the value when the user prefers the light theme */
|
|
168
169
|
export declare function prefersLight<T>($: T): T;
|
|
169
170
|
|
|
170
171
|
export { setMobileMaxWidth, setTabletMaxWidth, setLaptopMaxWidth } from "vasille-css";
|
|
@@ -183,7 +184,7 @@ export declare const styleSheet: <
|
|
|
183
184
|
input: T,
|
|
184
185
|
) => { [K in keyof T]: string };
|
|
185
186
|
|
|
186
|
-
/** Mounts a Vasille.JS component to page */
|
|
187
|
+
/** Mounts a Vasille.JS component to a page */
|
|
187
188
|
export declare function mount<T>(element: Element, component: ($: T) => void, $: T): App<Node, Element, TagOptions>;
|
|
188
189
|
|
|
189
190
|
interface RouterInitialization<Routes extends string> {
|
|
@@ -206,15 +207,15 @@ export declare function routerApp<Routes extends string>(
|
|
|
206
207
|
element?: Element,
|
|
207
208
|
): App<Node, Element, TagOptions>;
|
|
208
209
|
|
|
209
|
-
/** Run a function before component mount */
|
|
210
|
+
/** Run a function before the component mount */
|
|
210
211
|
export declare function beforeMount(fn: () => void): void;
|
|
211
212
|
export declare function beforeMount(fn: () => Promise<void>): void;
|
|
212
213
|
|
|
213
|
-
/** Run a function after component mount */
|
|
214
|
+
/** Run a function after the component mount */
|
|
214
215
|
export declare function afterMount(fn: () => void): void;
|
|
215
216
|
export declare function afterMount(fn: () => Promise<void>): void;
|
|
216
217
|
|
|
217
|
-
/** Run a function before component
|
|
218
|
+
/** Run a function before the component destruction */
|
|
218
219
|
export declare function beforeDestroy(fn: () => void): void;
|
|
219
220
|
|
|
220
221
|
/** Returns the current used router */
|
|
@@ -244,25 +245,25 @@ export declare function context<Value, Args extends unknown[] = never[]>(
|
|
|
244
245
|
fn: (...args: Args) => Value,
|
|
245
246
|
): SteelContext<Args, Value>;
|
|
246
247
|
|
|
247
|
-
/** Share
|
|
248
|
+
/** Share a context to children components */
|
|
248
249
|
export declare function share<Args extends unknown[], Value>(ctx: SteelContext<Args, Value>, ...args: Args): Value;
|
|
249
250
|
|
|
250
251
|
/** Share a dependency */
|
|
251
252
|
export declare function share<Class>(className: abstract new (...args: unknown[]) => Class, value: Class): Class;
|
|
252
253
|
|
|
253
|
-
/** Share a
|
|
254
|
+
/** Share a setting */
|
|
254
255
|
export declare function share(key: string, value: string): string;
|
|
255
256
|
|
|
256
|
-
/** Receive
|
|
257
|
+
/** Receive a shared context */
|
|
257
258
|
export declare function receive<Args extends unknown[], Value>(ctx: SteelContext<Args, Value>): Value;
|
|
258
259
|
|
|
259
260
|
/** Receive a dependency */
|
|
260
261
|
export declare function receive<Class>(className: abstract new (...args: unknown[]) => Class): Class;
|
|
261
262
|
|
|
262
|
-
/** Receive a
|
|
263
|
+
/** Receive a setting */
|
|
263
264
|
export declare function receive(key: string): string;
|
|
264
265
|
|
|
265
|
-
/** Create and share
|
|
266
|
+
/** Create and share a context when it is missing */
|
|
266
267
|
export declare function impute<Args extends unknown[], Value>(ctx: SteelContext<Args, Value>, ...args: Args): Value;
|
|
267
268
|
|
|
268
269
|
/** Ensure a dependency presence in context */
|
package/lib/inspector.js
CHANGED
|
@@ -88,7 +88,8 @@ class AppHandler {
|
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
const tags = new Set();
|
|
91
|
-
|
|
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
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(
|
|
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
|
}
|