@nice-code/state 0.4.0 → 0.4.1

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.
@@ -191,105 +191,6 @@ var DEVTOOL_JSON_PUNCTUATION = "#475569";
191
191
  var MONO_FONT = "ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace";
192
192
  var SANS_FONT = "ui-sans-serif, system-ui, sans-serif";
193
193
 
194
- // src/devtools/browser/devtools_dock.ts
195
- var GLOBAL_KEY = "__NICE_DEVTOOLS_DOCK__";
196
- var VERSION = 2;
197
- function createCoordinator() {
198
- const panels = new Map;
199
- const listeners = new Set;
200
- function toRef(panel) {
201
- return {
202
- id: panel.id,
203
- label: panel.label,
204
- icon: panel.icon,
205
- badge: panel.badge,
206
- onOpen: panel.onOpen
207
- };
208
- }
209
- function applyBodyMargins() {
210
- if (typeof document === "undefined")
211
- return;
212
- const margins = { top: 0, bottom: 0, left: 0, right: 0 };
213
- for (const panel of panels.values()) {
214
- if (panel.open)
215
- margins[panel.side] += panel.size;
216
- }
217
- const sides = ["top", "bottom", "left", "right"];
218
- for (const side of sides) {
219
- if (margins[side] > 0) {
220
- document.body.style.setProperty(`margin-${side}`, `${margins[side]}px`);
221
- } else {
222
- document.body.style.removeProperty(`margin-${side}`);
223
- }
224
- }
225
- }
226
- function notify() {
227
- applyBodyMargins();
228
- for (const listener of listeners)
229
- listener();
230
- }
231
- return {
232
- version: VERSION,
233
- register(panel) {
234
- panels.set(panel.id, { ...panel });
235
- notify();
236
- return () => {
237
- panels.delete(panel.id);
238
- notify();
239
- };
240
- },
241
- update(id, next) {
242
- const existing = panels.get(id);
243
- if (existing == null)
244
- return;
245
- if (existing.side === next.side && existing.size === next.size && existing.open === next.open && existing.badge === next.badge) {
246
- return;
247
- }
248
- panels.set(id, { ...existing, ...next });
249
- notify();
250
- },
251
- getView(id) {
252
- const list = [...panels.values()];
253
- const anyOpen = list.some((p) => p.open);
254
- const firstId = list.length > 0 ? list[0].id : null;
255
- let dockOffset = 0;
256
- const self = panels.get(id);
257
- if (self != null && self.open) {
258
- for (const panel of list) {
259
- if (panel.id === id)
260
- break;
261
- if (panel.open && panel.side === self.side)
262
- dockOffset += panel.size;
263
- }
264
- }
265
- return {
266
- dockOffset,
267
- anyOpen,
268
- isPrimary: id === firstId,
269
- devtools: list.map(toRef),
270
- otherClosed: list.filter((p) => !p.open && p.id !== id).map(toRef)
271
- };
272
- },
273
- subscribe(listener) {
274
- listeners.add(listener);
275
- return () => {
276
- listeners.delete(listener);
277
- };
278
- }
279
- };
280
- }
281
- function getDevtoolsDockCoordinator() {
282
- if (typeof window === "undefined")
283
- return createCoordinator();
284
- const host = window;
285
- const existing = host[GLOBAL_KEY];
286
- if (existing != null && existing.version === VERSION)
287
- return existing;
288
- const created = createCoordinator();
289
- host[GLOBAL_KEY] = created;
290
- return created;
291
- }
292
-
293
194
  // src/devtools/browser/components/ChangeDetailPanel.tsx
294
195
  import { useState as useState2 } from "react";
295
196
 
@@ -1395,6 +1296,105 @@ function Pill({
1395
1296
  }, undefined, true, undefined, this);
1396
1297
  }
1397
1298
 
