@aerogel/core 0.1.0 → 0.1.1-next.d86959f8ee7dcf2194447eb424c1095912a5e5f8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aerogel/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-next.d86959f8ee7dcf2194447eb424c1095912a5e5f8",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -3,22 +3,26 @@ import type { Directive } from 'vue';
3
3
  import { definePlugin } from '@aerogel/core/plugins';
4
4
 
5
5
  import measure from './measure';
6
+ import safeHtml from './safe-html';
6
7
 
7
- const builtInDirectives: Record<string, Directive> = {
8
- measure: measure,
9
- };
8
+ export const aerogelDirectives = {
9
+ 'measure': measure,
10
+ 'safe-html': safeHtml,
11
+ } as const satisfies Record<string, Directive>;
12
+
13
+ export type AerogelDirectives = typeof aerogelDirectives;
10
14
 
11
15
  export * from './measure';
12
16
 
13
17
  export default definePlugin({
14
18
  install(app, options) {
15
19
  const directives = {
16
- ...builtInDirectives,
20
+ ...aerogelDirectives,
17
21
  ...options.directives,
18
22
  };
19
23
 
20
24
  for (const [name, directive] of Object.entries(directives)) {
21
- app.directive(name, directive);
25
+ app.directive(name, directive as Directive);
22
26
  }
23
27
  },
24
28
  });
@@ -30,7 +34,5 @@ declare module '@aerogel/core/bootstrap/options' {
30
34
  }
31
35
 
32
36
  declare module 'vue' {
33
- interface ComponentCustomDirectives {
34
- measure: Directive<string, string>;
35
- }
37
+ interface ComponentCustomDirectives extends AerogelDirectives {}
36
38
  }
@@ -0,0 +1,10 @@
1
+ import { safeHtml } from '@aerogel/core/utils';
2
+ import { defineDirective } from '@aerogel/core/utils/vue';
3
+
4
+ export type SafeHTMLDirectiveValue = string;
5
+
6
+ export default defineDirective<SafeHTMLDirectiveValue>({
7
+ mounted(element: HTMLElement, { value }) {
8
+ element.innerHTML = safeHtml(value);
9
+ },
10
+ });