mobx 6.6.1 → 6.6.2

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.
@@ -3,7 +3,9 @@ export interface IKeyValueMap<V = any> {
3
3
  [key: string]: V;
4
4
  }
5
5
  export declare type IMapEntry<K = any, V = any> = [K, V];
6
+ export declare type IReadonlyMapEntry<K = any, V = any> = readonly [K, V];
6
7
  export declare type IMapEntries<K = any, V = any> = IMapEntry<K, V>[];
8
+ export declare type IReadonlyMapEntries<K = any, V = any> = IReadonlyMapEntry<K, V>[];
7
9
  export declare type IMapDidChange<K = any, V = any> = {
8
10
  observableKind: "map";
9
11
  debugObjectName: string;
@@ -32,7 +34,7 @@ export interface IMapWillChange<K = any, V = any> {
32
34
  }
33
35
  export declare const ADD = "add";
34
36
  export declare const DELETE = "delete";
35
- export declare type IObservableMapInitialValues<K = any, V = any> = IMapEntries<K, V> | IKeyValueMap<V> | Map<K, V>;
37
+ export declare type IObservableMapInitialValues<K = any, V = any> = IMapEntries<K, V> | IReadonlyMapEntries<K, V> | IKeyValueMap<V> | Map<K, V>;
36
38
  export declare class ObservableMap<K = any, V = any> implements Map<K, V>, IInterceptable<IMapWillChange<K, V>>, IListenable {
37
39
  enhancer_: IEnhancer<V>;
38
40
  name_: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx",
3
- "version": "6.6.1",
3
+ "version": "6.6.2",
4
4
  "description": "Simple, scalable state management.",
5
5
  "source": "src/mobx.ts",
6
6
  "main": "dist/index.js",
@@ -51,7 +51,7 @@ function assertNotDecorated(prototype: object, annotation: Annotation, key: Prop
51
51
  `Cannot apply '@${requestedAnnotationType}' to '${fieldName}':` +
52
52
  `\nThe field is already decorated with '@${currentAnnotationType}'.` +
53
53
  `\nRe-decorating fields is not allowed.` +
54
- `\nUse '@override' decorator for methods overriden by subclass.`
54
+ `\nUse '@override' decorator for methods overridden by subclass.`
55
55
  )
56
56
  }
57
57
  }
@@ -14,6 +14,21 @@ import {
14
14
  defineProperty
15
15
  } from "../internal"
16
16
 
17
+ // Bug in safari 9.* (or iOS 9 safari mobile). See #364
18
+ const ENTRY_0 = createArrayEntryDescriptor(0)
19
+
20
+ const safariPrototypeSetterInheritanceBug = (() => {
21
+ let v = false
22
+ const p = {}
23
+ Object.defineProperty(p, "0", {
24
+ set: () => {
25
+ v = true
26
+ }
27
+ })
28
+ Object.create(p)["0"] = 1
29
+ return v === false
30
+ })()
31
+
17
32
  /**
18
33
  * This array buffer contains two lists of properties, so that all arrays
19
34
  * can recycle their property definitions, which significantly improves performance of creating
@@ -57,6 +72,12 @@ class LegacyObservableArray<T> extends StubArray {
57
72
  this.spliceWithArray(0, 0, initialValues)
58
73
  allowStateChangesEnd(prev)
59
74
  }
75
+
76
+ if (safariPrototypeSetterInheritanceBug) {
77
+ // Seems that Safari won't use numeric prototype setter untill any * numeric property is
78
+ // defined on the instance. After that it works fine, even if this property is deleted.
79
+ Object.defineProperty(this, "0", ENTRY_0)
80
+ }
60
81
  }
61
82
 
62
83
  concat(...arrays: T[][]): T[] {
@@ -43,7 +43,9 @@ export interface IKeyValueMap<V = any> {
43
43
  }
44
44
 
45
45
  export type IMapEntry<K = any, V = any> = [K, V]
46
+ export type IReadonlyMapEntry<K = any, V = any> = readonly [K, V]
46
47
  export type IMapEntries<K = any, V = any> = IMapEntry<K, V>[]
48
+ export type IReadonlyMapEntries<K = any, V = any> = IReadonlyMapEntry<K, V>[]
47
49
 
48
50
  export type IMapDidChange<K = any, V = any> = { observableKind: "map"; debugObjectName: string } & (
49
51
  | {
@@ -81,14 +83,14 @@ export const DELETE = "delete"
81
83
 
82
84
  export type IObservableMapInitialValues<K = any, V = any> =
83
85
  | IMapEntries<K, V>
86
+ | IReadonlyMapEntries<K, V>
84
87
  | IKeyValueMap<V>
85
88
  | Map<K, V>
86
89
 
87
90
  // just extend Map? See also https://gist.github.com/nestharus/13b4d74f2ef4a2f4357dbd3fc23c1e54
88
91
  // But: https://github.com/mobxjs/mobx/issues/1556
89
92
  export class ObservableMap<K = any, V = any>
90
- implements Map<K, V>, IInterceptable<IMapWillChange<K, V>>, IListenable
91
- {
93
+ implements Map<K, V>, IInterceptable<IMapWillChange<K, V>>, IListenable {
92
94
  [$mobx] = ObservableMapMarker
93
95
  data_: Map<K, ObservableValue<V>>
94
96
  hasMap_: Map<K, ObservableValue<boolean>> // hasMap, not hashMap >-).
@@ -776,7 +776,7 @@ function assertAnnotable(
776
776
  `Cannot apply '${requestedAnnotationType}' to '${fieldName}':` +
777
777
  `\nThe field is already annotated with '${currentAnnotationType}'.` +
778
778
  `\nRe-annotating fields is not allowed.` +
779
- `\nUse 'override' annotation for methods overriden by subclass.`
779
+ `\nUse 'override' annotation for methods overridden by subclass.`
780
780
  )
781
781
  }
782
782
  }