ropegeo-common 1.16.1 → 1.16.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.
package/README.md CHANGED
@@ -326,7 +326,7 @@ Legend entries for page minimaps are keyed objects (`legend` on `PageMiniMap`);
326
326
 
327
327
  | Name | Description | Import |
328
328
  | --- | --- | --- |
329
- | `RopeGeoDataLoader` | Single-request loader: `onlinePath` / `onlinePathParams`, optional `offlineData` (object used as `data` immediately; no network), optional `timeoutAfterSeconds` and `isOnline`. Children receive `data`, `errors`, `timeoutCountdown` (numeric only while an online fetch is in flight, otherwise `null`), and `reload`. Reconnect refetch uses `dirtyWhileOffline` driven by a semantic key (no `refreshOnReconnect` prop). Also exports `Method`, `Service`, `SERVICE_BASE_URL`. | `import { RopeGeoDataLoader, Method, Service } from 'ropegeo-common/components'` |
329
+ | `RopeGeoDataLoader` | Single-request loader: `onlinePath` / `onlinePathParams`, optional `offlineData` (`undefined` fetch online; `null` → `data` null / loading-style, no fetch; `T` → use as `data`, no fetch), optional `timeoutAfterSeconds` and `isOnline`. Children receive `data`, `errors`, `timeoutCountdown` (numeric only while an online fetch is in flight, otherwise `null`), and `reload`. Reconnect refetch uses `dirtyWhileOffline` driven by a semantic key (no `refreshOnReconnect` prop). Also exports `Method`, `Service`, `SERVICE_BASE_URL`. | `import { RopeGeoDataLoader, Method, Service } from 'ropegeo-common/components'` |
330
330
  | `RopeGeoPagedDataLoader` | Cursor-paginated list: same networking props as above; children get `loadNextPage`, `loadingNextPage`, `morePages`, plus `data`, `errors`, `timeoutCountdown`, `reload`. | `import { RopeGeoPagedDataLoader } from 'ropegeo-common/components'` |
331
331
  | `RopeGeoProgressDataLoader` | Page-based “progress” fetch: batches additional pages until `total` is satisfied; children get `received`, `total`, `data`, `errors`, `timeoutCountdown`, `reload`. | `import { RopeGeoProgressDataLoader } from 'ropegeo-common/components'` |
332
332
 
@@ -31,10 +31,12 @@ export type RopeGeoDataLoaderProps<T = unknown> = {
31
31
  */
32
32
  isOnline?: boolean;
33
33
  /**
34
- * When set, this value is used as `data` immediately (no network). Callers that load from disk
35
- * should read and parse the file themselves, then pass the resulting object here.
34
+ * Offline / local-first behavior without reading files inside the loader:
35
+ * - **`undefined`**: omit or leave unset fetch from {@link onlinePath} as usual.
36
+ * - **`null`**: do not fetch; children receive `data: null` and `errors: null` (loading-style).
37
+ * - **`T`**: use as `data` immediately; no network.
36
38
  */
37
- offlineData?: T;
39
+ offlineData?: T | null;
38
40
  children: (args: {
39
41
  data: T | null;
40
42
  errors: Error | null;
@@ -1 +1 @@
1
- {"version":3,"file":"RopeGeoDataLoader.d.ts","sourceRoot":"","sources":["../../src/components/RopeGeoDataLoader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAavC,eAAO,MAAM,OAAO;;CAEV,CAAC;AACX,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;AAE7D,eAAO,MAAM,MAAM;;;;;CAKT,CAAC;AACX,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC;AAE1D,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAEpD,CAAC;AAoEF,MAAM,MAAM,sBAAsB,CAAC,CAAC,GAAG,OAAO,IAAI;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,0FAA0F;IAC1F,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG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,0FAA0F;IAC1F,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,CAAC,IAAI,EAAE;QACf,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;QACf,MAAM,EAAE,KAAK,GAAG,IAAI,CAAC;QACrB;;;WAGG;QACH,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;QAChC,iFAAiF;QACjF,MAAM,EAAE,MAAM,IAAI,CAAC;KACpB,KAAK,SAAS,CAAC;CACjB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,OAAO,EAAE,EAC7C,OAAO,EACP,MAAM,EACN,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,IAAI,EACJ,mBAAmB,EACnB,QAAQ,EACR,WAAW,EACX,QAAQ,GACT,EAAE,sBAAsB,CAAC,CAAC,CAAC,2CAgU3B"}
@@ -57,6 +57,8 @@ function dataLoaderReconnectSemanticKey(service, method, onlinePath, pathParamsK
57
57
  function offlineDataKeyPart(offlineData) {
58
58
  if (offlineData === undefined)
59
59
  return "";
60
+ if (offlineData === null)
61
+ return "|offline:null";
60
62
  return `|obj:${JSON.stringify(offlineData)}`;
61
63
  }
62
64
  function RopeGeoDataLoader({ service, method, onlinePath, onlinePathParams, queryParams, body, timeoutAfterSeconds, isOnline, offlineData, children, }) {
@@ -104,11 +106,19 @@ function RopeGeoDataLoader({ service, method, onlinePath, onlinePathParams, quer
104
106
  setReloadTick((n) => n + 1);
105
107
  }, [isOnline]);
106
108
  const lastRequestKeyRef = (0, react_1.useRef)("");
107
- /** `offlineData` object immediate `data`, no network. */
109
+ /** Sync `data` from {@link offlineData} when it is `null` or `T`; `undefined` defers to the network effect. */
108
110
  (0, react_1.useEffect)(() => {
109
111
  if (offlineData === undefined) {
110
112
  return;
111
113
  }
114
+ if (offlineData === null) {
115
+ setData(null);
116
+ setErrors(null);
117
+ hasCommittedRef.current = false;
118
+ dirtyWhileOfflineRef.current = false;
119
+ semanticSnapshotRef.current = null;
120
+ return;
121
+ }
112
122
  setData(offlineData);
113
123
  setErrors(null);
114
124
  hasCommittedRef.current = true;
@@ -130,7 +140,7 @@ function RopeGeoDataLoader({ service, method, onlinePath, onlinePathParams, quer
130
140
  dirtyWhileOfflineRef.current = true;
131
141
  }
132
142
  }
133
- /** Object `offlineData`: dedicated effect owns `data`; never hit the network here. */
143
+ /** `offlineData` is `null` or `T`: own `data`; never hit the network here. */
134
144
  if (offlineData !== undefined) {
135
145
  prevIsOnlineRef.current = online;
136
146
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ropegeo-common",
3
- "version": "1.16.1",
3
+ "version": "1.16.2",
4
4
  "description": "Shared domain models and helpers for RopeGeo and WebScraper",
5
5
  "license": "ISC",
6
6
  "repository": {