@coherent.js/core 1.0.0-rc.2 → 1.0.0-rc.4
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 +13 -20
- package/dist/index.cjs +10 -0
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +10 -0
- package/dist/index.js.map +2 -2
- package/package.json +1 -2
- package/types/index.d.ts +0 -151
package/README.md
CHANGED
|
@@ -27,9 +27,9 @@ Requirements:
|
|
|
27
27
|
|
|
28
28
|
JavaScript (ESM):
|
|
29
29
|
```js
|
|
30
|
-
import {
|
|
30
|
+
import { render } from '@coherent.js/core';
|
|
31
31
|
|
|
32
|
-
const html =
|
|
32
|
+
const html = render({
|
|
33
33
|
div: { class: 'greeting', text: 'Hello Coherent' }
|
|
34
34
|
});
|
|
35
35
|
|
|
@@ -38,28 +38,21 @@ console.log(html);
|
|
|
38
38
|
|
|
39
39
|
TypeScript:
|
|
40
40
|
```ts
|
|
41
|
-
import {
|
|
41
|
+
import { render } from '@coherent.js/core';
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
console.log(html);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
main();
|
|
43
|
+
const html = render({
|
|
44
|
+
div: { class: 'greeting', text: 'Hello Coherent (TS)' }
|
|
45
|
+
});
|
|
46
|
+
console.log(html);
|
|
51
47
|
```
|
|
52
48
|
|
|
53
49
|
## Exports overview
|
|
54
50
|
|
|
55
|
-
The package
|
|
51
|
+
The package ships built ESM and CJS bundles under `dist/` with types under `types/`.
|
|
56
52
|
|
|
57
53
|
Key APIs (selected):
|
|
58
54
|
- Rendering
|
|
59
|
-
- `
|
|
60
|
-
- `render(input)` (alias of `renderToString`)
|
|
61
|
-
- `renderScopedComponent(input)` – applies scoped attributes and style processing
|
|
62
|
-
- `renderUnsafe(input)` – render without encapsulation
|
|
55
|
+
- `render(input, options?)` – renders a component object to an HTML string
|
|
63
56
|
- Component system (re-exported from internal modules)
|
|
64
57
|
- `createComponent`, `defineComponent`, `registerComponent`, `getComponent`, `getRegisteredComponents`
|
|
65
58
|
- State helpers: `withState`, `withStateUtils`, `createStateManager`
|
|
@@ -73,7 +66,7 @@ Tip: When working in the monorepo website/dev flow, imports can resolve to `src`
|
|
|
73
66
|
## Minimal component example
|
|
74
67
|
|
|
75
68
|
```js
|
|
76
|
-
import { createComponent,
|
|
69
|
+
import { createComponent, render } from '@coherent.js/core';
|
|
77
70
|
|
|
78
71
|
const Counter = createComponent(({ count = 0 }) => ({
|
|
79
72
|
div: {
|
|
@@ -84,12 +77,12 @@ const Counter = createComponent(({ count = 0 }) => ({
|
|
|
84
77
|
}
|
|
85
78
|
}));
|
|
86
79
|
|
|
87
|
-
const html =
|
|
80
|
+
const html = render(Counter({ count: 2 }));
|
|
88
81
|
```
|
|
89
82
|
|
|
90
83
|
TypeScript:
|
|
91
84
|
```ts
|
|
92
|
-
import { createComponent,
|
|
85
|
+
import { createComponent, render } from '@coherent.js/core';
|
|
93
86
|
|
|
94
87
|
type Props = { count?: number };
|
|
95
88
|
|
|
@@ -100,7 +93,7 @@ const Counter = createComponent((props: Props) => ({
|
|
|
100
93
|
}
|
|
101
94
|
}));
|
|
102
95
|
|
|
103
|
-
const html =
|
|
96
|
+
const html = render(Counter({ count: 2 }));
|
|
104
97
|
```
|
|
105
98
|
|
|
106
99
|
## Development
|
package/dist/index.cjs
CHANGED
|
@@ -2190,6 +2190,16 @@ var HTMLRenderer = class extends BaseRenderer {
|
|
|
2190
2190
|
const { children, text, key: _key, html: _rawHtml, ...attributes } = element || {};
|
|
2191
2191
|
const attributeString = formatAttributes(attributes);
|
|
2192
2192
|
const openingTag = attributeString ? `<${tagName} ${attributeString}>` : `<${tagName}>`;
|
|
2193
|
+
if (isVoidElement(tagName)) {
|
|
2194
|
+
if (options.enableCache && this.cache && RendererUtils.isCacheable(element, options)) {
|
|
2195
|
+
const cacheKey = RendererUtils.generateCacheKey(tagName, element);
|
|
2196
|
+
if (cacheKey) {
|
|
2197
|
+
this.cache.set(cacheKey, openingTag);
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
this.recordPerformance(tagName, startTime, false);
|
|
2201
|
+
return openingTag;
|
|
2202
|
+
}
|
|
2193
2203
|
if (_rawHtml !== void 0) {
|
|
2194
2204
|
const rawContent = typeof _rawHtml === "function" ? String(_rawHtml()) : String(_rawHtml);
|
|
2195
2205
|
const result = `${openingTag}${rawContent}</${tagName}>`;
|