vasille 4.3.1 → 5.0.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.
Files changed (42) hide show
  1. package/README.md +71 -37
  2. package/lib/dev/components.js +82 -0
  3. package/lib/dev/core.js +15 -0
  4. package/lib/dev/index.js +8 -0
  5. package/lib/dev/inspectable.js +113 -0
  6. package/lib/dev/models.js +147 -0
  7. package/lib/dev/node.js +59 -0
  8. package/lib/dev/runner.js +141 -0
  9. package/lib/dev/state.js +194 -0
  10. package/lib/dev/views.js +62 -0
  11. package/lib/index.js +1 -2
  12. package/lib/models/set-model.js +1 -0
  13. package/lib/node/app.js +1 -1
  14. package/lib/node/node.js +14 -33
  15. package/lib/runner/web/binding/class.js +2 -15
  16. package/lib/runner/web/runner.js +25 -53
  17. package/lib/value/expression.js +3 -2
  18. package/lib/views/repeat-node.js +4 -1
  19. package/package.json +7 -1
  20. package/types/dev/components.d.ts +20 -0
  21. package/types/dev/core.d.ts +8 -0
  22. package/types/dev/index.d.ts +8 -0
  23. package/types/dev/inspectable.d.ts +244 -0
  24. package/types/dev/models.d.ts +38 -0
  25. package/types/dev/node.d.ts +12 -0
  26. package/types/dev/runner.d.ts +37 -0
  27. package/types/dev/state.d.ts +53 -0
  28. package/types/dev/views.d.ts +22 -0
  29. package/types/index.d.ts +2 -3
  30. package/types/node/app.d.ts +8 -9
  31. package/types/node/node.d.ts +17 -34
  32. package/types/node/runner.d.ts +2 -5
  33. package/types/node/watch.d.ts +5 -6
  34. package/types/runner/web/runner.d.ts +21 -25
  35. package/types/value/expression.d.ts +2 -1
  36. package/types/views/array-view.d.ts +3 -2
  37. package/types/views/base-view.d.ts +4 -4
  38. package/types/views/map-view.d.ts +2 -1
  39. package/types/views/repeat-node.d.ts +7 -6
  40. package/types/views/set-view.d.ts +3 -3
  41. package/lib/value/pointer.js +0 -61
  42. package/types/value/pointer.d.ts +0 -46
@@ -1,4 +1,4 @@
1
- import { TextNode as AbstractTextNode, DebugNode as AbstractDebugNode, Tag as AbstractTag, IValue, safe, } from "../../index.js";
1
+ import { TextNode as AbstractTextNode, Tag as AbstractTag, IValue, safe } from "../../index.js";
2
2
  import { internalError } from "../../core/errors.js";
3
3
  import { AttributeBinding } from "./binding/attribute.js";
4
4
  import { addClass, DynamicalClassBinding, removeClass, StaticClassBinding } from "./binding/class.js";
@@ -25,25 +25,6 @@ export class TextNode extends AbstractTextNode {
25
25
  return this.node;
26
26
  }
27
27
  }
