dara-core 1.21.3__py3-none-any.whl → 1.21.4__py3-none-any.whl

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.
@@ -5466,7 +5466,6 @@
5466
5466
  var Recoil_index_24 = Recoil_index.useSetRecoilState;
5467
5467
  var Recoil_index_28 = Recoil_index.useRecoilValueLoadable_TRANSITION_SUPPORT_UNSTABLE;
5468
5468
  var Recoil_index_31 = Recoil_index.useRecoilCallback;
5469
- var Recoil_index_34 = Recoil_index.useRecoilSnapshot;
5470
5469
  var Key;
5471
5470
  (function(Key2) {
5472
5471
  Key2["BACKSPACE"] = "Backspace";
@@ -31976,9 +31975,15 @@
31976
31975
  width: 10px;
31977
31976
  height: 10px;
31978
31977
 
31979
- color: ${(props) => props.theme.colors.grey4};
31978
+ color: ${(props) => {
31979
+ var _a;
31980
+ return (_a = props.$grey4) !== null && _a !== void 0 ? _a : props.theme.colors.grey4;
31981
+ }};
31980
31982
 
31981
- background-color: ${(props) => props.theme.colors.grey4};
31983
+ background-color: ${(props) => {
31984
+ var _a;
31985
+ return (_a = props.$grey4) !== null && _a !== void 0 ? _a : props.theme.colors.grey4;
31986
+ }};
31982
31987
  border-radius: 5px;
31983
31988
 
31984
31989
  animation: dot-flashing 1s infinite linear alternate;
@@ -31998,9 +32003,15 @@
31998
32003
  width: 10px;
31999
32004
  height: 10px;
32000
32005
 
32001
- color: ${(props) => props.theme.colors.grey4};
32006
+ color: ${(props) => {
32007
+ var _a;
32008
+ return (_a = props.$grey4) !== null && _a !== void 0 ? _a : props.theme.colors.grey4;
32009
+ }};
32002
32010
 
32003
- background-color: ${(props) => props.theme.colors.grey4};
32011
+ background-color: ${(props) => {
32012
+ var _a;
32013
+ return (_a = props.$grey4) !== null && _a !== void 0 ? _a : props.theme.colors.grey4;
32014
+ }};
32004
32015
  border-radius: 5px;
32005
32016
 
32006
32017
  animation: dot-flashing 1s infinite alternate;
@@ -32013,9 +32024,15 @@
32013
32024
  width: 10px;
32014
32025
  height: 10px;
32015
32026
 
32016
- color: ${(props) => props.theme.colors.grey4};
32027
+ color: ${(props) => {
32028
+ var _a;
32029
+ return (_a = props.$grey4) !== null && _a !== void 0 ? _a : props.theme.colors.grey4;
32030
+ }};
32017
32031
 
32018
- background-color: ${(props) => props.theme.colors.grey4};
32032
+ background-color: ${(props) => {
32033
+ var _a;
32034
+ return (_a = props.$grey4) !== null && _a !== void 0 ? _a : props.theme.colors.grey4;
32035
+ }};
32019
32036
  border-radius: 5px;
32020
32037
 
32021
32038
  animation: dot-flashing 1s infinite alternate;
@@ -32024,17 +32041,23 @@
32024
32041
 
32025
32042
  @keyframes dot-flashing {
32026
32043
  0% {
32027
- background-color: ${(props) => props.theme.colors.grey4};
32044
+ background-color: ${(props) => {
32045
+ var _a;
32046
+ return (_a = props.$grey4) !== null && _a !== void 0 ? _a : props.theme.colors.grey4;
32047
+ }};
32028
32048
  }
32029
32049
 
32030
32050
  50%,
32031
32051
  100% {
32032
- background-color: ${(props) => props.theme.colors.grey3};
32052
+ background-color: ${(props) => {
32053
+ var _a;
32054
+ return (_a = props.$grey3) !== null && _a !== void 0 ? _a : props.theme.colors.grey3;
32055
+ }};
32033
32056
  }
32034
32057
  }
32035
32058
  `;
32036
32059
  function Dots(props) {
32037
- return jsxRuntimeExports.jsx(Wrapper$4, { className: props.className, style: props.style, children: jsxRuntimeExports.jsx(FlashingDots, { "data-testid": "LOADING" }) });
32060
+ return jsxRuntimeExports.jsx(Wrapper$4, { className: props.className, style: props.style, children: jsxRuntimeExports.jsx(FlashingDots, { "$grey3": props.grey3, "$grey4": props.grey4, "data-testid": "LOADING" }) });
32038
32061
  }
32039
32062
  var COMMON_MIME_TYPES = /* @__PURE__ */ new Map([
32040
32063
  ["avi", "video/avi"],
@@ -50502,6 +50525,9 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
50502
50525
  url.searchParams.set("token", sessionToken);
50503
50526
  return new WebSocketClient(socketUrl, sessionToken, liveReload);
50504
50527
  }
50528
+ function isPathParamStore(store2) {
50529
+ return store2.__typename === "_PathParamStore";
50530
+ }
50505
50531
  var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
50506
50532
  ComponentType2["JS"] = "js";
50507
50533
  ComponentType2["PY"] = "py";
@@ -64112,15 +64138,17 @@ ${String(error)}`;
64112
64138
  children,
64113
64139
  routeDefinitions,
64114
64140
  routeObjects,
64115
- routeDefMap
64141
+ routeDefMap,
64142
+ defaultPath
64116
64143
  }) {
64117
64144
  const value = React__namespace.useMemo(
64118
64145
  () => ({
64119
64146
  routeDefinitions,
64120
64147
  routeObjects,
64121
- routeDefMap
64148
+ routeDefMap,
64149
+ defaultPath
64122
64150
  }),
64123
- [routeDefinitions, routeObjects, routeDefMap]
64151
+ [routeDefinitions, routeObjects, routeDefMap, defaultPath]
64124
64152
  );
64125
64153
  return /* @__PURE__ */ React__namespace.createElement(RouterContext.Provider, { value }, children);
64126
64154
  }
