@zcomponent/core 1.8.0-beta → 1.9.0-beta

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.
@@ -0,0 +1,5 @@
1
+ import { Component } from "../component";
2
+ import { Context } from "../context";
3
+ export declare class GlobalTagContext extends Context {
4
+ componentsByGlobalTag: Map<string, Set<Component<any, import("../component").ConstructorProps>>>;
5
+ }
@@ -0,0 +1,7 @@
1
+ import { Context } from "../context";
2
+ export class GlobalTagContext extends Context {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.componentsByGlobalTag = new Map();
6
+ }
7
+ }
@@ -3,7 +3,7 @@ import { ContextManager, Context } from "../context";
3
3
  export declare class TagContext extends Context {
4
4
  tagsByComponent: Map<Component<any, import("../component").ConstructorProps>, Set<string>>;
5
5
  componentsByLocalTag: Map<string, Set<Component<any, import("../component").ConstructorProps>>>;
6
- componentsByGlobalTag: Map<string, Set<Component<any, import("../component").ConstructorProps>>>;
6
+ private _global;
7
7
  registerComponent(component: Component, tags: string[]): void;
8
8
  unregisterComponent(component: Component): void;
9
9
  getComponentsByTag(tag: string): Set<Component>;
@@ -1,15 +1,16 @@
1
1
  import { Context } from "../context";
2
+ import { GlobalTagContext } from "./globaltagcontext";
2
3
  export class TagContext extends Context {
3
4
  constructor() {
4
5
  super(...arguments);
5
6
  this.tagsByComponent = new Map();
6
7
  this.componentsByLocalTag = new Map();
7
- this.componentsByGlobalTag = new Map();
8
+ this._global = this.contextManager.get(GlobalTagContext);
8
9
  }
9
10
  registerComponent(component, tags) {
10
11
  this.unregisterComponent(component);
11
12
  for (const tag of tags) {
12
- const map = tag.startsWith('global:') ? this.componentsByGlobalTag : this.componentsByLocalTag;
13
+ const map = !tag.startsWith('local:') ? this._global.componentsByGlobalTag : this.componentsByLocalTag;
13
14
  const set = map.get(tag) ?? new Set();
14
15
  set.add(component);
15
16
  map.set(tag, set);
@@ -22,7 +23,7 @@ export class TagContext extends Context {
22
23
  if (!tags)
23
24
  return;
24
25
  for (const tag of tags.values()) {
25
- const map = tag.startsWith('global:') ? this.componentsByGlobalTag : this.componentsByLocalTag;
26
+ const map = !tag.startsWith('local:') ? this._global.componentsByGlobalTag : this.componentsByLocalTag;
26
27
  const entry = map.get(tag);
27
28
  if (!entry)
28
29
  continue;
@@ -31,7 +32,7 @@ export class TagContext extends Context {
31
32
  this.tagsByComponent.delete(component);
32
33
  }
33
34
  getComponentsByTag(tag) {
34
- return ((tag.startsWith('global:') ? this.componentsByGlobalTag : this.componentsByLocalTag).get(tag)) ?? new Set();
35
+ return ((tag.startsWith('global:') ? this._global.componentsByGlobalTag : this.componentsByLocalTag).get(tag)) ?? new Set();
35
36
  }
36
37
  getComponentsByTags(tags) {
37
38
  if (tags.length === 0)
@@ -40,7 +41,7 @@ export class TagContext extends Context {
40
41
  return this.getComponentsByTag(tags[0]);
41
42
  const ret = new Set();
42
43
  for (const tag of tags) {
43
- const map = tag.startsWith('global:') ? this.componentsByGlobalTag : this.componentsByLocalTag;
44
+ const map = !tag.startsWith('local:') ? this._global.componentsByGlobalTag : this.componentsByLocalTag;
44
45
  const entries = map.get(tag);
45
46
  if (!entries)
46
47
  continue;
package/lib/observable.js CHANGED
@@ -113,7 +113,7 @@ export class Observable extends Emitter {
113
113
  this._emitValue();
114
114
  return;
115
115
  }
116
- this._value = this._wrap(v);
116
+ this._value = this._wrap(Array.isArray(v) ? [...v] : v);
117
117
  this._emitValue();
118
118
  }
119
119
  addListener(fn, priority = 0, callImmediately = true) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zcomponent/core",
3
- "version": "1.8.0-beta",
3
+ "version": "1.9.0-beta",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",