atom.io 0.40.2 → 0.40.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.
@@ -744,7 +744,6 @@ function writeToCache(target, state, value) {
744
744
  writeToCache(target, state, resolved);
745
745
  switch (type) {
746
746
  case `atom`:
747
- case `mutable_atom`:
748
747
  evictDownstreamFromAtom(target, state);
749
748
  break;
750
749
  case `readonly_pure_selector`:
@@ -759,7 +758,7 @@ function writeToCache(target, state, value) {
759
758
  });
760
759
  }
761
760
  }).catch((thrown) => {
762
- target.logger.error(`💥`, `state`, key, `rejected:`, thrown);
761
+ target.logger.error(`💥`, state.type, key, `rejected:`, thrown);
763
762
  });
764
763
  return future;
765
764
  }
@@ -828,12 +827,12 @@ function readOrComputeValue(target, state, mut) {
828
827
  target.logger.info(`🧮`, state.type, key, `computing value`);
829
828
  try {
830
829
  val = state.getFrom(target);
831
- if (val instanceof Promise) return val.catch((e) => {
832
- target.logger.error(`💥`, state.type, key, `rejected:`, e);
830
+ if (val instanceof Promise) return val.catch((thrown) => {
831
+ target.logger.error(`💥`, state.type, key, `rejected:`, thrown);
833
832
  if (state.catch) {
834
- for (const Class of state.catch) if (e instanceof Class) return writeToCache(target, state, e);
833
+ for (const Class of state.catch) if (thrown instanceof Class) return thrown;
835
834
  }
836
- throw e;
835
+ throw thrown;
837
836
  });
838
837
  } catch (e) {
839
838
  target.logger.error(`💥`, state.type, key, `rejected:`, e);
@@ -849,15 +848,12 @@ function readOrComputeValue(target, state, mut) {
849
848
  let def;
850
849
  if (isFn(state.default)) try {
851
850
  def = state.default();
852
- if (def instanceof Promise) def = def.catch((e) => {
853
- target.logger.error(`💥`, state.type, key, `rejected:`, e);
851
+ if (def instanceof Promise) def = def.catch((thrown) => {
852
+ target.logger.error(`💥`, state.type, key, `rejected:`, thrown);
854
853
  if (state.catch) {
855
- for (const Class of state.catch) if (e instanceof Class) {
856
- def = writeToCache(target, state, e);
857
- return def;
858
- }
854
+ for (const Class of state.catch) if (thrown instanceof Class) return thrown;
859
855
  }
860
- throw e;
856
+ throw thrown;
861
857
  });
862
858
  } catch (e) {
863
859
  target.logger.error(`💥`, state.type, key, `rejected:`, e);
@@ -909,7 +905,7 @@ function mintInStore(store, family, key, mustCreate) {
909
905
  let token;
910
906
  if (mustCreate === MUST_CREATE) {
911
907
  store.logger.info(`👪`, family.type, family.key, `adds member`, typeof key === `string` ? `\`${key}\`` : key);
912
- token = family(key);
908
+ token = family.create(key);
913
909
  if (molecule) store.moleculeData.set(stringKey, family.key);
914
910
  } else token = mint(family, key);
915
911
  return token;
@@ -2030,7 +2026,7 @@ function createReadonlyPureSelectorFamily(store, options, internalRoles) {
2030
2026
  const existing = store.families.get(familyKey);
2031
2027
  if (existing) store.logger.error(`❗`, type, familyKey, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
2032
2028
  const subject = new Subject();
2033
- const familyFunction = (key) => {
2029
+ const create = (key) => {
2034
2030
  const subKey = stringifyJson(key);
2035
2031
  const family = {
2036
2032
  key: familyKey,
@@ -2043,10 +2039,11 @@ function createReadonlyPureSelectorFamily(store, options, internalRoles) {
2043
2039
  get: options.get(key)
2044
2040
  };
2045
2041
  if (options.catch) individualOptions.catch = options.catch;
2046
- const token = createReadonlyPureSelector(target, individualOptions, family);
2047
- return token;
2042
+ return createReadonlyPureSelector(target, individualOptions, family);
2048
2043
  };
2049
- const readonlySelectorFamily = Object.assign(familyFunction, familyToken, {
2044
+ const readonlySelectorFamily = {
2045
+ ...familyToken,
2046
+ create,
2050
2047
  internalRoles,
2051
2048
  subject,
2052
2049
  install: (s) => createReadonlyPureSelectorFamily(s, options),
@@ -2057,9 +2054,8 @@ function createReadonlyPureSelectorFamily(store, options, internalRoles) {
2057
2054
  find: ((...args) => findInStore(store, ...args)),
2058
2055
  json: (token) => getJsonToken(store, token)
2059
2056
  });
2060
- },
2061
- ...options.catch ? { catch: options.catch } : {}
2062
- });
2057
+ }
2058
+ };
2063
2059
  store.families.set(familyKey, readonlySelectorFamily);
2064
2060
  return familyToken;
2065
2061
  }
@@ -2074,7 +2070,7 @@ function createRegularAtomFamily(store, options, internalRoles) {
2074
2070
  const existing = store.families.get(options.key);
2075
2071
  if (existing) store.logger.error(`❗`, `atom_family`, options.key, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
2076
2072
  const subject = new Subject();
2077
- const familyFunction = (key) => {
2073
+ const create = (key) => {
2078
2074
  const subKey = stringifyJson(key);
2079
2075
  const family = {
2080
2076
  key: options.key,
@@ -2089,17 +2085,16 @@ function createRegularAtomFamily(store, options, internalRoles) {
2089
2085
  };
2090
2086
  if (options.effects) individualOptions.effects = options.effects(key);
2091
2087
  if (options.catch) individualOptions.catch = options.catch;
2092
- const token = createRegularAtom(target, individualOptions, family);
2093
- return token;
2088
+ return createRegularAtom(target, individualOptions, family);
2094
2089
  };
2095
- const atomFamily$1 = Object.assign(familyFunction, {
2090
+ const atomFamily$1 = {
2096
2091
  ...familyToken,
2092
+ create,
2097
2093
  default: options.default,
2098
2094
  subject,
2099
2095
  install: (s) => createRegularAtomFamily(s, options),
2100
- internalRoles,
2101
- ...options.catch ? { catch: options.catch } : {}
2102
- });
2096
+ internalRoles
2097
+ };
2103
2098
  store.families.set(options.key, atomFamily$1);
2104
2099
  if (isFn(options.default) === false) store.defaults.set(options.key, options.default);
2105
2100
  return familyToken;
@@ -2117,7 +2112,7 @@ function createReadonlyHeldSelectorFamily(store, options, internalRoles) {
2117
2112
  const existing = store.families.get(familyKey);
2118
2113
  if (existing) store.logger.error(`❗`, type, familyKey, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
2119
2114
  const subject = new Subject();
2120
- const familyFunction = (key) => {
2115
+ const create = (key) => {
2121
2116
  const subKey = stringifyJson(key);
2122
2117
  const family = {
2123
2118
  key: familyKey,
@@ -2125,19 +2120,20 @@ function createReadonlyHeldSelectorFamily(store, options, internalRoles) {
2125
2120
  };
2126
2121
  const fullKey = `${familyKey}(${subKey})`;
2127
2122
  const target = newest(store);
2128
- const token = createReadonlyHeldSelector(target, {
2123
+ return createReadonlyHeldSelector(target, {
2129
2124
  key: fullKey,
2130
2125
  const: options.const(key),
2131
2126
  get: options.get(key)
2132
2127
  }, family);
2133
- return token;
2134
2128
  };
2135
- const readonlySelectorFamily = Object.assign(familyFunction, familyToken, {
2129
+ const readonlySelectorFamily = {
2130
+ ...familyToken,
2131
+ create,
2136
2132
  internalRoles,
2137
2133
  subject,
2138
2134
  install: (s) => createReadonlyHeldSelectorFamily(s, options),
2139
2135
  default: options.const
2140
- });
2136
+ };
2141
2137
  store.families.set(familyKey, readonlySelectorFamily);
2142
2138
  return familyToken;
2143
2139
  }
@@ -2154,7 +2150,7 @@ function createWritableHeldSelectorFamily(store, options, internalRoles) {
2154
2150
  const existing = store.families.get(familyKey);
2155
2151
  if (existing) store.logger.error(`❗`, type, familyKey, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
2156
2152
  const subject = new Subject();
2157
- const familyFunction = (key) => {
2153
+ const create = (key) => {
2158
2154
  const subKey = stringifyJson(key);
2159
2155
  const family = {
2160
2156
  key: familyKey,
@@ -2162,20 +2158,21 @@ function createWritableHeldSelectorFamily(store, options, internalRoles) {
2162
2158
  };
2163
2159
  const fullKey = `${familyKey}(${subKey})`;
2164
2160
  const target = newest(store);
2165
- const token = createWritableHeldSelector(target, {
2161
+ return createWritableHeldSelector(target, {
2166
2162
  key: fullKey,
2167
2163
  const: options.const(key),
2168
2164
  get: options.get(key),
2169
2165
  set: options.set(key)
2170
2166
  }, family);
2171
- return token;
2172
2167
  };
2173
- const selectorFamily$1 = Object.assign(familyFunction, familyToken, {
2168
+ const selectorFamily$1 = {
2169
+ ...familyToken,
2170
+ create,
2174
2171
  internalRoles,
2175
2172
  subject,
2176
2173
  install: (s) => createWritableHeldSelectorFamily(s, options),
2177
2174
  default: options.const
2178
- });
2175
+ };
2179
2176
  store.families.set(familyKey, selectorFamily$1);
2180
2177
  return familyToken;
2181
2178
  }
@@ -2192,7 +2189,7 @@ function createWritablePureSelectorFamily(store, options, internalRoles) {
2192
2189
  const existing = store.families.get(familyKey);
2193
2190
  if (existing) store.logger.error(`❗`, type, familyKey, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
2194
2191
  const subject = new Subject();
2195
- const familyFunction = (key) => {
2192
+ const create = (key) => {
2196
2193
  const subKey = stringifyJson(key);
2197
2194
  const family = {
2198
2195
  key: familyKey,
@@ -2206,10 +2203,11 @@ function createWritablePureSelectorFamily(store, options, internalRoles) {
2206
2203
  set: options.set(key)
2207
2204
  };
2208
2205
  if (options.catch) individualOptions.catch = options.catch;
2209
- const token = createWritablePureSelector(target, individualOptions, family);
2210
- return token;
2206
+ return createWritablePureSelector(target, individualOptions, family);
2211
2207
  };
2212
- const selectorFamily$1 = Object.assign(familyFunction, familyToken, {
2208
+ const selectorFamily$1 = {
2209
+ ...familyToken,
2210
+ create,
2213
2211
  internalRoles,
2214
2212
  subject,
2215
2213
  install: (s) => createWritablePureSelectorFamily(s, options),
@@ -2220,9 +2218,8 @@ function createWritablePureSelectorFamily(store, options, internalRoles) {
2220
2218
  find: ((...args) => findInStore(store, ...args)),
2221
2219
  json: (token) => getJsonToken(store, token)
2222
2220
  });
2223
- },
2224
- ...options.catch ? { catch: options.catch } : {}
2225
- });
2221
+ }
2222
+ };
2226
2223
  store.families.set(familyKey, selectorFamily$1);
2227
2224
  return familyToken;
2228
2225
  }
@@ -2728,7 +2725,7 @@ function createMutableAtomFamily(store, options, internalRoles) {
2728
2725
  const existing = store.families.get(options.key);
2729
2726
  if (existing) store.logger.error(`❗`, `mutable_atom_family`, options.key, `Overwriting an existing ${PRETTY_TOKEN_TYPES[existing.type]} "${existing.key}" in store "${store.config.name}". You can safely ignore this warning if it is due to hot module replacement.`);
2730
2727
  const subject = new Subject();
2731
- const familyFunction = (key) => {
2728
+ const create = (key) => {
2732
2729
  const subKey = stringifyJson(key);
2733
2730
  const family = {
2734
2731
  key: options.key,
@@ -2741,15 +2738,16 @@ function createMutableAtomFamily(store, options, internalRoles) {
2741
2738
  class: options.class
2742
2739
  };
2743
2740
  if (options.effects) individualOptions.effects = options.effects(key);
2744
- const token = createMutableAtom(target, individualOptions, family);
2745
- return token;
2741
+ return createMutableAtom(target, individualOptions, family);
2746
2742
  };
2747
- const atomFamily$1 = Object.assign(familyFunction, familyToken, {
2743
+ const atomFamily$1 = {
2744
+ ...familyToken,
2745
+ create,
2748
2746
  class: options.class,
2749
2747
  subject,
2750
2748
  install: (s) => createMutableAtomFamily(s, options),
2751
2749
  internalRoles
2752
- });
2750
+ };
2753
2751
  store.families.set(options.key, atomFamily$1);
2754
2752
  createWritablePureSelectorFamily(store, {
2755
2753
  key: `${options.key}:JSON`,