typecomposer 0.1.42 → 0.1.44

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,56 +1,129 @@
1
1
  import { Ref } from ".";
2
2
  import { RefContainer } from "./RefContainer";
3
+ /**
4
+ * Creates a reactive wrapper for a Set of values.
5
+ *
6
+ * @param values - Optional array of initial values for the Set.
7
+ * @returns A new instance of RefSet.
8
+ */
3
9
  export function refSet(values) {
4
10
  return new RefSet(values);
5
11
  }
12
+ // Enables `instanceof refSet` to work with RefSet instances
6
13
  Object.defineProperty(refSet, Symbol.hasInstance, {
7
14
  value: function (instance) {
8
15
  return !!instance && instance instanceof RefSet;
9
16
  },
10
17
  });
11
- // @ts-ignore
18
+ /**
19
+ * A reactive wrapper around the native Set object.
20
+ * Notifies subscribers when the contents of the Set are mutated.
21
+ */
12
22
  export class RefSet extends Set {
23
+ /**
24
+ * Internal container that manages the reactive value and subscribers.
25
+ */
13
26
  container = new RefContainer(this);
27
+ /**
28
+ * An optional key used to register the reference globally.
29
+ */
14
30
  refKey;
31
+ /**
32
+ * Constructs a new reactive Set instance.
33
+ *
34
+ * @param values - Optional array of initial values.
35
+ * @param refKey - Optional identifier to register in the global Ref registry.
36
+ */
15
37
  constructor(values, refKey) {
16
38
  super();
17
39
  this.refKey = refKey;
18
40
  this.value = new Set(values);
19
41
  refKey && Ref.set(refKey, this);
20
42
  }
43
+ /**
44
+ * Emits a change event to all subscribers for a given mutation.
45
+ *
46
+ * @param propertyName - The mutation name (e.g., "add", "delete", "clear").
47
+ * @param value - The current state of the Set.
48
+ */
21
49
  // @ts-ignore
22
50
  emit(propertyName, value) {
23
51
  this.container.emitAll(propertyName, value);
24
52
  }
53
+ /**
54
+ * Subscribes to changes and immediately emits the current Set.
55
+ */
25
56
  subscribe(target, propertyName, onUnsubscribe) {
26
57
  return this.container.emit(this.container.subscribe(target, propertyName, onUnsubscribe), this);
27
58
  }
59
+ /**
60
+ * Subscribes to future changes without emitting the current value.
61
+ *
62
+ * @param target - A callback function to be called on update.
63
+ * @param onUnsubscribe - Optional callback for when unsubscribed.
64
+ * @returns true if subscription was successful.
65
+ */
66
+ listen(target, onUnsubscribe) {
67
+ return this.container.subscribe(target, onUnsubscribe) !== undefined;
68
+ }
28
69
  unsubscribe(targe, propertyName = "") {
29
70
  return this.container.unsubscribe(targe, propertyName);
30
71
  }
72
+ /** Reactive mutation overrides **/
73
+ /**
74
+ * Adds a new value to the Set and notifies subscribers.
75
+ *
76
+ * @param value - The value to add.
77
+ * @returns The Set instance.
78
+ */
31
79
  add(value) {
32
80
  const result = super.add(value);
33
81
  this.container.emitAll("add", this);
34
82
  return result;
35
83
  }
84
+ /**
85
+ * Removes a value from the Set and notifies subscribers.
86
+ *
87
+ * @param value - The value to remove.
88
+ * @returns True if the value was present and removed.
89
+ */
36
90
  delete(value) {
37
91
  const result = super.delete(value);
38
92
  this.container.emitAll("delete", this);
39
93
  return result;
40
94
  }
95
+ /**
96
+ * Removes all values from the Set and notifies subscribers.
97
+ */
41
98
  clear() {
42
99
  super.clear();
43
100
  this.container.emitAll("clear", this);
44
101
  }
102
+ /**
103
+ * Returns a shallow copy of the current Set state.
104
+ */
45
105
  valueOf() {
46
106
  return new Set(Array.from(this));
47
107
  }
108
+ /**
109
+ * Ensures native Set is used in methods like `slice`, `filter`, etc.
110
+ */
48
111
  static get [Symbol.species]() {
49
112
  return Set;
50
113
  }
114
+ /** Value access and serialization **/
115
+ /**
116
+ * Gets the current Set value.
117
+ */
51
118
  get value() {
52
119
  return this.container.value.valueOf();
53
120
  }
121
+ /**
122
+ * Replaces the entire Set with a new Set and notifies subscribers.
123
+ * If the same Set reference is passed, no update is triggered.
124
+ *
125
+ * @param value - A new Set instance to replace the current content.
126
+ */
54
127
  set value(value) {
55
128
  if (this === value)
56
129
  return;
@@ -60,6 +133,9 @@ export class RefSet extends Set {
60
133
  }
61
134
  this.emit("value", value);
62
135
  }
136
+ /**
137
+ * Serializes the Set to an object with numeric keys for JSON output.
138
+ */
63
139
  toJSON() {
64
140
  const obj = {};
65
141
  let i = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"RefSet.js","sourceRoot":"","sources":["../../../src/core/ref/RefSet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,GAAG,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,UAAU,MAAM,CAAI,MAA4B;IACpD,OAAO,IAAI,MAAM,CAAI,MAAM,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE;IAChD,KAAK,EAAE,UAAU,QAAa;QAC5B,OAAO,CAAC,CAAC,QAAQ,IAAI,QAAQ,YAAY,MAAM,CAAC;IAClD,CAAC;CACF,CAAC,CAAC;AAGH,aAAa;AACb,MAAM,OAAO,MAAU,SAAQ,GAAM;IAC1B,SAAS,GAAiB,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;IACjD,MAAM,CAAS;IAExB,YAAY,MAA4B,EAAE,MAAe;QACvD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,CAAI,MAAM,CAAC,CAAC;QAChC,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,IAAW,CAAC,CAAC;IACzC,CAAC;IAED,aAAa;IACL,IAAI,CAAC,YAA6B,EAAE,KAAU;QACpD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAOD,SAAS,CAAC,MAAe,EAAE,YAAsB,EAAE,aAAuB;QACxE,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,aAAa,CAAC,EAAE,IAAI,CAA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AK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;QACzB,OAAO,GAAG,CAAC;IACb,CAAC;IAED,sCAAsC;IAEtC;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,IAAI,KAAK,KAAK;YAAE,OAAO;QAC3B,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,MAAM,GAAG,GAAQ,EAAE,CAAC;QACpB,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC3B,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
@@ -14,6 +14,7 @@ export declare class RefState<T> implements ref<T> {
14
14
  subscribe(target: object, propertyName: string | symbol): boolean;
15
15
  subscribe(target: object, propertyName: string | symbol, onUnsubscribe: Function): boolean;
16
16
  subscribe(target: object | ((arg: boolean) => void), propertyName: string | symbol | Function, onUnsubscribe?: Function): boolean;
17
+ listen(target: (arg: T) => void, onUnsubscribe?: Function): boolean;
17
18
  unsubscribe(target: (arg: T) => void): boolean;
18
19
  unsubscribe(target: object, propertyName: string | symbol): boolean;
19
20
  get value(): T;
@@ -51,6 +51,9 @@ export class RefState {
51
51
  this.#subscribers.push({ target, propertyName, onUnsubscribe });
52
52
  return true;
53
53
  }
54
+ listen(target, onUnsubscribe) {
55
+ return this.subscribe(target, onUnsubscribe);
56
+ }
54
57
  unsubscribe(targe, propertyName = "") {
55
58
  if (this.ref) {
56
59
  // @ts-ignore
@@ -1 +1 @@
1
- {"version":3,"file":"RefState.js","sourceRoot":"","sources":["../../../src/core/ref/RefState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAO,MAAM,GAAG,CAAC;AAE7B,MAAM,UAAU,QAAQ,CAAI,MAAc;IACxC,OAAO,IAAI,QAAQ,CAAI,MAAM,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE;IAClD,KAAK,EAAE,UAAU,QAAa;QAC5B,OAAO,CAAC,CAAC,QAAQ,IAAI,QAAQ,YAAY,QAAQ,CAAC;IACpD,CAAC;CACF,CAAC,CAAC;AAGH,aAAa;AACb,MAAM,OAAO,QAAQ;IACV,MAAM,CAAS;IACxB,IAAI,CAAqB;IACzB,YAAY,GAA2E,EAAE,CAAC;IAE1F,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC5B,aAAa;gBACb,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;gBAChB,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;oBAC3C,aAAa;oBACb,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,YAAmB,EAAE,UAAU,CAAC,aAAoB,CAAC,CAAC;gBAC3G,CAAC;gBACD,IAAI,CAAC,YAAY,GAAG,SAAgB,CAA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AC,KAAa,EAAE,eAAgC,EAAE;QAC3D,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACb,aAAa;YACb,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,KAAK,KAAK,IAAI,UAAU,CAAC,YAAY,KAAK,YAAY,CAAC,CAAC;QACpI,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,aAAa;IACb,IAAI,KAAK;QACP,aAAa;QACb,OAAO,IAAI,CAAC,GAAG,EAAE,KAAK,CAAA;IACxB,CAAC;IACD,aAAa;IAEb,IAAI,KAAK,CAAC,KAAQ;QAChB,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACb,aAAa;YACb,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,CAAA;QACxB,CAAC;IACH,CAAC;IAED,OAAO;QACL,aAAa;QACb,OAAO,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC;IAC7B,CAAC;IACD,aAAa;IACb,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;IACjC,CAAC;IAED,QAAQ;QACN,OAAO,0BAA0B,CAAA;IACnC,CAAC;CACF"}
@@ -1,36 +1,140 @@
1
1
  import { ref } from ".";
2
2
  import { RefContainer } from "./RefContainer";
3
+ /**
4
+ * Creates a reactive wrapper around a string.
5
+ *
6
+ * @param value - The initial string value.
7
+ * @returns A new instance of RefString.
8
+ */
3
9
  export declare function refString(value: string): RefString;
10
+ /**
11
+ * A union type representing either a primitive string or a RefString.
12
+ */
4
13
  export type refString = string | RefString;
14
+ /**
15
+ * A reactive string wrapper that mimics the String API,
16
+ * supports subscriptions to changes, and acts like a primitive.
17
+ */
5
18
  export declare class RefString implements ref<string> {
19
+ /**
20
+ * Internal container for value management and subscriptions.
21
+ */
6
22
  readonly container: RefContainer;
7
- readonly [index: number]: string;
23
+ /**
24
+ * Optional key used to register the reference globally.
25
+ */
8
26
  readonly refKey: string;
27
+ /**
28
+ * String index access (e.g., refStr[0]) — readonly.
29
+ */
30
+ readonly [index: number]: string;
31
+ /**
32
+ * Constructs a new RefString instance.
33
+ *
34
+ * @param value - Initial string value.
35
+ * @param refKey - Optional reference key for global registry.
36
+ */
9
37
  constructor(value: string, refKey?: string);
38
+ /** Reactive subscription methods **/
39
+ subscribe(target: (arg: string) => void): boolean;
40
+ subscribe(target: (arg: string) => void, onUnsubscribe: Function): boolean;
41
+ subscribe(target: object, propertyName: string | symbol): boolean;
42
+ subscribe(target: object, propertyName: string | symbol, onUnsubscribe: Function): boolean;
43
+ subscribe(target: object | ((arg: string) => void), propertyName: string | symbol | Function, onUnsubscribe?: Function): boolean;
44
+ /**
45
+ * Subscribes to future changes without emitting the current value.
46
+ */
47
+ listen(target: (arg: string) => void, onUnsubscribe?: Function): boolean;
48
+ /**
49
+ * Unsubscribes a function or object-property pair from updates.
50
+ */
51
+ unsubscribe(target: (arg: string) => void): boolean;
52
+ unsubscribe(targe: object, propertyName: string | symbol): boolean;
53
+ /** Reactive value access **/
54
+ /**
55
+ * Gets the current string value.
56
+ */
57
+ get value(): string;
58
+ /**
59
+ * Sets a new value and notifies subscribers if it changed.
60
+ *
61
+ * @param value - The new string value.
62
+ */
63
+ set value(value: string);
64
+ /**
65
+ * Emits a change notification if the value changed.
66
+ */
67
+ protected emit(propertyName: string | symbol, value: any): void;
68
+ /**
69
+ * Returns the string value as a primitive.
70
+ */
71
+ [Symbol.toPrimitive](_hint: string): string;
72
+ /**
73
+ * Ensures String is returned for string operations like concat/slice.
74
+ */
75
+ static get [Symbol.species](): StringConstructor;
76
+ /**
77
+ * Returns the primitive string value.
78
+ */
79
+ valueOf(): string;
80
+ /**
81
+ * Returns the string representation of the value.
82
+ */
83
+ toString(): string;
84
+ /**
85
+ * Returns a JSON-serializable representation of the string.
86
+ */
87
+ toJSON(): string | {
88
+ value: string;
89
+ };
90
+ /**
91
+ * Returns the length of the string.
92
+ */
93
+ get length(): number;
94
+ /**
95
+ * Compares this string to another string.
96
+ *
97
+ * @param value - The value to compare with.
98
+ */
99
+ equals(value: string): boolean;
100
+ /**
101
+ * Allows iteration over each character in the string.
102
+ */
103
+ [Symbol.iterator](): StringIterator<string>;
104
+ /** String method wrappers **/
10
105
  charAt(pos: number): string;
11
106
  charCodeAt(index: number): number;
107
+ codePointAt(pos: number): number | undefined;
12
108
  concat(...strings: string[]): string;
13
109
  indexOf(searchString: string, position?: number): number;
14
110
  lastIndexOf(searchString: string, position?: number): number;
15
- localeCompare(that: string, locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions): number;
111
+ includes(searchString: string, position?: number): boolean;
112
+ startsWith(searchString: string, position?: number): boolean;
113
+ endsWith(searchString: string, endPosition?: number): boolean;
114
+ slice(start?: number, end?: number): string;
115
+ substring(start: number, end?: number): string;
116
+ substr(from: number, length?: number): string;
16
117
  match(regexp: string | RegExp): RegExpMatchArray | null;
118
+ matchAll(regexp: RegExp): RegExpStringIterator<RegExpExecArray>;
17
119
  replace(searchValue: string | RegExp, replacer: string): string;
120
+ replaceAll(searchValue: string, replacer: string | ((substring: string, ...args: any[]) => string)): string;
18
121
  search(searcher: string | RegExp): number;
19
- slice(start?: number, end?: number): string;
20
122
  split(separator: string | RegExp, limit?: number): string[];
21
- substring(start: number, end?: number): string;
123
+ repeat(count: number): string;
124
+ padStart(maxLength: number, fillString?: string): string;
125
+ padEnd(maxLength: number, fillString?: string): string;
126
+ trim(): string;
127
+ trimStart(): string;
128
+ trimEnd(): string;
129
+ trimLeft(): string;
130
+ trimRight(): string;
22
131
  toLowerCase(): string;
23
- toLocaleLowerCase(locales?: string): string;
24
132
  toUpperCase(): string;
133
+ toLocaleLowerCase(locales?: string): string;
25
134
  toLocaleUpperCase(locales?: string): string;
26
- trim(): string;
27
- substr(from: number, length?: number): string;
28
- codePointAt(pos: number): number | undefined;
29
- includes(searchString: string, position?: number): boolean;
30
- endsWith(searchString: string, endPosition?: number): boolean;
31
135
  normalize(form?: string): string;
32
- repeat(count: number): string;
33
- startsWith(searchString: string, position?: number): boolean;
136
+ localeCompare(that: string, locales?: Intl.LocalesArgument, options?: Intl.CollatorOptions): number;
137
+ /** Deprecated HTML string methods (still supported in JS) **/
34
138
  anchor(name: string): string;
35
139
  big(): string;
36
140
  blink(): string;
@@ -44,32 +148,4 @@ export declare class RefString implements ref<string> {
44
148
  strike(): string;
45
149
  sub(): string;
46
150
  sup(): string;
47
- padStart(maxLength: number, fillString?: string): string;
48
- padEnd(maxLength: number, fillString?: string): string;
49
- trimEnd(): string;
50
- trimStart(): string;
51
- trimLeft(): string;
52
- trimRight(): string;
53
- matchAll(regexp: RegExp): RegExpStringIterator<RegExpExecArray>;
54
- replaceAll(searchValue: string, replacer: string | ((substring: string, ...args: any[]) => string)): string;
55
- [Symbol.iterator](): StringIterator<string>;
56
- equals(value: string): boolean;
57
- valueOf(): string;
58
- get length(): number;
59
- protected emit(propertyName: string | symbol, value: any): void;
60
- subscribe(target: (arg: string) => void): boolean;
61
- subscribe(target: (arg: string) => void, onUnsubscribe: Function): boolean;
62
- subscribe(target: object, propertyName: string | symbol): boolean;
63
- subscribe(target: object, propertyName: string | symbol, onUnsubscribe: Function): boolean;
64
- subscribe(target: object | ((arg: string) => void), propertyName: string | symbol | Function, onUnsubscribe?: Function): boolean;
65
- unsubscribe(target: (arg: string) => void): boolean;
66
- unsubscribe(targe: object, propertyName: string | symbol): boolean;
67
- [Symbol.toPrimitive](_hint: string): string;
68
- static get [Symbol.species](): StringConstructor;
69
- get value(): string;
70
- set value(value: string);
71
- toJSON(): string | {
72
- value: string;
73
- };
74
- toString(): string;
75
151
  }