@coherent.js/core 1.0.0-beta.6 → 1.0.0-beta.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 (108) hide show
  1. package/dist/coherent.d.ts +150 -10
  2. package/dist/coherent.d.ts.map +1 -1
  3. package/dist/coherent.js +166 -33
  4. package/dist/coherent.js.map +1 -1
  5. package/dist/components/component-system.js +109 -109
  6. package/dist/components/lifecycle.d.ts +212 -0
  7. package/dist/components/lifecycle.d.ts.map +1 -0
  8. package/dist/components/lifecycle.js +525 -0
  9. package/dist/components/lifecycle.js.map +1 -0
  10. package/dist/core/html-utils.js +5 -5
  11. package/dist/core/object-factory.js +21 -21
  12. package/dist/core/object-utils.js +2 -2
  13. package/dist/dev/dev-tools.d.ts +1 -1
  14. package/dist/dev/dev-tools.js +28 -28
  15. package/dist/forms/validation.d.ts +271 -0
  16. package/dist/forms/validation.d.ts.map +1 -0
  17. package/dist/forms/validation.js +573 -0
  18. package/dist/forms/validation.js.map +1 -0
  19. package/dist/index.cjs +157 -4
  20. package/dist/index.cjs.map +4 -4
  21. package/dist/index.js +153 -4
  22. package/dist/index.js.map +4 -4
  23. package/dist/performance/bundle-optimizer.js +11 -11
  24. package/dist/performance/cache-manager.js +6 -6
  25. package/dist/performance/component-cache.d.ts +120 -0
  26. package/dist/performance/component-cache.d.ts.map +1 -0
  27. package/dist/performance/component-cache.js +364 -0
  28. package/dist/performance/component-cache.js.map +1 -0
  29. package/dist/performance/monitor.js +10 -10
  30. package/dist/performance/monitor.js.map +1 -1
  31. package/dist/rendering/base-renderer.js +13 -13
  32. package/dist/rendering/css-manager.d.ts +73 -0
  33. package/dist/rendering/css-manager.d.ts.map +1 -0
  34. package/dist/rendering/css-manager.js +176 -0
  35. package/dist/rendering/css-manager.js.map +1 -0
  36. package/dist/rendering/dom-renderer.d.ts +23 -0
  37. package/dist/rendering/dom-renderer.d.ts.map +1 -1
  38. package/dist/rendering/dom-renderer.js +77 -9
  39. package/dist/rendering/dom-renderer.js.map +1 -1
  40. package/dist/rendering/html-renderer.d.ts +15 -0
  41. package/dist/rendering/html-renderer.d.ts.map +1 -1
  42. package/dist/rendering/html-renderer.js +85 -4
  43. package/dist/rendering/html-renderer.js.map +1 -1
  44. package/dist/rendering/streaming-renderer.js +12 -12
  45. package/dist/rendering/vdom-diff.d.ts +47 -0
  46. package/dist/rendering/vdom-diff.d.ts.map +1 -0
  47. package/dist/rendering/vdom-diff.js +416 -0
  48. package/dist/rendering/vdom-diff.js.map +1 -0
  49. package/dist/routing/router.d.ts +241 -0
  50. package/dist/routing/router.d.ts.map +1 -0
  51. package/dist/routing/router.js +648 -0
  52. package/dist/routing/router.js.map +1 -0
  53. package/dist/state/reactive-state.d.ts +166 -0
  54. package/dist/state/reactive-state.d.ts.map +1 -0
  55. package/dist/state/reactive-state.js +546 -0
  56. package/dist/state/reactive-state.js.map +1 -0
  57. package/dist/utils/dependency-utils.js +2 -2
  58. package/dist/utils/error-handler.d.ts +148 -0
  59. package/dist/utils/error-handler.d.ts.map +1 -0
  60. package/dist/utils/error-handler.js +468 -0
  61. package/dist/utils/error-handler.js.map +1 -0
  62. package/dist/utils/normalization.js +1 -1
  63. package/dist/utils/validation.js +1 -1
  64. package/package.json +5 -1
  65. package/dist/database/adapters/mongodb.d.ts +0 -15
  66. package/dist/database/adapters/mongodb.d.ts.map +0 -1
  67. package/dist/database/adapters/mongodb.js +0 -216
  68. package/dist/database/adapters/mongodb.js.map +0 -1
  69. package/dist/database/adapters/mysql.d.ts +0 -12
  70. package/dist/database/adapters/mysql.d.ts.map +0 -1
  71. package/dist/database/adapters/mysql.js +0 -171
  72. package/dist/database/adapters/mysql.js.map +0 -1
  73. package/dist/database/adapters/postgresql.d.ts +0 -12
  74. package/dist/database/adapters/postgresql.d.ts.map +0 -1
  75. package/dist/database/adapters/postgresql.js +0 -177
  76. package/dist/database/adapters/postgresql.js.map +0 -1
  77. package/dist/database/adapters/sqlite.d.ts +0 -15
  78. package/dist/database/adapters/sqlite.d.ts.map +0 -1
  79. package/dist/database/adapters/sqlite.js +0 -241
  80. package/dist/database/adapters/sqlite.js.map +0 -1
  81. package/dist/database/connection-manager.d.ts +0 -135
  82. package/dist/database/connection-manager.d.ts.map +0 -1
  83. package/dist/database/connection-manager.js +0 -362
  84. package/dist/database/connection-manager.js.map +0 -1
  85. package/dist/database/index.d.ts +0 -38
  86. package/dist/database/index.d.ts.map +0 -1
  87. package/dist/database/index.js +0 -60
  88. package/dist/database/index.js.map +0 -1
  89. package/dist/database/middleware.d.ts +0 -122
  90. package/dist/database/middleware.d.ts.map +0 -1
  91. package/dist/database/middleware.js +0 -390
  92. package/dist/database/middleware.js.map +0 -1
  93. package/dist/database/migration.d.ts +0 -62
  94. package/dist/database/migration.d.ts.map +0 -1
  95. package/dist/database/migration.js +0 -423
  96. package/dist/database/migration.js.map +0 -1
  97. package/dist/database/model.d.ts +0 -8
  98. package/dist/database/model.d.ts.map +0 -1
  99. package/dist/database/model.js +0 -167
  100. package/dist/database/model.js.map +0 -1
  101. package/dist/database/query-builder.d.ts +0 -111
  102. package/dist/database/query-builder.d.ts.map +0 -1
  103. package/dist/database/query-builder.js +0 -187
  104. package/dist/database/query-builder.js.map +0 -1
  105. package/dist/database/utils.d.ts +0 -196
  106. package/dist/database/utils.d.ts.map +0 -1
  107. package/dist/database/utils.js +0 -372
  108. 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,
