@nice-code/state 0.4.9 → 0.4.11

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.
@@ -2032,6 +2032,7 @@ function readPrefs(defaultPosition, initialOpen) {
2032
2032
  dockedWidth: DOCKED_WIDTH_DEFAULT,
2033
2033
  detailRatio: DETAIL_RATIO_DEFAULT,
2034
2034
  stayOnLatest: true,
2035
+ followLatestOnSelect: true,
2035
2036
  compressDiff: true,
2036
2037
  detailView: "diff",
2037
2038
  diffLatestFirst: true
@@ -2088,6 +2089,7 @@ function NiceStateDevtools_Panel({
2088
2089
  dockedWidth,
2089
2090
  detailRatio,
2090
2091
  stayOnLatest,
2092
+ followLatestOnSelect,
2091
2093
  compressDiff,
2092
2094
  detailView,
2093
2095
  diffLatestFirst
@@ -2253,9 +2255,17 @@ function NiceStateDevtools_Panel({
2253
2255
  overflow: "hidden"
2254
2256
  },
2255
2257
  children: [
2256
- /* @__PURE__ */ jsxDEV10(StayOnLatestToggle, {
2257
- checked: stayOnLatest,
2258
- onChange: (next) => setPrefs({ stayOnLatest: next })
2258
+ /* @__PURE__ */ jsxDEV10(TimelineFollowToggles, {
2259
+ stayOnLatest,
2260
+ onStayOnLatestChange: (next) => setPrefs({ stayOnLatest: next }),
2261
+ followLatestOnSelect,
2262
+ onFollowLatestOnSelectChange: (next) => {
2263
+ if (next && latestCuid != null && selectedChangeCuid === latestCuid && !stayOnLatest) {
2264
+ setPrefs({ followLatestOnSelect: next, stayOnLatest: true });
2265
+ } else {
2266
+ setPrefs({ followLatestOnSelect: next });
2267
+ }
2268
+ }
2259
2269
  }, undefined, false, undefined, this),
2260
2270
  /* @__PURE__ */ jsxDEV10("div", {
2261
2271
  style: { flex: 1, minHeight: 0, overflowY: "auto" },
@@ -2263,9 +2273,14 @@ function NiceStateDevtools_Panel({
2263
2273
  groups,
2264
2274
  selectedCuid: selectedChangeCuid,
2265
2275
  onSelect: (cuid) => {
2266
- if (stayOnLatest)
2276
+ const next = selectedChangeCuid === cuid ? null : cuid;
2277
+ if (next != null && next === latestCuid && followLatestOnSelect) {
2278
+ if (!stayOnLatest)
2279
+ setPrefs({ stayOnLatest: true });
2280
+ } else if (stayOnLatest) {
2267
2281
  setPrefs({ stayOnLatest: false });
2268
- setSelectedChangeCuid((prev) => prev === cuid ? null : cuid);
2282
+ }
2283
+ setSelectedChangeCuid(next);
2269
2284
  },
2270
2285
  showStore: storeFilter == null
2271
2286
  }, undefined, false, undefined, this)
@@ -2314,22 +2329,67 @@ function NiceStateDevtools_Panel({
2314
2329
  ]
2315
2330
  }, undefined, true, undefined, this);
2316
2331
  }
2317
- function StayOnLatestToggle({
2332
+ function TimelineFollowToggles({
2333
+ stayOnLatest,
2334
+ onStayOnLatestChange,
2335
+ followLatestOnSelect,
2336
+ onFollowLatestOnSelectChange
2337
+ }) {
2338
+ return /* @__PURE__ */ jsxDEV10("div", {
2339
+ style: {
2340
+ display: "flex",
2341
+ flexDirection: "column",
2342
+ flexShrink: 0,
2343
+ paddingBottom: "3px",
2344
+ background: DEVTOOL_SECTION_BACKGROUND,
2345
+ borderBottom: `1px solid ${DEVTOOL_LIST_BASE_BACKGROUND}`
2346
+ },
2347
+ children: [
2348
+ /* @__PURE__ */ jsxDEV10(ToggleLabel, {
2349
+ title: "Auto-select the most recent change so the detail pane keeps showing the latest as new changes land",
2350
+ checked: stayOnLatest,
2351
+ onChange: onStayOnLatestChange,
2352
+ children: "Follow latest"
2353
+ }, undefined, false, undefined, this),
2354
+ /* @__PURE__ */ jsxDEV10("div", {
2355
+ style: { display: "flex", alignItems: "center", paddingLeft: "12px", marginTop: "-4px" },
2356
+ children: [
2357
+ /* @__PURE__ */ jsxDEV10("span", {
2358
+ "aria-hidden": true,
2359
+ style: {
2360
+ color: DEVTOOL_COLOR_TEXT_MUTED,
2361
+ fontFamily: SANS_FONT,
2362
+ fontSize: "10px",
2363
+ lineHeight: 1
2364
+ },
2365
+ children: "└"
2366
+ }, undefined, false, undefined, this),
2367
+ /* @__PURE__ */ jsxDEV10(ToggleLabel, {
2368
+ title: "When you click the latest change, turn 'Follow latest' back on so the view resumes tracking new changes. Turn this off to pin exactly to the change you click instead.",
2369
+ checked: followLatestOnSelect,
2370
+ onChange: onFollowLatestOnSelectChange,
2371
+ children: "clicking latest re-follows"
2372
+ }, undefined, false, undefined, this)
2373
+ ]
2374
+ }, undefined, true, undefined, this)
2375
+ ]
2376
+ }, undefined, true, undefined, this);
2377
+ }
2378
+ function ToggleLabel({
2318
2379
  checked,
2319
- onChange
2380
+ onChange,
2381
+ title,
2382
+ children
2320
2383
  }) {
2321
2384
  return /* @__PURE__ */ jsxDEV10("label", {
2322
- title: "Always select the most recent change so the detail pane follows it",
2385
+ title,
2323
2386
  style: {
2324
2387
  display: "flex",
2325
2388
  alignItems: "center",
2326
2389
  gap: "6px",
2327
2390
  padding: "5px 10px",
2328
- flexShrink: 0,
2329
2391
  cursor: "pointer",
2330
2392
  userSelect: "none",
2331
- background: DEVTOOL_SECTION_BACKGROUND,
2332
- borderBottom: `1px solid ${DEVTOOL_LIST_BASE_BACKGROUND}`,
2333
2393
  color: checked ? DEVTOOL_COLOR_TEXT_SECONDARY : DEVTOOL_COLOR_TEXT_MUTED,
2334
2394
  fontSize: "10px",
2335
2395
  fontFamily: SANS_FONT
@@ -2341,7 +2401,7 @@ function StayOnLatestToggle({
2341
2401
  onChange: (e) => onChange(e.target.checked),
2342
2402
  style: { accentColor: DEVTOOL_COLOR_SEMANTIC_SYSTEM, cursor: "pointer", margin: 0 }
2343
2403
  }, undefined, false, undefined, this),
2344
- "stay on latest"
2404
+ children
2345
2405
  ]
2346
2406
  }, undefined, true, undefined, this);
2347
2407
  }
package/build/index.js CHANGED
@@ -77,6 +77,9 @@ class Store {
77
77
  this.currentState = initialState;
78
78
  }
79
79
  }
80
+ get state() {
81
+ return Object.freeze(this.currentState);
82
+ }
80
83
  _setInternalOptions({ ssr, reactionCreators = [] }) {
81
84
  this.ssr = ssr;
82
85
  this.reactionCreators = reactionCreators;
@@ -124,6 +124,9 @@ class Store {
124
124
  this.currentState = initialState;
125
125
  }
126
126
  }
127
+ get state() {
128
+ return Object.freeze(this.currentState);
129
+ }
127
130
  _setInternalOptions({ ssr, reactionCreators = [] }) {
128
131
  this.ssr = ssr;
129
132
  this.reactionCreators = reactionCreators;
@@ -55,6 +55,7 @@ export declare class Store<S extends object = object> {
55
55
  private reactions;
56
56
  private clientSubscriptions;
57
57
  constructor(initialState: S | (() => S));
58
+ get state(): S;
58
59
  /**
59
60
  * Returns the raw state object contained within this store at this moment.
60
61
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-code/state",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {