@coherent.js/adapters 1.0.0-beta.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 +21 -0
- package/README.md +49 -0
- package/package.json +49 -0
- package/src/astro.js +23 -0
- package/src/index.js +8 -0
- package/src/remix.js +25 -0
- package/src/sveltekit.js +24 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Coherent.js Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @coherent.js/adapters
|
|
2
|
+
|
|
3
|
+
Framework adapters for Coherent.js, providing seamless integration with popular web frameworks.
|
|
4
|
+
|
|
5
|
+
## Supported Frameworks
|
|
6
|
+
|
|
7
|
+
- **Astro** - Full SSR integration
|
|
8
|
+
- **Remix** - Loader and component adapters
|
|
9
|
+
- **SvelteKit** - Adapter and preprocessor
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @coherent.js/adapters
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Astro Integration
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { createAstroIntegration } from '@coherent.js/adapters/astro';
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
integrations: [
|
|
26
|
+
createAstroIntegration()
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Remix Adapter
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { createRemixAdapter } from '@coherent.js/adapters/remix';
|
|
35
|
+
|
|
36
|
+
const adapter = createRemixAdapter();
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### SvelteKit Adapter
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import { createSvelteKitAdapter } from '@coherent.js/adapters/sveltekit';
|
|
43
|
+
|
|
44
|
+
export default {
|
|
45
|
+
kit: {
|
|
46
|
+
adapter: createSvelteKitAdapter()
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@coherent.js/adapters",
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
|
+
"description": "Framework adapters for Coherent.js (Astro, Remix, SvelteKit)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"types": "./types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.js",
|
|
10
|
+
"./astro": "./src/astro.js",
|
|
11
|
+
"./remix": "./src/remix.js",
|
|
12
|
+
"./sveltekit": "./src/sveltekit.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"src/",
|
|
16
|
+
"types/",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"astro",
|
|
22
|
+
"remix",
|
|
23
|
+
"svelte",
|
|
24
|
+
"sveltekit",
|
|
25
|
+
"coherent",
|
|
26
|
+
"ssr",
|
|
27
|
+
"adapters"
|
|
28
|
+
],
|
|
29
|
+
"author": "Coherent.js Team",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@coherent.js/core": "1.0.0-beta.2"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"vitest": "^3.2.4"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/Tomdrouv1/coherent.js.git"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public",
|
|
43
|
+
"registry": "https://registry.npmjs.org/"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "node build.mjs",
|
|
47
|
+
"test": "vitest"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/astro.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Astro Integration for Coherent.js
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { render } from '@coherent.js/core';
|
|
6
|
+
|
|
7
|
+
export function createAstroIntegration(_options = {}) {
|
|
8
|
+
return {
|
|
9
|
+
name: 'coherent',
|
|
10
|
+
hooks: {
|
|
11
|
+
'astro:config:setup': ({ addRenderer }) => {
|
|
12
|
+
addRenderer({
|
|
13
|
+
name: '@coherent.js/adapters/astro',
|
|
14
|
+
serverEntrypoint: '@coherent.js/adapters/astro/server.js',
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function renderComponent(Component, props) {
|
|
22
|
+
return render(Component, props);
|
|
23
|
+
}
|
package/src/index.js
ADDED
package/src/remix.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remix Adapter for Coherent.js
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { render } from '@coherent.js/core';
|
|
6
|
+
|
|
7
|
+
export function createRemixAdapter(_options = {}) {
|
|
8
|
+
return {
|
|
9
|
+
renderComponent: (component, props) => render(component, props),
|
|
10
|
+
createLoader: (component) => {
|
|
11
|
+
return async ({ request, params }) => {
|
|
12
|
+
return {
|
|
13
|
+
component,
|
|
14
|
+
props: { request, params }
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function withCoherent(Component) {
|
|
22
|
+
return function CoherentRemixComponent(props) {
|
|
23
|
+
return render(Component, props);
|
|
24
|
+
};
|
|
25
|
+
}
|
package/src/sveltekit.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SvelteKit Adapter for Coherent.js
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { render } from '@coherent.js/core';
|
|
6
|
+
|
|
7
|
+
export function createSvelteKitAdapter(_options = {}) {
|
|
8
|
+
return {
|
|
9
|
+
name: '@coherent.js/sveltekit',
|
|
10
|
+
renderComponent: (component, props) => render(component, props)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function createPreprocessor(_options = {}) {
|
|
15
|
+
return {
|
|
16
|
+
name: 'coherent-preprocessor',
|
|
17
|
+
markup({ content, _filename }) {
|
|
18
|
+
// Basic preprocessor logic
|
|
19
|
+
return {
|
|
20
|
+
code: content
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|