@kermodes/react 0.5.1-dev.3.gbfc7d38 → 0.5.1-dev.5.g952f27b

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.
@@ -79,9 +79,9 @@ function fakeKermodes2(tables) {
79
79
  return;
80
80
  }
81
81
  const { top, bottom } = view.viewport;
82
- const window = rows.slice(top, bottom + 1);
83
- const ipc = tableToIPC(window.length > 0 ? tableFromJSON(window) : new Table, "stream");
84
- const keys = BigUint64Array.from(window, (_, i) => BigInt(top + i));
82
+ const window2 = rows.slice(top, bottom + 1);
83
+ const ipc = tableToIPC(window2.length > 0 ? tableFromJSON(window2) : new Table, "stream");
84
+ const keys = BigUint64Array.from(window2, (_, i) => BigInt(top + i));
85
85
  const header = { type: "rows", start: top, total: rows.length, cycle };
86
86
  view.messages.forEach((handler) => handler(header, [ipc, keys]));
87
87
  };
@@ -167,15 +167,16 @@ function columnsOf(rows) {
167
167
  // react/src/index.tsx
168
168
  import { jsx } from "react/jsx-runtime";
169
169
  var ConnectionContext = createContext(null);
170
- function sameOrigin() {
171
- return `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}/ws`;
170
+ function pageServer2(location) {
171
+ const app = /^\/apps\/[^/]+\/[^/]+\//.exec(location.pathname)?.[0] ?? "/";
172
+ return `${location.protocol === "https:" ? "wss" : "ws"}://${location.host}${app}ws`;
172
173
  }
173
174
  function KermodesProvider2({
174
175
  url,
175
176
  connection: given,
176
177
  children
177
178
  }) {
178
- const connection = useMemo(() => given ?? new KermodesConnection(url ?? sameOrigin()), [given, url]);
179
+ const connection = useMemo(() => given ?? new KermodesConnection(url ?? pageServer2(window.location)), [given, url]);
179
180
  useEffect(() => given == null ? () => connection.close() : undefined, [connection, given]);
180
181
  return /* @__PURE__ */ jsx(ConnectionContext.Provider, {
181
182
  value: connection,
@@ -223,22 +224,22 @@ function useTable2(name, { sort = [], filters = {}, offset = 0, limit = 100, las
223
224
  const opened = connection.open(name);
224
225
  view.current = opened;
225
226
  sentViewport.current = "";
226
- let window = null;
227
+ let window2 = null;
227
228
  const publish = () => {
228
229
  const current = opened.state();
229
230
  const { from, count } = rowRange2(current.row_count, range.current);
230
231
  setState({
231
- rows: window == null ? [] : windowRows2(window.table, window.start, from, count),
232
+ rows: window2 == null ? [] : windowRows2(window2.table, window2.start, from, count),
232
233
  total: current.row_count,
233
234
  columns: current.columns,
234
- status: tableStatus2(current, window != null),
235
+ status: tableStatus2(current, window2 != null),
235
236
  error: current.error ?? null
236
237
  });
237
238
  sendViewport(current.row_count);
238
239
  };
239
240
  const stopRows = opened.onMessage((header, buffers) => {
240
241
  if (header.type === "rows") {
241
- window = { start: header.start, table: tableFromIPC(toBytes(buffers[0])) };
242
+ window2 = { start: header.start, table: tableFromIPC(toBytes(buffers[0])) };
242
243
  publish();
243
244
  }
244
245
  });
@@ -277,4 +278,4 @@ function useTable2(name, { sort = [], filters = {}, offset = 0, limit = 100, las
277
278
  return state;
278
279
  }
279
280
 
280
- export { windowRows2, rowRange2, sortKeys2, tableStatus2, fakeKermodes2, KermodesProvider2, useKermodes2, useTables2, useTable2 };
281
+ export { windowRows2, rowRange2, sortKeys2, tableStatus2, fakeKermodes2, pageServer2, KermodesProvider2, useKermodes2, useTables2, useTable2 };
package/dist/index.d.ts CHANGED
@@ -5,6 +5,16 @@ import { type TableRow, type TableStatus } from './rows';
5
5
  export type { Connection } from './connection';
6
6
  export { fakeKermodes, type FakeKermodes } from './fake';
7
7
  export { rowRange, sortKeys, tableStatus, windowRows, type TableRow, type TableStatus, } from './rows';
8
+ /**
9
+ * The page's own server: an app's at `<its path>ws`, as Kermodes serves every app under
10
+ * `/apps/<project>/<name>/` (its own process, in the cluster and under `kermodes dev`), at any
11
+ * page of the app's own router; any other page's at the origin's `/ws`.
12
+ */
13
+ export declare function pageServer(location: {
14
+ protocol: string;
15
+ host: string;
16
+ pathname: string;
17
+ }): string;
8
18
  /**
9
19
  * One connection to a Kermodes server for everything inside it, reconnecting by itself. `url`
10
20
  * is the server's WebSocket (`wss://kermodes.example.com/ws`); by default the page's own. Tests
package/dist/index.js CHANGED
@@ -4,14 +4,16 @@ import {
4
4
  sortKeys2,
5
5
  tableStatus2,
6
6
  fakeKermodes2,
7
+ pageServer2,
7
8
  KermodesProvider2,
8
9
  useKermodes2,
9
10
  useTables2,
10
11
  useTable2
11
- } from "./chunk-dcena2cz.js";
12
+ } from "./chunk-c8fqw0ed.js";
12
13
  export {
13
14
  KermodesProvider2 as KermodesProvider,
14
15
  fakeKermodes2 as fakeKermodes,
16
+ pageServer2 as pageServer,
15
17
  rowRange2 as rowRange,
16
18
  sortKeys2 as sortKeys,
17
19
  tableStatus2 as tableStatus,
package/dist/table.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useKermodes2
3
- } from "./chunk-dcena2cz.js";
3
+ } from "./chunk-c8fqw0ed.js";
4
4
 
5
5
  // react/src/table.tsx
6
6
  import { useEffect, useLayoutEffect, useRef, useState } from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kermodes/react",
3
- "version": "0.5.1-dev.3.gbfc7d38",
3
+ "version": "0.5.1-dev.5.g952f27b",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,8 +24,8 @@
24
24
  "dist"
25
25
  ],
26
26
  "dependencies": {
27
- "@kermodes/client": "0.5.1-dev.3.gbfc7d38",
28
- "@kermodes/grid": "0.5.1-dev.3.gbfc7d38",
27
+ "@kermodes/client": "0.5.1-dev.5.g952f27b",
28
+ "@kermodes/grid": "0.5.1-dev.5.g952f27b",
29
29
  "apache-arrow": "^21.0.0"
30
30
  },
31
31
  "peerDependencies": {