@manyducks.co/dolla 0.71.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 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") {