@owlmeans/web-client 0.1.0 → 0.1.2
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/LICENSE +1 -1
- package/build/components/dispatcher/component.js +1 -1
- package/build/components/dispatcher/component.js.map +1 -1
- package/build/components/dispatcher/index.d.ts +2 -0
- package/build/components/dispatcher/index.d.ts.map +1 -1
- package/build/components/dispatcher/index.js +1 -0
- package/build/components/dispatcher/index.js.map +1 -1
- package/build/components/dispatcher/parametrise.d.ts +5 -0
- package/build/components/dispatcher/parametrise.d.ts.map +1 -0
- package/build/components/dispatcher/parametrise.js +24 -0
- package/build/components/dispatcher/parametrise.js.map +1 -0
- package/build/components/dispatcher/simplified.d.ts +1 -0
- package/build/components/dispatcher/simplified.d.ts.map +1 -0
- package/build/components/dispatcher/simplified.js +2 -0
- package/build/components/dispatcher/simplified.js.map +1 -0
- package/build/components/dispatcher/types.d.ts +6 -0
- package/build/components/dispatcher/types.d.ts.map +1 -0
- package/build/components/dispatcher/types.js +2 -0
- package/build/components/dispatcher/types.js.map +1 -0
- package/build/components/index.d.ts +1 -0
- package/build/components/index.d.ts.map +1 -1
- package/build/components/index.js +1 -0
- package/build/components/index.js.map +1 -1
- package/build/components/web-app/component.d.ts +4 -0
- package/build/components/web-app/component.d.ts.map +1 -0
- package/build/components/web-app/component.js +7 -0
- package/build/components/web-app/component.js.map +1 -0
- package/build/components/web-app/index.d.ts +2 -0
- package/build/components/web-app/index.d.ts.map +1 -0
- package/build/components/web-app/index.js +2 -0
- package/build/components/web-app/index.js.map +1 -0
- package/build/context.d.ts.map +1 -1
- package/build/context.js +2 -0
- package/build/context.js.map +1 -1
- package/build/helper.d.ts.map +1 -1
- package/build/main.d.ts +2 -1
- package/build/main.d.ts.map +1 -1
- package/build/main.js +4 -0
- package/build/main.js.map +1 -1
- package/build/middleware.d.ts +3 -0
- package/build/middleware.d.ts.map +1 -0
- package/build/middleware.js +44 -0
- package/build/middleware.js.map +1 -0
- package/build/router.d.ts.map +1 -1
- package/build/router.js +1 -1
- package/build/router.js.map +1 -1
- package/build/service.d.ts +1 -1
- package/build/service.d.ts.map +1 -1
- package/build/service.js +3 -2
- package/build/service.js.map +1 -1
- package/package.json +24 -24
- package/src/components/dispatcher/component.tsx +1 -1
- package/src/components/dispatcher/index.ts +2 -0
- package/src/components/dispatcher/parametrise.tsx +28 -0
- package/src/components/dispatcher/types.ts +6 -0
- package/src/components/index.ts +1 -0
- package/src/components/web-app/component.tsx +12 -0
- package/src/components/web-app/index.ts +2 -0
- package/src/context.ts +2 -0
- package/src/main.tsx +6 -1
- package/src/middleware.ts +51 -0
- package/src/router.ts +3 -2
- package/src/service.ts +7 -6
- package/tsconfig.tsbuildinfo +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 OwlMeans Common — Fullstack typescript framework
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { DispatcherHOC } from '@owlmeans/client-auth';
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
|
-
import { useSearchParams } from 'react-router
|
|
4
|
+
import { useSearchParams } from 'react-router';
|
|
5
5
|
import { useI18nLib } from '@owlmeans/client-i18n';
|
|
6
6
|
import { AUTH_QUERY } from '@owlmeans/auth';
|
|
7
7
|
import { useContext } from '../../context.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/components/dispatcher/component.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAA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EAAE,CAAC;oBACvB,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;gBACxC,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,cAAK,KAAK,EAAE;YACzC,KAAK,EAAE,MAAM,EAAE,sCAAsC;YACrD,OAAO,EAAE,MAAM,EAAE,yBAAyB;YAC1C,cAAc,EAAE,QAAQ,EAAE,+BAA+B;YACzD,UAAU,EAAE,QAAQ,EAAE,yCAAyC;YAC/D,SAAS,EAAE,QAAQ,EAAE,8BAA8B;YACnD,UAAU,EAAE,MAAM,EAAE,6BAA6B;YACjD,aAAa,EAAE,MAAM,EAAE,6BAA6B;SACrD,YAAG,CAAC,CAAC,SAAS,CAAC,GAAO,CAAC,CAAC,CAAC,SAAS,CAAA;AACrC,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dispatcher/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dispatcher/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/dispatcher/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/dispatcher/index.ts"],"names":[],"mappings":"AAEA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RoutedComponent } from "@owlmeans/client";
|
|
2
|
+
import type { DispatcherProps } from "@owlmeans/client-auth";
|
|
3
|
+
import { ParametrisedProps } from "./types.js";
|
|
4
|
+
export declare const parametriseDispatcher: (def: Partial<ParametrisedProps>, Com?: RoutedComponent<DispatcherProps>) => (props: ParametrisedProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
//# sourceMappingURL=parametrise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parametrise.d.ts","sourceRoot":"","sources":["../../../src/components/dispatcher/parametrise.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAI5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9C,eAAO,MAAM,qBAAqB,GAAI,KAAK,OAAO,CAAC,iBAAiB,CAAC,EAAE,MAAM,eAAe,CAAC,eAAe,CAAC,MAEnG,OAAO,iBAAiB,4CAiBjC,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { Dispatcher } from "./component.js";
|
|
4
|
+
export const parametriseDispatcher = (def, Com) => {
|
|
5
|
+
console.log('Parametrising dispatcher with', def);
|
|
6
|
+
return (props) => {
|
|
7
|
+
console.log('Rendering parametrised dispatcher with', props);
|
|
8
|
+
const _props = useMemo(() => {
|
|
9
|
+
let payload = undefined;
|
|
10
|
+
if (def.payload != null) {
|
|
11
|
+
payload = def.payload;
|
|
12
|
+
}
|
|
13
|
+
if (props.payload != null) {
|
|
14
|
+
payload ??= {};
|
|
15
|
+
Object.assign(payload, props.payload);
|
|
16
|
+
}
|
|
17
|
+
return { ...def, ...props, payload };
|
|
18
|
+
}, [props]);
|
|
19
|
+
console.log('Computed dispatcher props', _props);
|
|
20
|
+
Com ??= Dispatcher;
|
|
21
|
+
return _jsx(Com, { ..._props });
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=parametrise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parametrise.js","sourceRoot":"","sources":["../../../src/components/dispatcher/parametrise.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAG3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAA+B,EAAE,GAAsC,EAAG,EAAE;IAChH,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAA;IACjD,OAAO,CAAC,KAAwB,EAAE,EAAE;QAClC,OAAO,CAAC,GAAG,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAA;QAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE;YAC1B,IAAI,OAAO,GAA4B,SAAS,CAAA;YAChD,IAAI,GAAG,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;gBACxB,OAAO,GAAG,GAAG,CAAC,OAAO,CAAA;YACvB,CAAC;YACD,IAAI,KAAK,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;gBAC1B,OAAO,KAAK,EAAE,CAAA;gBACd,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;YACvC,CAAC;YACD,OAAO,EAAE,GAAG,GAAG,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,CAAA;QACtC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;QACX,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAA;QAChD,GAAG,KAAK,UAAU,CAAA;QAClB,OAAO,KAAC,GAAG,OAAK,MAAM,GAAI,CAAA;IAC5B,CAAC,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=simplified.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simplified.d.ts","sourceRoot":"","sources":["../../../src/components/dispatcher/simplified.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simplified.js","sourceRoot":"","sources":["../../../src/components/dispatcher/simplified.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ModuleContextParams } from "@owlmeans/client";
|
|
2
|
+
import type { DispatcherProps } from "@owlmeans/client-auth";
|
|
3
|
+
import type { PropsWithChildren } from "react";
|
|
4
|
+
export interface ParametrisedProps extends PropsWithChildren<ModuleContextParams & DispatcherProps> {
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/dispatcher/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAE9C,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB,CAAC,mBAAmB,GAAG,eAAe,CAAC;CAClG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/dispatcher/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/components/web-app/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAGhD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAE/B,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,QAAQ,CAM/B,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { I18nContext } from "@owlmeans/client-i18n";
|
|
3
|
+
import { App } from '@owlmeans/client';
|
|
4
|
+
export const WebApp = ({ context, provide, children }) => {
|
|
5
|
+
return _jsx(I18nContext, { config: context.cfg, children: _jsx(App, { context: context, provide: provide, children: children }) });
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/components/web-app/component.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC,MAAM,CAAC,MAAM,MAAM,GAAiB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IACrE,OAAO,KAAC,WAAW,IAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YACrC,KAAC,GAAG,IAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,YACpC,QAAQ,GACL,GACM,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/web-app/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/web-app/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAA"}
|
package/build/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AASlD,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAClG,KAAK,CAAC,KACL,CAYF,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EAAC,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,QACnF,CAAA"}
|
package/build/context.js
CHANGED
|
@@ -5,12 +5,14 @@ import { appendClientResource } from '@owlmeans/client-resource';
|
|
|
5
5
|
import { useContext as useCtx } from '@owlmeans/client';
|
|
6
6
|
import { extractPrimaryHost } from './helper.js';
|
|
7
7
|
import { appendWebAuthService } from './service.js';
|
|
8
|
+
import { appendWebRouter } from '@owlmeans/web-router';
|
|
8
9
|
export const makeContext = (cfg) => {
|
|
9
10
|
const context = makeClientContext(cfg);
|
|
10
11
|
extractPrimaryHost(context);
|
|
11
12
|
appendWebAuthService(context);
|
|
12
13
|
appendWebDbService(context);
|
|
13
14
|
appendClientResource(context, AUTH_RESOURCE);
|
|
15
|
+
appendWebRouter(context);
|
|
14
16
|
context.makeContext = makeContext;
|
|
15
17
|
return context;
|
|
16
18
|
};
|
package/build/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAEtD,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,GAAM,EACH,EAAE;IACL,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAM,CAAA;IAC3C,kBAAkB,CAAO,OAAO,CAAC,CAAA;IAEjC,oBAAoB,CAAO,OAAO,CAAC,CAAA;IACnC,kBAAkB,CAAO,OAAO,CAAC,CAAA;IACjC,oBAAoB,CAAO,OAAO,EAAE,aAAa,CAAC,CAAA;IAClD,eAAe,CAAO,OAAO,CAAC,CAAA;IAE9B,OAAO,CAAC,WAAW,GAAG,WAAyC,CAAA;IAE/D,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,GAA4E,EAAE,CACtG,MAAM,EAAO,CAAA"}
|
package/build/helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,SAAS,
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvD,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,SAAS,GAAG,SAAS,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,SAKtH,CAAA"}
|
package/build/main.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import type { RenderOptions } from './types.js';
|
|
2
|
+
import type { AppConfig, AppContext, RenderOptions } from './types.js';
|
|
3
3
|
export declare const render: (node: ReactNode, opts?: RenderOptions) => void;
|
|
4
|
+
export declare const renderApp: <C extends AppConfig, T extends AppContext<C>>(context: T, opts?: RenderOptions) => void;
|
|
4
5
|
//# sourceMappingURL=main.d.ts.map
|
package/build/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAItE,eAAO,MAAM,MAAM,GAAI,MAAM,SAAS,EAAE,OAAO,aAAa,SAkB3D,CAAA;AAED,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,SAAS,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,OAAO,aAAa,SAC1C,CAAA"}
|
package/build/main.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
2
3
|
import { DEFAULT_ROOT } from './consts.js';
|
|
4
|
+
import { WebApp } from './components/index.js';
|
|
5
|
+
import { provide } from './router.js';
|
|
3
6
|
export const render = (node, opts) => {
|
|
4
7
|
const _callback = () => {
|
|
5
8
|
const key = opts?.domId ?? DEFAULT_ROOT;
|
|
@@ -19,4 +22,5 @@ export const render = (node, opts) => {
|
|
|
19
22
|
};
|
|
20
23
|
opts?.onReady ?? true ? window.addEventListener('DOMContentLoaded', _callback) : _callback();
|
|
21
24
|
};
|
|
25
|
+
export const renderApp = (context, opts) => render(_jsx(WebApp, { context: context, provide: provide }), opts);
|
|
22
26
|
//# sourceMappingURL=main.js.map
|
package/build/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAe,EAAE,IAAoB,EAAE,EAAE;IAC9D,MAAM,SAAS,GAAG,GAAG,EAAE;QACrB,MAAM,GAAG,GAAG,IAAI,EAAE,KAAK,IAAI,YAAY,CAAA;QACvC,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;QACzC,IAAI,IAAI,EAAE,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,uBAAuB,GAAG,EAAE,CAAC,CAAA;QAC7C,CAAC;QACD,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,EAAE,CAAC,CAAA;QAC3D,CAAC;QACD,IAAI,IAAI,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;YAC3B,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAC/B,CAAC;IACH,CAAC,CAAA;IAED,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAA;AAC9F,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CAA+C,OAAU,EAAE,IAAoB,EAAE,EAAE,CAC1G,MAAM,CAAC,KAAC,MAAM,IAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAI,EAAE,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAQnD,eAAO,MAAM,gBAAgB,EAAE,UAsC9B,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { MiddlewareType, MiddlewareStage, AppType } from '@owlmeans/context';
|
|
2
|
+
import { AuthUnknown } from '@owlmeans/auth';
|
|
3
|
+
import { ResilientError } from '@owlmeans/error';
|
|
4
|
+
import { DEFAULT_ALIAS } from '@owlmeans/client-auth';
|
|
5
|
+
export const logoutMiddleware = {
|
|
6
|
+
type: MiddlewareType.Context,
|
|
7
|
+
stage: MiddlewareStage.Loading,
|
|
8
|
+
apply: async (context) => {
|
|
9
|
+
context.modules().forEach(module => {
|
|
10
|
+
if (module.route.route.type === AppType.Backend && module.call != null) {
|
|
11
|
+
const guards = module.getGuards();
|
|
12
|
+
if (guards.length > 0) {
|
|
13
|
+
if (module._auth_web_middleware_applied === true) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
module._auth_web_middleware_applied = true;
|
|
17
|
+
// const auth = context.service<GuardService>(service)
|
|
18
|
+
const call = module.call;
|
|
19
|
+
module.call = async (req, res) => {
|
|
20
|
+
try {
|
|
21
|
+
return await call(req, res);
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
if (e instanceof Error) {
|
|
25
|
+
const err = ResilientError.ensure(e);
|
|
26
|
+
if (err instanceof AuthUnknown) {
|
|
27
|
+
if (err.message.endsWith(':invalid')) {
|
|
28
|
+
if (typeof window !== 'undefined') {
|
|
29
|
+
const auth = context.service(DEFAULT_ALIAS);
|
|
30
|
+
await auth.update(undefined);
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAGrD,MAAM,CAAC,MAAM,gBAAgB,GAAe;IAC1C,IAAI,EAAE,cAAc,CAAC,OAAO;IAC5B,KAAK,EAAE,eAAe,CAAC,OAAO;IAC9B,KAAK,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;QACrB,OAAO,CAAC,OAAO,EAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACzC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,OAAO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sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAItD,eAAO,MAAM,OAAO,EAAE,cAErB,CAAA"}
|
package/build/router.js
CHANGED
package/build/router.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.js","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAElD,MAAM,CAAC,MAAM,OAAO,GAAmB,CAAC,MAAM,EAAE,EAAE;IAChD,OAAO,mBAAmB,CAAC,MAAuB,CAAQ,CAAA;AAC5D,CAAC,CAAA"}
|
package/build/service.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AuthServiceAppend } from '@owlmeans/client-auth';
|
|
2
1
|
import type { AuthService } from '@owlmeans/auth-common';
|
|
2
|
+
import type { AuthServiceAppend } from '@owlmeans/client-auth';
|
|
3
3
|
import type { ClientConfig, ClientContext } from '@owlmeans/client-context';
|
|
4
4
|
export declare const makeAuthWebService: (alias?: string) => AuthService;
|
|
5
5
|
export declare const appendWebAuthService: <C extends ClientConfig, T extends ClientContext<C>>(ctx: T, alias?: string) => T & AuthServiceAppend;
|
package/build/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAI3E,eAAO,MAAM,kBAAkB,GAAI,QAAO,MAAsB,KAAG,WAclE,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,YAAY,EAAE,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,EACrF,KAAK,CAAC,EAAE,QAAO,MAAsB,KACpC,CAAC,GAAG,iBAaN,CAAA"}
|
package/build/service.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DEFAULT_ALIAS } from '@owlmeans/client-auth';
|
|
2
|
-
import { makeAuthService } from '@owlmeans/client-auth';
|
|
3
1
|
import { DISPATCHER } from '@owlmeans/auth';
|
|
4
2
|
import { authMiddleware } from '@owlmeans/auth-common';
|
|
3
|
+
import { DEFAULT_ALIAS, makeAuthService } from '@owlmeans/client-auth';
|
|
4
|
+
import { logoutMiddleware } from './middleware.js';
|
|
5
5
|
export const makeAuthWebService = (alias = DEFAULT_ALIAS) => {
|
|
6
6
|
const service = makeAuthService(alias);
|
|
7
7
|
const update = service.update;
|
|
@@ -20,6 +20,7 @@ export const appendWebAuthService = (ctx, alias = DEFAULT_ALIAS) => {
|
|
|
20
20
|
const context = ctx;
|
|
21
21
|
context.registerService(service);
|
|
22
22
|
context.registerMiddleware(authMiddleware);
|
|
23
|
+
context.registerMiddleware(logoutMiddleware);
|
|
23
24
|
context.auth = () => ctx.service(service.alias);
|
|
24
25
|
return context;
|
|
25
26
|
};
|
package/build/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.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C,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAE/C,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/web-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"build": "tsc -b",
|
|
@@ -20,38 +21,37 @@
|
|
|
20
21
|
}
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@owlmeans/auth": "^0.1.
|
|
24
|
-
"@owlmeans/auth-common": "^0.1.
|
|
25
|
-
"@owlmeans/client": "^0.1.
|
|
26
|
-
"@owlmeans/client-auth": "^0.1.
|
|
27
|
-
"@owlmeans/client-context": "^0.1.
|
|
28
|
-
"@owlmeans/client-i18n": "^0.1.
|
|
29
|
-
"@owlmeans/client-module": "^0.1.
|
|
30
|
-
"@owlmeans/client-resource": "^0.1.
|
|
31
|
-
"@owlmeans/client-route": "^0.1.
|
|
32
|
-
"@owlmeans/config": "^0.1.
|
|
33
|
-
"@owlmeans/context": "^0.1.
|
|
34
|
-
"@owlmeans/error": "^0.1.
|
|
35
|
-
"@owlmeans/i18n": "^0.1.
|
|
36
|
-
"@owlmeans/route": "^0.1.
|
|
37
|
-
"@owlmeans/web-db": "^0.1.
|
|
24
|
+
"@owlmeans/auth": "^0.1.2",
|
|
25
|
+
"@owlmeans/auth-common": "^0.1.2",
|
|
26
|
+
"@owlmeans/client": "^0.1.2",
|
|
27
|
+
"@owlmeans/client-auth": "^0.1.2",
|
|
28
|
+
"@owlmeans/client-context": "^0.1.2",
|
|
29
|
+
"@owlmeans/client-i18n": "^0.1.2",
|
|
30
|
+
"@owlmeans/client-module": "^0.1.2",
|
|
31
|
+
"@owlmeans/client-resource": "^0.1.2",
|
|
32
|
+
"@owlmeans/client-route": "^0.1.2",
|
|
33
|
+
"@owlmeans/config": "^0.1.2",
|
|
34
|
+
"@owlmeans/context": "^0.1.2",
|
|
35
|
+
"@owlmeans/error": "^0.1.2",
|
|
36
|
+
"@owlmeans/i18n": "^0.1.2",
|
|
37
|
+
"@owlmeans/route": "^0.1.2",
|
|
38
|
+
"@owlmeans/web-db": "^0.1.2",
|
|
39
|
+
"@owlmeans/web-router": "^0.1.2",
|
|
38
40
|
"react-dropzone": "^14.3.5"
|
|
39
41
|
},
|
|
40
42
|
"peerDependencies": {
|
|
41
43
|
"react": "*",
|
|
42
44
|
"react-dom": "*",
|
|
43
|
-
"react-router
|
|
45
|
+
"react-router": "^7.*"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
|
-
"@types/react": "^
|
|
47
|
-
"@types/react-dom": "^
|
|
48
|
-
"nodemon": "^3.1.
|
|
48
|
+
"@types/react": "^19.2.7",
|
|
49
|
+
"@types/react-dom": "^19.2.3",
|
|
50
|
+
"nodemon": "^3.1.11",
|
|
49
51
|
"npm-check": "^6.0.1",
|
|
50
|
-
"
|
|
51
|
-
"typescript": "^5.6.3"
|
|
52
|
+
"typescript": "^5.8.3"
|
|
52
53
|
},
|
|
53
|
-
"private": false,
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
}
|
|
57
|
-
}
|
|
57
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DispatcherHOC } from '@owlmeans/client-auth'
|
|
2
2
|
import { useEffect } from 'react'
|
|
3
|
-
import { useSearchParams } from 'react-router
|
|
3
|
+
import { useSearchParams } from 'react-router'
|
|
4
4
|
import { useI18nLib } from '@owlmeans/client-i18n'
|
|
5
5
|
import { AUTH_QUERY } from '@owlmeans/auth'
|
|
6
6
|
import { useContext } from '../../context.js'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { RoutedComponent } from "@owlmeans/client"
|
|
2
|
+
import type { DispatcherProps } from "@owlmeans/client-auth"
|
|
3
|
+
import type { FlowPayload } from "@owlmeans/flow"
|
|
4
|
+
import { useMemo } from "react"
|
|
5
|
+
import { Dispatcher } from "./component.js"
|
|
6
|
+
import { ParametrisedProps } from "./types.js"
|
|
7
|
+
|
|
8
|
+
export const parametriseDispatcher = (def: Partial<ParametrisedProps>, Com?: RoutedComponent<DispatcherProps> ) => {
|
|
9
|
+
console.log('Parametrising dispatcher with', def)
|
|
10
|
+
return (props: ParametrisedProps) => {
|
|
11
|
+
console.log('Rendering parametrised dispatcher with', props)
|
|
12
|
+
const _props = useMemo(() => {
|
|
13
|
+
let payload: FlowPayload | undefined = undefined
|
|
14
|
+
if (def.payload != null) {
|
|
15
|
+
payload = def.payload
|
|
16
|
+
}
|
|
17
|
+
if (props.payload != null) {
|
|
18
|
+
payload ??= {}
|
|
19
|
+
Object.assign(payload, props.payload)
|
|
20
|
+
}
|
|
21
|
+
return { ...def, ...props, payload }
|
|
22
|
+
}, [props])
|
|
23
|
+
console.log('Computed dispatcher props', _props)
|
|
24
|
+
Com ??= Dispatcher
|
|
25
|
+
return <Com {..._props} />
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ModuleContextParams } from "@owlmeans/client"
|
|
2
|
+
import type { DispatcherProps } from "@owlmeans/client-auth"
|
|
3
|
+
import type { PropsWithChildren } from "react"
|
|
4
|
+
|
|
5
|
+
export interface ParametrisedProps extends PropsWithChildren<ModuleContextParams & DispatcherProps> {
|
|
6
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AppProps } from "@owlmeans/client"
|
|
2
|
+
import { I18nContext } from "@owlmeans/client-i18n"
|
|
3
|
+
import { App } from '@owlmeans/client'
|
|
4
|
+
import type { FC } from "react"
|
|
5
|
+
|
|
6
|
+
export const WebApp: FC<AppProps> = ({ context, provide, children }) => {
|
|
7
|
+
return <I18nContext config={context.cfg}>
|
|
8
|
+
<App context={context} provide={provide}>
|
|
9
|
+
{children}
|
|
10
|
+
</App>
|
|
11
|
+
</I18nContext>
|
|
12
|
+
}
|
package/src/context.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { appendClientResource } from '@owlmeans/client-resource'
|
|
|
7
7
|
import { useContext as useCtx } from '@owlmeans/client'
|
|
8
8
|
import { extractPrimaryHost } from './helper.js'
|
|
9
9
|
import { appendWebAuthService } from './service.js'
|
|
10
|
+
import { appendWebRouter } from '@owlmeans/web-router'
|
|
10
11
|
|
|
11
12
|
export const makeContext = <C extends AppConfig = AppConfig, T extends AppContext<C> = AppContext<C>>(
|
|
12
13
|
cfg: C
|
|
@@ -17,6 +18,7 @@ export const makeContext = <C extends AppConfig = AppConfig, T extends AppContex
|
|
|
17
18
|
appendWebAuthService<C, T>(context)
|
|
18
19
|
appendWebDbService<C, T>(context)
|
|
19
20
|
appendClientResource<C, T>(context, AUTH_RESOURCE)
|
|
21
|
+
appendWebRouter<C, T>(context)
|
|
20
22
|
|
|
21
23
|
context.makeContext = makeContext as typeof context.makeContext
|
|
22
24
|
|
package/src/main.tsx
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import type { ReactNode } from 'react'
|
|
3
3
|
import { createRoot, hydrateRoot } from 'react-dom/client'
|
|
4
4
|
import { DEFAULT_ROOT } from './consts.js'
|
|
5
|
-
import type { RenderOptions } from './types.js'
|
|
5
|
+
import type { AppConfig, AppContext, RenderOptions } from './types.js'
|
|
6
|
+
import { WebApp } from './components/index.js'
|
|
7
|
+
import { provide } from './router.js'
|
|
6
8
|
|
|
7
9
|
export const render = (node: ReactNode, opts?: RenderOptions) => {
|
|
8
10
|
const _callback = () => {
|
|
@@ -23,3 +25,6 @@ export const render = (node: ReactNode, opts?: RenderOptions) => {
|
|
|
23
25
|
|
|
24
26
|
opts?.onReady ?? true ? window.addEventListener('DOMContentLoaded', _callback) : _callback()
|
|
25
27
|
}
|
|
28
|
+
|
|
29
|
+
export const renderApp = <C extends AppConfig, T extends AppContext<C>>(context: T, opts?: RenderOptions) =>
|
|
30
|
+
render(<WebApp context={context} provide={provide} />, opts)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Middleware } from '@owlmeans/context'
|
|
2
|
+
import { MiddlewareType, MiddlewareStage, AppType } from '@owlmeans/context'
|
|
3
|
+
import type { ClientModule } from '@owlmeans/client-module'
|
|
4
|
+
import { AuthUnknown } from '@owlmeans/auth'
|
|
5
|
+
import { ResilientError } from '@owlmeans/error'
|
|
6
|
+
import { DEFAULT_ALIAS } from '@owlmeans/client-auth'
|
|
7
|
+
import { AuthService } from '@owlmeans/auth-common'
|
|
8
|
+
|
|
9
|
+
export const logoutMiddleware: Middleware = {
|
|
10
|
+
type: MiddlewareType.Context,
|
|
11
|
+
stage: MiddlewareStage.Loading,
|
|
12
|
+
apply: async context => {
|
|
13
|
+
context.modules<Perked>().forEach(module => {
|
|
14
|
+
if (module.route.route.type === AppType.Backend && module.call != null) {
|
|
15
|
+
const guards = module.getGuards()
|
|
16
|
+
if (guards.length > 0) {
|
|
17
|
+
if (module._auth_web_middleware_applied === true) {
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
module._auth_web_middleware_applied = true
|
|
21
|
+
// const auth = context.service<GuardService>(service)
|
|
22
|
+
const call = module.call
|
|
23
|
+
module.call = async (req, res) => {
|
|
24
|
+
try {
|
|
25
|
+
return await call(req, res)
|
|
26
|
+
} catch (e) {
|
|
27
|
+
if (e instanceof Error) {
|
|
28
|
+
const err = ResilientError.ensure(e)
|
|
29
|
+
if (err instanceof AuthUnknown) {
|
|
30
|
+
if (err.message.endsWith(':invalid')) {
|
|
31
|
+
if (typeof window !== 'undefined') {
|
|
32
|
+
const auth = context.service<AuthService>(DEFAULT_ALIAS)
|
|
33
|
+
await auth.update(undefined)
|
|
34
|
+
throw err
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
throw e
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface Perked extends ClientModule<unknown> {
|
|
50
|
+
_auth_web_middleware_applied?: boolean
|
|
51
|
+
}
|
package/src/router.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import type { RouterProvider } from '@owlmeans/client'
|
|
3
|
-
import {
|
|
3
|
+
import type { RouteObject } from 'react-router'
|
|
4
|
+
import { createBrowserRouter } from 'react-router'
|
|
4
5
|
|
|
5
6
|
export const provide: RouterProvider = (routes) => {
|
|
6
|
-
return createBrowserRouter(routes)
|
|
7
|
+
return createBrowserRouter(routes as RouteObject[]) as any
|
|
7
8
|
}
|
package/src/service.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
|
-
import { DEFAULT_ALIAS } from '@owlmeans/client-auth'
|
|
3
|
-
import type { AuthServiceAppend } from '@owlmeans/client-auth'
|
|
4
|
-
import type { AuthService } from '@owlmeans/auth-common'
|
|
5
|
-
import { makeAuthService } from '@owlmeans/client-auth'
|
|
6
|
-
import type { ClientModule } from '@owlmeans/client-module'
|
|
7
2
|
import { DISPATCHER } from '@owlmeans/auth'
|
|
8
|
-
import type {
|
|
3
|
+
import type { AuthService } from '@owlmeans/auth-common'
|
|
9
4
|
import { authMiddleware } from '@owlmeans/auth-common'
|
|
5
|
+
import type { AuthServiceAppend } from '@owlmeans/client-auth'
|
|
6
|
+
import { DEFAULT_ALIAS, makeAuthService } from '@owlmeans/client-auth'
|
|
7
|
+
import type { ClientConfig, ClientContext } from '@owlmeans/client-context'
|
|
8
|
+
import type { ClientModule } from '@owlmeans/client-module'
|
|
9
|
+
import { logoutMiddleware } from './middleware.js'
|
|
10
10
|
|
|
11
11
|
export const makeAuthWebService = (alias: string = DEFAULT_ALIAS): AuthService => {
|
|
12
12
|
const service = makeAuthService(alias)
|
|
@@ -34,6 +34,7 @@ export const appendWebAuthService = <C extends ClientConfig, T extends ClientCon
|
|
|
34
34
|
context.registerService(service)
|
|
35
35
|
|
|
36
36
|
context.registerMiddleware(authMiddleware)
|
|
37
|
+
context.registerMiddleware(logoutMiddleware)
|
|
37
38
|
|
|
38
39
|
context.auth = () => ctx.service(service.alias)
|
|
39
40
|
|
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./src/consts.ts","./src/context.ts","./src/errors.ts","./src/exports.ts","./src/helper.ts","./src/i18n.ts","./src/index.ts","./src/main.tsx","./src/modules.ts","./src/router.ts","./src/service.ts","./src/types.ts","./src/components/index.ts","./src/components/dispatcher/component.tsx","./src/components/dispatcher/index.ts","./src/components/uploader/component.tsx","./src/components/uploader/image.tsx","./src/components/uploader/index.ts","./src/components/uploader/types.ts"],"version":"5.6.3"}
|