1299
+ // src/devtools/browser/devtools_dock.ts
1300
+ var GLOBAL_KEY = "__NICE_DEVTOOLS_DOCK__";
1301
+ var VERSION = 2;
1302
+ function createCoordinator() {
1303
+ const panels = new Map;
1304
+ const listeners = new Set;
1305
+ function toRef(panel) {
1306
+ return {
1307
+ id: panel.id,
1308
+ label: panel.label,
1309
+ icon: panel.icon,
1310
+ badge: panel.badge,
1311
+ onOpen: panel.onOpen
1312
+ };
1313
+ }
1314
+ function applyBodyMargins() {
1315
+ if (typeof document === "undefined")
1316
+ return;
1317
+ const margins = { top: 0, bottom: 0, left: 0, right: 0 };
1318
+ for (const panel of panels.values()) {
1319
+ if (panel.open)
1320
+ margins[panel.side] += panel.size;
1321
+ }
1322
+ const sides = ["top", "bottom", "left", "right"];
1323
+ for (const side of sides) {
1324
+ if (margins[side] > 0) {
1325
+ document.body.style.setProperty(`margin-${side}`, `${margins[side]}px`);
1326
+ } else {
1327
+ document.body.style.removeProperty(`margin-${side}`);
1328
+ }
1329
+ }
1330
+ }
1331
+ function notify() {
1332
+ applyBodyMargins();
1333
+ for (const listener of listeners)
1334
+ listener();
1335
+ }
1336
+ return {
1337
+ version: VERSION,
1338
+ register(panel) {
1339
+ panels.set(panel.id, { ...panel });
1340
+ notify();
1341
+ return () => {
1342
+ panels.delete(panel.id);
1343
+ notify();
1344
+ };
1345
+ },
1346
+ update(id, next) {
1347
+ const existing = panels.get(id);
1348
+ if (existing == null)
1349
+ return;
1350
+ if (existing.side === next.side && existing.size === next.size && existing.open === next.open && existing.badge === next.badge) {
1351
+ return;
1352
+ }
1353
+ panels.set(id, { ...existing, ...next });
1354
+ notify();
1355
+ },
1356
+ getView(id) {
1357
+ const list = [...panels.values()];
1358
+ const anyOpen = list.some((p) => p.open);
1359
+ const firstId = list.length > 0 ? list[0].id : null;
1360
+ let dockOffset = 0;
1361
+ const self = panels.get(id);
1362
+ if (self != null && self.open) {
1363
+ for (const panel of list) {
1364
+ if (panel.id === id)
1365
+ break;
1366
+ if (panel.open && panel.side === self.side)
1367
+ dockOffset += panel.size;
1368
+ }
1369
+ }
1370
+ return {
1371
+ dockOffset,
1372
+ anyOpen,
1373
+ isPrimary: id === firstId,
1374
+ devtools: list.map(toRef),
1375
+ otherClosed: list.filter((p) => !p.open && p.id !== id).map(toRef)
1376
+ };
1377
+ },
1378
+ subscribe(listener) {
1379
+ listeners.add(listener);
1380
+ return () => {
1381
+ listeners.delete(listener);
1382
+ };
1383
+ }
1384
+ };
1385
+ }
1386
+ function getDevtoolsDockCoordinator() {
1387
+ if (typeof window === "undefined")
1388
+ return createCoordinator();
1389
+ const host = window;
1390
+ const existing = host[GLOBAL_KEY];
1391
+ if (existing != null && existing.version === VERSION)
1392
+ return existing;
1393
+ const created = createCoordinator();
1394
+ host[GLOBAL_KEY] = created;
1395
+ return created;
1396
+ }
1397
+
1398
1398
  // src/devtools/browser/NiceStateDevtools.tsx
1399
1399
  import { jsxDEV as jsxDEV9, Fragment } from "react/jsx-dev-runtime";
