@manyducks.co/dolla 0.70.0 → 0.72.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/lib/index.d.ts +1 -1
- package/lib/index.js +52 -3
- package/lib/index.js.map +2 -2
- package/lib/stores/http.d.ts +2 -2
- package/lib/stores/router.d.ts +33 -2
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { $, $$, observe, unwrap, isReadable, isWritable, type Readable, type Wri
|
|
|
3
3
|
export { m, cond, repeat, portal } from "./markup.js";
|
|
4
4
|
export { Fragment } from "./views/fragment.js";
|
|
5
5
|
export { StoreScope, type StoreScopeProps } from "./views/store-scope.js";
|
|
6
|
-
export { RouterStore } from "./stores/router.js";
|
|
6
|
+
export { RouterStore, type RouteMatchContext } from "./stores/router.js";
|
|
7
7
|
export { LanguageStore } from "./stores/language.js";
|
|
8
8
|
export { HTTPStore, type HTTPMiddleware } from "./stores/http.js";
|
|
9
9
|
export { DialogStore, type DialogProps } from "./stores/dialog.js";
|
package/lib/index.js
CHANGED
|
@@ -3193,7 +3193,8 @@ function RouterStore(ctx) {
|
|
|
3193
3193
|
pattern: route.path,
|
|
3194
3194
|
meta: {
|
|
3195
3195
|
pattern: route.path,
|
|
3196
|
-
layers: [...layers, layer]
|
|
3196
|
+
layers: [...layers, layer],
|
|
3197
|
+
beforeMatch: route.beforeMatch
|
|
3197
3198
|
}
|
|
3198
3199
|
});
|
|
3199
3200
|
}
|
|
@@ -3276,6 +3277,44 @@ function RouterStore(ctx) {
|
|
|
3276
3277
|
});
|
|
3277
3278
|
return;
|
|
3278
3279
|
}
|
|
3280
|
+
if (matched.meta.beforeMatch) {
|
|
3281
|
+
await matched.meta.beforeMatch({
|
|
3282
|
+
getStore(store) {
|
|
3283
|
+
let name;
|
|
3284
|
+
if (typeof store === "string") {
|
|
3285
|
+
name = store;
|
|
3286
|
+
} else {
|
|
3287
|
+
name = store.name;
|
|
3288
|
+
}
|
|
3289
|
+
if (typeof store !== "string") {
|
|
3290
|
+
let ec = elementContext;
|
|
3291
|
+
while (ec) {
|
|
3292
|
+
if (ec.stores.has(store)) {
|
|
3293
|
+
return ec.stores.get(store)?.instance.exports;
|
|
3294
|
+
}
|
|
3295
|
+
ec = ec.parent;
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
if (appContext.stores.has(store)) {
|
|
3299
|
+
const _store = appContext.stores.get(store);
|
|
3300
|
+
if (!_store.instance) {
|
|
3301
|
+
appContext.crashCollector.crash({
|
|
3302
|
+
componentName: ctx.name,
|
|
3303
|
+
error: new Error(`Store '${name}' is not registered on this app.`)
|
|
3304
|
+
});
|
|
3305
|
+
}
|
|
3306
|
+
return _store.instance.exports;
|
|
3307
|
+
}
|
|
3308
|
+
appContext.crashCollector.crash({
|
|
3309
|
+
componentName: ctx.name,
|
|
3310
|
+
error: new Error(`Store '${name}' is not registered on this app.`)
|
|
3311
|
+
});
|
|
3312
|
+
},
|
|
3313
|
+
redirect: (path) => {
|
|
3314
|
+
throw new Error(`Redirect not yet implemented.`);
|
|
3315
|
+
}
|
|
3316
|
+
});
|
|
3317
|
+
}
|
|
3279
3318
|
ctx.info(`Matched route: '${matched.pattern}'`);
|
|
3280
3319
|
if (matched.meta.redirect != null) {
|
|
3281
3320
|
if (typeof matched.meta.redirect === "string") {
|
|
@@ -3684,7 +3723,12 @@ async function makeRequest(config) {
|
|
|
3684
3723
|
});
|
|
3685
3724
|
} else if (headers != null && typeof headers === "object" && !Array.isArray(headers)) {
|
|
3686
3725
|
for (const name in headers) {
|
|
3687
|
-
|
|
3726
|
+
const value = headers[name];
|
|
3727
|
+
if (value instanceof Date) {
|
|
3728
|
+
request.headers.set(name, value.toISOString());
|
|
3729
|
+
} else if (value != null) {
|
|
3730
|
+
request.headers.set(name, String(value));
|
|
3731
|
+
}
|
|
3688
3732
|
}
|
|
3689
3733
|
} else {
|
|
3690
3734
|
throw new TypeError(`Unknown headers type. Got: ${headers}`);
|
|
@@ -3697,7 +3741,12 @@ async function makeRequest(config) {
|
|
|
3697
3741
|
});
|
|
3698
3742
|
} else if (query != null && typeof query === "object" && !Array.isArray(query)) {
|
|
3699
3743
|
for (const name in query) {
|
|
3700
|
-
|
|
3744
|
+
const value = query[name];
|
|
3745
|
+
if (value instanceof Date) {
|
|
3746
|
+
request.query.set(name, value.toISOString());
|
|
3747
|
+
} else if (value != null) {
|
|
3748
|
+
request.query.set(name, String(value));
|
|
3749
|
+
}
|
|
3701
3750
|
}
|
|
3702
3751
|
} else {
|
|
3703
3752
|
throw new TypeError(`Unknown query params type. Got: ${query}`);
|