28
- export class DebugNode extends AbstractDebugNode {
29
- node;
30
- compose() {
31
- const text = this.data;
32
- this.node = this.runner.document.createComment(text.V?.toString() ?? "");
33
- this.handler = (v) => {
34
- this.node.replaceData(0, -1, v?.toString() ?? "");
35
- };
36
- text.on(this.handler);
37
- this.parent.appendNode(this.node);
38
- }
39
- destroy() {
40
- this.node.remove();
41
- super.destroy();
42
- }
43
- findFirstChild() {
44
- return this.node;
45
- }
46
- }
47
28
  export class Tag extends AbstractTag {
48
29
  compose() {
49
30
  if (!this.name) {
@@ -53,17 +34,18 @@ export class Tag extends AbstractTag {
53
34
  this.node = node;
54
35
  this.applyOptions(this.options);
55
36
  this.parent.appendNode(node);
56
- this.options.callback?.(this.node);
57
- this.options.slot?.(this);
37
+ this.options.l?.(this);
38
+ this.options.k?.(this.node);
58
39
  }
59
40
  destroy() {
60
41
  this.node.remove();
61
42
  super.destroy();
62
43
  }
63
44
  applyOptions(options) {
64
- if (options.attr) {
65
- for (const name in options.attr) {
66
- const value = options.attr[name];
45
+ const { node } = this;
46
+ if (options.a) {
47
+ for (const name in options.a) {
48
+ const value = options.a[name];
67
49
  if (value instanceof IValue) {
68
50
  this.bind(new AttributeBinding(this, name, value));
69
51
  }
@@ -72,17 +54,17 @@ export class Tag extends AbstractTag {
72
54
  if (typeof value === "boolean") {
73
55
  /* istanbul ignore else */
74
56
  if (value) {
75
- this.node.setAttribute(name, "");
57
+ node.setAttribute(name, "");
76
58
  }
77
59
  }
78
60
  else if (value !== null && value !== undefined) {
79
- this.node.setAttribute(name, `${value}`);
61
+ node.setAttribute(name, `${value}`);
80
62
  }
81
63
  }
82
64
  }
83
65
  }
84
- if (options.class) {
85
- options.class.forEach(item => {
66
+ if (options.c) {
67
+ options.c.forEach(item => {
86
68
  if (item instanceof IValue) {
87
69
  this.bind(new DynamicalClassBinding(this, item));
88
70
  }
@@ -105,32 +87,27 @@ export class Tag extends AbstractTag {
105
87
  }
106
88
  });
107
89
  }
108
- if (options.style && this.node instanceof HTMLElement) {
109
- for (const name in options.style) {
110
- const value = options.style[name];
90
+ if (options.s && node instanceof HTMLElement) {
91
+ for (const name in options.s) {
92
+ const value = options.s[name];
111
93
  if (value instanceof IValue) {
112
94
  this.bind(new StyleBinding(this, name, value));
113
95
  }
114
96
  else {
115
- this.node.style.setProperty(name, stringifyStyleValue(value));
97
+ node.style.setProperty(name, stringifyStyleValue(value));
116
98
  }
117
99
  }
118
100
  }
119
- if (options.events) {
120
- for (const name in options.events) {
121
- const event = options.events[name];
122
- if (event instanceof Array) {
123
- this.node.addEventListener(name, safe(event[0]), event[1]);
124
- }
125
- else {
126
- this.node.addEventListener(name, safe(event));
127
- }
101
+ if (options.e) {
102
+ for (const name in options.e) {
103
+ const event = options.e[name];
104
+ const handler = event instanceof Array ? event : [event, {}];
105
+ node.addEventListener(name, safe(ev => handler[0](ev, node)), handler[1]);
128
106
  }
129
107
  }
130
- if (options.bind) {
131
- const node = this.node;
132
- for (const k in options.bind) {
133
- const value = options.bind[k];
108
+ if (options.b) {
109
+ for (const k in options.b) {
110
+ const value = options.b[k];
134
111
  if (!(value instanceof IValue)) {
135
112
  node[k] = value;
136
113
  }
@@ -143,10 +120,8 @@ export class Tag extends AbstractTag {
143
120
  }
144
121
  }
145
122
  export class Runner {
146
- debugUi;
147
123
  document;
148
- constructor(debugUi, document) {
149
- this.debugUi = debugUi;
124
+ constructor(document) {
150
125
  this.document = document;
151
126
  }
152
127
  insertBefore(node, before) {
@@ -162,12 +137,9 @@ export class Runner {
162
137
  textNode(text) {
163
138
  return new TextNode({ text }, this);
164
139
  }
165
- debugNode(text) {
166
- return new DebugNode({ text }, this);
167
- }
168
140
  tag(tagName, input, cb) {
169
141
  if (cb) {
170
- input.slot = cb;
142
+ input.l = cb;
171
143
  }
172
144
  return new Tag(input, this, tagName);
173
145
  }
@@ -1,3 +1,4 @@
1
+ import { safe } from "../functional/safety.js";
1
2
  import { Reference } from "./reference.js";
2
3
  import { IValue } from "../core/ivalue.js";
3
4
  /**
@@ -29,13 +30,13 @@ export class Expression extends IValue {
29
30
  */
30
31
  constructor(func, values, ctx) {
31
32
  super();
32
- const handler = (i) => {
33
+ const handler = safe((i) => {
33
34
  /* istanbul ignore else */
34
35
  if (typeof i === "number") {
35
36
  this.valuesCache[i] = this.values[i]?.V;
36
37
  }
37
38
  this.sync.V = func.apply(this, this.valuesCache);
38
- };
39
+ });
39
40
  this.valuesCache = values.map(item => item?.V);
40
41
  this.sync = new Reference(func.apply(this, this.valuesCache));
41
42
  let i = 0;
@@ -17,7 +17,7 @@ export class RepeatNode extends Fragment {
17
17
  this.slot = input.slot && safe(input.slot);
18
18
  }
19
19
  createChild(id, item, before) {
20
- const node = new Fragment(this.runner);
20
+ const node = this.newChild(id, item);
21
21
  node.parent = this;
22
22
  this.destroyChild(id, item);
23
23
  if (before) {
@@ -47,4 +47,7 @@ export class RepeatNode extends Fragment {
47
47
  destroy() {
48
48
  this.nodes.clear();
49
49
  }
50
+ newChild(_id, _item) {
51
+ return new Fragment(this.runner);
52
+ }
50
53
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "The same framework which is designed to build bulletproof frontends (core library).",
4
4
  "main": "lib/index.js",
5
5
  "types": "types/index.d.ts",
6
- "version": "4.3.1",
6
+ "version": "5.0.1",
7
7
  "exports": {
8
8
  ".": {
9
9
  "types": "./types/index.d.ts",
@@ -11,6 +11,12 @@
11
11
  "browser": "./lib/index.js",
12
12
  "node": "./lib/index.js"
13
13
  },
14
+ "./dev": {
15
+ "types": "./types/dev/index.d.ts",
16
+ "import": "./lib/dev/index.js",
17
+ "browser": "./lib/dev/index.js",
18
+ "node": "./lib/dev/index.js"
19
+ },
14
20
  "./web-runner": {
15
21
  "types": "./types/runner/web/runner.d.ts",
16
22
  "import": "./lib/runner/web/runner.js",
@@ -0,0 +1,20 @@
1
+ import { App, Portal, PortalOptions } from "../node/app.js";
2
+ import { Fragment, SwitchedNode, SwitchedNodeCase } from "../node/node.js";
3
+ import { Watch, WatchOptions } from "../node/watch.js";
4
+ import { IDevRunner, StaticPosition } from "./inspectable.js";
5
+ export declare class DevWatch<Node, Element, TagOptions extends object, T> extends Watch<Node, Element, TagOptions, T> {
6
+ constructor(input: WatchOptions<Node, Element, TagOptions, IDevRunner<Node, Element, TagOptions>, T>, runner: IDevRunner<Node, Element, TagOptions>, usage: StaticPosition);
7
+ }
8
+ export declare class DevApp<Node, Element, TagOptions extends object> extends App<Node, Element, TagOptions> {
9
+ constructor(node: Element, runner: IDevRunner<Node, Element, TagOptions>);
10
+ }
11
+ export declare class DevPortal<Node, Element, TagOptions extends object, Runner extends IDevRunner<Node, Element, TagOptions>> extends Portal<Node, Element, TagOptions, Runner> {
12
+ readonly id: number;
13
+ constructor(input: PortalOptions<Node, Element, TagOptions, Runner>, runner: Runner, declaration: StaticPosition | undefined, usage: StaticPosition | undefined, name: string | undefined);
14
+ }
15
+ export declare class DevSwitchedNode<Node, Element, TagOptions extends object> extends SwitchedNode<Node, Element, TagOptions, IDevRunner<Node, Element, TagOptions>> {
16
+ readonly id: number;
17
+ constructor(usage: StaticPosition, runner: IDevRunner<Node, Element, TagOptions>, cases: SwitchedNodeCase<Node, Element, TagOptions, IDevRunner<Node, Element, TagOptions>>[], _default?: (node: Fragment<Node, Element, TagOptions>) => void);
18
+ destroy(): void;
19
+ protected newChild(index: number): Fragment<Node, Element, TagOptions, IDevRunner<Node, Element, TagOptions>>;
20
+ }
@@ -0,0 +1,8 @@
1
+ import { Reactive } from "../core/core.js";
2
+ import { IDevRunner, InspectableReactive } from "./inspectable.js";
3
+ export declare class DevReactive<Runner extends IDevRunner<unknown, unknown, object>> extends Reactive implements InspectableReactive {
4
+ readonly id: number;
5
+ readonly runner: Pick<Runner, "inspector">;
6
+ constructor(runner: Pick<Runner, "inspector">);
7
+ destroy(): void;
8
+ }
@@ -0,0 +1,8 @@
1
+ export { DevReactive } from "./core.js";
2
+ export { DevApp, DevPortal, DevSwitchedNode, DevWatch } from "./components.js";
3
+ export { type Dependency, type DevValue, type Inspectable, type InspectableReactive, type InspectableReference, type Inspector, type StaticPosition, type ExecutionPosition, type ProtocolExecutionPosition, type ProtocolComponent, type ProtocolDependency, type ProtocolExpression, type ProtocolExpressionError, type ProtocolExpressionUpdate, type ProtocolModel, type ProtocolModelUpdate, type ProtocolNode, type ProtocolParent, type ProtocolPosition, type ProtocolReference, type ProtocolReferenceError, type ProtocolReferenceUpdate, type ProtocolState, type ProtocolTag, type ProtocolCustomModel, type ProtocolStore, type ProtocolRouterActionCall, type ProtocolDevValue, type ProtocolSlotError, type ProtocolRouterStateChange, type ProtocolRoutes, type ProtocolRouterTargetResult, type ProtocolFunctionError, type ProtocolFunctionResult, type ProtocolFunctionCall, type ProtocolEventTrigger, type ProtocolComposeTime, type ProtocolError, type IDevRunner, type DestroyData, executionPosition, provideId, runFn, wrapFn, registerReference, toDevId, toDevIdOrValue, toDevObject, toDevValue, } from "./inspectable.js";
4
+ export { DevArrayModel, DevMapModel, DevSetModel } from "./models.js";
5
+ export { DevFragment, ModelId, shareStateById } from "./node.js";
6
+ export { DevRunner, PositionedText, type DevTagOptions, positionedText, remapObject, DevTextNode, DevTag, } from "./runner.js";
7
+ export { BaseDevReference, DevExpression, DevIValue, DevReference, ExpressionDevReference, type KindOfDevIValue, } from "./state.js";
8
+ export { DevArrayView, DevMapView, DevSetView } from "./views.js";
@@ -0,0 +1,244 @@
1
+ import { IRunner } from "../node/runner.js";
2
+ import { DevReference } from "./state.js";
3
+ export type StaticPosition = [string, number, number, number, number];
4
+ export type ExecutionPosition = number;
5
+ export declare function executionPosition(inspector: Inspector, pathLineAndChar: StaticPosition, error: Error): ExecutionPosition;
6
+ export interface Inspectable {
7
+ id: number;
8
+ }
9
+ export interface InspectableReactive {
10
+ id: number;
11
+ }
12
+ export interface InspectableReference<T> extends Inspectable {
13
+ declaration?: StaticPosition;
14
+ update(value: T, position?: ExecutionPosition): void;
15
+ }
16
+ export interface Dependency extends Inspectable {
17
+ code: string;
18
+ value: DevValue;
19
+ }
20
+ export interface ProtocolPosition {
21
+ id: number;
22
+ declaration: StaticPosition;
23
+ }
24
+ export interface ProtocolReference extends ProtocolPosition {
25
+ value: DevValue;
26
+ time: number;
27
+ }
28
+ export interface ProtocolReferenceUpdate {
29
+ id: number;
30
+ time: number;
31
+ value: DevValue;
32
+ position?: ExecutionPosition;
33
+ }
34
+ export interface ProtocolError {
35
+ targetId: number;
36
+ time: number;
37
+ error: string;
38
+ }
39
+ export interface ProtocolReferenceError extends ProtocolError {
40
+ position?: ExecutionPosition;
41
+ }
42
+ export interface ProtocolExpression extends ProtocolReference {
43
+ deps: (Dependency | string)[];
44
+ isWatch: boolean;
45
+ }
46
+ export interface ProtocolExpressionUpdate extends ProtocolReferenceUpdate {
47
+ deps: DevValue[];
48
+ }
49
+ export interface ProtocolExpressionError extends ProtocolReferenceError {
50
+ deps: DevValue[];
51
+ }
52
+ export interface ProtocolDependency {
53
+ dependant: number;
54
+ dependency: number;
55
+ }
56
+ export interface ProtocolComponent {
57
+ id: number;
58
+ name: string;
59
+ props: {
60
+ [k: string]: number | DevValue;
61
+ };
62
+ declaration?: StaticPosition | null;
63
+ usage?: StaticPosition | null;
64
+ time: number;
65
+ }
66
+ export interface ProtocolState {
67
+ id: number;
68
+ name: string;
69
+ stateId: number;
70
+ }
71
+ export interface ProtocolParent {
72
+ child: number;
73
+ parent: number;
74
+ }
75
+ export interface ProtocolTag {
76
+ id: number;
77
+ time: number;
78
+ usage: StaticPosition | undefined;
79
+ tagName: string;
80
+ attr?: {
81
+ [k: string]: number | DevValue;
82
+ };
83
+ class?: (number | string | {
84
+ [k: string]: number | DevValue;
85
+ })[];
86
+ style?: {
87
+ [k: string]: number | string;
88
+ };
89
+ events?: {
90
+ [k: string]: DevValue;
91
+ };
92
+ bind?: {
93
+ [k: string]: number | DevValue;
94
+ };
95
+ callback?: number | DevValue;
96
+ }
97
+ export interface ProtocolNode {
98
+ id: number;
99
+ time: number;
100
+ text: number | DevValue;
101
+ position: StaticPosition;
102
+ }
103
+ export interface ProtocolSlotError extends ProtocolError {
104
+ usage: StaticPosition;
105
+ }
106
+ export interface ProtocolComposeTime {
107
+ id: number;
108
+ time: number;
109
+ }
110
+ export interface ProtocolModel {
111
+ id: number;
112
+ type: "array" | "set" | "map";
113
+ values: [DevValue, DevValue][];
114
+ usage: StaticPosition;
115
+ time: number;
116
+ }
117
+ export interface ProtocolModelUpdate {
118
+ id: number;
119
+ method: string;
120
+ args: DevValue[];
121
+ return: DevValue;
122
+ }
123
+ export interface ProtocolStore extends ProtocolPosition {
124
+ name: string;
125
+ time: number;
126
+ }
127
+ export interface ProtocolCustomModel extends ProtocolPosition {
128
+ time: number;
129
+ usage: StaticPosition;
130
+ name: string;
131
+ props: {
132
+ [k: string]: number | DevValue;
133
+ };
134
+ }
135
+ export interface ProtocolRouterTargetResult {
136
+ time: number;
137
+ url: string;
138
+ path: string;
139
+ query: {
140
+ [k: string]: string[];
141
+ };
142
+ hash: string;
143
+ targetFound: boolean;
144
+ params: object;
145
+ }
146
+ export interface ProtocolExecutionPosition {
147
+ id: number;
148
+ position: StaticPosition;
149
+ stack: string[];
150
+ }
151
+ export interface ProtocolDevValue {
152
+ id: number;
153
+ pos: StaticPosition;
154
+ }
155
+ export interface ProtocolRoutes {
156
+ time: number;
157
+ paths: string[];
158
+ }
159
+ export interface ProtocolRouterStateChange {
160
+ time: number;
161
+ name: string;
162
+ value: string | null | undefined;
163
+ }
164
+ export interface ProtocolRouterActionCall {
165
+ time: number;
166
+ name: string;
167
+ path: string;
168
+ }
169
+ export interface ProtocolFunctionCall {
170
+ position: StaticPosition;
171
+ id: number;
172
+ args: DevValue[];
173
+ time: number;
174
+ }
175
+ export interface ProtocolEventTrigger {
176
+ tagId: number;
177
+ eventName: string;
178
+ time: number;
179
+ }
180
+ export interface ProtocolFunctionResult {
181
+ id: number;
182
+ result: DevValue;
183
+ async: boolean;
184
+ time: number;
185
+ }
186
+ export interface ProtocolFunctionError extends ProtocolError {
187
+ async: boolean;
188
+ }
189
+ export interface DestroyData {
190
+ id: number;
191
+ time: number;
192
+ }
193
+ export interface Inspector {
194
+ registerExecutionPosition(pos: ProtocolExecutionPosition): void;
195
+ reportError(err: ProtocolError): void;
196
+ newReference(ref: ProtocolReference): void;
197
+ updateReference(update: ProtocolReferenceUpdate): void;
198
+ reportReferenceError(error: ProtocolReferenceError): void;
199
+ newExpression(expr: ProtocolExpression): void;
200
+ updateExpression(update: ProtocolExpressionUpdate): void;
201
+ reportExpressionCalculationError(error: ProtocolExpressionError): void;
202
+ createComponent(comp: ProtocolComponent): void;
203
+ createTag(tag: ProtocolTag): void;
204
+ createNode(node: ProtocolNode): void;
205
+ addContextState(state: ProtocolState): void;
206
+ setElementParent(parent: ProtocolParent): void;
207
+ reportComponentError(error: ProtocolError): void;
208
+ reportComponentSlotError(error: ProtocolSlotError): void;
209
+ composeTime(time: ProtocolComposeTime): void;
210
+ createModel(model: ProtocolModel): void;
211
+ updateModel(update: ProtocolModelUpdate): void;
212
+ createStore(store: ProtocolStore): void;
213
+ createCustomModel(model: ProtocolCustomModel): void;
214
+ registeredRoutes(routes: ProtocolRoutes): void;
215
+ routerStateChange(change: ProtocolRouterStateChange): void;
216
+ routerActionCall(call: ProtocolRouterActionCall): void;
217
+ routerTargetResult(data: ProtocolRouterTargetResult): void;
218
+ functionCall(call: ProtocolFunctionCall): void;
219
+ functionReturn(result: ProtocolFunctionResult): void;
220
+ functionThrows(error: ProtocolFunctionError): void;
221
+ eventTrigger(call: ProtocolEventTrigger): void;
222
+ destroy(data: DestroyData): void;
223
+ }
224
+ export declare function provideId(): number;
225
+ export interface DevValue {
226
+ type: string;
227
+ value?: string | undefined;
228
+ id?: number;
229
+ }
230
+ export declare function registerReference<T>(value: DevReference<T>, declaration: StaticPosition, inspector: Inspector): DevReference<T>;
231
+ export declare function wrapFn<Args extends unknown[], Result extends object>(fn: (...args: Args) => Result, declaration: StaticPosition, inspector: Inspector): (...args: Args) => Result;
232
+ export declare function runFn<Args extends unknown[], Result extends object>(fn: (...args: Args) => Result, args: Args, declaration: StaticPosition, inspector: Inspector): Result;
233
+ export declare function toDevValue(value: unknown): {
234
+ type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
235
+ value: string | undefined;
236
+ };
237
+ export declare function toDevId(value: unknown): number | undefined;
238
+ export declare function toDevIdOrValue(value: unknown): number | DevValue;
239
+ export declare function toDevObject(value: object): {
240
+ [k: string]: number | DevValue;
241
+ };
242
+ export interface IDevRunner<Node, Element, TagOptions extends object> extends IRunner<Node, Element, TagOptions> {
243
+ inspector: Inspector;
244
+ }
@@ -0,0 +1,38 @@
1
+ import { Reactive } from "../core/core.js";
2
+ import { ArrayModel } from "../models/array-model.js";
3
+ import { MapModel } from "../models/map-model.js";
4
+ import { SetModel } from "../models/set-model.js";
5
+ import { Inspector, StaticPosition } from "./inspectable.js";
6
+ export declare class DevArrayModel<T> extends ArrayModel<T> {
7
+ readonly id: number;
8
+ readonly inspector: Inspector | undefined;
9
+ constructor(inspector: Inspector | undefined, usage: StaticPosition, data?: Array<T> | number, ctx?: Reactive);
10
+ destroy(): void;
11
+ fill(value: T, start?: number, end?: number): this;
12
+ pop(): T | undefined;
13
+ push(...items: T[]): number;
14
+ shift(): T | undefined;
15
+ splice(start: number, deleteCount?: number, ...items: T[]): ArrayModel<T>;
16
+ unshift(...items: T[]): number;
17
+ protected shareChange(method: string, args: unknown[], result: unknown): void;
18
+ }
19
+ export declare class DevSetModel<T> extends SetModel<T> {
20
+ readonly id: number;
21
+ readonly inspector: Inspector | undefined;
22
+ constructor(inspector: Inspector | undefined, usage: StaticPosition, set?: T[], ctx?: Reactive);
23
+ destroy(): void;
24
+ add(value: T): this;
25
+ clear(): void;
26
+ delete(value: T): boolean;
27
+ protected shareChange(method: string, args: unknown[], result: unknown): void;
28
+ }
29
+ export declare class DevMapModel<K, T> extends MapModel<K, T> {
30
+ readonly id: number;
31
+ readonly inspector: Inspector | undefined;
32
+ constructor(inspector: Inspector | undefined, usage: StaticPosition, map?: [K, T][], ctx?: Reactive);
33
+ destroy(): void;
34
+ clear(): void;
35
+ delete(key: K): boolean;
36
+ set(key: K, value: T): this;
37
+ protected shareChange(method: string, args: unknown[], result: unknown): void;
38
+ }
@@ -0,0 +1,12 @@
1
+ import { Fragment } from "../node/node.js";
2
+ import { IDevRunner, InspectableReactive, Inspector, StaticPosition } from "./inspectable.js";
3
+ export declare const ModelId: unique symbol;
4
+ export declare function shareStateById<T>(id: number | undefined, runner: IDevRunner<unknown, unknown, object>, name: string, value: T): T;
5
+ export declare class DevFragment<Node, Element, TagOptions extends object> extends Fragment<Node, Element, TagOptions, IDevRunner<Node, Element, TagOptions>> implements InspectableReactive {
6
+ id: number;
7
+ declaration: StaticPosition | null;
8
+ inspector: Inspector;
9
+ constructor(runner: IDevRunner<Node, Element, TagOptions>, declaration: StaticPosition | null, usage: StaticPosition | null, name: string, props: object);
10
+ destroy(): void;
11
+ protected pushNode(node: Fragment<Node, Element, TagOptions>): void;
12
+ }
@@ -0,0 +1,37 @@
1
+ import { TextProps } from "../node/node.js";
2
+ import { Runner, Tag, TagOptions, TextNode } from "../runner/web/runner.js";
3
+ import { IDevRunner, Inspector, StaticPosition } from "./inspectable.js";
4
+ export interface DevTagOptions extends TagOptions {
5
+ usage?: StaticPosition;
6
+ }
7
+ export declare class PositionedText {
8
+ text: unknown;
9
+ position: StaticPosition;
10
+ constructor(text: unknown, position: StaticPosition);
11
+ }
12
+ export declare function positionedText(text: unknown, position: StaticPosition): PositionedText;
13
+ export declare class DevTextNode extends TextNode<DevTagOptions, DevRunner> {
14
+ readonly id: number;
15
+ constructor(input: TextProps, runner: DevRunner, usage: StaticPosition, inspector: Inspector);
16
+ destroy(): void;
17
+ compose(): void;
18
+ }
19
+ export declare function remapObject<Before, After>(obj: {
20
+ [k: string]: Before;
21
+ }, transform: (v: Before) => After): {
22
+ [k: string]: After;
23
+ };
24
+ export declare class DevTag extends Tag<DevTagOptions, DevRunner> {
25
+ readonly id: number;
26
+ constructor(options: DevTagOptions, runner: DevRunner, tagName: string, usage: StaticPosition | undefined, inspector: Inspector);
27
+ applyOptions(options: DevTagOptions): void;
28
+ getNode(): Element;
29
+ destroy(): void;
30
+ compose(): void;
31
+ }
32
+ export declare class DevRunner extends Runner<DevTagOptions> implements IDevRunner<Node, Element, DevTagOptions> {
33
+ readonly inspector: Inspector;
34
+ constructor(document: Document, inspector: Inspector);
35
+ textNode(text: unknown): TextNode<DevTagOptions, DevRunner>;
36
+ tag(tagName: string, input: DevTagOptions, cb?: ((ctx: DevTag) => void) | undefined): DevTag;
37
+ }
@@ -0,0 +1,53 @@
1
+ import { Reactive } from "../core/core.js";
2
+ import { Destroyable } from "../core/destroyable.js";
3
+ import { IValue } from "../core/ivalue.js";
4
+ import { ExecutionPosition, InspectableReference, Inspector, StaticPosition } from "./inspectable.js";
5
+ export type KindOfDevIValue<T extends unknown[]> = {
6
+ [K in keyof T]: IValue<T[K]> | DevIValue<T[K]> | undefined;
7
+ };
8
+ export declare abstract class DevIValue<T> extends IValue<T> {
9
+ abstract update(value: T, position: ExecutionPosition): void;
10
+ }
11
+ export declare class BaseDevReference<T> extends DevIValue<T> {
12
+ protected state: T;
13
+ protected readonly onChange: Set<(value: T, position?: ExecutionPosition) => void>;
14
+ constructor(value: T);
15
+ get V(): T;
16
+ set V(value: T);
17
+ update(value: T, position?: ExecutionPosition): void;
18
+ on(handler: (value: T, position: ExecutionPosition) => void): void;
19
+ off(handler: (value: T, position: ExecutionPosition) => void): void;
20
+ protected shareUpdate(position?: ExecutionPosition): void;
21
+ protected shareError(error: unknown, position?: ExecutionPosition): void;
22
+ }
23
+ export declare class DevReference<T> extends BaseDevReference<T> implements InspectableReference<T>, Destroyable {
24
+ readonly id: number;
25
+ readonly inspector: Inspector | undefined;
26
+ constructor(value: T, declaration: StaticPosition, inspector?: Inspector);
27
+ destroy(): void;
28
+ protected shareUpdate(position?: ExecutionPosition): void;
29
+ protected shareError(error: unknown, position?: ExecutionPosition): void;
30
+ protected shareDestroy(): void;
31
+ }
32
+ export declare class ExpressionDevReference<T> extends BaseDevReference<T> implements InspectableReference<T> {
33
+ readonly id: number;
34
+ readonly inspector: Inspector | undefined;
35
+ constructor(id: number, value: T, inspector: Inspector | undefined);
36
+ protected shareError(error: unknown, position: ExecutionPosition): void;
37
+ }
38
+ export declare class DevExpression<T, Args extends unknown[]> extends IValue<T> implements Destroyable, InspectableReference<T> {
39
+ readonly id: number;
40
+ readonly declaration: StaticPosition;
41
+ readonly inspector: Inspector | undefined;
42
+ private values;
43
+ private readonly valuesCache;
44
+ private linkedFunc;
45
+ private sync;
46
+ constructor(func: (...args: Args) => T, values: KindOfDevIValue<Args>, ctx: Reactive | undefined, depsCode: string[], declaration: StaticPosition, inspector: Inspector | undefined, isWatch: boolean);
47
+ update(value: T, position?: ExecutionPosition): void;
48
+ get V(): T;
49
+ set V(v: T);
50
+ on(handler: (value: T, position: ExecutionPosition) => void): void;
51
+ off(handler: (value: T, position: ExecutionPosition) => void): void;
52
+ destroy(): void;
53
+ }
@@ -0,0 +1,22 @@
1
+ import { Fragment } from "../node/node.js";
2
+ import { ArrayView } from "../views/array-view.js";
3
+ import { BaseViewOptions } from "../views/base-view.js";
4
+ import { MapView } from "../views/map-view.js";
5
+ import { SetView } from "../views/set-view.js";
6
+ import { IDevRunner, StaticPosition } from "./inspectable.js";
7
+ import { DevArrayModel, DevMapModel, DevSetModel } from "./models.js";
8
+ export declare class DevArrayView<Node, Element, TagOptions extends object, T> extends ArrayView<Node, Element, TagOptions, T, IDevRunner<Node, Element, TagOptions>> {
9
+ readonly id: number;
10
+ constructor(input: BaseViewOptions<Node, Element, TagOptions, T, T, DevArrayModel<T>, IDevRunner<Node, Element, TagOptions>>, runner: IDevRunner<Node, Element, TagOptions>, usage: StaticPosition);
11
+ protected newChild(id: T, item: T): Fragment<Node, Element, TagOptions, IDevRunner<Node, Element, TagOptions>>;
12
+ }
13
+ export declare class DevSetView<Node, Element, TagOptions extends object, T> extends SetView<Node, Element, TagOptions, T, IDevRunner<Node, Element, TagOptions>> {
14
+ readonly id: number;
15
+ constructor(input: BaseViewOptions<Node, Element, TagOptions, T, T, DevSetModel<T>, IDevRunner<Node, Element, TagOptions>>, runner: IDevRunner<Node, Element, TagOptions>, usage: StaticPosition);
16
+ protected newChild(_id: T, item: T): Fragment<Node, Element, TagOptions, IDevRunner<Node, Element, TagOptions>>;
17
+ }
18
+ export declare class DevMapView<Node, Element, TagOptions extends object, K, T> extends MapView<Node, Element, TagOptions, K, T, IDevRunner<Node, Element, TagOptions>> {
19
+ readonly id: number;
20
+ constructor(input: BaseViewOptions<Node, Element, TagOptions, K, T, DevMapModel<K, T>, IDevRunner<Node, Element, TagOptions>>, runner: IDevRunner<Node, Element, TagOptions>, usage: StaticPosition);
21
+ protected newChild(key: K, value: T): Fragment<Node, Element, TagOptions, IDevRunner<Node, Element, TagOptions>>;
22
+ }