@withstudiocms/component-registry 0.1.0-beta.6 → 0.1.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 +37 -0
- package/dist/registry/Registry.js +1 -1
- package/dist/runtime.d.ts +2 -1
- package/dist/runtime.js +2 -2
- package/dist/transform-html.d.ts +2 -1
- package/dist/transform-html.js +10 -2
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +2 -1
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @withstudiocms/component-registry
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1157](https://github.com/withstudiocms/studiocms/pull/1157) [`f8a2d34`](https://github.com/withstudiocms/studiocms/commit/f8a2d342cc3c35bf4478bb523bf28d78dd2d0404) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Add effect-language-service diagnostics scripts to all workspace packages
|
|
8
|
+
|
|
9
|
+
- [#1165](https://github.com/withstudiocms/studiocms/pull/1165) [`9007ca5`](https://github.com/withstudiocms/studiocms/commit/9007ca5d8d6c471ee25f07bd2f0a101ba195440c) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Tweaks `transformHTML` sanitization so StudioCMS components and custom elements are always passed through (caller-provided `sanitizeOpts` cannot disable `allowComponents`/`allowCustomElements`).
|
|
10
|
+
|
|
11
|
+
- [#1101](https://github.com/withstudiocms/studiocms/pull/1101) [`8f53993`](https://github.com/withstudiocms/studiocms/commit/8f539933716b9d3335a13c180e3c607e44a63f8a) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Introduces new transformer option in component registry and creates new StorageAPI transformer to allow Storage API automatic url swapping
|
|
12
|
+
|
|
13
|
+
- [#1160](https://github.com/withstudiocms/studiocms/pull/1160) [`30de271`](https://github.com/withstudiocms/studiocms/commit/30de271f347a3a997669c8118006143148efb33a) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Refactors code to handle Effect LSP diagnostic warnings and errors
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`87d36ba`](https://github.com/withstudiocms/studiocms/commit/87d36ba83d24d83c7b2b17daa47231a63c225fa2), [`f8a2d34`](https://github.com/withstudiocms/studiocms/commit/f8a2d342cc3c35bf4478bb523bf28d78dd2d0404), [`cb8ffda`](https://github.com/withstudiocms/studiocms/commit/cb8ffda2d6fb31e3a754996b3e938a5c1b643af1), [`30de271`](https://github.com/withstudiocms/studiocms/commit/30de271f347a3a997669c8118006143148efb33a)]:
|
|
16
|
+
- @withstudiocms/effect@0.1.0
|
|
17
|
+
|
|
18
|
+
## 0.1.0-beta.8
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [#1157](https://github.com/withstudiocms/studiocms/pull/1157) [`f8a2d34`](https://github.com/withstudiocms/studiocms/commit/f8a2d342cc3c35bf4478bb523bf28d78dd2d0404) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Add effect-language-service diagnostics scripts to all workspace packages
|
|
23
|
+
|
|
24
|
+
- [#1101](https://github.com/withstudiocms/studiocms/pull/1101) [`8f53993`](https://github.com/withstudiocms/studiocms/commit/8f539933716b9d3335a13c180e3c607e44a63f8a) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Introduces new transformer option in component registry and creates new StorageAPI transformer to allow Storage API automatic url swapping
|
|
25
|
+
|
|
26
|
+
- [#1160](https://github.com/withstudiocms/studiocms/pull/1160) [`30de271`](https://github.com/withstudiocms/studiocms/commit/30de271f347a3a997669c8118006143148efb33a) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Refactors code to handle Effect LSP diagnostic warnings and errors
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [[`8e50cd0`](https://github.com/withstudiocms/studiocms/commit/8e50cd0885fa1e4664d457ff3fe4fa77b344ecc4), [`87d36ba`](https://github.com/withstudiocms/studiocms/commit/87d36ba83d24d83c7b2b17daa47231a63c225fa2), [`f8a2d34`](https://github.com/withstudiocms/studiocms/commit/f8a2d342cc3c35bf4478bb523bf28d78dd2d0404), [`cb8ffda`](https://github.com/withstudiocms/studiocms/commit/cb8ffda2d6fb31e3a754996b3e938a5c1b643af1), [`30de271`](https://github.com/withstudiocms/studiocms/commit/30de271f347a3a997669c8118006143148efb33a)]:
|
|
29
|
+
- @withstudiocms/effect@0.1.0-beta.8
|
|
30
|
+
|
|
31
|
+
## 0.1.0-beta.7
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- [#1029](https://github.com/withstudiocms/studiocms/pull/1029) [`da369c7`](https://github.com/withstudiocms/studiocms/commit/da369c7bd8f40670cb56821d74686c79840f06e4) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Integrates new Kysely based SDK into StudioCMS
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [[`ee90810`](https://github.com/withstudiocms/studiocms/commit/ee9081053f808d4366a9c95e13539a5198b27bb5), [`a5b84c5`](https://github.com/withstudiocms/studiocms/commit/a5b84c52383bf299aa70c04b064850c7883b59b1), [`9a8bfed`](https://github.com/withstudiocms/studiocms/commit/9a8bfeda461dbc7e3188222db3adeffca1c29f6a), [`ba79740`](https://github.com/withstudiocms/studiocms/commit/ba797403563b8fbd381e0fc28f4ccba0ec6432a6), [`3c54788`](https://github.com/withstudiocms/studiocms/commit/3c54788df0bd548f1e3489b7c7334279ee85d5cb), [`1e1e6a1`](https://github.com/withstudiocms/studiocms/commit/1e1e6a1038de31bfe73070b4feb7163a3e7385a0), [`97c7847`](https://github.com/withstudiocms/studiocms/commit/97c7847c0cdd41998e0a6d8c61ab6f3c4ac4474e), [`675b7d5`](https://github.com/withstudiocms/studiocms/commit/675b7d5bbb2c40e6a204d3c7227812923e37289f)]:
|
|
38
|
+
- @withstudiocms/effect@0.1.0-beta.7
|
|
39
|
+
|
|
3
40
|
## 0.1.0-beta.6
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -33,7 +33,7 @@ class ComponentRegistry extends Effect.Service()("ComponentRegistry", {
|
|
|
33
33
|
const _getComponentProps = Effect.fn(function* (componentName) {
|
|
34
34
|
const component = components.get(componentName);
|
|
35
35
|
if (!component) {
|
|
36
|
-
return yield*
|
|
36
|
+
return yield* new ComponentNotFoundError({ componentName });
|
|
37
37
|
}
|
|
38
38
|
return component;
|
|
39
39
|
});
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { componentProps } from 'virtual:component-registry-internal-proxy';
|
|
2
2
|
import type { SSRResult } from 'astro';
|
|
3
|
+
import type { Transformer } from 'ultrahtml';
|
|
3
4
|
import type { SanitizeOptions } from 'ultrahtml/transformers/sanitize';
|
|
4
5
|
import type { ComponentRegistryEntry } from './types.js';
|
|
5
6
|
export * from './utils.js';
|
|
@@ -31,4 +32,4 @@ export declare function setupRendererComponentProxy(result: SSRResult): Promise<
|
|
|
31
32
|
* @param preRenderer - An optional function to preprocess the HTML content before rendering.
|
|
32
33
|
* @returns A function that takes HTML content as input and returns the transformed HTML.
|
|
33
34
|
*/
|
|
34
|
-
export declare function createRenderer(result: SSRResult, sanitizeOpts?: SanitizeOptions, preRenderer?: (content: string) => Promise<string
|
|
35
|
+
export declare function createRenderer(result: SSRResult, sanitizeOpts?: SanitizeOptions, preRenderer?: (content: string) => Promise<string>, transformers?: Transformer[]): Promise<(content: string) => Promise<string>>;
|
package/dist/runtime.js
CHANGED
|
@@ -28,7 +28,7 @@ async function setupRendererComponentProxy(result) {
|
|
|
28
28
|
const components = await getRendererComponents();
|
|
29
29
|
return createComponentProxy(result, components);
|
|
30
30
|
}
|
|
31
|
-
async function createRenderer(result, sanitizeOpts, preRenderer) {
|
|
31
|
+
async function createRenderer(result, sanitizeOpts, preRenderer, transformers) {
|
|
32
32
|
const components = await setupRendererComponentProxy(result);
|
|
33
33
|
return async (content) => {
|
|
34
34
|
let html;
|
|
@@ -37,7 +37,7 @@ async function createRenderer(result, sanitizeOpts, preRenderer) {
|
|
|
37
37
|
} else {
|
|
38
38
|
html = content;
|
|
39
39
|
}
|
|
40
|
-
return await transformHTML(html, components, sanitizeOpts);
|
|
40
|
+
return await transformHTML(html, components, sanitizeOpts, transformers);
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
export {
|
package/dist/transform-html.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Transformer } from 'ultrahtml';
|
|
1
2
|
import type { SanitizeOptions } from 'ultrahtml/transformers/sanitize';
|
|
2
3
|
import type { ComponentType } from './types.js';
|
|
3
4
|
/**
|
|
@@ -8,4 +9,4 @@ import type { ComponentType } from './types.js';
|
|
|
8
9
|
* @param sanitizeOpts - Optional sanitization options to be applied to the HTML.
|
|
9
10
|
* @returns A promise that resolves to the transformed HTML string.
|
|
10
11
|
*/
|
|
11
|
-
export declare function transformHTML(html: string, components: ComponentType, sanitizeOpts?: SanitizeOptions): Promise<string>;
|
|
12
|
+
export declare function transformHTML(html: string, components: ComponentType, sanitizeOpts?: SanitizeOptions, transformers?: Transformer[]): Promise<string>;
|
package/dist/transform-html.js
CHANGED
|
@@ -2,8 +2,16 @@ import { transform } from "ultrahtml";
|
|
|
2
2
|
import sanitize from "ultrahtml/transformers/sanitize";
|
|
3
3
|
import swap from "ultrahtml/transformers/swap";
|
|
4
4
|
import { dedent } from "./utils.js";
|
|
5
|
-
async function transformHTML(html, components, sanitizeOpts) {
|
|
6
|
-
|
|
5
|
+
async function transformHTML(html, components, sanitizeOpts = {}, transformers) {
|
|
6
|
+
const allTransformers = [
|
|
7
|
+
// We enable allowComponents and allowCustomElements to ensure that custom components are not stripped out during sanitization.
|
|
8
|
+
// This is important because the swap transformer relies on these elements being present to perform the component swapping.
|
|
9
|
+
// Users can still control other aspects of sanitization via the sanitizeOpts parameter.
|
|
10
|
+
sanitize({ ...sanitizeOpts, allowComponents: true, allowCustomElements: true }),
|
|
11
|
+
swap(components),
|
|
12
|
+
...transformers ?? []
|
|
13
|
+
];
|
|
14
|
+
return await transform(dedent(html), allTransformers);
|
|
7
15
|
}
|
|
8
16
|
export {
|
|
9
17
|
transformHTML
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Effect } from '@withstudiocms/effect';
|
|
2
2
|
import type { AstroIntegrationLogger } from 'astro';
|
|
3
|
+
import { ComponentRegistryError } from './errors.js';
|
|
3
4
|
/**
|
|
4
5
|
* Options for configuring the logger.
|
|
5
6
|
*
|
|
@@ -63,4 +64,4 @@ export declare function dedent(str: string): string;
|
|
|
63
64
|
* const resolveEffect = resolver('/components');
|
|
64
65
|
* const result = yield* resolveEffect((resolve) => resolve('Button'));
|
|
65
66
|
*/
|
|
66
|
-
export declare const resolver: (base: string) => Effect.Effect<(fn: (resolve: (...path: Array<string>) => string) => string) => Effect.Effect<string,
|
|
67
|
+
export declare const resolver: (base: string) => Effect.Effect<(fn: (resolve: (...path: Array<string>) => string) => string) => Effect.Effect<string, ComponentRegistryError, never>, never, never>;
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Effect } from "@withstudiocms/effect";
|
|
2
2
|
import { createResolver } from "astro-integration-kit";
|
|
3
|
+
import { ComponentRegistryError } from "./errors.js";
|
|
3
4
|
const integrationLogger = async (opts, message) => {
|
|
4
5
|
const { logLevel, logger, verbose = false } = opts;
|
|
5
6
|
switch (verbose) {
|
|
@@ -41,7 +42,7 @@ const resolver = Effect.fn(function* (base) {
|
|
|
41
42
|
try: () => fn(_resolve),
|
|
42
43
|
catch: (error) => {
|
|
43
44
|
console.error("Error occurred while resolving component:", error);
|
|
44
|
-
return new
|
|
45
|
+
return new ComponentRegistryError({ message: "Failed to resolve component", cause: error });
|
|
45
46
|
}
|
|
46
47
|
})
|
|
47
48
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@withstudiocms/component-registry",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Component Registry Utilities for Astro",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"astro-integration-kit": "^0.19.1",
|
|
73
73
|
"ts-morph": "^27.0.2",
|
|
74
74
|
"ultrahtml": "1.6.0",
|
|
75
|
-
"@withstudiocms/effect": "0.1.0
|
|
75
|
+
"@withstudiocms/effect": "0.1.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@types/node": "^22.0.0",
|
|
@@ -85,6 +85,8 @@
|
|
|
85
85
|
"build": "buildkit build 'src/**/*.{ts,d.ts}'",
|
|
86
86
|
"dev": "buildkit dev 'src/**/*.{ts,d.ts}'",
|
|
87
87
|
"test": "vitest",
|
|
88
|
+
"effect-check": "pnpm effect-language-service diagnostics --project tsconfig.tspc.json",
|
|
89
|
+
"ci:effect-check": "pnpm effect-check --format github-actions",
|
|
88
90
|
"typecheck": "tspc -p tsconfig.tspc.json"
|
|
89
91
|
}
|
|
90
92
|
}
|