vasille 7.0.0-rc.2 → 7.0.0-rc.4

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.
@@ -1,17 +1,11 @@
1
1
  import { DevExpression, DevReference } from "./state.js";
2
2
  let positionId = 1;
3
- function getErrorStack(error) {
4
- return (error.stack
5
- ?.split("\n")
6
- .slice(1)
7
- .map(line => line.trim()) ?? []);
8
- }
9
- export function executionPosition(inspector, pathLineAndChar, error) {
3
+ export function executionPosition(pathLineAndChar, error) {
10
4
  const id = positionId++;
11
5
  inspector.registerExecutionPosition({
12
6
  id: id,
13
7
  position: pathLineAndChar,
14
- stack: getErrorStack(error),
8
+ stack: error.stack ?? "",
15
9
  });
16
10
  return id;
17
11
  }
@@ -24,7 +24,7 @@ export class StyleBinding extends Binding {
24
24
  super(value);
25
25
  this.init(value => {
26
26
  /* istanbul ignore else */
27
- if (node.node instanceof HTMLElement) {
27
+ if (node.node instanceof HTMLElement && value !== undefined) {
28
28
  node.node.style.setProperty(name, stringifyStyleValue(value));
29
29
  }
30
30
  });
@@ -124,7 +124,7 @@ export class Tag extends AbstractTag {
124
124
  if (value instanceof IValue) {
125
125
  this.bind(new StyleBinding(this, name, value));
126
126
  }
127
- else {
127
+ else if (value) {
128
128
  node.style.setProperty(name, stringifyStyleValue(value));
129
129
  }
130
130
  }
@@ -1,5 +1,4 @@
1
1
  import { safe } from "../functional/safety.js";
2
- import { Reference } from "./reference.js";
3
2
  import { IValue } from "../core/ivalue.js";
4
3
  /**
5
4
  * Bind some values to one expression
@@ -28,7 +27,7 @@ export class Expression extends IValue {
28
27
  /**
29
28
  * Creates a function bounded to N values
30
29
  */
31
- constructor(func, values, ctx) {
30
+ constructor(func, ref, values, ctx) {
32
31
  super(ctx?.sDeep ?? 0);
33
32
  const handler = safe((i) => {
34
33
  /* istanbul ignore else */
@@ -37,8 +36,7 @@ export class Expression extends IValue {
37
36
  }
38
37
  this.sync.V = func.apply(this, this.valuesCache);
39
38
  });
40
- this.valuesCache = values.map(item => item?.V);
41
- this.sync = new Reference(func.apply(this, this.valuesCache));
39
+ this.sync = ref((this.valuesCache = values.map(item => item?.V)));
42
40
  let i = 0;
43
41
  let deep = -1;
44
42
  values.forEach(value => {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "The same devkit which is designed to build fault tolerant frontends (core library).",
4
4
  "main": "lib/index.js",
5
5
  "types": "types/index.d.ts",
6
- "version": "7.0.0-rc.2",
6
+ "version": "7.0.0-rc.4",
7
7
  "exports": {
8
8
  ".": {
9
9
  "types": "./types/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  import { DevReference } from "./state.js";
2
2
  export type StaticPosition = [string, number, number, number, number];
3
3
  export type ExecutionPosition = number;
4
- export declare function executionPosition(inspector: Inspector, pathLineAndChar: StaticPosition, error: Error): ExecutionPosition;
4
+ export declare function executionPosition(pathLineAndChar: StaticPosition, error: Error): ExecutionPosition;
5
5
  export declare function errorToString(e: unknown): string;
6
6
  export interface Inspectable {
7
7
  id: number;
@@ -150,7 +150,7 @@ export interface ProtocolRouterTargetResult {
150
150
  export interface ProtocolExecutionPosition {
151
151
  id: number;
152
152
  position: StaticPosition;
153
- stack: string[];
153
+ stack: string;
154
154
  }
155
155
  export interface ProtocolDevValue {
156
156
  id: number;
@@ -19,7 +19,7 @@ export declare class DevTextNode extends TextNode<DevTagOptions, DevRunner> {
19
19
  }
20
20
  export declare function remapObject<Before, After>(obj: {
21
21
  [k: string]: Before;
22
- }, transform: (v: Before) => After): {
22
+ } | undefined, transform: (v: Before) => After): {
23
23
  [k: string]: After;
24
24
  };
25
25
  export declare class DevTag extends Tag<DevTagOptions, DevRunner> {
@@ -7,12 +7,12 @@ export declare function stringifyStyleValue(value: string | number | number[]):
7
7
  * @class StyleBinding
8
8
  * @extends Binding
9
9
  */
10
- export declare class StyleBinding extends Binding<string | number | number[]> {
10
+ export declare class StyleBinding extends Binding<string | number | number[] | undefined> {
11
11
  /**
12
12
  * Constructs a style binding attribute
13
13
  * @param node {Tag} the vasille node
14
14
  * @param name {string} the name of style property
15
15
  * @param value {IValue} the value to bind
16
16
  */
17
- constructor(node: Tag<Node, Element, object>, name: string, value: IValue<string | number | number[]>);
17
+ constructor(node: Tag<Node, Element, object>, name: string, value: IValue<string | number | number[] | undefined>);
18
18
  }
@@ -1,11 +1,11 @@
1
1
  import { TextNode as AbstractTextNode, Tag as AbstractTag, Runner as IRunner, IValue } from "../../index.js";
2
2
  export type AttrType<T> = IValue<T | string | null> | T | string | null | undefined;
3
- export type StyleType<T> = T | number | number[] | IValue<string | number | number[]>;
3
+ export type StyleType<T> = T | number | number[] | IValue<string | number | number[] | undefined> | undefined;
4
4
  export interface TagOptions {
5
5
  /** attributes */
6
6
  a?: Record<string, AttrType<number | boolean>>;
7
7
  /** classes */
8
- c?: (string | IValue<string> | Record<string, boolean | IValue<boolean>>)[];
8
+ c?: (string | IValue<string> | Record<string, boolean | IValue<boolean>> | undefined)[];
9
9
  /** style */
10
10
  s?: Record<string, StyleType<string>>;
11
11
  /** events */
@@ -1,6 +1,5 @@
1
1
  import { Reactive } from "../core/core.js";
2
2
  import { Destroyable } from "../core/destroyable.js";
3
- import { Reference } from "./reference.js";
4
3
  import { IValue } from "../core/ivalue.js";
5
4
  export type KindOfIValue<T extends unknown[]> = {
6
5
  [K in keyof T]: IValue<T[K]> | undefined;
@@ -28,11 +27,11 @@ export declare class Expression<T, Args extends unknown[]> extends IValue<T> imp
28
27
  /**
29
28
  * The buffer to keep the last calculated value
30
29
  */
31
- protected sync: Reference<T>;
30
+ protected sync: IValue<T>;
32
31
  /**
33
32
  * Creates a function bounded to N values
34
33
  */
35
- constructor(func: (...args: Args) => T, values: KindOfIValue<Args>, ctx?: Reactive);
34
+ constructor(func: (...args: Args) => T, ref: (args: Args) => IValue<T>, values: KindOfIValue<Args>, ctx?: Reactive);
36
35
  get V(): T;
37
36
  set V(value: T);
38
37
  on(handler: (value: T) => void): void;