@schneiderelli/cms-runtime 0.0.1

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/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Svelte library
2
+
3
+ Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
4
+
5
+ Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
6
+
7
+ ## Creating a project
8
+
9
+ If you're seeing this, you've probably already done this step. Congrats!
10
+
11
+ ```sh
12
+ # create a new project in the current directory
13
+ npx sv create
14
+
15
+ # create a new project in my-app
16
+ npx sv create my-app
17
+ ```
18
+
19
+ ## Developing
20
+
21
+ Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
22
+
23
+ ```sh
24
+ npm run dev
25
+
26
+ # or start the server and open the app in a new browser tab
27
+ npm run dev -- --open
28
+ ```
29
+
30
+ Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
31
+
32
+ ## Building
33
+
34
+ To build your library:
35
+
36
+ ```sh
37
+ npm pack
38
+ ```
39
+
40
+ To create a production version of your showcase app:
41
+
42
+ ```sh
43
+ npm run build
44
+ ```
45
+
46
+ You can preview the production build with `npm run preview`.
47
+
48
+ > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
49
+
50
+ ## Publishing
51
+
52
+ Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
53
+
54
+ To publish your library to [npm](https://www.npmjs.com):
55
+
56
+ ```sh
57
+ npm publish
58
+ ```
@@ -0,0 +1,12 @@
1
+ <script lang="ts">
2
+ import { resolveBlockComponent } from '../resolve.js';
3
+ import type { Block } from '../types.js';
4
+
5
+ let { blocks } = $props<{
6
+ blocks: Block[];
7
+ }>();
8
+ </script>
9
+
10
+ {#each blocks as block}
11
+ {@render resolveBlockComponent(block)(block)}
12
+ {/each}
@@ -0,0 +1,7 @@
1
+ import type { Block } from '../types.ts';
2
+ type $$ComponentProps = {
3
+ blocks: Block[];
4
+ };
5
+ declare const BlockRenderer: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type BlockRenderer = ReturnType<typeof BlockRenderer>;
7
+ export default BlockRenderer;
@@ -0,0 +1,8 @@
1
+ <script lang="ts">
2
+ import type { HeadingBlock } from '../../types.js';
3
+ let { block } = $props<{ block: HeadingBlock }>();
4
+ </script>
5
+
6
+ <svelte:element this={`h${block.level ?? 2}`} class="my-4 text-2xl font-bold">
7
+ {block.text}
8
+ </svelte:element>
@@ -0,0 +1,7 @@
1
+ import type { HeadingBlock } from '../../types.ts';
2
+ type $$ComponentProps = {
3
+ block: HeadingBlock;
4
+ };
5
+ declare const HeadingBlock: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type HeadingBlock = ReturnType<typeof HeadingBlock>;
7
+ export default HeadingBlock;
@@ -0,0 +1,6 @@
1
+ <script lang="ts">
2
+ import type { ImageBlock } from '../../types.js';
3
+ let { block } = $props<{ block: ImageBlock }>();
4
+ </script>
5
+
6
+ <img src={block.src} alt={block.alt ?? ''} class="my-4 rounded-lg shadow-md" />
@@ -0,0 +1,7 @@
1
+ import type { ImageBlock } from '../../types.ts';
2
+ type $$ComponentProps = {
3
+ block: ImageBlock;
4
+ };
5
+ declare const ImageBlock: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type ImageBlock = ReturnType<typeof ImageBlock>;
7
+ export default ImageBlock;
@@ -0,0 +1,8 @@
1
+ <script lang="ts">
2
+ import type { TextBlock } from '../../types.js';
3
+ let { block } = $props<{ block: TextBlock }>();
4
+ </script>
5
+
6
+ <p class="prose whitespace-pre-line">
7
+ {@html block.content}
8
+ </p>
@@ -0,0 +1,7 @@
1
+ import type { TextBlock } from '../../types.ts';
2
+ type $$ComponentProps = {
3
+ block: TextBlock;
4
+ };
5
+ declare const TextBlock: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type TextBlock = ReturnType<typeof TextBlock>;
7
+ export default TextBlock;
@@ -0,0 +1,3 @@
1
+ export * from "./types";
2
+ export * from "./resolve";
3
+ export { default as BlockRenderer } from "./components/BlockRenderer.svelte";
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // Reexport your entry components here
2
+ export * from "./types";
3
+ export * from "./resolve";
4
+ export { default as BlockRenderer } from "./components/BlockRenderer.svelte";
@@ -0,0 +1,15 @@
1
+ import TextBlock from "./components/blocks/TextBlock.svelte";
2
+ import HeadingBlock from "./components/blocks/HeadingBlock.svelte";
3
+ import ImageBlock from "./components/blocks/ImageBlock.svelte";
4
+ export declare const BlockRegistry: {
5
+ text: import("svelte").Component<{
6
+ block: TextBlock;
7
+ }, {}, "">;
8
+ heading: import("svelte").Component<{
9
+ block: HeadingBlock;
10
+ }, {}, "">;
11
+ image: import("svelte").Component<{
12
+ block: ImageBlock;
13
+ }, {}, "">;
14
+ };
15
+ export declare const resolveBlockComponent: (block: any) => any;
@@ -0,0 +1,15 @@
1
+ import TextBlock from "./components/blocks/TextBlock.svelte";
2
+ import HeadingBlock from "./components/blocks/HeadingBlock.svelte";
3
+ import ImageBlock from "./components/blocks/ImageBlock.svelte";
4
+ export const BlockRegistry = {
5
+ text: TextBlock,
6
+ heading: HeadingBlock,
7
+ image: ImageBlock
8
+ };
9
+ export const resolveBlockComponent = (block) => {
10
+ const Component = BlockRegistry[block.type];
11
+ if (!Component) {
12
+ throw new Error(`Unknown block type: ${block.type}`);
13
+ }
14
+ return Component;
15
+ };
@@ -0,0 +1,15 @@
1
+ export interface TextBlock {
2
+ type: "text";
3
+ content: string;
4
+ }
5
+ export interface HeadingBlock {
6
+ type: "heading";
7
+ level: number;
8
+ text: string;
9
+ }
10
+ export interface ImageBlock {
11
+ type: "image";
12
+ src: string;
13
+ alt?: string;
14
+ }
15
+ export type Block = TextBlock | HeadingBlock | ImageBlock;
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ //
2
+ // Basic shared types for the runtime system
3
+ //
4
+ export {};
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@schneiderelli/cms-runtime",
3
+ "version": "0.0.1",
4
+ "scripts": {
5
+ "dev": "vite dev",
6
+ "build": "vite build && npm run prepack",
7
+ "preview": "vite preview",
8
+ "prepare": "svelte-kit sync || echo ''",
9
+ "prepack": "svelte-kit sync && svelte-package && publint",
10
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
11
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
12
+ "format": "prettier --write .",
13
+ "lint": "prettier --check . && eslint .",
14
+ "test:unit": "vitest",
15
+ "test": "npm run test:unit -- --run",
16
+ "release:patch": "npm version patch && npm publish --access public --no-git-tag-version",
17
+ "release:minor": "npm version minor && npm publish --access public --no-git-tag-version",
18
+ "release:major": "npm version major && npm publish --access public --no-git-tag-version"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "!dist/**/*.test.*",
23
+ "!dist/**/*.spec.*"
24
+ ],
25
+ "sideEffects": [
26
+ "**/*.css"
27
+ ],
28
+ "svelte": "./dist/index.js",
29
+ "types": "./dist/index.d.ts",
30
+ "type": "module",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "svelte": "./dist/index.js"
35
+ }
36
+ },
37
+ "peerDependencies": {
38
+ "svelte": "^5.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@eslint/compat": "^1.4.0",
42
+ "@eslint/js": "^9.39.1",
43
+ "@sveltejs/adapter-auto": "^7.0.0",
44
+ "@sveltejs/kit": "^2.49.1",
45
+ "@sveltejs/package": "^2.5.7",
46
+ "@sveltejs/vite-plugin-svelte": "^6.2.1",
47
+ "@tailwindcss/forms": "^0.5.10",
48
+ "@tailwindcss/typography": "^0.5.19",
49
+ "@tailwindcss/vite": "^4.1.17",
50
+ "@types/node": "^22",
51
+ "@vitest/browser-playwright": "^4.0.15",
52
+ "eslint": "^9.39.1",
53
+ "eslint-config-prettier": "^10.1.8",
54
+ "eslint-plugin-svelte": "^3.13.1",
55
+ "globals": "^16.5.0",
56
+ "playwright": "^1.57.0",
57
+ "prettier": "^3.7.4",
58
+ "prettier-plugin-svelte": "^3.4.0",
59
+ "prettier-plugin-tailwindcss": "^0.7.2",
60
+ "publint": "^0.3.15",
61
+ "svelte": "^5.45.6",
62
+ "svelte-check": "^4.3.4",
63
+ "tailwindcss": "^4.1.17",
64
+ "typescript": "^5.9.3",
65
+ "typescript-eslint": "^8.48.1",
66
+ "vite": "^7.2.6",
67
+ "vitest": "^4.0.15",
68
+ "vitest-browser-svelte": "^2.0.1"
69
+ },
70
+ "keywords": [
71
+ "svelte"
72
+ ]
73
+ }