@@ -64622,14 +64650,19 @@ Inferred class string: "${iconClasses}."`
64622
64650
  }
64623
64651
  return atomInstance;
64624
64652
  }
64625
- function resolvePlainVariableStatic(variable, snapshot) {
64653
+ function resolvePlainVariableStatic(variable, snapshot, params) {
64654
+ if (variable.store && isPathParamStore(variable.store)) {
64655
+ return params[variable.store.param_name];
64656
+ }
64626
64657
  const family = atomFamilyRegistry.get(variable.uid);
64627
64658
  if (family) {
64628
64659
  const extrasSerializable = new RequestExtrasSerializable({});
64629
- const atomInstance = family(extrasSerializable);
64630
- const atomValue = snapshot.getLoadable(atomInstance).valueMaybe();
64631
- if (atomValue !== null && !(atomValue instanceof Promise)) {
64632
- return atomInstance;
64660
+ const atomInstance = atomFamilyMembersRegistry.get(family).get(extrasSerializable.toJSON());
64661
+ if (atomInstance) {
64662
+ const atomValue = snapshot.getLoadable(atomInstance).valueMaybe();
64663
+ if (atomValue !== null && !(atomValue instanceof Promise)) {
64664
+ return atomValue;
64665
+ }
64633
64666
  }
64634
64667
  }
64635
64668
  return variable.default;
@@ -69510,14 +69543,67 @@ Inferred class string: "${iconClasses}."`
69510
69543
  }
69511
69544
  var setExports = requireSet();
69512
69545
  const set = /* @__PURE__ */ getDefaultExportFromCjs(setExports);
