@rededor/cura-hydrate 1.7.1 → 2.0.0-alpha.7

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.
Files changed (4) hide show
  1. package/index.d.ts +38 -7
  2. package/index.js +5376 -1417
  3. package/index.mjs +5375 -1416
  4. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -3,6 +3,18 @@
3
3
  import { Readable } from 'node:stream';
4
4
 
5
5
  export declare function createWindowFromHtml(templateHtml: string, uniqueId: string): any;
6
+ /**
7
+ * Serialize a value to a string that can be deserialized later.
8
+ * @param {unknown} value - The value to serialize.
9
+ * @returns {string} A string that can be deserialized later.
10
+ */
11
+ export declare function serializeProperty(value: unknown): string | number | boolean;
12
+ /**
13
+ * Deserialize a value from a string that was serialized earlier.
14
+ * @param {string} value - The string to deserialize.
15
+ * @returns {unknown} The deserialized value.
16
+ */
17
+ export declare function deserializeProperty(value: string): any;
6
18
  export type ResolutionHandler = (elm: HTMLElement) => string | undefined | null;
7
19
  export interface HydrateDocumentOptions {
8
20
  /**
@@ -95,6 +107,30 @@ export interface HydrateDocumentOptions {
95
107
  * Sets `navigator.userAgent`
96
108
  */
97
109
  userAgent?: string;
110
+ /**
111
+ * Configure how Stencil serializes the components shadow root.
112
+ * - If set to `declarative-shadow-dom` the component will be rendered within a Declarative Shadow DOM.
113
+ * - If set to `scoped` Stencil will render the contents of the shadow root as a `scoped: true` component
114
+ * and the shadow DOM will be created during client-side hydration.
115
+ * - Alternatively you can mix and match the two by providing an object with `declarative-shadow-dom` and `scoped` keys,
116
+ * the value arrays containing the tag names of the components that should be rendered in that mode.
117
+ *
118
+ * Examples:
119
+ * - `{ 'declarative-shadow-dom': ['my-component-1', 'another-component'], default: 'scoped' }`
120
+ * Render all components as `scoped` apart from `my-component-1` and `another-component`
121
+ * - `{ 'scoped': ['an-option-component'], default: 'declarative-shadow-dom' }`
122
+ * Render all components within `declarative-shadow-dom` apart from `an-option-component`
123
+ * - `'scoped'` Render all components as `scoped`
124
+ * - `false` disables shadow root serialization
125
+ *
126
+ * *NOTE* `true` has been deprecated in favor of `declarative-shadow-dom` and `scoped`
127
+ * @default 'declarative-shadow-dom'
128
+ */
129
+ serializeShadowRoot?: "declarative-shadow-dom" | "scoped" | {
130
+ "declarative-shadow-dom"?: string[];
131
+ scoped?: string[];
132
+ default: "declarative-shadow-dom" | "scoped";
133
+ } | boolean;
98
134
  }
99
135
  export interface SerializeDocumentOptions extends HydrateDocumentOptions {
100
136
  /**
@@ -137,13 +173,6 @@ export interface SerializeDocumentOptions extends HydrateDocumentOptions {
137
173
  * Remove HTML comments. Defaults to `true`.
138
174
  */
139
175
  removeHtmlComments?: boolean;
140
- /**
141
- * If set to `true` the component will be rendered within a Declarative Shadow DOM.
142
- * If set to `false` Stencil will ignore the contents of the shadow root and render the
143
- * element as given in provided template.
144
- * @default true
145
- */
146
- serializeShadowRoot?: boolean;
147
176
  /**
148
177
  * The `fullDocument` flag determines the format of the rendered output. Set it to true to
149
178
  * generate a complete HTML document, or false to render only the component.
@@ -225,7 +254,9 @@ export interface HydrateScriptElement extends HydrateElement {
225
254
  type?: string;
226
255
  }
227
256
  export interface HydrateStyleElement extends HydrateElement {
257
+ id?: string;
228
258
  href?: string;
259
+ content?: string;
229
260
  }
230
261
  export interface HydrateStaticData {
231
262
  id: string;