@coherent.js/core 1.0.0-beta.6 → 1.0.0-beta.8
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/dist/coherent.d.ts +150 -10
- package/dist/coherent.d.ts.map +1 -1
- package/dist/coherent.js +166 -33
- package/dist/coherent.js.map +1 -1
- package/dist/components/component-system.js +109 -109
- package/dist/components/lifecycle.d.ts +212 -0
- package/dist/components/lifecycle.d.ts.map +1 -0
- package/dist/components/lifecycle.js +525 -0
- package/dist/components/lifecycle.js.map +1 -0
- package/dist/core/html-utils.js +5 -5
- package/dist/core/object-factory.js +21 -21
- package/dist/core/object-utils.js +2 -2
- package/dist/dev/dev-tools.d.ts +1 -1
- package/dist/dev/dev-tools.js +28 -28
- package/dist/forms/validation.d.ts +271 -0
- package/dist/forms/validation.d.ts.map +1 -0
- package/dist/forms/validation.js +573 -0
- package/dist/forms/validation.js.map +1 -0
- package/dist/index.cjs +185 -28
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +181 -29
- package/dist/index.js.map +4 -4
- package/dist/performance/bundle-optimizer.js +11 -11
- package/dist/performance/cache-manager.js +6 -6
- package/dist/performance/component-cache.d.ts +120 -0
- package/dist/performance/component-cache.d.ts.map +1 -0
- package/dist/performance/component-cache.js +364 -0
- package/dist/performance/component-cache.js.map +1 -0
- package/dist/performance/monitor.js +10 -10
- package/dist/performance/monitor.js.map +1 -1
- package/dist/rendering/base-renderer.js +13 -13
- package/dist/rendering/css-manager.d.ts +73 -0
- package/dist/rendering/css-manager.d.ts.map +1 -0
- package/dist/rendering/css-manager.js +176 -0
- package/dist/rendering/css-manager.js.map +1 -0
- package/dist/rendering/dom-renderer.d.ts +23 -0
- package/dist/rendering/dom-renderer.d.ts.map +1 -1
- package/dist/rendering/dom-renderer.js +77 -9
- package/dist/rendering/dom-renderer.js.map +1 -1
- package/dist/rendering/html-renderer.d.ts +15 -0
- package/dist/rendering/html-renderer.d.ts.map +1 -1
- package/dist/rendering/html-renderer.js +85 -4
- package/dist/rendering/html-renderer.js.map +1 -1
- package/dist/rendering/streaming-renderer.js +12 -12
- package/dist/rendering/vdom-diff.d.ts +47 -0
- package/dist/rendering/vdom-diff.d.ts.map +1 -0
- package/dist/rendering/vdom-diff.js +416 -0
- package/dist/rendering/vdom-diff.js.map +1 -0
- package/dist/routing/router.d.ts +241 -0
- package/dist/routing/router.d.ts.map +1 -0
- package/dist/routing/router.js +648 -0
- package/dist/routing/router.js.map +1 -0
- package/dist/state/reactive-state.d.ts +166 -0
- package/dist/state/reactive-state.d.ts.map +1 -0
- package/dist/state/reactive-state.js +546 -0
- package/dist/state/reactive-state.js.map +1 -0
- package/dist/utils/dependency-utils.js +2 -2
- package/dist/utils/error-handler.d.ts +148 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +468 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/normalization.js +1 -1
- package/dist/utils/validation.js +1 -1
- package/package.json +5 -1
- package/dist/database/adapters/mongodb.d.ts +0 -15
- package/dist/database/adapters/mongodb.d.ts.map +0 -1
- package/dist/database/adapters/mongodb.js +0 -216
- package/dist/database/adapters/mongodb.js.map +0 -1
- package/dist/database/adapters/mysql.d.ts +0 -12
- package/dist/database/adapters/mysql.d.ts.map +0 -1
- package/dist/database/adapters/mysql.js +0 -171
- package/dist/database/adapters/mysql.js.map +0 -1
- package/dist/database/adapters/postgresql.d.ts +0 -12
- package/dist/database/adapters/postgresql.d.ts.map +0 -1
- package/dist/database/adapters/postgresql.js +0 -177
- package/dist/database/adapters/postgresql.js.map +0 -1
- package/dist/database/adapters/sqlite.d.ts +0 -15
- package/dist/database/adapters/sqlite.d.ts.map +0 -1
- package/dist/database/adapters/sqlite.js +0 -241
- package/dist/database/adapters/sqlite.js.map +0 -1
- package/dist/database/connection-manager.d.ts +0 -135
- package/dist/database/connection-manager.d.ts.map +0 -1
- package/dist/database/connection-manager.js +0 -362
- package/dist/database/connection-manager.js.map +0 -1
- package/dist/database/index.d.ts +0 -38
- package/dist/database/index.d.ts.map +0 -1
- package/dist/database/index.js +0 -60
- package/dist/database/index.js.map +0 -1
- package/dist/database/middleware.d.ts +0 -122
- package/dist/database/middleware.d.ts.map +0 -1
- package/dist/database/middleware.js +0 -390
- package/dist/database/middleware.js.map +0 -1
- package/dist/database/migration.d.ts +0 -62
- package/dist/database/migration.d.ts.map +0 -1
- package/dist/database/migration.js +0 -423
- package/dist/database/migration.js.map +0 -1
- package/dist/database/model.d.ts +0 -8
- package/dist/database/model.d.ts.map +0 -1
- package/dist/database/model.js +0 -167
- package/dist/database/model.js.map +0 -1
- package/dist/database/query-builder.d.ts +0 -111
- package/dist/database/query-builder.d.ts.map +0 -1
- package/dist/database/query-builder.js +0 -187
- package/dist/database/query-builder.js.map +0 -1
- package/dist/database/utils.d.ts +0 -196
- package/dist/database/utils.d.ts.map +0 -1
- package/dist/database/utils.js +0 -372
- package/dist/database/utils.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -27,9 +27,11 @@ __export(index_exports, {
|
|
|
27
27
|
FORBIDDEN_CHILDREN: () => FORBIDDEN_CHILDREN,
|
|
28
28
|
GlobalErrorHandler: () => GlobalErrorHandler,
|
|
29
29
|
HTMLNestingError: () => HTMLNestingError,
|
|
30
|
+
Island: () => Island,
|
|
30
31
|
LIFECYCLE_PHASES: () => LIFECYCLE_PHASES,
|
|
31
32
|
VERSION: () => VERSION,
|
|
32
33
|
checkPeerDependencies: () => checkPeerDependencies,
|
|
34
|
+
compose: () => compose,
|
|
33
35
|
createActionHandlers: () => createActionHandlers,
|
|
34
36
|
createAsyncErrorBoundary: () => createAsyncErrorBoundary,
|
|
35
37
|
createComponent: () => createComponent,
|
|
@@ -54,6 +56,7 @@ __export(index_exports, {
|
|
|
54
56
|
emitSync: () => emitSync,
|
|
55
57
|
evaluateLazy: () => evaluateLazy,
|
|
56
58
|
eventSystem: () => events_default,
|
|
59
|
+
fp: () => fp,
|
|
57
60
|
getComponent: () => getComponent,
|
|
58
61
|
getRegisteredComponents: () => getRegisteredComponents,
|
|
59
62
|
globalDOMIntegration: () => globalDOMIntegration,
|
|
@@ -61,6 +64,7 @@ __export(index_exports, {
|
|
|
61
64
|
h: () => h,
|
|
62
65
|
handleAction: () => handleAction,
|
|
63
66
|
hasChildren: () => hasChildren,
|
|
67
|
+
hoc: () => hoc,
|
|
64
68
|
importPeerDependency: () => importPeerDependency,
|
|
65
69
|
initializeDOMIntegration: () => initializeDOMIntegration,
|
|
66
70
|
isCoherentComponent: () => isCoherentComponent,
|
|
@@ -94,7 +98,6 @@ __export(index_exports, {
|
|
|
94
98
|
withStateUtils: () => withStateUtils
|
|
95
99
|
});
|
|
96
100
|
module.exports = __toCommonJS(index_exports);
|
|
97
|
-
var import_node_fs = require("node:fs");
|
|
98
101
|
|
|
99
102
|
// src/performance/monitor.js
|
|
100
103
|
function createPerformanceMonitor(options = {}) {
|
|
@@ -547,6 +550,23 @@ function createPerformanceMonitor(options = {}) {
|
|
|
547
550
|
startReporting();
|
|
548
551
|
startProfiling();
|
|
549
552
|
}
|
|
553
|
+
let _renderCounter = 0;
|
|
554
|
+
const _renderTimers = /* @__PURE__ */ new Map();
|
|
555
|
+
function startRender() {
|
|
556
|
+
const id = `render_${++_renderCounter}`;
|
|
557
|
+
_renderTimers.set(id, performance.now());
|
|
558
|
+
return id;
|
|
559
|
+
}
|
|
560
|
+
function endRender(id) {
|
|
561
|
+
const startTime = _renderTimers.get(id);
|
|
562
|
+
if (startTime !== void 0) {
|
|
563
|
+
const duration = performance.now() - startTime;
|
|
564
|
+
_renderTimers.delete(id);
|
|
565
|
+
recordMetric("render", duration);
|
|
566
|
+
return duration;
|
|
567
|
+
}
|
|
568
|
+
return 0;
|
|
569
|
+
}
|
|
550
570
|
return {
|
|
551
571
|
recordMetric,
|
|
552
572
|
measure,
|
|
@@ -556,6 +576,8 @@ function createPerformanceMonitor(options = {}) {
|
|
|
556
576
|
generateReport,
|
|
557
577
|
getStats,
|
|
558
578
|
reset,
|
|
579
|
+
startRender,
|
|
580
|
+
endRender,
|
|
559
581
|
start() {
|
|
560
582
|
opts.enabled = true;
|
|
561
583
|
startResourceMonitoring();
|
|
@@ -1276,7 +1298,13 @@ function formatAttributes(props) {
|
|
|
1276
1298
|
}
|
|
1277
1299
|
}
|
|
1278
1300
|
}
|
|
1279
|
-
if (value ===
|
|
1301
|
+
if (attributeName === "style" && typeof value === "object" && value !== null) {
|
|
1302
|
+
const cssString = Object.entries(value).map(([prop, val]) => {
|
|
1303
|
+
const kebabProp = prop.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
1304
|
+
return `${kebabProp}: ${val}`;
|
|
1305
|
+
}).join("; ");
|
|
1306
|
+
formatted += ` ${attributeName}="${escapeHtml(cssString)}"`;
|
|
1307
|
+
} else if (value === true) {
|
|
1280
1308
|
formatted += ` ${attributeName}`;
|
|
1281
1309
|
} else if (value !== false && value !== null && value !== void 0) {
|
|
1282
1310
|
formatted += ` ${attributeName}="${escapeHtml(String(value))}"`;
|
|
@@ -1497,6 +1525,9 @@ function createCacheManager(options = {}) {
|
|
|
1497
1525
|
}
|
|
1498
1526
|
clear();
|
|
1499
1527
|
}
|
|
1528
|
+
function hashObject(obj) {
|
|
1529
|
+
return simpleHash(JSON.stringify(obj));
|
|
1530
|
+
}
|
|
1500
1531
|
return {
|
|
1501
1532
|
get,
|
|
1502
1533
|
set,
|
|
@@ -1506,6 +1537,7 @@ function createCacheManager(options = {}) {
|
|
|
1506
1537
|
cleanup,
|
|
1507
1538
|
destroy,
|
|
1508
1539
|
generateCacheKey,
|
|
1540
|
+
hashObject,
|
|
1509
1541
|
get memoryUsage() {
|
|
1510
1542
|
return memoryUsage;
|
|
1511
1543
|
},
|
|
@@ -2158,6 +2190,11 @@ var HTMLRenderer = class extends BaseRenderer {
|
|
|
2158
2190
|
const { children, text, key: _key, html: _rawHtml, ...attributes } = element || {};
|
|
2159
2191
|
const attributeString = formatAttributes(attributes);
|
|
2160
2192
|
const openingTag = attributeString ? `<${tagName} ${attributeString}>` : `<${tagName}>`;
|
|
2193
|
+
if (_rawHtml !== void 0) {
|
|
2194
|
+
const rawContent = typeof _rawHtml === "function" ? String(_rawHtml()) : String(_rawHtml);
|
|
2195
|
+
const result = `${openingTag}${rawContent}</${tagName}>`;
|
|
2196
|
+
return result;
|
|
2197
|
+
}
|
|
2161
2198
|
let textContent = "";
|
|
2162
2199
|
if (text !== void 0) {
|
|
2163
2200
|
const isScript = tagName === "script";
|
|
@@ -5087,7 +5124,7 @@ var EventBus = class {
|
|
|
5087
5124
|
}
|
|
5088
5125
|
}
|
|
5089
5126
|
/**
|
|
5090
|
-
* Emit
|
|
5127
|
+
* Emit throttled event
|
|
5091
5128
|
*/
|
|
5092
5129
|
emitThrottled(event, data, delay) {
|
|
5093
5130
|
if (!this.throttledEmitters.has(event)) {
|
|
@@ -5111,7 +5148,7 @@ var EventBus = class {
|
|
|
5111
5148
|
}
|
|
5112
5149
|
}
|
|
5113
5150
|
/**
|
|
5114
|
-
* Flush
|
|
5151
|
+
* Flush batched events
|
|
5115
5152
|
*/
|
|
5116
5153
|
async flushBatch() {
|
|
5117
5154
|
if (this.batchTimer) {
|
|
@@ -5249,7 +5286,7 @@ var EventBus = class {
|
|
|
5249
5286
|
}
|
|
5250
5287
|
}
|
|
5251
5288
|
/**
|
|
5252
|
-
* Run middleware
|
|
5289
|
+
* Run middleware
|
|
5253
5290
|
*/
|
|
5254
5291
|
async runMiddleware(event, data) {
|
|
5255
5292
|
if (this.middleware.length === 0) return;
|
|
@@ -5449,7 +5486,6 @@ var DOMEventIntegration = class {
|
|
|
5449
5486
|
}
|
|
5450
5487
|
/**
|
|
5451
5488
|
* Set up delegated DOM event listeners
|
|
5452
|
-
* @private
|
|
5453
5489
|
*/
|
|
5454
5490
|
setupDOMEventListeners() {
|
|
5455
5491
|
const clickHandler = this.createDelegatedHandler("click", this.handleClick);
|
|
@@ -5476,7 +5512,6 @@ var DOMEventIntegration = class {
|
|
|
5476
5512
|
}
|
|
5477
5513
|
/**
|
|
5478
5514
|
* Create a delegated event handler
|
|
5479
|
-
* @private
|
|
5480
5515
|
*/
|
|
5481
5516
|
createDelegatedHandler(eventType, handler) {
|
|
5482
5517
|
return (event) => {
|
|
@@ -5492,7 +5527,6 @@ var DOMEventIntegration = class {
|
|
|
5492
5527
|
}
|
|
5493
5528
|
/**
|
|
5494
5529
|
* Handle click events
|
|
5495
|
-
* @private
|
|
5496
5530
|
*/
|
|
5497
5531
|
handleClick(element, event) {
|
|
5498
5532
|
const action = element.getAttribute?.("data-action");
|
|
@@ -5508,7 +5542,6 @@ var DOMEventIntegration = class {
|
|
|
5508
5542
|
}
|
|
5509
5543
|
/**
|
|
5510
5544
|
* Handle change events
|
|
5511
|
-
* @private
|
|
5512
5545
|
*/
|
|
5513
5546
|
handleChange(element, event) {
|
|
5514
5547
|
const action = element.getAttribute?.("data-action");
|
|
@@ -5525,7 +5558,6 @@ var DOMEventIntegration = class {
|
|
|
5525
5558
|
}
|
|
5526
5559
|
/**
|
|
5527
5560
|
* Handle input events
|
|
5528
|
-
* @private
|
|
5529
5561
|
*/
|
|
5530
5562
|
handleInput(element, event) {
|
|
5531
5563
|
const action = element.getAttribute?.("data-action");
|
|
@@ -5542,7 +5574,6 @@ var DOMEventIntegration = class {
|
|
|
5542
5574
|
}
|
|
5543
5575
|
/**
|
|
5544
5576
|
* Handle submit events
|
|
5545
|
-
* @private
|
|
5546
5577
|
*/
|
|
5547
5578
|
handleSubmit(element, event) {
|
|
5548
5579
|
const action = element.getAttribute?.("data-action");
|
|
@@ -5560,7 +5591,6 @@ var DOMEventIntegration = class {
|
|
|
5560
5591
|
}
|
|
5561
5592
|
/**
|
|
5562
5593
|
* Handle keydown events
|
|
5563
|
-
* @private
|
|
5564
5594
|
*/
|
|
5565
5595
|
handleKeydown(element, event) {
|
|
5566
5596
|
const action = element.getAttribute?.("data-action");
|
|
@@ -5583,7 +5613,6 @@ var DOMEventIntegration = class {
|
|
|
5583
5613
|
}
|
|
5584
5614
|
/**
|
|
5585
5615
|
* Handle focus events
|
|
5586
|
-
* @private
|
|
5587
5616
|
*/
|
|
5588
5617
|
handleFocus(element, event) {
|
|
5589
5618
|
this.activeElement = element;
|
|
@@ -5595,7 +5624,6 @@ var DOMEventIntegration = class {
|
|
|
5595
5624
|
}
|
|
5596
5625
|
/**
|
|
5597
5626
|
* Handle blur events
|
|
5598
|
-
* @private
|
|
5599
5627
|
*/
|
|
5600
5628
|
handleBlur(element, event) {
|
|
5601
5629
|
if (this.activeElement === element) {
|
|
@@ -5609,7 +5637,6 @@ var DOMEventIntegration = class {
|
|
|
5609
5637
|
}
|
|
5610
5638
|
/**
|
|
5611
5639
|
* Handle data-action attributes
|
|
5612
|
-
* @private
|
|
5613
5640
|
*/
|
|
5614
5641
|
handleDataAction(element, event, action) {
|
|
5615
5642
|
if (!action) return;
|
|
@@ -5631,7 +5658,6 @@ var DOMEventIntegration = class {
|
|
|
5631
5658
|
}
|
|
5632
5659
|
/**
|
|
5633
5660
|
* Parse data attributes from an element
|
|
5634
|
-
* @private
|
|
5635
5661
|
*/
|
|
5636
5662
|
parseDataAttributes(element) {
|
|
5637
5663
|
if (!element?.attributes) return {};
|
|
@@ -5659,7 +5685,6 @@ var DOMEventIntegration = class {
|
|
|
5659
5685
|
}
|
|
5660
5686
|
/**
|
|
5661
5687
|
* Extract form data from a form element
|
|
5662
|
-
* @private
|
|
5663
5688
|
*/
|
|
5664
5689
|
extractFormData(formElement) {
|
|
5665
5690
|
if (!formElement || formElement.tagName !== "FORM") {
|
|
@@ -5682,7 +5707,6 @@ var DOMEventIntegration = class {
|
|
|
5682
5707
|
}
|
|
5683
5708
|
/**
|
|
5684
5709
|
* Check if a key event should trigger an action
|
|
5685
|
-
* @private
|
|
5686
5710
|
*/
|
|
5687
5711
|
shouldTriggerKeyAction(event) {
|
|
5688
5712
|
const triggerKeys = ["Enter", "Space", "Escape"];
|
|
@@ -5690,7 +5714,6 @@ var DOMEventIntegration = class {
|
|
|
5690
5714
|
}
|
|
5691
5715
|
/**
|
|
5692
5716
|
* Debounce utility function
|
|
5693
|
-
* @private
|
|
5694
5717
|
*/
|
|
5695
5718
|
debounce(func, wait) {
|
|
5696
5719
|
let timeout;
|
|
@@ -5705,7 +5728,6 @@ var DOMEventIntegration = class {
|
|
|
5705
5728
|
}
|
|
5706
5729
|
/**
|
|
5707
5730
|
* Throttle utility function
|
|
5708
|
-
* @private
|
|
5709
5731
|
*/
|
|
5710
5732
|
throttle(func, limit) {
|
|
5711
5733
|
let inThrottle;
|
|
@@ -6220,8 +6242,98 @@ var eventSystem2 = {
|
|
|
6220
6242
|
};
|
|
6221
6243
|
var events_default = eventSystem2;
|
|
6222
6244
|
|
|
6245
|
+
// src/components/enhanced-composition.js
|
|
6246
|
+
var hoc = {
|
|
6247
|
+
/**
|
|
6248
|
+
* Wrap component with additional props
|
|
6249
|
+
*/
|
|
6250
|
+
withProps(additionalProps) {
|
|
6251
|
+
return (Component2) => (props) => {
|
|
6252
|
+
return Component2({ ...props, ...additionalProps });
|
|
6253
|
+
};
|
|
6254
|
+
},
|
|
6255
|
+
/**
|
|
6256
|
+
* Conditional rendering HOC
|
|
6257
|
+
*/
|
|
6258
|
+
withCondition(condition) {
|
|
6259
|
+
return (Component2) => (props) => {
|
|
6260
|
+
return condition(props) ? Component2(props) : null;
|
|
6261
|
+
};
|
|
6262
|
+
},
|
|
6263
|
+
/**
|
|
6264
|
+
* Loading state HOC
|
|
6265
|
+
*/
|
|
6266
|
+
withLoading(loadingComponent) {
|
|
6267
|
+
return (Component2) => (props) => {
|
|
6268
|
+
return props.loading ? loadingComponent(props) : Component2(props);
|
|
6269
|
+
};
|
|
6270
|
+
},
|
|
6271
|
+
/**
|
|
6272
|
+
* Error boundary HOC
|
|
6273
|
+
*/
|
|
6274
|
+
withError(errorComponent) {
|
|
6275
|
+
return (Component2) => (props) => {
|
|
6276
|
+
try {
|
|
6277
|
+
return Component2(props);
|
|
6278
|
+
} catch (error) {
|
|
6279
|
+
return errorComponent({ error, ...props });
|
|
6280
|
+
}
|
|
6281
|
+
};
|
|
6282
|
+
},
|
|
6283
|
+
/**
|
|
6284
|
+
* Memoization HOC
|
|
6285
|
+
*/
|
|
6286
|
+
withMemo(getMemoKey) {
|
|
6287
|
+
const cache = /* @__PURE__ */ new Map();
|
|
6288
|
+
return (Component2) => (props) => {
|
|
6289
|
+
const key = getMemoKey ? getMemoKey(props) : JSON.stringify(props);
|
|
6290
|
+
if (cache.has(key)) {
|
|
6291
|
+
return cache.get(key);
|
|
6292
|
+
}
|
|
6293
|
+
const result = Component2(props);
|
|
6294
|
+
cache.set(key, result);
|
|
6295
|
+
return result;
|
|
6296
|
+
};
|
|
6297
|
+
}
|
|
6298
|
+
};
|
|
6299
|
+
var compose = {
|
|
6300
|
+
/**
|
|
6301
|
+
* Combine multiple components into one
|
|
6302
|
+
*/
|
|
6303
|
+
combine(...components) {
|
|
6304
|
+
return (props) => ({
|
|
6305
|
+
fragment: {
|
|
6306
|
+
children: components.map((Component2) => Component2(props))
|
|
6307
|
+
}
|
|
6308
|
+
});
|
|
6309
|
+
},
|
|
6310
|
+
/**
|
|
6311
|
+
* Pipe components through transformations
|
|
6312
|
+
*/
|
|
6313
|
+
pipe(...transformers) {
|
|
6314
|
+
return (Component2) => {
|
|
6315
|
+
return transformers.reduce((acc, transformer) => transformer(acc), Component2);
|
|
6316
|
+
};
|
|
6317
|
+
},
|
|
6318
|
+
/**
|
|
6319
|
+
* Branch based on conditions
|
|
6320
|
+
*/
|
|
6321
|
+
branch(condition, leftComponent, rightComponent) {
|
|
6322
|
+
return (props) => {
|
|
6323
|
+
return condition(props) ? leftComponent(props) : rightComponent(props);
|
|
6324
|
+
};
|
|
6325
|
+
},
|
|
6326
|
+
/**
|
|
6327
|
+
* Render component or fallback
|
|
6328
|
+
*/
|
|
6329
|
+
maybe(Component2, fallback = null) {
|
|
6330
|
+
return (props) => {
|
|
6331
|
+
return Component2 ? Component2(props) : fallback;
|
|
6332
|
+
};
|
|
6333
|
+
}
|
|
6334
|
+
};
|
|
6335
|
+
|
|
6223
6336
|
// src/index.js
|
|
6224
|
-
var import_meta = {};
|
|
6225
6337
|
var scopeCounter = { value: 0 };
|
|
6226
6338
|
function generateScopeId() {
|
|
6227
6339
|
return `coh-${scopeCounter.value++}`;
|
|
@@ -6275,10 +6387,46 @@ function dangerouslySetInnerContent(content) {
|
|
|
6275
6387
|
__trusted: true
|
|
6276
6388
|
};
|
|
6277
6389
|
}
|
|
6390
|
+
function injectHydrationAttributes(component, options) {
|
|
6391
|
+
if (!component || typeof component !== "object" || Array.isArray(component)) {
|
|
6392
|
+
return component;
|
|
6393
|
+
}
|
|
6394
|
+
const tagName = Object.keys(component)[0];
|
|
6395
|
+
if (!tagName) return component;
|
|
6396
|
+
const props = component[tagName];
|
|
6397
|
+
if (typeof props !== "object" || props === null) return component;
|
|
6398
|
+
const injected = { ...props };
|
|
6399
|
+
if (options.hydratable) {
|
|
6400
|
+
injected["data-hydratable"] = "true";
|
|
6401
|
+
}
|
|
6402
|
+
if (options.island) {
|
|
6403
|
+
injected["data-coherent-island"] = "true";
|
|
6404
|
+
}
|
|
6405
|
+
if (options._islandComponentName) {
|
|
6406
|
+
injected["data-coherent-island-component"] = options._islandComponentName;
|
|
6407
|
+
}
|
|
6408
|
+
return { [tagName]: injected };
|
|
6409
|
+
}
|
|
6410
|
+
function Island(componentFn) {
|
|
6411
|
+
const componentName = componentFn.name || "Anonymous";
|
|
6412
|
+
return function IslandComponent(props) {
|
|
6413
|
+
const result = componentFn(props);
|
|
6414
|
+
return injectHydrationAttributes(result, {
|
|
6415
|
+
island: true,
|
|
6416
|
+
_islandComponentName: componentName
|
|
6417
|
+
});
|
|
6418
|
+
};
|
|
6419
|
+
}
|
|
6278
6420
|
function render2(obj, options = {}) {
|
|
6279
6421
|
const scoped = options.scoped ?? options.encapsulate ?? false;
|
|
6280
|
-
const { scoped: _scoped, encapsulate: _encapsulate, ...rendererOptions } = options;
|
|
6281
|
-
|
|
6422
|
+
const { scoped: _scoped, encapsulate: _encapsulate, hydratable: _hydratable, island: _island, ...rendererOptions } = options;
|
|
6423
|
+
let component = scoped ? renderScopedComponent(obj) : obj;
|
|
6424
|
+
if (typeof component === "function") {
|
|
6425
|
+
component = component(options);
|
|
6426
|
+
}
|
|
6427
|
+
if (_hydratable || _island) {
|
|
6428
|
+
component = injectHydrationAttributes(component, { hydratable: _hydratable, island: _island });
|
|
6429
|
+
}
|
|
6282
6430
|
return render(component, rendererOptions);
|
|
6283
6431
|
}
|
|
6284
6432
|
function renderScopedComponent(component) {
|
|
@@ -6348,10 +6496,15 @@ function deepClone2(obj) {
|
|
|
6348
6496
|
}
|
|
6349
6497
|
return cloned;
|
|
6350
6498
|
}
|
|
6351
|
-
var
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6499
|
+
var VERSION = "1.0.0-beta.8";
|
|
6500
|
+
var fp = {
|
|
6501
|
+
/**
|
|
6502
|
+
* Curried map: fp.map(fn)(array)
|
|
6503
|
+
*/
|
|
6504
|
+
map(fn) {
|
|
6505
|
+
return (array) => array.map(fn);
|
|
6506
|
+
}
|
|
6507
|
+
};
|
|
6355
6508
|
var coherent = {
|
|
6356
6509
|
// Core rendering
|
|
6357
6510
|
render: render2,
|
|
@@ -6422,9 +6575,11 @@ var index_default = coherent;
|
|
|
6422
6575
|
FORBIDDEN_CHILDREN,
|
|
6423
6576
|
GlobalErrorHandler,
|
|
6424
6577
|
HTMLNestingError,
|
|
6578
|
+
Island,
|
|
6425
6579
|
LIFECYCLE_PHASES,
|
|
6426
6580
|
VERSION,
|
|
6427
6581
|
checkPeerDependencies,
|
|
6582
|
+
compose,
|
|
6428
6583
|
createActionHandlers,
|
|
6429
6584
|
createAsyncErrorBoundary,
|
|
6430
6585
|
createComponent,
|
|
@@ -6448,6 +6603,7 @@ var index_default = coherent;
|
|
|
6448
6603
|
emitSync,
|
|
6449
6604
|
evaluateLazy,
|
|
6450
6605
|
eventSystem,
|
|
6606
|
+
fp,
|
|
6451
6607
|
getComponent,
|
|
6452
6608
|
getRegisteredComponents,
|
|
6453
6609
|
globalDOMIntegration,
|
|
@@ -6455,6 +6611,7 @@ var index_default = coherent;
|
|
|
6455
6611
|
h,
|
|
6456
6612
|
handleAction,
|
|
6457
6613
|
hasChildren,
|
|
6614
|
+
hoc,
|
|
6458
6615
|
importPeerDependency,
|
|
6459
6616
|
initializeDOMIntegration,
|
|
6460
6617
|
isCoherentComponent,
|
|
@@ -6497,7 +6654,7 @@ var index_default = coherent;
|
|
|
6497
6654
|
* Coherent.js - Object-Based Rendering Framework
|
|
6498
6655
|
* A pure JavaScript framework for server-side rendering using natural object syntax
|
|
6499
6656
|
*
|
|
6500
|
-
* @version 1.0.0-beta.
|
|
6657
|
+
* @version 1.0.0-beta.8
|
|
6501
6658
|
* @author Coherent Framework Team
|
|
6502
6659
|
* @license MIT
|
|
6503
6660
|
*/
|