@@ -1276,7 +1280,13 @@ function formatAttributes(props) {
1276
1280
  }
1277
1281
  }
1278
1282
  }
1279
- if (value === true) {
1283
+ if (attributeName === "style" && typeof value === "object" && value !== null) {
1284
+ const cssString = Object.entries(value).map(([prop, val]) => {
1285
+ const kebabProp = prop.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
1286
+ return `${kebabProp}: ${val}`;
1287
+ }).join("; ");
1288
+ formatted += ` ${attributeName}="${escapeHtml(cssString)}"`;
1289
+ } else if (value === true) {
1280
1290
  formatted += ` ${attributeName}`;
1281
1291
  } else if (value !== false && value !== null && value !== void 0) {
1282
1292
  formatted += ` ${attributeName}="${escapeHtml(String(value))}"`;
@@ -1497,6 +1507,9 @@ function createCacheManager(options = {}) {
1497
1507
  }
1498
1508
  clear();
1499
1509
  }
1510
+ function hashObject(obj) {
1511
+ return simpleHash(JSON.stringify(obj));
1512
+ }
1500
1513
  return {
1501
1514
  get,
1502
1515
  set,
@@ -1506,6 +1519,7 @@ function createCacheManager(options = {}) {
1506
1519
  cleanup,
1507
1520
  destroy,
1508
1521
  generateCacheKey,
1522
+ hashObject,
1509
1523
  get memoryUsage() {
1510
1524
  return memoryUsage;
1511
1525
  },
@@ -6220,6 +6234,97 @@ var eventSystem2 = {
6220
6234
  };
6221
6235
  var events_default = eventSystem2;
6222
6236
 
6237
+ // src/components/enhanced-composition.js
6238
+ var hoc = {
6239
+ /**
6240
+ * Wrap component with additional props
6241
+ */
6242
+ withProps(additionalProps) {
6243
+ return (Component2) => (props) => {
6244
+ return Component2({ ...props, ...additionalProps });
6245
+ };
6246
+ },
6247
+ /**
6248
+ * Conditional rendering HOC
6249
+ */
6250
+ withCondition(condition) {
6251
+ return (Component2) => (props) => {
6252
+ return condition(props) ? Component2(props) : null;
6253
+ };
6254
+ },
6255
+ /**
6256
+ * Loading state HOC
6257
+ */
6258
+ withLoading(loadingComponent) {
6259
+ return (Component2) => (props) => {
6260
+ return props.loading ? loadingComponent(props) : Component2(props);
6261
+ };
6262
+ },
6263
+ /**
6264
+ * Error boundary HOC
6265
+ */
6266
+ withError(errorComponent) {
6267
+ return (Component2) => (props) => {
6268
+ try {
6269
+ return Component2(props);
6270
+ } catch (error) {
6271
+ return errorComponent({ error, ...props });
6272
+ }
6273
+ };
6274
+ },
6275
+ /**
6276
+ * Memoization HOC
6277
+ */
6278
+ withMemo(getMemoKey) {
6279
+ const cache = /* @__PURE__ */ new Map();
6280
+ return (Component2) => (props) => {
6281
+ const key = getMemoKey ? getMemoKey(props) : JSON.stringify(props);
6282
+ if (cache.has(key)) {
6283
+ return cache.get(key);
6284
+ }
6285
+ const result = Component2(props);
6286
+ cache.set(key, result);
6287
+ return result;
6288
+ };
6289
+ }
6290
+ };
6291
+ var compose = {
6292
+ /**
6293
+ * Combine multiple components into one
6294
+ */
6295
+ combine(...components) {
6296
+ return (props) => ({
6297
+ fragment: {
6298
+ children: components.map((Component2) => Component2(props))
6299
+ }
6300
+ });
6301
+ },
6302
+ /**
6303
+ * Pipe components through transformations
6304
+ */
6305
+ pipe(...transformers) {
6306
+ return (Component2) => {
6307
+ return transformers.reduce((acc, transformer) => transformer(acc), Component2);
6308
+ };
6309
+ },
6310
+ /**
6311
+ * Branch based on conditions
6312
+ */
6313
+ branch(condition, leftComponent, rightComponent) {
6314
+ return (props) => {
6315
+ return condition(props) ? leftComponent(props) : rightComponent(props);
6316
+ };
6317
+ },
6318
+ /**
6319
+ * Render component or fallback
6320
+ */
6321
+ maybe(Component2, fallback = null) {
6322
+ return (props) => {
6323
+ return Component2 ? Component2(props) : fallback;
6324
+ };
6325
+ }
6326
+ };
6327
+
6223
6328
  // src/index.js
6224
6329
  var import_meta = {};
6225
6330
  var scopeCounter = { value: 0 };
@@ -6275,10 +6380,46 @@ function dangerouslySetInnerContent(content) {
6275
6380
  __trusted: true
6276
6381
  };
6277
6382
  }
6383
+ function injectHydrationAttributes(component, options) {
6384
+ if (!component || typeof component !== "object" || Array.isArray(component)) {
6385
+ return component;
6386
+ }
6387
+ const tagName = Object.keys(component)[0];
6388
+ if (!tagName) return component;
6389
+ const props = component[tagName];
6390
+ if (typeof props !== "object" || props === null) return component;
6391
+ const injected = { ...props };
6392
+ if (options.hydratable) {
6393
+ injected["data-hydratable"] = "true";
6394
+ }
6395
+ if (options.island) {
6396
+ injected["data-coherent-island"] = "true";
6397
+ }
6398
+ if (options._islandComponentName) {
6399
+ injected["data-coherent-island-component"] = options._islandComponentName;
6400
+ }
6401
+ return { [tagName]: injected };
6402
+ }
6403
+ function Island(componentFn) {
6404
+ const componentName = componentFn.name || "Anonymous";
6405
+ return function IslandComponent(props) {
6406
+ const result = componentFn(props);
6407
+ return injectHydrationAttributes(result, {
6408
+ island: true,
6409
+ _islandComponentName: componentName
6410
+ });
6411
+ };
6412
+ }
6278
6413
  function render2(obj, options = {}) {
6279
6414
  const scoped = options.scoped ?? options.encapsulate ?? false;
6280
- const { scoped: _scoped, encapsulate: _encapsulate, ...rendererOptions } = options;
6281
- const component = scoped ? renderScopedComponent(obj) : obj;
6415
+ const { scoped: _scoped, encapsulate: _encapsulate, hydratable: _hydratable, island: _island, ...rendererOptions } = options;
6416
+ let component = scoped ? renderScopedComponent(obj) : obj;
6417
+ if (typeof component === "function") {
6418
+ component = component(options);
6419
+ }
6420
+ if (_hydratable || _island) {
6421
+ component = injectHydrationAttributes(component, { hydratable: _hydratable, island: _island });
6422
+ }
6282
6423
  return render(component, rendererOptions);
6283
6424
  }
6284
6425
  function renderScopedComponent(component) {
@@ -6352,6 +6493,14 @@ var _corePackageJson = JSON.parse(
6352
6493
  (0, import_node_fs.readFileSync)(new URL("../package.json", import_meta.url), "utf-8")
6353
6494
  );
6354
6495
  var VERSION = _corePackageJson.version;
6496
+ var fp = {
6497
+ /**
6498
+ * Curried map: fp.map(fn)(array)
6499
+ */
6500
+ map(fn) {
6501
+ return (array) => array.map(fn);
6502
+ }
6503
+ };
6355
6504
  var coherent = {
6356
6505
  // Core rendering
6357
6506
  render: render2,
@@ -6422,9 +6571,11 @@ var index_default = coherent;
6422
6571
  FORBIDDEN_CHILDREN,
6423
6572
  GlobalErrorHandler,
6424
6573
  HTMLNestingError,
6574
+ Island,
6425
6575
  LIFECYCLE_PHASES,
6426
6576
  VERSION,
6427
6577
  checkPeerDependencies,
6578
+ compose,
6428
6579
  createActionHandlers,
6429
6580
  createAsyncErrorBoundary,
6430
6581
  createComponent,
@@ -6448,6 +6599,7 @@ var index_default = coherent;
6448
6599
  emitSync,
6449
6600
  evaluateLazy,
6450
6601
  eventSystem,
6602
+ fp,
6451
6603
  getComponent,
6452
6604
  getRegisteredComponents,
6453
6605
  globalDOMIntegration,
@@ -6455,6 +6607,7 @@ var index_default = coherent;
6455
6607
  h,
6456
6608
  handleAction,
6457
6609
  hasChildren,
6610
+ hoc,
6458
6611
  importPeerDependency,
6459
6612
  initializeDOMIntegration,
6460
6613
  isCoherentComponent,
@@ -6497,7 +6650,7 @@ var index_default = coherent;
6497
6650
  * Coherent.js - Object-Based Rendering Framework
6498
6651
  * A pure JavaScript framework for server-side rendering using natural object syntax
6499
6652
  *
6500
- * @version 1.0.0-beta.6
6653
+ * @version 1.0.0-beta.7
6501
6654
  * @author Coherent Framework Team
6502
6655
  * @license MIT
6503
6656
  */