@okam/directus-next-component 1.4.0 → 1.5.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/CHANGELOG.md +96 -0
- package/README.md +142 -0
- package/components/DirectusFile/config.d.ts +1 -1
- package/{hooks → directus/directus-next-component/src/hooks}/directus-file.js +2 -1
- package/{hooks → directus/directus-next-component/src/hooks}/directus-file.mjs +2 -1
- package/{index.js → directus/directus-next-component/src/index.js} +2 -0
- package/{index.mjs → directus/directus-next-component/src/index.mjs} +2 -0
- package/directus/directus-next-component/src/logger.js +6 -0
- package/directus/directus-next-component/src/logger.mjs +6 -0
- package/{server.js → directus/directus-next-component/src/server.js} +2 -0
- package/{server.mjs → directus/directus-next-component/src/server.mjs} +2 -0
- package/index.d.ts +1 -0
- package/logger.d.ts +1 -0
- package/package.json +12 -2
- package/server.d.ts +1 -0
- package/stack/logger/src/lib/factoryLogger.js +8 -0
- package/stack/logger/src/lib/factoryLogger.mjs +9 -0
- package/stack/logger/src/lib/logger.js +37 -0
- package/stack/logger/src/lib/logger.mjs +37 -0
- /package/{components → directus/directus-next-component/src/components}/DirectusFile/config.js +0 -0
- /package/{components → directus/directus-next-component/src/components}/DirectusFile/config.mjs +0 -0
- /package/{components → directus/directus-next-component/src/components}/DirectusFile/index.js +0 -0
- /package/{components → directus/directus-next-component/src/components}/DirectusFile/index.mjs +0 -0
- /package/{components → directus/directus-next-component/src/components}/DirectusImg/index.js +0 -0
- /package/{components → directus/directus-next-component/src/components}/DirectusImg/index.mjs +0 -0
- /package/{components → directus/directus-next-component/src/components}/DirectusLink/index.js +0 -0
- /package/{components → directus/directus-next-component/src/components}/DirectusLink/index.mjs +0 -0
- /package/{components → directus/directus-next-component/src/components}/DirectusVideo/index.js +0 -0
- /package/{components → directus/directus-next-component/src/components}/DirectusVideo/index.mjs +0 -0
- /package/{hooks → directus/directus-next-component/src/hooks}/directus-link.js +0 -0
- /package/{hooks → directus/directus-next-component/src/hooks}/directus-link.mjs +0 -0
- /package/{hooks → directus/directus-next-component/src/hooks}/navigation-items.js +0 -0
- /package/{hooks → directus/directus-next-component/src/hooks}/navigation-items.mjs +0 -0
- /package/{lib → directus/directus-next-component/src/lib}/withDirectus.js +0 -0
- /package/{lib → directus/directus-next-component/src/lib}/withDirectus.mjs +0 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
## 1.4.0 (2024-09-24)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### 🚀 Features
|
|
5
|
+
|
|
6
|
+
- **directus-next:** directus based routing ([196ab1e](https://github.com/OKAMca/stack/commit/196ab1e))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ❤️ Thank You
|
|
10
|
+
|
|
11
|
+
- David Paquet Pitts
|
|
12
|
+
|
|
13
|
+
## 1.3.1 (2024-08-15)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### 🩹 Fixes
|
|
17
|
+
|
|
18
|
+
- **directus-link:** file type links render correct href ([454a847](https://github.com/OKAMca/stack/commit/454a847))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### ❤️ Thank You
|
|
22
|
+
|
|
23
|
+
- poclerson
|
|
24
|
+
|
|
25
|
+
## 1.3.0 (2024-08-15)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### 🚀 Features
|
|
29
|
+
|
|
30
|
+
- directus image support for videos ([4d45c9c](https://github.com/OKAMca/stack/commit/4d45c9c))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### 🩹 Fixes
|
|
34
|
+
|
|
35
|
+
- move tokens and variant from links to navigation item ([7fca919](https://github.com/OKAMca/stack/commit/7fca919))
|
|
36
|
+
|
|
37
|
+
- **directus-next-component:** a11y props and bugfix ([dc3dbde](https://github.com/OKAMca/stack/commit/dc3dbde))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### ❤️ Thank You
|
|
41
|
+
|
|
42
|
+
- Marie-Maxime Tanguay @marie-maxime
|
|
43
|
+
- mykimd
|
|
44
|
+
- Pierre-Olivier Clerson @poclerson
|
|
45
|
+
- poclerson
|
|
46
|
+
- Yan Morin
|
|
47
|
+
- yanmorinokamca @yanmorinokamca
|
|
48
|
+
|
|
49
|
+
## 1.2.0 (2024-07-25)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### 🚀 Features
|
|
53
|
+
|
|
54
|
+
- directus link component + use nav items hook ([750fa5c](https://github.com/OKAMca/stack/commit/750fa5c))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### ❤️ Thank You
|
|
58
|
+
|
|
59
|
+
- Jérôme Trottier
|
|
60
|
+
- Marie-Maxime Tanguay @marie-maxime
|
|
61
|
+
- Pierre-Olivier Clerson @poclerson
|
|
62
|
+
|
|
63
|
+
## 1.1.1 (2024-07-16)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
### 🩹 Fixes
|
|
67
|
+
|
|
68
|
+
- **publish:** add building packages step to workflow ([c9ce442](https://github.com/OKAMca/stack/commit/c9ce442))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
### ❤️ Thank You
|
|
72
|
+
|
|
73
|
+
- Jérôme Trottier
|
|
74
|
+
- Pierre-Olivier Clerson @poclerson
|
|
75
|
+
- yanmorinokamca @yanmorinokamca
|
|
76
|
+
|
|
77
|
+
## 1.1.0 (2024-06-28)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
### 🚀 Features
|
|
81
|
+
|
|
82
|
+
- add new libs ([#71](https://github.com/OKAMca/stack/pull/71))
|
|
83
|
+
|
|
84
|
+
- add dynamic page routing from directus page settings ([#97](https://github.com/OKAMca/stack/pull/97))
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
### 🩹 Fixes
|
|
88
|
+
|
|
89
|
+
- publishing for new libs ([#125](https://github.com/OKAMca/stack/pull/125))
|
|
90
|
+
|
|
91
|
+
- publishing for new libs ([#126](https://github.com/OKAMca/stack/pull/126))
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
### ❤️ Thank You
|
|
95
|
+
|
|
96
|
+
- Marie-Maxime Tanguay @marie-maxime
|
package/README.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# directus-next-component
|
|
2
|
+
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## directusRouteMiddleware usage
|
|
6
|
+
|
|
7
|
+
Create a middleware.ts file in the project, in the `/src/app` directory of the next application, and add the following code to it.
|
|
8
|
+
|
|
9
|
+
```jsx
|
|
10
|
+
// middleware.ts
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
directusRouteMiddleware,
|
|
14
|
+
config as directusRouteMiddlewareConfig,
|
|
15
|
+
} from '@okam/directus-next-component/src/server'
|
|
16
|
+
import type { NextRequest } from 'next/server'
|
|
17
|
+
|
|
18
|
+
export function middleware(request: NextRequest) {
|
|
19
|
+
const { locale } = request.nextUrl
|
|
20
|
+
return directusRouteMiddleware(request, [locale])
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const config = {
|
|
24
|
+
...directusRouteMiddlewareConfig,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
After, modify the `next.config.js` file to add `withDirectus` in the plugins.
|
|
30
|
+
|
|
31
|
+
## useDirectusLink hook
|
|
32
|
+
|
|
33
|
+
The role of the directus link hook is to dispatch different props according to the type of the directus link. The configuration for the dispatching is overridable using the `propsConfig` prop
|
|
34
|
+
|
|
35
|
+
## DirectusLink component
|
|
36
|
+
|
|
37
|
+
The role of the directus link component is to wrap `next/link` and dispatch the props to different components according to a configuration. The configuration for dispatching different components is overridable using the `componentsConfig` prop.
|
|
38
|
+
|
|
39
|
+
The directus link component uses the directus link hook, which means it can be passed both `componentsConfig` and `propsConfig` for both dispatching uses.
|
|
40
|
+
|
|
41
|
+
By default, the following are included:
|
|
42
|
+
|
|
43
|
+
- `collection`: Render a link using a `page_settings` relation
|
|
44
|
+
- `anchor`: Render a link pointing to an element's id on the page (always starts with `#`)
|
|
45
|
+
- `external-link`: Render a link with an external URL (e.g.: https://google.com)
|
|
46
|
+
- `file`: Render a link for a downloadable file
|
|
47
|
+
|
|
48
|
+
The mentionned configuration can be overwritten by passing a `componentsConfig` prop to the directus link component
|
|
49
|
+
|
|
50
|
+
```jsx
|
|
51
|
+
const overrideConfig = {
|
|
52
|
+
'external-link': (props) => <CustomExternalLinkComponent {...props} />
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const BrandLink = (props) => {
|
|
56
|
+
return <DirectusLink config={overrideConfig} {...props} />
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## useNavigationItems hook
|
|
61
|
+
|
|
62
|
+
The `useNavigationItems` hook allows to build recursively a navigation structure using the `DirectusLink` component.
|
|
63
|
+
|
|
64
|
+
The tokens passed to `link` and `linkProps` include also include, in order of priority:
|
|
65
|
+
- The tokens passed from `onNavigationItem`
|
|
66
|
+
- The variant of the navigation item, passed as the `type` token
|
|
67
|
+
- The tokens of the navigation item
|
|
68
|
+
|
|
69
|
+
### Props
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Returned props of each parsed navigation item in the tree
|
|
74
|
+
|
|
75
|
+
- `link`: A rendered react node of the `DirectusLink` component
|
|
76
|
+
- `linkProps`: The props that were passed to the link
|
|
77
|
+
- `children`: The navigation items containing link, linkProps, children
|
|
78
|
+
- `parent`: A single navigation item containing link, linkProps, parent
|
|
79
|
+
- `depth`: The current depth of the recursion. For each level of parent, the depth will go down by one. For each level of children, the depth will go up by one. The depth starts at zero
|
|
80
|
+
|
|
81
|
+
### Example usage
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
// Any styling could go here
|
|
85
|
+
const depthMap: Record<number, object> = {
|
|
86
|
+
0: { backgroundColor: 'red' },
|
|
87
|
+
1: { backgroundColor: 'blue' },
|
|
88
|
+
2: { backgroundColor: 'green' },
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Loop recursively through navigation items and assign style based on depth
|
|
92
|
+
function renderTree(tree: Nullable<TNavigationItemsTree>): React.ReactNode {
|
|
93
|
+
if (!tree) return null
|
|
94
|
+
const { children, link, linkProps, depth } = tree
|
|
95
|
+
const style = depthMap[depth]
|
|
96
|
+
|
|
97
|
+
if (!link && !children) return null
|
|
98
|
+
if (!children) {
|
|
99
|
+
return (
|
|
100
|
+
<li style={style} key={link.id}>
|
|
101
|
+
{
|
|
102
|
+
/*
|
|
103
|
+
* Here, `link` represents a rendered version of `DirectusLink` for quick use
|
|
104
|
+
* Use `linkProps` for custom rendering needs
|
|
105
|
+
*/
|
|
106
|
+
}
|
|
107
|
+
{link}
|
|
108
|
+
</li>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
return (
|
|
112
|
+
<ul key={link.id}>
|
|
113
|
+
<li style={style}>{link}</li>
|
|
114
|
+
{children.map((child) => renderTree(child))}
|
|
115
|
+
</ul>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const NavigationComponent = (props) => {
|
|
120
|
+
// Depth and links type cannot be inferred directly, they must be passed
|
|
121
|
+
const navigation = useNavigationItems<3, { link?: LinksFragment }>(
|
|
122
|
+
props.navigationItems,
|
|
123
|
+
|
|
124
|
+
// Use `onNavigationItem` to parse the fragments
|
|
125
|
+
(item) => {
|
|
126
|
+
const { link } = item ?? {}
|
|
127
|
+
const collection = getFragment(PageSettingsFragmentDoc, link?.collection)
|
|
128
|
+
const file = getFragment(FilesFragmentDoc, link?.file)
|
|
129
|
+
return {
|
|
130
|
+
...link,
|
|
131
|
+
collection,
|
|
132
|
+
file,
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<nav>
|
|
138
|
+
{navigation.map((item) => renderTree(item))}
|
|
139
|
+
</nav>
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentType } from 'react-spring';
|
|
1
|
+
import type { ComponentType } from '@react-spring/web';
|
|
2
2
|
import type { TDirectusFileProps } from './interface';
|
|
3
3
|
declare const directusFileConfig: Record<string, ComponentType<TDirectusFileProps>>;
|
|
4
4
|
export default directusFileConfig;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const logger = require("../logger.js");
|
|
2
3
|
const IMG_DOMAIN = process.env.NEXT_PUBLIC_IMG_DOMAIN;
|
|
3
4
|
const IMG_PORT = process.env.NEXT_PUBLIC_IMG_PORT;
|
|
4
5
|
const IMG_PROTOCOL = process.env.NEXT_PUBLIC_IMG_PROTOCOL ?? "https";
|
|
@@ -18,7 +19,7 @@ function getDirectusUrl(file, baseUrl, searchParams) {
|
|
|
18
19
|
if (searchParams) setSearchParams(url, searchParams);
|
|
19
20
|
return url;
|
|
20
21
|
} catch (error) {
|
|
21
|
-
|
|
22
|
+
logger.logger.log("Couldn't create URL", "warn", { error });
|
|
22
23
|
return null;
|
|
23
24
|
}
|
|
24
25
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { logger } from "../logger.mjs";
|
|
1
2
|
const IMG_DOMAIN = process.env.NEXT_PUBLIC_IMG_DOMAIN;
|
|
2
3
|
const IMG_PORT = process.env.NEXT_PUBLIC_IMG_PORT;
|
|
3
4
|
const IMG_PROTOCOL = process.env.NEXT_PUBLIC_IMG_PROTOCOL ?? "https";
|
|
@@ -17,7 +18,7 @@ function getDirectusUrl(file, baseUrl, searchParams) {
|
|
|
17
18
|
if (searchParams) setSearchParams(url, searchParams);
|
|
18
19
|
return url;
|
|
19
20
|
} catch (error) {
|
|
20
|
-
|
|
21
|
+
logger.log("Couldn't create URL", "warn", { error });
|
|
21
22
|
return null;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
@@ -7,6 +7,7 @@ const index$3 = require("./components/DirectusFile/index.js");
|
|
|
7
7
|
const directusFile = require("./hooks/directus-file.js");
|
|
8
8
|
const directusLink = require("./hooks/directus-link.js");
|
|
9
9
|
const navigationItems = require("./hooks/navigation-items.js");
|
|
10
|
+
const logger = require("./logger.js");
|
|
10
11
|
exports.DirectusLink = index;
|
|
11
12
|
exports.DirectusImg = index$1;
|
|
12
13
|
exports.DirectusVideo = index$2;
|
|
@@ -14,3 +15,4 @@ exports.DirectusFile = index$3;
|
|
|
14
15
|
exports.useDirectusFile = directusFile;
|
|
15
16
|
exports.useDirectusLink = directusLink;
|
|
16
17
|
exports.useNavigationItems = navigationItems;
|
|
18
|
+
exports.DirectusNextComponent = logger.logger;
|
|
@@ -5,10 +5,12 @@ import { default as default5 } from "./components/DirectusFile/index.mjs";
|
|
|
5
5
|
import { default as default6 } from "./hooks/directus-file.mjs";
|
|
6
6
|
import { default as default7 } from "./hooks/directus-link.mjs";
|
|
7
7
|
import { default as default8 } from "./hooks/navigation-items.mjs";
|
|
8
|
+
import { logger } from "./logger.mjs";
|
|
8
9
|
export {
|
|
9
10
|
default5 as DirectusFile,
|
|
10
11
|
default3 as DirectusImg,
|
|
11
12
|
default2 as DirectusLink,
|
|
13
|
+
logger as DirectusNextComponent,
|
|
12
14
|
default4 as DirectusVideo,
|
|
13
15
|
default6 as useDirectusFile,
|
|
14
16
|
default7 as useDirectusLink,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("../../../stack/logger/src/lib/logger.js");
|
|
4
|
+
const factoryLogger = require("../../../stack/logger/src/lib/factoryLogger.js");
|
|
5
|
+
const logger = factoryLogger("[DirectusNextComponent]");
|
|
6
|
+
exports.logger = logger;
|
|
@@ -5,6 +5,7 @@ const index = require("./components/DirectusFile/index.js");
|
|
|
5
5
|
const index$1 = require("./components/DirectusImg/index.js");
|
|
6
6
|
const index$2 = require("./components/DirectusLink/index.js");
|
|
7
7
|
const index$3 = require("./components/DirectusVideo/index.js");
|
|
8
|
+
const logger = require("./logger.js");
|
|
8
9
|
const directusFile = require("./hooks/directus-file.js");
|
|
9
10
|
const directusLink = require("./hooks/directus-link.js");
|
|
10
11
|
const navigationItems = require("./hooks/navigation-items.js");
|
|
@@ -13,6 +14,7 @@ exports.DirectusFile = index;
|
|
|
13
14
|
exports.DirectusImg = index$1;
|
|
14
15
|
exports.DirectusLink = index$2;
|
|
15
16
|
exports.DirectusVideo = index$3;
|
|
17
|
+
exports.DirectusNextComponent = logger.logger;
|
|
16
18
|
exports.useDirectusFile = directusFile;
|
|
17
19
|
exports.useDirectusLink = directusLink;
|
|
18
20
|
exports.useNavigationItems = navigationItems;
|
|
@@ -3,6 +3,7 @@ import { default as default3 } from "./components/DirectusFile/index.mjs";
|
|
|
3
3
|
import { default as default4 } from "./components/DirectusImg/index.mjs";
|
|
4
4
|
import { default as default5 } from "./components/DirectusLink/index.mjs";
|
|
5
5
|
import { default as default6 } from "./components/DirectusVideo/index.mjs";
|
|
6
|
+
import { logger } from "./logger.mjs";
|
|
6
7
|
import { default as default7 } from "./hooks/directus-file.mjs";
|
|
7
8
|
import { default as default8 } from "./hooks/directus-link.mjs";
|
|
8
9
|
import { default as default9 } from "./hooks/navigation-items.mjs";
|
|
@@ -10,6 +11,7 @@ export {
|
|
|
10
11
|
default3 as DirectusFile,
|
|
11
12
|
default4 as DirectusImg,
|
|
12
13
|
default5 as DirectusLink,
|
|
14
|
+
logger as DirectusNextComponent,
|
|
13
15
|
default6 as DirectusVideo,
|
|
14
16
|
default7 as useDirectusFile,
|
|
15
17
|
default8 as useDirectusLink,
|
package/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { default as DirectusFile } from './components/DirectusFile';
|
|
|
5
5
|
export { default as useDirectusFile } from './hooks/directus-file';
|
|
6
6
|
export { default as useDirectusLink } from './hooks/directus-link';
|
|
7
7
|
export { default as useNavigationItems } from './hooks/navigation-items';
|
|
8
|
+
export { logger as DirectusNextComponent } from './logger';
|
|
8
9
|
export type { TFiles } from './types/files';
|
|
9
10
|
export type { TPageSettings } from './types/page-settings';
|
|
10
11
|
export type { TNavigationItems, TNavigationItemsTree } from './types/navigation-items';
|
package/logger.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const logger: import("@okam/logger").Logger;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okam/directus-next-component",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"types": "./index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -14,9 +14,19 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"publishConfig": {
|
|
17
|
-
"
|
|
17
|
+
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"url": "https://github.com/OKAMca/stack.git"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@okam/logger": "1.1.0",
|
|
24
|
+
"@okam/next-component": "0.4.0",
|
|
25
|
+
"@okam/stack-ui": "1.31.0",
|
|
26
|
+
"@react-spring/web": "^9.7.5",
|
|
27
|
+
"next": "^14.1.1",
|
|
28
|
+
"radashi": "^12.3.0",
|
|
29
|
+
"react": "18.3.1",
|
|
30
|
+
"unlazy": "^0.12.1"
|
|
21
31
|
}
|
|
22
32
|
}
|
package/server.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { default as DirectusFile } from './components/DirectusFile';
|
|
|
3
3
|
export { default as DirectusImg } from './components/DirectusImg';
|
|
4
4
|
export { default as DirectusLink } from './components/DirectusLink';
|
|
5
5
|
export { default as DirectusVideo } from './components/DirectusVideo';
|
|
6
|
+
export { logger as DirectusNextComponent } from './logger';
|
|
6
7
|
export { default as useDirectusFile } from './hooks/directus-file';
|
|
7
8
|
export { default as useDirectusLink } from './hooks/directus-link';
|
|
8
9
|
export { default as useNavigationItems } from './hooks/navigation-items';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const logger = require("./logger.js");
|
|
3
|
+
const createLogger = (name, logger$1, suppressConsole = false) => {
|
|
4
|
+
const log = new logger.Logger(name, logger$1, suppressConsole);
|
|
5
|
+
log.log(`Logger initialized`, "info");
|
|
6
|
+
return log;
|
|
7
|
+
};
|
|
8
|
+
module.exports = createLogger;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Logger } from "./logger.mjs";
|
|
2
|
+
const createLogger = (name, logger, suppressConsole = false) => {
|
|
3
|
+
const log = new Logger(name, logger, suppressConsole);
|
|
4
|
+
log.log(`Logger initialized`, "info");
|
|
5
|
+
return log;
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
createLogger as default
|
|
9
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
class Logger {
|
|
4
|
+
constructor(nameSpace, logger2, suppressConsole) {
|
|
5
|
+
this.nameSpace = "[STACK]";
|
|
6
|
+
this.suppressConsole = false;
|
|
7
|
+
this.env = process.env["NODE_ENV"];
|
|
8
|
+
this.nameSpace = nameSpace ?? this.nameSpace;
|
|
9
|
+
this.suppressConsole = suppressConsole ?? this.suppressConsole;
|
|
10
|
+
this.logger = logger2 ?? this.internalLogger;
|
|
11
|
+
}
|
|
12
|
+
internalLogger(message, severity, context) {
|
|
13
|
+
if (this.env === "production") {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
console[severity || "log"](`${this.nameSpace} ${message}`.trimStart(), context ?? "");
|
|
17
|
+
}
|
|
18
|
+
setLogger(logger2) {
|
|
19
|
+
this.logger = (message, severity, context) => {
|
|
20
|
+
if (this.suppressConsole) {
|
|
21
|
+
this.internalLogger(message, severity, context);
|
|
22
|
+
}
|
|
23
|
+
logger2(message, severity, context);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
static getInstance() {
|
|
27
|
+
if (!Logger.instance) {
|
|
28
|
+
Logger.instance = new Logger();
|
|
29
|
+
}
|
|
30
|
+
return Logger.instance;
|
|
31
|
+
}
|
|
32
|
+
log(message, severity, context) {
|
|
33
|
+
this.logger(message, severity, context);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
Logger.getInstance();
|
|
37
|
+
exports.Logger = Logger;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
class Logger {
|
|
2
|
+
constructor(nameSpace, logger2, suppressConsole) {
|
|
3
|
+
this.nameSpace = "[STACK]";
|
|
4
|
+
this.suppressConsole = false;
|
|
5
|
+
this.env = process.env["NODE_ENV"];
|
|
6
|
+
this.nameSpace = nameSpace ?? this.nameSpace;
|
|
7
|
+
this.suppressConsole = suppressConsole ?? this.suppressConsole;
|
|
8
|
+
this.logger = logger2 ?? this.internalLogger;
|
|
9
|
+
}
|
|
10
|
+
internalLogger(message, severity, context) {
|
|
11
|
+
if (this.env === "production") {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
console[severity || "log"](`${this.nameSpace} ${message}`.trimStart(), context ?? "");
|
|
15
|
+
}
|
|
16
|
+
setLogger(logger2) {
|
|
17
|
+
this.logger = (message, severity, context) => {
|
|
18
|
+
if (this.suppressConsole) {
|
|
19
|
+
this.internalLogger(message, severity, context);
|
|
20
|
+
}
|
|
21
|
+
logger2(message, severity, context);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
static getInstance() {
|
|
25
|
+
if (!Logger.instance) {
|
|
26
|
+
Logger.instance = new Logger();
|
|
27
|
+
}
|
|
28
|
+
return Logger.instance;
|
|
29
|
+
}
|
|
30
|
+
log(message, severity, context) {
|
|
31
|
+
this.logger(message, severity, context);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
Logger.getInstance();
|
|
35
|
+
export {
|
|
36
|
+
Logger
|
|
37
|
+
};
|
/package/{components → directus/directus-next-component/src/components}/DirectusFile/config.js
RENAMED
|
File without changes
|
/package/{components → directus/directus-next-component/src/components}/DirectusFile/config.mjs
RENAMED
|
File without changes
|
/package/{components → directus/directus-next-component/src/components}/DirectusFile/index.js
RENAMED
|
File without changes
|
/package/{components → directus/directus-next-component/src/components}/DirectusFile/index.mjs
RENAMED
|
File without changes
|
/package/{components → directus/directus-next-component/src/components}/DirectusImg/index.js
RENAMED
|
File without changes
|
/package/{components → directus/directus-next-component/src/components}/DirectusImg/index.mjs
RENAMED
|
File without changes
|
/package/{components → directus/directus-next-component/src/components}/DirectusLink/index.js
RENAMED
|
File without changes
|
/package/{components → directus/directus-next-component/src/components}/DirectusLink/index.mjs
RENAMED
|
File without changes
|
/package/{components → directus/directus-next-component/src/components}/DirectusVideo/index.js
RENAMED
|
File without changes
|
/package/{components → directus/directus-next-component/src/components}/DirectusVideo/index.mjs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|