1400
1400
  if (typeof document !== "undefined" && !document.getElementById("__nice-state-devtools-styles")) {
@@ -1529,7 +1529,31 @@ function NiceStateDevtools_Panel({
1529
1529
  flexDirection: "column",
1530
1530
  boxShadow: "0 -4px 24px rgba(0,0,0,0.4)",
1531
1531
  overflow: "hidden",
1532
- ...dockSide === "bottom" ? { bottom: view.dockOffset, left: 0, right: 0, height: `${dockedSize}px`, borderRadius: "8px 8px 0 0" } : dockSide === "top" ? { top: view.dockOffset, left: 0, right: 0, height: `${dockedSize}px`, borderRadius: "0 0 8px 8px" } : dockSide === "left" ? { top: 0, left: view.dockOffset, bottom: 0, width: `${dockedSize}px`, borderRadius: "0 8px 8px 0" } : { top: 0, right: view.dockOffset, bottom: 0, width: `${dockedSize}px`, borderRadius: "8px 0 0 8px" }
1532
+ ...dockSide === "bottom" ? {
1533
+ bottom: view.dockOffset,
1534
+ left: 0,
1535
+ right: 0,
1536
+ height: `${dockedSize}px`,
1537
+ borderRadius: "8px 8px 0 0"
1538
+ } : dockSide === "top" ? {
1539
+ top: view.dockOffset,
1540
+ left: 0,
1541
+ right: 0,
1542
+ height: `${dockedSize}px`,
1543
+ borderRadius: "0 0 8px 8px"
1544
+ } : dockSide === "left" ? {
1545
+ top: 0,
1546
+ left: view.dockOffset,
1547
+ bottom: 0,
1548
+ width: `${dockedSize}px`,
1549
+ borderRadius: "0 8px 8px 0"
1550
+ } : {
1551
+ top: 0,
1552
+ right: view.dockOffset,
1553
+ bottom: 0,
1554
+ width: `${dockedSize}px`,
1555
+ borderRadius: "8px 0 0 8px"
1556
+ }
1533
1557
  };
1534
1558
  return /* @__PURE__ */ jsxDEV9("div", {
1535
1559
  id: "__nice-state-devtools-panel",
@@ -1,5 +1,5 @@
1
- import type { StateDevtoolsCore } from "../core/StateDevtoolsCore";
2
1
  import type { TDevtoolsPosition } from "../core/StateDevtools.types";
2
+ import type { StateDevtoolsCore } from "../core/StateDevtoolsCore";
3
3
  export interface INiceStateDevtoolsProps {
4
4
  core: StateDevtoolsCore;
5
5
  position?: TDevtoolsPosition;
package/package.json CHANGED
@@ -1,56 +1,56 @@
1
- {
2
- "name": "@nice-code/state",
3
- "version": "0.4.0",
4
- "private": false,
5
- "type": "module",
6
- "exports": {
7
- ".": {
8
- "source": "./src/index.ts",
9
- "types": "./build/types/index.d.ts",
10
- "import": "./build/index.js"
11
- },
12
- "./react": {
13
- "source": "./src/react/index.ts",
14
- "types": "./build/types/react/index.d.ts",
15
- "import": "./build/react/index.js"
16
- },
17
- "./devtools/browser": {
18
- "source": "./src/devtools/browser/index.ts",
19
- "types": "./build/types/devtools/browser/index.d.ts",
20
- "import": "./build/devtools/browser/index.js"
21
- }
22
- },
23
- "files": [
24
- "build",
25
- "package.json",
26
- "README.md"
27
- ],
28
- "publishConfig": {
29
- "access": "public"
30
- },
31
- "scripts": {
32
- "type-check": "bunx tsc --noEmit",
33
- "type-check-watch": "bunx tsc --noEmit --watch",
34
- "clean-build": "bunx rimraf build",
35
- "vitest": "vitest --typecheck",
36
- "vitest-agent": "vitest --typecheck --reporter=agent",
37
- "build": "bun run clean-build && bun run build.ts && bun run build-types",
38
- "build-watch": "bun run clean-build && bun run build.ts --watch && bun run build-types --watch",
39
- "build-types": "tsc --project tsconfig.build.json"
40
- },
41
- "dependencies": {
42
- "immer": "11.1.8",
43
- "fast-equals": "6.0.0"
44
- },
45
- "devDependencies": {
46
- "react": "19.2.7"
47
- },
48
- "peerDependencies": {
49
- "react": ">=19"
50
- },
51
- "peerDependenciesMeta": {
52
- "react": {
53
- "optional": true
54
- }
55
- }
56
- }
1
+ {
2
+ "name": "@nice-code/state",
3
+ "version": "0.4.1",
4
+ "private": false,
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "source": "./src/index.ts",
9
+ "types": "./build/types/index.d.ts",
10
+ "import": "./build/index.js"
11
+ },
12
+ "./react": {
13
+ "source": "./src/react/index.ts",
14
+ "types": "./build/types/react/index.d.ts",
15
+ "import": "./build/react/index.js"
16
+ },
17
+ "./devtools/browser": {
18
+ "source": "./src/devtools/browser/index.ts",
19
+ "types": "./build/types/devtools/browser/index.d.ts",
20
+ "import": "./build/devtools/browser/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "build",
25
+ "package.json",
26
+ "README.md"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "scripts": {
32
+ "type-check": "bunx tsc --noEmit",
33
+ "type-check-watch": "bunx tsc --noEmit --watch",
34
+ "clean-build": "bunx rimraf build",
35
+ "vitest": "vitest --typecheck",
36
+ "vitest-agent": "vitest --typecheck --reporter=agent",
37
+ "build": "bun run clean-build && bun run build.ts && bun run build-types",
38
+ "build-watch": "bun run clean-build && bun run build.ts --watch && bun run build-types --watch",
39
+ "build-types": "tsc --project tsconfig.build.json"
40
+ },
41
+ "dependencies": {
42
+ "immer": "11.1.8",
43
+ "fast-equals": "6.0.0"
44
+ },
45
+ "devDependencies": {
46
+ "react": "19.2.7"
47
+ },
48
+ "peerDependencies": {
49
+ "react": ">=19"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "react": {
53
+ "optional": true
54
+ }
55
+ }
56
+ }