@manyducks.co/dolla 0.67.0 → 0.68.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.
- package/README.md +2 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +45 -19
- package/lib/index.js.map +3 -3
- package/lib/state.d.ts +1 -1
- package/lib/store.d.ts +1 -1
- package/lib/views/store-scope.d.ts +5 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -466,7 +466,7 @@ function ExampleView(props, ctx) {
|
|
|
466
466
|
|
|
467
467
|
function LayoutView() {
|
|
468
468
|
return (
|
|
469
|
-
<StoreScope
|
|
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
|
|
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,12 +774,26 @@ function computed(...args) {
|
|
|
774
774
|
const readable2 = args[0];
|
|
775
775
|
const compute = args[1];
|
|
776
776
|
return {
|
|
777
|
-
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;
|
|
781
788
|
return readable2[OBSERVE]((currentValue) => {
|
|
782
789
|
const computedValue = compute(currentValue, lastObservedValue);
|
|
790
|
+
if (isReadable(computedValue)) {
|
|
791
|
+
lastComputedValue = computedValue;
|
|
792
|
+
return computedValue[OBSERVE]((current, previous) => {
|
|
793
|
+
callback(current, previous);
|
|
794
|
+
lastObservedValue = current;
|
|
795
|
+
});
|
|
796
|
+
}
|
|
783
797
|
if (!deepEqual(computedValue, lastComputedValue)) {
|
|
784
798
|
const previousValue = lastComputedValue === UNOBSERVED ? void 0 : lastComputedValue;
|
|
785
799
|
callback(computedValue, previousValue);
|
|
@@ -2565,7 +2579,7 @@ async function makeRequest(config) {
|
|
|
2565
2579
|
let response;
|
|
2566
2580
|
const handler = async () => {
|
|
2567
2581
|
const query2 = request.query.toString();
|
|
2568
|
-
const fullURL =
|
|
2582
|
+
const fullURL = query2.length > 0 ? request.uri + "?" + query2 : request.uri;
|
|
2569
2583
|
let reqBody;
|
|
2570
2584
|
if (!request.headers.has("content-type") && isObject(request.body)) {
|
|
2571
2585
|
request.headers.set("content-type", "application/json");
|
|
@@ -2692,7 +2706,7 @@ function LanguageStore(ctx) {
|
|
|
2692
2706
|
if (values) {
|
|
2693
2707
|
const readableValues = {};
|
|
2694
2708
|
for (const [key2, value] of Object.entries(values)) {
|
|
2695
|
-
if (
|
|
2709
|
+
if (isReadable(value)) {
|
|
2696
2710
|
readableValues[key2] = value;
|
|
2697
2711
|
}
|
|
2698
2712
|
}
|
|
@@ -3357,7 +3371,7 @@ function RouterStore(ctx) {
|
|
|
3357
3371
|
const $$path = writable("");
|
|
3358
3372
|
const $$params = writable({});
|
|
3359
3373
|
const $$query = writable({});
|
|
3360
|
-
let isRouteChange =
|
|
3374
|
+
let isRouteChange = true;
|
|
3361
3375
|
ctx.observe($$query, (current) => {
|
|
3362
3376
|
if (isRouteChange) {
|
|
3363
3377
|
isRouteChange = false;
|
|
@@ -3389,7 +3403,7 @@ function RouterStore(ctx) {
|
|
|
3389
3403
|
if (location.search !== lastQuery) {
|
|
3390
3404
|
lastQuery = location.search;
|
|
3391
3405
|
isRouteChange = true;
|
|
3392
|
-
$$query.set(parseQueryParams(location.search));
|
|
3406
|
+
$$query.set(parseQueryParams(location.search.startsWith("?") ? location.search.slice(1) : location.search));
|
|
3393
3407
|
}
|
|
3394
3408
|
const matched = matchRoutes(ctx.options.routes, location.pathname);
|
|
3395
3409
|
if (!matched) {
|
|
@@ -4021,23 +4035,35 @@ function Fragment(_, ctx) {
|
|
|
4021
4035
|
// src/views/store-scope.ts
|
|
4022
4036
|
function StoreScope(props, ctx) {
|
|
4023
4037
|
const { appContext, elementContext } = getViewSecrets(ctx);
|
|
4024
|
-
const
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
instance
|
|
4035
|
-
|
|
4038
|
+
const instances = [];
|
|
4039
|
+
for (const config of props.stores) {
|
|
4040
|
+
let store;
|
|
4041
|
+
let options;
|
|
4042
|
+
if (isFunction(config)) {
|
|
4043
|
+
store = config;
|
|
4044
|
+
} else {
|
|
4045
|
+
store = config.store;
|
|
4046
|
+
options = config.options;
|
|
4047
|
+
}
|
|
4048
|
+
const instance = initStore({
|
|
4049
|
+
store,
|
|
4050
|
+
options,
|
|
4051
|
+
appContext,
|
|
4052
|
+
elementContext
|
|
4053
|
+
});
|
|
4054
|
+
instance.setup();
|
|
4055
|
+
elementContext.stores.set(store, { store, options, instance });
|
|
4056
|
+
instances.push(instance);
|
|
4057
|
+
}
|
|
4036
4058
|
ctx.beforeConnect(() => {
|
|
4037
|
-
|
|
4059
|
+
for (const instance of instances) {
|
|
4060
|
+
instance.connect();
|
|
4061
|
+
}
|
|
4038
4062
|
});
|
|
4039
4063
|
ctx.onDisconnected(() => {
|
|
4040
|
-
instance
|
|
4064
|
+
for (const instance of instances) {
|
|
4065
|
+
instance.disconnect();
|
|
4066
|
+
}
|
|
4041
4067
|
});
|
|
4042
4068
|
return ctx.outlet();
|
|
4043
4069
|
}
|