@manyducks.co/dolla 0.67.0 → 0.68.0

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
@@ -466,7 +466,7 @@ function ExampleView(props, ctx) {
466
466
 
467
467
  function LayoutView() {
468
468
  return (
469
- <StoreScope store={ExampleStore}>
469
+ <StoreScope stores={[ExampleStore]}>
470
470
  <ExampleView />
471
471
  </StoreScope>
472
472
  );
@@ -512,7 +512,7 @@ The main view (defined with the app's `main` method) is the top-level view that
512
512
  // Here is a hypothetical main view with a layout and navigation:
513
513
  app.main((props, ctx) => {
514
514
  return (
515
- <div className="todo-layout">
515
+ <div class="todo-layout">
516
516
  <nav>
517
517
  <ul>
518
518
  <li>
package/lib/index.d.ts CHANGED
@@ -12,7 +12,7 @@ export type { ViewContext } from "./view.js";
12
12
  export type { StoreContext } from "./store.js";
13
13
  export type { Markup } from "./markup.js";
14
14
  export type { HTTPMiddleware } from "./stores/http.js";
15
- export type { InputType } from "./types.js";
15
+ export type { InputType, Renderable } from "./types.js";
16
16
  import type { IntrinsicElements as Elements } from "./types";
17
17
  declare global {
18
18
  namespace JSX {
package/lib/index.js CHANGED
@@ -774,7 +774,14 @@ function computed(...args) {
774
774
  const readable2 = args[0];
775
775
  const compute = args[1];
776
776
  return {
777
- get: () => compute(readable2.get()),
777
+ get: () => {
778
+ const computed2 = compute(readable2.get());
779
+ if (isReadable(computed2)) {
780
+ return computed2.get();
781
+ } else {
782
+ return computed2;
783
+ }
784
+ },
778
785
  [OBSERVE]: (callback) => {
779
786
  let lastComputedValue = UNOBSERVED;
780
787
  let lastObservedValue;
@@ -2692,7 +2699,7 @@ function LanguageStore(ctx) {
2692
2699
  if (values) {
2693
2700
  const readableValues = {};
2694
2701
  for (const [key2, value] of Object.entries(values)) {
2695
- if (typeof value?.observe === "function") {
2702
+ if (isReadable(value)) {
2696
2703
  readableValues[key2] = value;
2697
2704
  }
2698
2705
  }
@@ -4021,23 +4028,35 @@ function Fragment(_, ctx) {
4021
4028
  // src/views/store-scope.ts
4022
4029
  function StoreScope(props, ctx) {
4023
4030
  const { appContext, elementContext } = getViewSecrets(ctx);
4024
- const instance = initStore({
4025
- store: props.store,
4026
- options: props.options,
4027
- appContext,
4028
- elementContext
4029
- });
4030
- instance.setup();
4031
- elementContext.stores.set(props.store, {
4032
- store: props.store,
4033
- options: props.options,
4034
- instance
4035
- });
4031
+ const instances = [];
4032
+ for (const config of props.stores) {
4033
+ let store;
4034
+ let options;
4035
+ if (isFunction(config)) {
4036
+ store = config;
4037
+ } else {
4038
+ store = config.store;
4039
+ options = config.options;
4040
+ }
4041
+ const instance = initStore({
4042
+ store,
4043
+ options,
4044
+ appContext,
4045
+ elementContext
4046
+ });
4047
+ instance.setup();
4048
+ elementContext.stores.set(store, { store, options, instance });
4049
+ instances.push(instance);
4050
+ }
4036
4051
  ctx.beforeConnect(() => {
4037
- return instance.connect();
4052
+ for (const instance of instances) {
4053
+ instance.connect();
4054
+ }
4038
4055
  });
4039
4056
  ctx.onDisconnected(() => {
4040
- instance.disconnect();
4057
+ for (const instance of instances) {
4058
+ instance.disconnect();
4059
+ }
4041
4060
  });
4042
4061
  return ctx.outlet();
4043
4062
  }