@withstudiocms/component-registry 0.1.0-beta.7 → 0.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @withstudiocms/component-registry
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1186](https://github.com/withstudiocms/studiocms/pull/1186) [`415a512`](https://github.com/withstudiocms/studiocms/commit/415a51241ffddf5045ad8f8d695a5f40a86b5af7) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - fix workspace package dependency specifiers
8
+
9
+ ## 0.1.0
10
+
11
+ ### Patch Changes
12
+
13
+ - [#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
14
+
15
+ - [#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`).
16
+
17
+ - [#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
18
+
19
+ - [#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
20
+
21
+ - 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)]:
22
+ - @withstudiocms/effect@0.1.0
23
+
24
+ ## 0.1.0-beta.8
25
+
26
+ ### Patch Changes
27
+
28
+ - [#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
29
+
30
+ - [#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
31
+
32
+ - [#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
33
+
34
+ - 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)]:
35
+ - @withstudiocms/effect@0.1.0-beta.8
36
+
3
37
  ## 0.1.0-beta.7
4
38
 
5
39
  ### 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* Effect.fail(new ComponentNotFoundError({ componentName }));
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>): Promise<(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 {
@@ -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>;
@@ -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
- return await transform(dedent(html), [sanitize(sanitizeOpts), swap(components)]);
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, Error, never>, never, never>;
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 Error("Failed to resolve component", { cause: error });
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-beta.7",
3
+ "version": "0.1.1",
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-beta.7"
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
  }