@noya-app/noya-api-client-react 0.1.50 → 0.1.52

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/dist/index.mjs CHANGED
@@ -33,11 +33,11 @@ var require_access = __commonJS({
33
33
  "../../node_modules/tree-visit/lib/access.js"(exports) {
34
34
  "use strict";
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.get = get4;
36
+ exports.get = get5;
37
37
  exports.ancestors = ancestors;
38
38
  exports.access = access;
39
39
  exports.accessPath = accessPath;
40
- function get4(node, indexPath, options) {
40
+ function get5(node, indexPath, options) {
41
41
  if (options.includeTraversalContext) {
42
42
  const accessed = _getPath(node, indexPath, options);
43
43
  return accessed[accessed.length - 1];
@@ -6064,11 +6064,11 @@ function handleValue(target, handledSet, options) {
6064
6064
  }
6065
6065
  });
6066
6066
  if (setMap) {
6067
- const set4 = target;
6068
- const values = Array.from(set4);
6069
- set4.clear();
6067
+ const set3 = target;
6068
+ const values = Array.from(set3);
6069
+ set3.clear();
6070
6070
  values.forEach((value) => {
6071
- set4.add(setMap.has(value) ? setMap.get(value) : value);
6071
+ set3.add(setMap.has(value) ? setMap.get(value) : value);
6072
6072
  });
6073
6073
  }
6074
6074
  }
@@ -7293,19 +7293,14 @@ function applyExtendedPatch(obj, patches) {
7293
7293
  // ../state-manager/src/diff.ts
7294
7294
  var import_fast_diff = __toESM(require_diff());
7295
7295
 
7296
- // ../state-manager/src/EvalManager.ts
7297
- import { uuid as uuid2 } from "@noya-app/noya-utils";
7298
-
7299
- // ../state-manager/src/FilePropertyManager.ts
7300
- import { uuid as uuid3 } from "@noya-app/noya-utils";
7301
- import { Observable as Observable5 } from "@noya-app/observable";
7302
-
7303
- // ../state-manager/src/multiplayer.ts
7304
- import { Cache, hash, isDeepEqual as isDeepEqual3, uuid as uuid5 } from "@noya-app/noya-utils";
7305
- import { Observable as Observable8, get as get2, set as set2 } from "@noya-app/observable";
7296
+ // ../state-manager/src/documentAITools.ts
7297
+ import { get as get2 } from "@noya-app/observable";
7306
7298
 
7307
- // ../state-manager/src/LogManager.ts
7308
- import { Observable as Observable6 } from "@noya-app/observable";
7299
+ // ../state-manager/src/stateManager.ts
7300
+ import {
7301
+ Observable as Observable5,
7302
+ get as getPath2
7303
+ } from "@noya-app/observable";
7309
7304
 
7310
7305
  // ../state-manager/src/historyEntries.ts
7311
7306
  var HistoryEntries;
@@ -7393,6 +7388,73 @@ var HistoryEntries;
7393
7388
  HistoryEntries2.pathsEqual = pathsEqual;
7394
7389
  })(HistoryEntries || (HistoryEntries = {}));
7395
7390
 
7391
+ // ../state-manager/src/documentAITools.ts
7392
+ var pathSchema = Type.Array(Type.Union([Type.String(), Type.Number()]), {
7393
+ description: "An exact path into the JSON document, expressed as string and number segments."
7394
+ });
7395
+ var documentOperationSchema = Type.Union([
7396
+ Type.Object({
7397
+ op: Type.Literal("set"),
7398
+ path: pathSchema,
7399
+ value: Type.Any()
7400
+ }),
7401
+ Type.Object({
7402
+ op: Type.Literal("add"),
7403
+ path: pathSchema,
7404
+ value: Type.Any()
7405
+ }),
7406
+ Type.Object({
7407
+ op: Type.Literal("remove"),
7408
+ path: pathSchema
7409
+ }),
7410
+ Type.Object({
7411
+ op: Type.Literal("move"),
7412
+ from: pathSchema,
7413
+ path: pathSchema
7414
+ })
7415
+ ]);
7416
+ var readDocumentParametersSchema = Type.Object({
7417
+ path: Type.Optional(pathSchema)
7418
+ });
7419
+ var applyDocumentOperationsParametersSchema = Type.Object({
7420
+ operations: Type.Array(documentOperationSchema, { minItems: 1 }),
7421
+ expectedHash: Type.Optional(
7422
+ Type.String({
7423
+ description: "The document hash returned by an earlier tool result. The edit is rejected if the document changed."
7424
+ })
7425
+ ),
7426
+ summary: Type.String({
7427
+ description: "A concise description of the requested document changes."
7428
+ })
7429
+ });
7430
+ var runDocumentScriptParametersSchema = Type.Object({
7431
+ sourceCode: Type.String({
7432
+ description: 'JavaScript defining a named function "updateState(state)" which mutates state in place.'
7433
+ }),
7434
+ expectedHash: Type.Optional(
7435
+ Type.String({
7436
+ description: "The document hash returned by an earlier tool result. The edit is rejected if the document changed."
7437
+ })
7438
+ ),
7439
+ summary: Type.String({
7440
+ description: "A concise description of the requested document changes."
7441
+ })
7442
+ });
7443
+
7444
+ // ../state-manager/src/EvalManager.ts
7445
+ import { uuid as uuid2 } from "@noya-app/noya-utils";
7446
+
7447
+ // ../state-manager/src/FilePropertyManager.ts
7448
+ import { uuid as uuid3 } from "@noya-app/noya-utils";
7449
+ import { Observable as Observable6 } from "@noya-app/observable";
7450
+
7451
+ // ../state-manager/src/multiplayer.ts
7452
+ import { Cache, hash, isDeepEqual as isDeepEqual3, uuid as uuid5 } from "@noya-app/noya-utils";
7453
+ import { Observable as Observable8, get as get3, set as set2 } from "@noya-app/observable";
7454
+
7455
+ // ../state-manager/src/LogManager.ts
7456
+ import { Observable as Observable7 } from "@noya-app/observable";
7457
+
7396
7458
  // ../../node_modules/@marcbachmann/cel-js/lib/errors.js
7397
7459
  var ParseError = class extends Error {
7398
7460
  #wasConstructedWithAst = false;
@@ -9541,10 +9603,10 @@ function registerOverloads(registry) {
9541
9603
  return true;
9542
9604
  }
9543
9605
  const arr = a instanceof Set ? b : a;
9544
- const set4 = a instanceof Set ? a : b;
9606
+ const set3 = a instanceof Set ? a : b;
9545
9607
  if (!Array.isArray(arr)) return false;
9546
- if (arr.length !== set4?.size) return false;
9547
- for (let i = 0; i < arr.length; i++) if (!set4.has(arr[i])) return false;
9608
+ if (arr.length !== set3?.size) return false;
9609
+ for (let i = 0; i < arr.length; i++) if (!set3.has(arr[i])) return false;
9548
9610
  return true;
9549
9611
  });
9550
9612
  binaryOverload2("map", `==`, "map", (a, b, ast, ev) => {
@@ -10410,20 +10472,18 @@ var READ_DENIED = Symbol("readDenied");
10410
10472
  // ../state-manager/src/serverScripts.ts
10411
10473
  import { uuid as createUuid, isDeepEqual as isDeepEqual2 } from "@noya-app/noya-utils";
10412
10474
 
10413
- // ../state-manager/src/stateManager.ts
10414
- import {
10415
- Observable as Observable7,
10416
- get as getPath2
10417
- } from "@noya-app/observable";
10418
-
10419
10475
  // ../state-manager/src/multiplayer.ts
10420
10476
  var createHash = (value, options) => hash(value, { ...options, ignoreUndefinedProperties: true });
10421
10477
 
10422
10478
  // ../state-manager/src/GitManager.ts
10423
10479
  import { Observable as Observable9 } from "@noya-app/observable";
10424
10480
 
10425
- // ../state-manager/src/IOManager.ts
10481
+ // ../state-manager/src/ImagePickerManager.ts
10426
10482
  import { Observable as Observable10 } from "@noya-app/observable";
10483
+ import { uuid as uuid6 } from "@noya-app/noya-utils";
10484
+
10485
+ // ../state-manager/src/IOManager.ts
10486
+ import { Observable as Observable11 } from "@noya-app/observable";
10427
10487
 
10428
10488
  // ../state-manager/src/jwt.ts
10429
10489
  function base64UrlEncode(str) {
@@ -10526,17 +10586,17 @@ var jwt;
10526
10586
 
10527
10587
  // ../state-manager/src/MenuManager.ts
10528
10588
  import { isDeepEqual as isDeepEqual4 } from "@noya-app/noya-utils";
10529
- import { Observable as Observable11 } from "@noya-app/observable";
10589
+ import { Observable as Observable12 } from "@noya-app/observable";
10530
10590
 
10531
10591
  // ../state-manager/src/NoyaManager.ts
10532
- import { uuid as uuid13 } from "@noya-app/noya-utils";
10533
- import { Observable as Observable22, set as set3 } from "@noya-app/observable";
10592
+ import { uuid as uuid14 } from "@noya-app/noya-utils";
10593
+ import { Observable as Observable23 } from "@noya-app/observable";
10534
10594
 
10535
10595
  // ../noya-pipeline/src/graphToTasks.ts
10536
- import { get as get3 } from "@noya-app/observable";
10596
+ import { get as get4 } from "@noya-app/observable";
10537
10597
 
10538
10598
  // ../noya-pipeline/src/state.ts
10539
- import { uuid as uuid6 } from "@noya-app/noya-utils";
10599
+ import { uuid as uuid7 } from "@noya-app/noya-utils";
10540
10600
  var rectSchema = Type.Object({
10541
10601
  x: Type.Number(),
10542
10602
  y: Type.Number(),
@@ -10635,38 +10695,38 @@ var pipelineSchema = Type.Object(
10635
10695
  );
10636
10696
 
10637
10697
  // ../state-manager/src/PipelineManager.ts
10638
- import { Observable as Observable12 } from "@noya-app/observable";
10698
+ import { Observable as Observable13 } from "@noya-app/observable";
10639
10699
 
10640
10700
  // ../state-manager/src/PublishingManager.ts
10641
- import { Observable as Observable13 } from "@noya-app/observable";
10701
+ import { Observable as Observable14 } from "@noya-app/observable";
10642
10702
 
10643
10703
  // ../state-manager/src/ResourceManager.ts
10644
- import { isDeepEqual as isDeepEqual5, uuid as uuid7 } from "@noya-app/noya-utils";
10645
- import { Observable as Observable14 } from "@noya-app/observable";
10704
+ import { isDeepEqual as isDeepEqual5, uuid as uuid8 } from "@noya-app/noya-utils";
10705
+ import { Observable as Observable15 } from "@noya-app/observable";
10646
10706
 
10647
10707
  // ../state-manager/src/SandboxManager.ts
10648
- import { Observable as Observable15 } from "@noya-app/observable";
10708
+ import { Observable as Observable16 } from "@noya-app/observable";
10649
10709
 
10650
10710
  // ../state-manager/src/rpcManager.ts
10651
- import { uuid as uuid8 } from "@noya-app/noya-utils";
10652
- import { Observable as Observable16 } from "@noya-app/observable";
10711
+ import { uuid as uuid9 } from "@noya-app/noya-utils";
10712
+ import { Observable as Observable17 } from "@noya-app/observable";
10653
10713
 
10654
10714
  // ../state-manager/src/SecretManager.ts
10655
- import { Observable as Observable17 } from "@noya-app/observable";
10715
+ import { Observable as Observable18 } from "@noya-app/observable";
10656
10716
 
10657
10717
  // ../state-manager/src/TaskManager.ts
10658
- import { Observable as Observable18 } from "@noya-app/observable";
10718
+ import { Observable as Observable19 } from "@noya-app/observable";
10659
10719
 
10660
10720
  // ../state-manager/src/TranscriptionManager.ts
10661
10721
  import { Base64 as Base643 } from "@noya-app/noya-utils";
10662
- import { Observable as Observable19 } from "@noya-app/observable";
10722
+ import { Observable as Observable20 } from "@noya-app/observable";
10663
10723
 
10664
10724
  // ../state-manager/src/UserManager.ts
10665
- import { Observable as Observable21 } from "@noya-app/observable";
10725
+ import { Observable as Observable22 } from "@noya-app/observable";
10666
10726
 
10667
10727
  // ../state-manager/src/sync/clientId.ts
10668
- import { uuid as uuid9 } from "@noya-app/noya-utils";
10669
- import { Observable as Observable20 } from "@noya-app/observable";
10728
+ import { uuid as uuid10 } from "@noya-app/noya-utils";
10729
+ import { Observable as Observable21 } from "@noya-app/observable";
10670
10730
 
10671
10731
  // ../state-manager/src/sync/defaultNames.ts
10672
10732
  import { upperFirst } from "@noya-app/noya-utils";
@@ -10739,9 +10799,9 @@ function getClientAnimalFromName(name) {
10739
10799
  var CLIENT_ID_STORAGE_KEY = "noya-client-id";
10740
10800
  var CLIENT_NAME_STORAGE_KEY = "noya-client-name";
10741
10801
  var CLIENT_IMAGE_STORAGE_KEY = "noya-client-image";
10742
- var clientId$ = new Observable20(void 0);
10743
- var clientName$ = new Observable20(void 0);
10744
- var clientImage$ = new Observable20(void 0);
10802
+ var clientId$ = new Observable21(void 0);
10803
+ var clientName$ = new Observable21(void 0);
10804
+ var clientImage$ = new Observable21(void 0);
10745
10805
  var safeGetItem = (key) => {
10746
10806
  try {
10747
10807
  return typeof localStorage !== "undefined" ? localStorage.getItem(key) : null;
@@ -10762,7 +10822,7 @@ if (typeof window !== "undefined") {
10762
10822
  if (storedClientId) {
10763
10823
  clientId$.set(storedClientId);
10764
10824
  } else {
10765
- const newClientId = uuid9();
10825
+ const newClientId = uuid10();
10766
10826
  safeSetItem(CLIENT_ID_STORAGE_KEY, newClientId);
10767
10827
  clientId$.set(newClientId);
10768
10828
  }
@@ -10785,13 +10845,13 @@ if (typeof window !== "undefined") {
10785
10845
  }
10786
10846
 
10787
10847
  // ../state-manager/src/sync/syncUtils.ts
10788
- import { uuid as uuid10 } from "@noya-app/noya-utils";
10848
+ import { uuid as uuid11 } from "@noya-app/noya-utils";
10789
10849
 
10790
10850
  // ../state-manager/src/sync/localRpcHelpers.ts
10791
- import { Base64 as Base644, uuid as uuid11 } from "@noya-app/noya-utils";
10851
+ import { Base64 as Base644, uuid as uuid12 } from "@noya-app/noya-utils";
10792
10852
 
10793
10853
  // ../state-manager/src/sync/localStorageSync.ts
10794
- import { uuid as uuid12 } from "@noya-app/noya-utils";
10854
+ import { uuid as uuid13 } from "@noya-app/noya-utils";
10795
10855
 
10796
10856
  // ../noya-keymap/src/hooks.ts
10797
10857
  import { useEffect as useEffect2, useRef as useRef2 } from "react";
@@ -10903,22 +10963,12 @@ var MenuItemTree = (0, import_tree_visit3.defineTree)((node) => {
10903
10963
  return node.type === "submenu" ? node.items : [];
10904
10964
  });
10905
10965
 
10906
- // ../state-manager/src/NoyaManager.ts
10907
- var createMutatorParametersSchema = Type.Object({
10908
- sourceCode: Type.String({
10909
- description: "The source code of the mutator function."
10910
- }),
10911
- message: Type.String({
10912
- description: `A message that summarizes the changes made to the document state.`
10913
- })
10914
- });
10915
-
10916
10966
  // ../noya-multiplayer-react/src/ai.ts
10917
10967
  import { useEffect as useEffect18 } from "react";
10918
10968
 
10919
10969
  // ../noya-multiplayer-react/src/NoyaStateContext.tsx
10920
10970
  import {
10921
- Observable as Observable23
10971
+ Observable as Observable24
10922
10972
  } from "@noya-app/observable";
10923
10973
 
10924
10974
  // ../noya-react-utils/src/components/AutoSizer.tsx
@@ -11328,7 +11378,7 @@ import React35 from "react";
11328
11378
  import { createRoot } from "react-dom/client";
11329
11379
 
11330
11380
  // ../noya-multiplayer-react/src/inspector/StateInspector.tsx
11331
- import { Base64 as Base645, memoize, uuid as uuid14 } from "@noya-app/noya-utils";
11381
+ import { Base64 as Base645, memoize, uuid as uuid15 } from "@noya-app/noya-utils";
11332
11382
  import React34, {
11333
11383
  useCallback as useCallback12,
11334
11384
  useEffect as useEffect14,
@@ -12526,7 +12576,7 @@ var import_is_dom = __toESM2(require_is_dom());
12526
12576
  // ../noya-multiplayer-react/src/useObservable.ts
12527
12577
  import { useMemo as useMemo8, useSyncExternalStore } from "react";
12528
12578
  function useObservable2(observable, pathOrSelector, options) {
12529
- const { get: get4, listen } = useMemo8(() => {
12579
+ const { get: get5, listen } = useMemo8(() => {
12530
12580
  if (!observable) {
12531
12581
  return {
12532
12582
  get: () => void 0,
@@ -12544,10 +12594,10 @@ function useObservable2(observable, pathOrSelector, options) {
12544
12594
  };
12545
12595
  }
12546
12596
  const listen2 = pathOrSelector ? (callback) => observable.subscribe(pathOrSelector, callback) : observable.subscribe;
12547
- const get5 = pathOrSelector ? () => observable.get(pathOrSelector) : observable.get;
12548
- return { get: get5, listen: listen2 };
12597
+ const get6 = pathOrSelector ? () => observable.get(pathOrSelector) : observable.get;
12598
+ return { get: get6, listen: listen2 };
12549
12599
  }, [observable, pathOrSelector, options?.isEqual]);
12550
- return useSyncExternalStore(listen, get4, get4);
12600
+ return useSyncExternalStore(listen, get5, get5);
12551
12601
  }
12552
12602
 
12553
12603
  // ../noya-multiplayer-react/src/inspector/ColoredDot.tsx
@@ -14379,6 +14429,7 @@ var StateInspector = memoGeneric(function StateInspector2({
14379
14429
  anchor = "right",
14380
14430
  unstyled = false,
14381
14431
  advanced = false,
14432
+ defaultCollapsed = false,
14382
14433
  ...props
14383
14434
  }) {
14384
14435
  const {
@@ -14408,7 +14459,7 @@ var StateInspector = memoGeneric(function StateInspector2({
14408
14459
  const serverSimulationLogsContainerRef = React34.useRef(null);
14409
14460
  const [showInspector, setShowInspector] = useLocalStorageState(
14410
14461
  "noya-multiplayer-react-show-inspector",
14411
- true
14462
+ !defaultCollapsed
14412
14463
  );
14413
14464
  const [showEvents, setShowEvents] = useLocalStorageState(
14414
14465
  "noya-multiplayer-react-show-events",
@@ -14857,7 +14908,7 @@ var StateInspector = memoGeneric(function StateInspector2({
14857
14908
  {
14858
14909
  theme: theme3,
14859
14910
  onClick: async () => {
14860
- const path2 = prompt("Enter directory path") || uuid14();
14911
+ const path2 = prompt("Enter directory path") || uuid15();
14861
14912
  await resourceManager.createResource({
14862
14913
  type: "directory",
14863
14914
  path: path2
@@ -14873,7 +14924,7 @@ var StateInspector = memoGeneric(function StateInspector2({
14873
14924
  const file = await uploadFile();
14874
14925
  resourceManager.createResource({
14875
14926
  type: "asset",
14876
- path: file.name || uuid14(),
14927
+ path: file.name || uuid15(),
14877
14928
  asset: {
14878
14929
  content: Base645.encode(await file.arrayBuffer()),
14879
14930
  contentType: file.type,
@@ -15167,7 +15218,7 @@ function useActivityEventsForManager(streamFilter, activityEventsManager) {
15167
15218
  }
15168
15219
 
15169
15220
  // ../noya-multiplayer-react/src/components/UserPointersOverlay.tsx
15170
- import { Observable as Observable24 } from "@noya-app/observable";
15221
+ import { Observable as Observable25 } from "@noya-app/observable";
15171
15222
  import React38, { useEffect as useEffect19, useMemo as useMemo12, useState as useState19 } from "react";
15172
15223
  function shouldShow(hideAfter, updatedAt) {
15173
15224
  return !!updatedAt && Date.now() - updatedAt < hideAfter;
@@ -15181,7 +15232,7 @@ var UserPointerInternal = memoGeneric(function UserPointerInternal2({
15181
15232
  const observable = useMemo12(() => {
15182
15233
  const metadata$ = sharedConnectionDataManager.metadata$.observePath([user.connectionId]).throttle(50);
15183
15234
  const data$ = sharedConnectionDataManager.data$.observePath([user.connectionId]).throttle(50);
15184
- return Observable24.combine([metadata$, data$], ([metadata2, data2]) => {
15235
+ return Observable25.combine([metadata$, data$], ([metadata2, data2]) => {
15185
15236
  return { metadata: metadata2, data: data2 };
15186
15237
  });
15187
15238
  }, [sharedConnectionDataManager, user.connectionId]);