69546
+ class DeferredImpl {
69547
+ #resolve;
69548
+ #reject;
69549
+ #promise;
69550
+ #status;
69551
+ #error;
69552
+ #value;
69553
+ constructor() {
69554
+ this.#status = "pending";
69555
+ this.#promise = new Promise((res, rej) => {
69556
+ this.#resolve = res;
69557
+ this.#reject = rej;
69558
+ });
69559
+ }
69560
+ get status() {
69561
+ return this.#status;
69562
+ }
69563
+ getOrThrow() {
69564
+ if (this.status === "pending") {
69565
+ throw new Error("Deferred not resolved");
69566
+ }
69567
+ if (this.status === "rejected") {
69568
+ throw this.#error;
69569
+ }
69570
+ return this.#value;
69571
+ }
69572
+ getValue() {
69573
+ if (this.status === "pending") {
69574
+ return this.#promise;
69575
+ }
69576
+ if (this.status === "rejected") {
69577
+ return Promise.reject(this.#error);
69578
+ }
69579
+ return Promise.resolve(this.#value);
69580
+ }
69581
+ resolve(value) {
69582
+ if (this.#status === "resolved") {
69583
+ throw new Error("Deferred already resolved");
69584
+ } else if (this.#status === "rejected") {
69585
+ throw new Error("Deferred already rejected");
69586
+ }
69587
+ this.#status = "resolved";
69588
+ this.#value = value;
69589
+ this.#resolve(value);
69590
+ }
69591
+ reject(reason) {
69592
+ if (this.#status === "resolved") {
69593
+ throw new Error("Deferred already resolved");
69594
+ } else if (this.#status === "rejected") {
69595
+ throw new Error("Deferred already rejected");
69596
+ }
69597
+ this.#status = "rejected";
69598
+ this.#error = reason;
69599
+ this.#reject(reason);
69600
+ }
69601
+ }
69513
69602
  function deferred() {
69514
- let resolve;
69515
- let reject;
69516
- const promise = new Promise((res, rej) => {
69517
- resolve = res;
69518
- reject = rej;
69519
- });
69520
- return { promise, resolve, reject };
69603
+ return new DeferredImpl();
69604
+ }
69605
+ function isDeferred(value) {
69606
+ return value && typeof value === "object" && value instanceof DeferredImpl;
69521
69607
  }
69522
69608
  function getOrRegisterTrigger(variable) {
69523
69609
  const triggerKey = getRegistryKey(variable, "trigger");
@@ -69695,8 +69781,8 @@ Inferred class string: "${iconClasses}."`
69695
69781
  triggers
69696
69782
  }) {
69697
69783
  const values = resolvedVariables.map((v) => {
69698
- if (resolutionStrategy.name === "snapshot") {
69699
- return resolveVariableStatic(v, resolutionStrategy.snapshot);
69784
+ if (resolutionStrategy.name === "static") {
69785
+ return resolveVariableStatic(v, resolutionStrategy.snapshot, resolutionStrategy.params);
69700
69786
  }
69701
69787
  return resolveValue(v, resolutionStrategy.get);
69702
69788
  });
@@ -69713,7 +69799,7 @@ Inferred class string: "${iconClasses}."`
69713
69799
  const areArgsTheSame = isEqual$4(previousEntry.args, relevantValues);
69714
69800
  if (areArgsTheSame) {
69715
69801
  const previousValue = previousEntry.result;
69716
- if (previousValue instanceof Promise) {
69802
+ if (isDeferred(previousValue)) {
69717
69803
  return {
69718
69804
  type: "cached",
69719
69805
  response: previousValue,
@@ -69861,7 +69947,7 @@ Inferred class string: "${iconClasses}."`
69861
69947
  let shouldFetchTask = false;
69862
69948
  if (derivedResult.type === "cached") {
69863
69949
  try {
69864
- const response = await derivedResult.response;
69950
+ const response = await derivedResult.response.getValue();
69865
69951
  shouldFetchTask = true;
69866
69952
  if (!response.ok) {
69867
69953
  throwError(new Error(response.value));
@@ -69950,14 +70036,15 @@ Inferred class string: "${iconClasses}."`
69950
70036
  deps,
69951
70037
  triggerList,
69952
70038
  triggers,
69953
- snapshot
70039
+ snapshot,
70040
+ params
69954
70041
  }) {
69955
70042
  const derivedResult = resolveDerivedValue({
69956
70043
  key,
69957
70044
  variables,
69958
70045
  deps,
69959
70046
  resolvedVariables: variables,
69960
- resolutionStrategy: { name: "snapshot", snapshot },
70047
+ resolutionStrategy: { name: "static", snapshot, params },
69961
70048
  triggerList,
69962
70049
  triggers
69963
70050
  });
@@ -69966,7 +70053,7 @@ Inferred class string: "${iconClasses}."`
69966
70053
  }
69967
70054
  return { result: derivedResult, handle: deferred() };
69968
70055
  }
69969
- function preloadDerivedVariable(variable, snapshot) {
70056
+ function preloadDerivedVariable(variable, snapshot, params) {
69970
70057
  const key = getRegistryKey(variable, "result-selector") + new RequestExtrasSerializable({}).toJSON();
69971
70058
  const triggerList = [...buildTriggerList(variable.variables), { path: [], variable }];
69972
70059
  const triggers = triggerList.map((ti) => resolveTriggerStatic(getOrRegisterTrigger(ti.variable), snapshot));
@@ -69976,7 +70063,8 @@ Inferred class string: "${iconClasses}."`
69976
70063
  deps: variable.deps,
69977
70064
  triggers,
69978
70065
  triggerList,
69979
- snapshot
70066
+ snapshot,
70067
+ params
69980
70068
  });
69981
70069
  }
69982
70070
  function useDerivedVariable(variable, WsClient, taskContext, extras) {
@@ -70080,9 +70168,9 @@ Inferred class string: "${iconClasses}."`
70080
70168
  }
70081
70169
  return resolver(getOrRegisterPlainVariable(variable, client2, taskContext, extras));
70082
70170
  }
70083
- function resolveVariableStatic(variable, snapshot) {
70171
+ function resolveVariableStatic(variable, snapshot, params) {
70084
70172
  if (isDerivedVariable(variable)) {
70085
- const values = variable.variables.map((v) => resolveVariableStatic(v, snapshot));
70173
+ const values = variable.variables.map((v) => resolveVariableStatic(v, snapshot, params));
70086
70174
  const deps = variable.deps.map((dep) => variable.variables.findIndex((v) => v.uid === dep.uid));
70087
70175
  return {
70088
70176
  deps,
@@ -70095,15 +70183,15 @@ Inferred class string: "${iconClasses}."`
70095
70183
  return resolveServerVariableStatic(variable, snapshot);
70096
70184
  }
70097
70185
  if (isSwitchVariable(variable)) {
70098
- let resolvedValue = isVariable(variable.value) ? resolveVariableStatic(variable.value, snapshot) : variable.value;
70186
+ let resolvedValue = isVariable(variable.value) ? resolveVariableStatic(variable.value, snapshot, params) : variable.value;
70099
70187
  if (isCondition(resolvedValue)) {
70100
70188
  resolvedValue = {
70101
70189
  ...resolvedValue,
70102
- variable: resolveVariableStatic(resolvedValue.variable, snapshot)
70190
+ variable: resolveVariableStatic(resolvedValue.variable, snapshot, params)
70103
70191
  };
70104
70192
  }
70105
- const resolvedValueMap = isVariable(variable.value_map) ? resolveVariableStatic(variable.value_map, snapshot) : variable.value_map;
70106
- const resolvedDefault = isVariable(variable.default) ? resolveVariableStatic(variable.default, snapshot) : variable.default;
70193
+ const resolvedValueMap = isVariable(variable.value_map) ? resolveVariableStatic(variable.value_map, snapshot, params) : variable.value_map;
70194
+ const resolvedDefault = isVariable(variable.default) ? resolveVariableStatic(variable.default, snapshot, params) : variable.default;
70107
70195
  return {
70108
70196
  type: "switch",
70109
70197
  uid: variable.uid,
@@ -70115,9 +70203,9 @@ Inferred class string: "${iconClasses}."`
70115
70203
  if (isStateVariable(variable)) {
70116
70204
  throw new Error("StateVariable should not be resolved - it should be handled by useVariable hook");
70117
70205
  }
70118
- let result = resolvePlainVariableStatic(variable, snapshot);
70206
+ let result = resolvePlainVariableStatic(variable, snapshot, params);
70119
70207
  while (isDerivedVariable(result)) {
70120
- result = resolveVariableStatic(result, snapshot);
70208
+ result = resolveVariableStatic(result, snapshot, params);
70121
70209
  }
70122
70210
  return result;
70123
70211
  }
@@ -71030,9 +71118,9 @@ Inferred class string: "${iconClasses}."`
71030
71118
  },
71031
71119
  [matchesRef, navigate, paramsRef, locationRef]
71032
71120
  );
71033
- const listenToStoreChanges = React__namespace.useCallback(({ updateAllKnownItems }) => {
71121
+ const listenToStoreChanges = React__namespace.useCallback(({ updateItems }) => {
71034
71122
  function handleUpdate(newParams) {
71035
- updateAllKnownItems(new Map(Object.entries(newParams)));
71123
+ updateItems(new Map(Object.entries(newParams)));
71036
71124
  }
71037
71125
  locationSubscribers.current.push(handleUpdate);
71038
71126
  return () => {
@@ -71631,7 +71719,7 @@ Inferred class string: "${iconClasses}."`
71631
71719
  return /* @__PURE__ */ React.createElement(StyledDots$1, { $rawCss: css2, style });
71632
71720
  }
71633
71721
  function DefaultFallbackStatic() {
71634
- return /* @__PURE__ */ React.createElement(StyledDots$1, null);
71722
+ return /* @__PURE__ */ React.createElement(StyledDots$1, { grey3: theme.colors.grey3, grey4: theme.colors.grey4 });
71635
71723
  }
71636
71724
  const Center = styled.div`
71637
71725
  overflow: hidden;
@@ -71755,8 +71843,9 @@ Inferred class string: "${iconClasses}."`
71755
71843
  const [isError2, setIsError] = React$1.useState(false);
71756
71844
  const location2 = useLocation();
71757
71845
  const navigate = useNavigate();
71846
+ const { defaultPath } = useRouterContext();
71758
71847
  const queryParams = new URLSearchParams(location2.search);
71759
- const previousLocation = queryParams.get("referrer") ?? "/";
71848
+ const previousLocation = queryParams.get("referrer") ?? defaultPath;
71760
71849
  const login = async () => {
71761
71850
  setIsLoggingIn(true);
71762
71851
  setIsError(false);
@@ -71775,7 +71864,7 @@ Inferred class string: "${iconClasses}."`
71775
71864
  if (getSessionToken()) {
71776
71865
  verifySessionToken().then((verified) => {
71777
71866
  if (verified) {
71778
- navigate(decodeURIComponent(previousLocation));
71867
+ navigate(decodeURIComponent(previousLocation), { replace: true });
71779
71868
  } else {
71780
71869
  setIsVerifyingToken(false);
71781
71870
  }
@@ -71842,8 +71931,9 @@ Inferred class string: "${iconClasses}."`
71842
71931
  function DefaultAuthLogin() {
71843
71932
  const location2 = useLocation();
71844
71933
  const navigate = useNavigate();
71934
+ const { defaultPath } = useRouterContext();
71845
71935
  const queryParams = new URLSearchParams(location2.search);
71846
- const previousLocation = queryParams.get("referrer") ?? "/";
71936
+ const previousLocation = queryParams.get("referrer") ?? defaultPath;
71847
71937
  async function getNewToken() {
71848
71938
  const sessionToken = await requestSessionToken({});
71849
71939
  if (sessionToken) {
@@ -71855,7 +71945,7 @@ Inferred class string: "${iconClasses}."`
71855
71945
  if (getSessionToken()) {
71856
71946
  verifySessionToken().then((verified) => {
71857
71947
  if (verified) {
71858
- navigate(decodeURIComponent(previousLocation));
71948
+ navigate(decodeURIComponent(previousLocation), { replace: true });
71859
71949
  } else {
71860
71950
  getNewToken();
71861
71951
  }
@@ -72399,7 +72489,7 @@ Inferred class string: "${iconClasses}."`
72399
72489
  let shouldFetchTask = false;
72400
72490
  if (derivedResult.type === "cached") {
72401
72491
  try {
72402
- const response = await derivedResult.response;
72492
+ const response = await derivedResult.response.getValue();
72403
72493
  shouldFetchTask = true;
72404
72494
  if (!response.ok) {
72405
72495
  throwError(new Error(response.value));
@@ -72486,7 +72576,7 @@ Inferred class string: "${iconClasses}."`
72486
72576
  selectorFamilyMembersRegistry.get(family).set(serializableExtras.toJSON(), selectorInstance);
72487
72577
  return selectorInstance;
72488
72578
  }
72489
- function preloadServerComponent(component, snapshot) {
72579
+ function preloadServerComponent(component, snapshot, params) {
72490
72580
  const key = getComponentRegistryKey(component.uid, false, component.loop_instance_uid);
72491
72581
  const kwargsList = Object.values(component.props.dynamic_kwargs);
72492
72582
  const triggerList = buildTriggerList(kwargsList);
@@ -72500,7 +72590,8 @@ Inferred class string: "${iconClasses}."`
72500
72590
  deps: kwargsList,
72501
72591
  triggerList,
72502
72592
  triggers,
72503
- snapshot
72593
+ snapshot,
72594
+ params
72504
72595
  });
72505
72596
  }
72506
72597
  function useServerComponent(name, uid2, dynamicKwargs, loop_instance_uid) {
@@ -73846,16 +73937,25 @@ Inferred class string: "${iconClasses}."`
73846
73937
  border-radius: 100px;
73847
73938
  }
73848
73939
  `;
73849
- function TemplateRoot(props) {
73940
+ function createAuthenticatedRootLoader(daraData) {
73941
+ return function loader() {
73942
+ if (window.dara.ws.status === "pending") {
73943
+ const token = getSessionToken();
73944
+ if (!token) {
73945
+ throw redirect("/login");
73946
+ }
73947
+ window.dara.ws.resolve(setupWebsocket(token, daraData.live_reload));
73948
+ }
73949
+ };
73950
+ }
73951
+ function AuthenticatedRoot(props) {
73850
73952
  const navigate = useNavigate();
73851
73953
  const token = useSessionToken();
73852
73954
  const [wsClient] = React$1.useState(() => {
73853
73955
  if (props.initialWebsocketClient) {
73854
73956
  return props.initialWebsocketClient;
73855
73957
  }
73856
- const ws = setupWebsocket(token, props.daraData.live_reload);
73857
- window.dara.ws.resolve(ws);
73858
- return ws;
73958
+ return window.dara.ws.getOrThrow();
73859
73959
  });
73860
73960
  React$1.useLayoutEffect(() => {
73861
73961
  if (token) {
@@ -74061,13 +74161,22 @@ body,
74061
74161
  clear() {
74062
74162
  this.cache.clear();
74063
74163
  }
74164
+ /**
74165
+ * Set a value if it doesn't exist in the cache, otherwise return the existing value.
74166
+ * The promise resolves the the new or existing value stored.
74167
+ *
74168
+ * @param key cache key
74169
+ * @param computeFn function to compute the value
74170
+ * @param timeout optional timeout in ms
74171
+ */
74064
74172
  setIfMissing(key, computeFn, timeout) {
74065
74173
  const entry = this.cache.get(key);
74066
74174
  if (entry && !this.isEntryStale(entry, timeout)) {
74067
- return;
74175
+ return Promise.resolve(entry.data);
74068
74176
  }
74069
74177
  const promise = computeFn();
74070
74178
  this.set(key, promise);
74179
+ return promise;
74071
74180
  }
74072
74181
  size() {
74073
74182
  return this.cache.size;
@@ -74145,7 +74254,7 @@ body,
74145
74254
  const kwargs = cleanKwargs(
74146
74255
  Object.fromEntries(
74147
74256
  Object.entries(a2.dynamic_kwargs).map(([k, v]) => {
74148
- return [k, resolveVariableStatic(v, snapshot)];
74257
+ return [k, resolveVariableStatic(v, snapshot, params)];
74149
74258
  })
74150
74259
  ),
74151
74260
  null
@@ -74157,7 +74266,7 @@ body,
74157
74266
  };
74158
74267
  });
74159
74268
  const dvHandles = Object.values(route.dependency_graph?.derived_variables ?? {}).flatMap((dv) => {
74160
- const handle = preloadDerivedVariable(dv, snapshot);
74269
+ const handle = preloadDerivedVariable(dv, snapshot, params);
74161
74270
  if (!handle) {
74162
74271
  return [];
74163
74272
  }
@@ -74171,7 +74280,7 @@ body,
74171
74280
  };
74172
74281
  });
74173
74282
  const pyHandles = Object.values(route.dependency_graph?.py_components ?? {}).flatMap((py) => {
74174
- const handle = preloadServerComponent(py, snapshot);
74283
+ const handle = preloadServerComponent(py, snapshot, params);
74175
74284
  if (!handle) {
74176
74285
  return [];
74177
74286
  }
@@ -74202,13 +74311,15 @@ body,
74202
74311
  (acc, h) => ({ ...acc, [h.py.uid]: h }),
74203
74312
  {}
74204
74313
  );
74314
+ const wsClient = await window.dara.ws.getValue();
74315
+ const wsChannel = await wsClient.getChannel();
74205
74316
  const response = await request(`/api/core/route/${route.id}`, {
74206
74317
  method: HTTP_METHOD.POST,
74207
74318
  body: JSON.stringify({
74208
74319
  action_payloads: actionPayloads,
74209
74320
  derived_variable_payloads: dvHandles.map((h) => h.payload),
74210
74321
  py_component_payloads: pyHandles.map((h) => h.payload),
74211
- ws_channel: await (await window.dara.ws.promise).getChannel(),
74322
+ ws_channel: wsChannel,
74212
74323
  params
74213
74324
  }),
74214
74325
  signal
@@ -74257,9 +74368,10 @@ body,
74257
74368
  }
74258
74369
  }
74259
74370
  });
74371
+ const [templateValue, onLoadActionsValue] = await Promise.all([template.getValue(), onLoadActions.getValue()]);
74260
74372
  return {
74261
- template: await template.promise,
74262
- on_load: await onLoadActions.promise,
74373
+ template: templateValue,
74374
+ on_load: onLoadActionsValue,
74263
74375
  route_definition: route,
74264
74376
  py_components: pyHandles,
74265
74377
  derived_variables: dvHandles
@@ -74269,24 +74381,36 @@ body,
74269
74381
  return preloadCache.get(createCacheKey(routeId, params));
74270
74382
  }
74271
74383
  function usePreloadRoute() {
74384
+ const currentMatches = useMatches();
74272
74385
  const { routeObjects, routeDefMap } = useRouterContext();
74273
74386
  return Recoil_index_31(
74274
- ({ snapshot }) => (url) => {
74387
+ ({ snapshot }) => async (url) => {
74275
74388
  const matches2 = matchRoutes(routeObjects, url, window.dara?.base_url);
74276
74389
  if (!matches2) {
74277
74390
  return;
74278
74391
  }
74279
- matches2.forEach((match2) => {
74280
- const routeDef = routeDefMap.get(match2.route.id);
74281
- if (!routeDef) {
74282
- return;
74283
- }
74284
- preloadCache.setIfMissing(createCacheKey(routeDef.id, match2.params), () => {
74285
- return fetchRouteData(routeDef, match2.params, snapshot);
74286
- });
74287
- });
74392
+ const release = snapshot.retain();
74393
+ try {
74394
+ await Promise.all(
74395
+ matches2.filter(
74396
+ (match2) => !currentMatches.some(
74397
+ (m) => m.id === match2.route.id && isEqual$4(m.params, match2.params)
74398
+ )
74399
+ ).map((match2) => {
74400
+ const routeDef = routeDefMap.get(match2.route.id);
74401
+ if (!routeDef) {
74402
+ return Promise.resolve();
74403
+ }
74404
+ return preloadCache.setIfMissing(createCacheKey(routeDef.id, match2.params), () => {
74405
+ return fetchRouteData(routeDef, match2.params, snapshot);
74406
+ });
74407
+ })
74408
+ );
74409
+ } finally {
74410
+ release();
74411
+ }
74288
74412
  },
74289
- [routeDefMap, routeObjects]
74413
+ [routeDefMap, routeObjects, currentMatches]
74290
74414
  );
74291
74415
  }
74292
74416
  function hasServerActions(route) {
@@ -74299,11 +74423,15 @@ body,
74299
74423
  function shouldHoldPromise(route) {
74300
74424
  return !((route.__typename === "IndexRoute" || route.__typename === "PageRoute") && hasServerActions(route));
74301
74425
  }
74302
- function createRouteLoader(route, snapshotRef) {
74426
+ function createRouteLoader(route, snapshot) {
74303
74427
  return async function loader({ request: loaderRequest, params }) {
74304
74428
  let result = getFromPreloadCache(route.id, params);
74305
74429
  if (!result) {
74306
- result = fetchRouteData(route, params, snapshotRef.current, loaderRequest.signal);
74430
+ const snapshotInstance = snapshot();
74431
+ const release = snapshotInstance.retain();
74432
+ result = fetchRouteData(route, params, snapshotInstance, loaderRequest.signal).finally(() => {
74433
+ release();
74434
+ });
74307
74435
  }
74308
74436
  if (shouldHoldPromise(route)) {
74309
74437
  result = await result;
@@ -74329,7 +74457,7 @@ body,
74329
74457
  for (const resultHandle of [...py_components, ...derived_variables]) {
74330
74458
  depsRegistry.set(resultHandle.result.depsKey, {
74331
74459
  args: resultHandle.result.relevantValues,
74332
- result: resultHandle.handle.promise
74460
+ result: resultHandle.handle
74333
74461
  });
74334
74462
  }
74335
74463
  let cancelled = false;
@@ -74384,7 +74512,7 @@ body,
74384
74512
  }
74385
74513
  return `/${cleanParent}/${cleanChild}`;
74386
74514
  }
74387
- function createRoute(route, snapshotRef, routeDefMap) {
74515
+ function createRoute(route, snapshot, routeDefMap) {
74388
74516
  routeDefMap.set(route.id, route);
74389
74517
  const sharedProps = {
74390
74518
  id: route.id,
@@ -74398,28 +74526,28 @@ body,
74398
74526
  ...sharedProps,
74399
74527
  index: true,
74400
74528
  element: /* @__PURE__ */ React__namespace.createElement(RouteContent, { route, key: route.id }),
74401
- loader: createRouteLoader(route, snapshotRef)
74529
+ loader: createRouteLoader(route, snapshot)
74402
74530
  };
74403
74531
  case "PageRoute":
74404
74532
  return {
74405
74533
  ...sharedProps,
74406
74534
  path: cleanPath(route.path),
74407
74535
  element: /* @__PURE__ */ React__namespace.createElement(RouteContent, { route, key: route.id }),
74408
- loader: createRouteLoader(route, snapshotRef),
74409
- children: route.children.map((r2) => createRoute(r2, snapshotRef, routeDefMap))
74536
+ loader: createRouteLoader(route, snapshot),
74537
+ children: route.children.map((r2) => createRoute(r2, snapshot, routeDefMap))
74410
74538
  };
74411
74539
  case "LayoutRoute":
74412
74540
  return {
74413
74541
  ...sharedProps,
74414
74542
  element: /* @__PURE__ */ React__namespace.createElement(RouteContent, { route, key: route.id }),
74415
- loader: createRouteLoader(route, snapshotRef),
74416
- children: route.children.map((r2) => createRoute(r2, snapshotRef, routeDefMap))
74543
+ loader: createRouteLoader(route, snapshot),
74544
+ children: route.children.map((r2) => createRoute(r2, snapshot, routeDefMap))
74417
74545
  };
74418
74546
  case "PrefixRoute":
74419
74547
  return {
74420
74548
  ...sharedProps,
74421
74549
  path: cleanPath(route.path),
74422
- children: route.children.map((r2) => createRoute(r2, snapshotRef, routeDefMap))
74550
+ children: route.children.map((r2) => createRoute(r2, snapshot, routeDefMap))
74423
74551
  };
74424
74552
  default:
74425
74553
  throw new Error(`Unknown route type ${JSON.stringify(route)}`);
@@ -74455,14 +74583,14 @@ body,
74455
74583
  return "/";
74456
74584
  }
74457
74585
  let verifiedToken = false;
74458
- function createRouter(config2, snapshotRef) {
74459
- let basename = "";
74586
+ function createRouter(config2, snapshot) {
74587
+ let basename = "/";
74460
74588
  if (window.dara.base_url !== "") {
74461
74589
  basename = new URL(window.dara.base_url, window.origin).pathname;
74462
74590
  }
74463
74591
  const { login, logout, ...extraRoutes } = config2.auth_components;
74464
74592
  const routeDefMap = /* @__PURE__ */ new Map();
74465
- const userRoutes = config2.router.children.map((r2) => createRoute(r2, snapshotRef, routeDefMap));
74593
+ const userRoutes = config2.router.children.map((r2) => createRoute(r2, snapshot, routeDefMap));
74466
74594
  const defaultPath = findFirstPath(config2.router.children) || "/";
74467
74595
  const router = createBrowserRouter(
74468
74596
  [
@@ -74492,7 +74620,8 @@ body,
74492
74620
  })),
74493
74621
  // root of the app
74494
74622
  {
74495
- element: /* @__PURE__ */ React__namespace.createElement(TemplateRoot, { daraData: config2 }),
74623
+ element: /* @__PURE__ */ React__namespace.createElement(AuthenticatedRoot, { daraData: config2 }),
74624
+ loader: createAuthenticatedRootLoader(config2),
74496
74625
  // token must be set to access the authenticated routes
74497
74626
  unstable_middleware: [
74498
74627
  async () => {
@@ -74530,19 +74659,20 @@ body,
74530
74659
  router,
74531
74660
  routeDefinitions: config2.router.children,
74532
74661
  routeObjects: userRoutes,
74533
- routeDefMap
74662
+ routeDefMap,
74663
+ defaultPath
74534
74664
  };
74535
74665
  }
74536
74666
  function RouterRoot({ daraData }) {
74537
- const snapshot = Recoil_index_34();
74538
- const snapshotRef = useLatestRef$3(snapshot);
74539
- const [routerData] = React$1.useState(() => createRouter(daraData, snapshotRef));
74667
+ const getSnapshot = Recoil_index_31((ctx) => () => ctx.snapshot, []);
74668
+ const [routerData] = React$1.useState(() => createRouter(daraData, getSnapshot));
74540
74669
  return /* @__PURE__ */ React.createElement(
74541
74670
  RouterContextProvider,
74542
74671
  {
74543
74672
  routeDefinitions: routerData.routeDefinitions,
74544
74673
  routeObjects: routerData.routeObjects,
74545
- routeDefMap: routerData.routeDefMap
74674
+ routeDefMap: routerData.routeDefMap,
74675
+ defaultPath: routerData.defaultPath
74546
74676
  },
74547
74677
  /* @__PURE__ */ React.createElement(RouterProvider2, { router: routerData.router })
74548
74678
  );
@@ -98476,7 +98606,7 @@ body,
98476
98606
  }
98477
98607
  exports.ActionImpl = ActionImpl;
98478
98608
  exports.AuthType = AuthType;
98479
- exports.AuthenticatedRoot = TemplateRoot;
98609
+ exports.AuthenticatedRoot = AuthenticatedRoot;
98480
98610
  exports.BasicAuthLogin = BasicAuthLogin;
98481
98611
  exports.BasicAuthLogout = BasicAuthLogout;
98482
98612
  exports.Center = Center;
@@ -98559,10 +98689,12 @@ body,
98559
98689
  exports.isCondition = isCondition;
98560
98690
  exports.isConditionTrue = isConditionTrue;
98561
98691
  exports.isDataResponse = isDataResponse;
98692
+ exports.isDeferred = isDeferred;
98562
98693
  exports.isDerivedVariable = isDerivedVariable;
98563
98694
  exports.isInvalidComponent = isInvalidComponent;
98564
98695
  exports.isJsComponent = isJsComponent;
98565
98696
  exports.isLoopVariable = isLoopVariable;
98697
+ exports.isPathParamStore = isPathParamStore;
98566
98698
  exports.isPyComponent = isPyComponent;
98567
98699
  exports.isRawString = isRawString;
98568
98700
  exports.isRegistered = isRegistered;
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dara-core
3
- Version: 1.21.3
3
+ Version: 1.21.4
4
4
  Summary: Dara Framework Core
5
5
  Home-page: https://dara.causalens.com/
6
6
  License: Apache-2.0
@@ -21,10 +21,10 @@ Requires-Dist: cachetools (>=5.0.0,<6.0.0)
21
21
  Requires-Dist: certifi (>=2024.7.4)
22
22
  Requires-Dist: click (==8.1.3)
23
23
  Requires-Dist: colorama (>=0.4.6,<0.5.0)
24
- Requires-Dist: create-dara-app (==1.21.3)
24
+ Requires-Dist: create-dara-app (==1.21.4)
25
25
  Requires-Dist: croniter (>=1.0.15,<3.0.0)
26
26
  Requires-Dist: cryptography (>=42.0.4)
27
- Requires-Dist: dara-components (==1.21.3) ; extra == "all"
27
+ Requires-Dist: dara-components (==1.21.4) ; extra == "all"
28
28
  Requires-Dist: exceptiongroup (>=1.1.3,<2.0.0)
29
29
  Requires-Dist: fastapi (>=0.115.0,<0.116.0)
30
30
  Requires-Dist: fastapi_vite_dara (==0.4.0)
@@ -55,7 +55,7 @@ Description-Content-Type: text/markdown
55
55
 
56
56
  # Dara Application Framework
57
57
 
58
- <img src="https://github.com/causalens/dara/blob/v1.21.3/img/dara_light.svg?raw=true">
58
+ <img src="https://github.com/causalens/dara/blob/v1.21.4/img/dara_light.svg?raw=true">
59
59
 
60
60
  ![Master tests](https://github.com/causalens/dara/actions/workflows/tests.yml/badge.svg?branch=master)
61
61
  [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
@@ -100,7 +100,7 @@ source .venv/bin/activate
100
100
  dara start
101
101
  ```
102
102
 
103
- ![Dara App](https://github.com/causalens/dara/blob/v1.21.3/img/components_gallery.png?raw=true)
103
+ ![Dara App](https://github.com/causalens/dara/blob/v1.21.4/img/components_gallery.png?raw=true)
104
104
 
105
105
  Note: `pip` installation uses [PEP 660](https://peps.python.org/pep-0660/) `pyproject.toml`-based editable installs which require `pip >= 21.3` and `setuptools >= 64.0.0`. You can upgrade both with:
106
106
 
@@ -117,9 +117,9 @@ Explore some of our favorite apps - a great way of getting started and getting t
117
117
 
118
118
  | Dara App | Description |
119
119
  | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
120
- | ![Large Language Model](https://github.com/causalens/dara/blob/v1.21.3/img/llm.png?raw=true) | Demonstrates how to use incorporate a LLM chat box into your decision app to understand model insights |
121
- | ![Plot Interactivity](https://github.com/causalens/dara/blob/v1.21.3/img/plot_interactivity.png?raw=true) | Demonstrates how to enable the user to interact with plots, trigger actions based on clicks, mouse movements and other interactions with `Bokeh` or `Plotly` plots |
122
- | ![Graph Editor](https://github.com/causalens/dara/blob/v1.21.3/img/graph_viewer.png?raw=true) | Demonstrates how to use the `CausalGraphViewer` component to display your graphs or networks, customising the displayed information through colors and tooltips, and updating the page based on user interaction. |
120
+ | ![Large Language Model](https://github.com/causalens/dara/blob/v1.21.4/img/llm.png?raw=true) | Demonstrates how to use incorporate a LLM chat box into your decision app to understand model insights |
121
+ | ![Plot Interactivity](https://github.com/causalens/dara/blob/v1.21.4/img/plot_interactivity.png?raw=true) | Demonstrates how to enable the user to interact with plots, trigger actions based on clicks, mouse movements and other interactions with `Bokeh` or `Plotly` plots |
122
+ | ![Graph Editor](https://github.com/causalens/dara/blob/v1.21.4/img/graph_viewer.png?raw=true) | Demonstrates how to use the `CausalGraphViewer` component to display your graphs or networks, customising the displayed information through colors and tooltips, and updating the page based on user interaction. |
123
123
 
124
124
  Check out our [App Gallery](https://dara.causalens.com/gallery) for more inspiration!
125
125
 
@@ -146,9 +146,9 @@ And the supporting UI packages and tools.
146
146
  - `ui-utils` - miscellaneous utility functions
147
147
  - `ui-widgets` - widget components
148
148
 
149
- More information on the repository structure can be found in the [CONTRIBUTING.md](https://github.com/causalens/dara/blob/v1.21.3/CONTRIBUTING.md) file.
149
+ More information on the repository structure can be found in the [CONTRIBUTING.md](https://github.com/causalens/dara/blob/v1.21.4/CONTRIBUTING.md) file.
150
150
 
151
151
  ## License
152
152
 
153
- Dara is open-source and licensed under the [Apache 2.0 License](https://github.com/causalens/dara/blob/v1.21.3/LICENSE).
153
+ Dara is open-source and licensed under the [Apache 2.0 License](https://github.com/causalens/dara/blob/v1.21.4/LICENSE).
154
154
 
@@ -93,7 +93,7 @@ dara/core/router/compat.py,sha256=WAVzDcJFJOVoIQ5inplIhXD58TWsWwTTebTCqpG4nGs,31
93
93
  dara/core/router/components.py,sha256=MDaiQ8Y0-94EH0Jm4j7p9S141k8G4osSbOKSTSu3aOM,4433
94
94
  dara/core/router/dependency_graph.py,sha256=AyjSk3DuvCgACrgpID4oSpms1X6GQJUbt-scY5X_LN4,2305
95
95
  dara/core/router/router.py,sha256=1r3rFGiftOXC6GP66hKqTdcVNDRJsZWBWvL74wNG4dA,29719
96
- dara/core/umd/dara.core.umd.cjs,sha256=ZPpEZP3w_XsC4CmeCdt1j6gTZUuKE1fcwdBiBDG2C-0,5143753
96
+ dara/core/umd/dara.core.umd.cjs,sha256=yL5RNTVCKf39V2ItxpFhMmwBZqFz4BdowFDjrKfH3NU,5148073
97
97
  dara/core/umd/style.css,sha256=yT3PKpi2sKI2-kQIF8xtVbTPQqgpK7-Ua7tfzDPuSsI,4095881
98
98
  dara/core/visual/__init__.py,sha256=QN0wbG9HPQ_vXh8BO8DnBXeYLIENVTNtRmYzZf1lx7c,577
99
99
  dara/core/visual/components/__init__.py,sha256=nmCsnMLXeZAjkhMYz-mIFodpVY-69IO1fvwwXbFlMQ4,2447
@@ -120,8 +120,8 @@ dara/core/visual/themes/__init__.py,sha256=aM4mgoIYo2neBSw5FRzswsht7PUKjLthiHLmF
120
120
  dara/core/visual/themes/dark.py,sha256=UQGDooOc8ric73eHs9E0ltYP4UCrwqQ3QxqN_fb4PwY,1942
121
121
  dara/core/visual/themes/definitions.py,sha256=5g83t24w8Ar51Cl9REBJfCU7_DtlashBQeUTKDg3D1M,2862
122
122
  dara/core/visual/themes/light.py,sha256=-Tviq8oEwGbdFULoDOqPuHO0UpAZGsBy8qFi0kAGolQ,1944
123
- dara_core-1.21.3.dist-info/LICENSE,sha256=r9u1w2RvpLMV6YjuXHIKXRBKzia3fx_roPwboGcLqCc,10944
124
- dara_core-1.21.3.dist-info/METADATA,sha256=P8O2VBTiSSG6w_PdTOdvOhnFDC7uVkcDSPx6zP7n5FA,7534
125
- dara_core-1.21.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
126
- dara_core-1.21.3.dist-info/entry_points.txt,sha256=H__D5sNIGuPIhVam0DChNL-To5k8Y7nY7TAFz9Mz6cc,139
127
- dara_core-1.21.3.dist-info/RECORD,,
123
+ dara_core-1.21.4.dist-info/LICENSE,sha256=r9u1w2RvpLMV6YjuXHIKXRBKzia3fx_roPwboGcLqCc,10944
124
+ dara_core-1.21.4.dist-info/METADATA,sha256=B3_u4qs8ZbvfSgO4LKfnS4IUTGM6hhFXEE_O7UUHryo,7534
125
+ dara_core-1.21.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
126
+ dara_core-1.21.4.dist-info/entry_points.txt,sha256=H__D5sNIGuPIhVam0DChNL-To5k8Y7nY7TAFz9Mz6cc,139
127
+ dara_core-1.21.4.dist-info/RECORD,,