coralite 0.33.1 → 0.35.0

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 (54) hide show
  1. package/README.md +51 -23
  2. package/dist/lib/client-runtime.d.ts +4 -2
  3. package/dist/lib/client-runtime.d.ts.map +1 -1
  4. package/dist/lib/coralite.d.ts +106 -32
  5. package/dist/lib/coralite.d.ts.map +1 -1
  6. package/dist/lib/errors.d.ts +16 -0
  7. package/dist/lib/errors.d.ts.map +1 -0
  8. package/dist/lib/html.d.ts +22 -1
  9. package/dist/lib/html.d.ts.map +1 -1
  10. package/dist/lib/index.d.ts +1 -0
  11. package/dist/lib/index.d.ts.map +1 -1
  12. package/dist/lib/index.js +1296 -765
  13. package/dist/lib/index.js.map +4 -4
  14. package/dist/lib/parse.d.ts.map +1 -1
  15. package/dist/lib/plugin.d.ts +17 -13
  16. package/dist/lib/plugin.d.ts.map +1 -1
  17. package/dist/lib/script-manager.d.ts +4 -2
  18. package/dist/lib/script-manager.d.ts.map +1 -1
  19. package/dist/lib/type-helper.d.ts +3 -3
  20. package/dist/lib/utils.d.ts +20 -3
  21. package/dist/lib/utils.d.ts.map +1 -1
  22. package/dist/plugins/index.d.ts +0 -1
  23. package/dist/plugins/index.js +0 -1
  24. package/dist/plugins/metadata.d.ts +1 -1
  25. package/dist/plugins/metadata.d.ts.map +1 -1
  26. package/dist/plugins/metadata.js +47 -42
  27. package/dist/plugins/refs.d.ts +2 -2
  28. package/dist/plugins/refs.d.ts.map +1 -1
  29. package/dist/plugins/refs.js +5 -11
  30. package/dist/plugins/static-assets.d.ts +1 -1
  31. package/dist/plugins/static-assets.d.ts.map +1 -1
  32. package/dist/plugins/static-assets.js +19 -9
  33. package/dist/plugins/testing.d.ts +1 -1
  34. package/dist/plugins/testing.d.ts.map +1 -1
  35. package/dist/plugins/testing.js +9 -7
  36. package/dist/types/collection.d.ts +5 -1
  37. package/dist/types/collection.d.ts.map +1 -1
  38. package/dist/types/component.d.ts +2 -2
  39. package/dist/types/component.d.ts.map +1 -1
  40. package/dist/types/core.d.ts +5 -1
  41. package/dist/types/core.d.ts.map +1 -1
  42. package/dist/types/index.d.ts +4 -3
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/dist/types/module.d.ts +6 -2
  45. package/dist/types/module.d.ts.map +1 -1
  46. package/dist/types/plugin.d.ts +23 -78
  47. package/dist/types/plugin.d.ts.map +1 -1
  48. package/dist/types/script.d.ts +23 -7
  49. package/dist/types/script.d.ts.map +1 -1
  50. package/llms.txt +292 -287
  51. package/package.json +1 -1
  52. package/dist/plugins/define-component.d.ts +0 -12
  53. package/dist/plugins/define-component.d.ts.map +0 -1
  54. package/dist/plugins/define-component.js +0 -187
package/README.md CHANGED
@@ -83,7 +83,7 @@ npx coralite --components src/components --pages src/pages --output dist
83
83
  Coralite uses a `coralite.config.js` file at the root of your project. We provide a `defineConfig` helper to give you full IDE autocomplete and type safety.
84
84
 
85
85
  ```javascript
86
- import { defineConfig } from 'coralite/plugins'
86
+ import { defineConfig } from 'coralite'
87
87
  import myCustomPlugin from './plugins/my-plugin.js'
88
88
 
89
89
  export default defineConfig({
@@ -113,9 +113,11 @@ Styles defined in the `<style>` block are automatically **scoped** to the compon
113
113
 
114
114
  ```html
115
115
  <template id="user-card">
116
- <div class="card">
116
+ <div class="card" ref="card">
117
117
  <h2>{{ formatName }}</h2>
118
- <p>Role: {{ userRole }}</p>
118
+ <p>{{ userMeta }}</p>
119
+ <slot>
120
+ <p class="stats">Logins: {{ loginCount }}</p>
119
121
  </div>
120
122
  </template>
121
123
 
@@ -125,41 +127,67 @@ Styles defined in the `<style>` block are automatically **scoped** to the compon
125
127
  border: 1px solid #eaeaea;
126
128
  padding: 1.5rem;
127
129
  border-radius: 8px;
130
+ cursor: pointer;
128
131
  }
129
132
  h2 {
130
133
  color: coral;
131
134
  }
135
+ .stats {
136
+ font-size: 0.85em;
137
+ color: gray;
138
+ }
132
139
  </style>
133
140
 
134
141
  <script type="module">
135
- import { defineComponent } from 'coralite/plugins'
142
+ import { defineComponent } from 'coralite'
143
+ import db from 'database'
136
144
 
137
145
  export default defineComponent({
138
- // Server-side state & data
139
- properties(context) {
140
- const { firstName, lastName, role } = context.properties
146
+ // INPUTS (Coerced from HTML string attributes)
147
+ attributes: {
148
+ firstName: { type: String, default: 'Unknown' },
149
+ lastName: { type: String, default: '' },
150
+ role: { type: String, default: 'Guest' }
151
+ },
152
+
153
+ // SERVER DATA (Async fetching, runs on build/server)
154
+ async data(context) {
155
+ // We can use the parsed attributes to fetch specific data
156
+ const stats = await db.fetchUserStats(context.attributes.firstName)
157
+
141
158
  return {
142
- formatName: `${firstName} ${lastName}`,
143
- userRole: role || 'Guest'
159
+ // These will be merged into the base state
160
+ department: stats.department || 'General',
161
+ loginCount: stats.loginCount || 0
144
162
  }
145
163
  },
146
164
 
165
+ // DERIVED STATE (Sync, pure functions, Read-Only Proxy)
166
+ getters: {
167
+ // state = attributes + data
168
+ formatName: (state) => `${state.firstName} ${state.lastName}`.trim(),
169
+ userMeta: (state) => `Role: ${state.role} | Dept: ${state.department}`
170
+ },
171
+
147
172
  // Light DOM transformations
148
173
  slots: {
149
- content(nodes, context) {
150
- return nodes.map(node => {
151
- // Perform SSR transformations on slot content
152
- return node
153
- })
174
+ default (nodes, context) {
175
+ return nodes.map(node => node)
154
176
  }
155
177
  },
156
178
 
157
- // Client-side behavior
158
- script({ properties, refs, root, page, signal }) {
159
- console.log(`Component mounted: ${properties.formatName}`)
179
+ // CLIENT CONTROLLER (Mutations, Events, Read/Write Proxy, Teardown)
180
+ script({ state, refs, root, signal }) {
181
+ console.log(`Component mounted: ${state.formatName}`)
160
182
 
161
- refs.card.addEventListener('click', () => {
162
- alert('Hello from the browser!')
183
+ // Use the refs dictionary provided by the core plugin to target the element
184
+ const cardEl = root.querySelector(`[ref="${refs.card}"]`)
185
+
186
+ cardEl.addEventListener('click', () => {
187
+ alert(`Hello from the browser, ${state.formatName}!`)
188
+
189
+ // automatically updates the DOM, and re-runs any dependent getters.
190
+ state.loginCount++
163
191
  }, { signal })
164
192
  }
165
193
  })
@@ -177,7 +205,7 @@ Coralite is built to be extended. The `definePlugin` API lets you tap directly i
177
205
  Plugins in Coralite use a functional, immutable API. Instead of mutating shared state, your plugin hooks simply return the specific data patches or pages you want to add. Core utilities are available via `coralite/utils`, and global engine state is accessible through `this` binding.
178
206
 
179
207
  ```javascript
180
- import { definePlugin } from 'coralite/plugins'
208
+ import { definePlugin } from 'coralite'
181
209
  import { parseHTML } from 'coralite/utils'
182
210
 
183
211
  export default function seoPlugin(options = {}) {
@@ -185,10 +213,10 @@ export default function seoPlugin(options = {}) {
185
213
  name: 'coralite-seo-plugin',
186
214
 
187
215
  // State Reducers: Patch the page context before rendering
188
- onBeforePageRender: async (context) => {
216
+ onBeforePageRender (context) {
189
217
  // Return a patch object; Coralite will safely deep-merge it for you!
190
218
  return {
191
- properties: {
219
+ state: {
192
220
  siteTitle: options.title || 'My Coralite Site',
193
221
  metaDescription: 'Generated by Coralite'
194
222
  }
@@ -196,7 +224,7 @@ export default function seoPlugin(options = {}) {
196
224
  },
197
225
 
198
226
  // Data Aggregators: Generate entirely new pages during the build
199
- onAfterPageRender: async (basePageResult) => {
227
+ onAfterPageRender (basePageResult) {
200
228
  // Access the engine instance via `this`
201
229
  // this.pages.getItem('/index.html')
202
230
 
@@ -9,10 +9,11 @@
9
9
  * @param {string} options.sharedChunkPath - The filename of the shared chunk.
10
10
  * @param {Object} options.chunkManifest - Manifest mapping component IDs to their chunk filenames.
11
11
  * @param {Object.<string, InstanceContext>} options.instances - Map of instance data.
12
- * @param {string} options.mode - Build mode ('development' or 'production').
12
+ * @param {string} options.mode - Build mode ('development' or 'development').
13
+ * @param {Object} [options.renderContext] - Build-time render context.
13
14
  * @returns {string} The generated JavaScript runtime.
14
15
  */
15
- export function generateClientRuntime({ base, sharedChunkPath, chunkManifest, instances, mode }: {
16
+ export function generateClientRuntime({ base, sharedChunkPath, chunkManifest, instances, mode, renderContext }: {
16
17
  base: string;
17
18
  sharedChunkPath: string;
18
19
  chunkManifest: any;
@@ -20,6 +21,7 @@ export function generateClientRuntime({ base, sharedChunkPath, chunkManifest, in
20
21
  [x: string]: InstanceContext;
21
22
  };
22
23
  mode: string;
24
+ renderContext?: any;
23
25
  }): string;
24
26
  import type { InstanceContext } from '../types/index.js';
25
27
  //# sourceMappingURL=client-runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-runtime.d.ts","sourceRoot":"","sources":["../../lib/client-runtime.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;GAUG;AACH,iGAPG;IAAwB,IAAI,EAApB,MAAM;IACU,eAAe,EAA/B,MAAM;IACU,aAAa;IACa,SAAS,EAAnD;YAAQ,MAAM,GAAE,eAAe;KAAC;IAChB,IAAI,EAApB,MAAM;CACd,GAAU,MAAM,CA8elB;qCA1fmC,mBAAmB"}
1
+ {"version":3,"file":"client-runtime.d.ts","sourceRoot":"","sources":["../../lib/client-runtime.js"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;;;GAWG;AACH,gHARG;IAAwB,IAAI,EAApB,MAAM;IACU,eAAe,EAA/B,MAAM;IACU,aAAa;IACa,SAAS,EAAnD;YAAQ,MAAM,GAAE,eAAe;KAAC;IAChB,IAAI,EAApB,MAAM;IACW,aAAa;CACtC,GAAU,MAAM,CAmkBlB;qCAhlBmC,mBAAmB"}
@@ -10,7 +10,6 @@
10
10
  * CoraliteComponentRoot,
11
11
  * CoraliteCollectionEventSet,
12
12
  * CoraliteComponentResult,
13
- * CoraliteProperties,
14
13
  * InstanceContext,
15
14
  * CoraliteConfig,
16
15
  * CoraliteFilePath,
@@ -47,7 +46,6 @@ export class Coralite {
47
46
  * CoraliteComponentRoot,
48
47
  * CoraliteCollectionEventSet,
49
48
  * CoraliteComponentResult,
50
- * CoraliteProperties,
51
49
  * InstanceContext,
52
50
  * CoraliteConfig,
53
51
  * CoraliteFilePath,
@@ -144,11 +142,11 @@ export class Coralite {
144
142
  * @param {string} data.message
145
143
  * @param {Error} [data.error]
146
144
  */
147
- _defaultOnError({ level, message, error }: {
145
+ readonly _defaultOnError: ({ level, message, error }: {
148
146
  level: "WARN" | "ERR" | "LOG";
149
147
  message: string;
150
148
  error?: Error;
151
- }): void;
149
+ }) => void;
152
150
  /**
153
151
  * Internal error handler for the Coralite instance.
154
152
  * @internal
@@ -157,18 +155,29 @@ export class Coralite {
157
155
  * @param {string} data.message - The descriptive message to be logged or thrown.
158
156
  * @param {Error} [data.error] - An optional Error instance providing a stack trace.
159
157
  */
160
- _handleError(data: {
158
+ readonly _handleError: (data: {
161
159
  level: "WARN" | "ERR" | "LOG";
162
160
  message: string;
163
161
  error?: Error;
164
- }): void;
162
+ }) => void;
163
+ /**
164
+ * Helper to create CoraliteError during component execution
165
+ * @internal
166
+ * @param {Error} error - The caught error
167
+ * @param {CoraliteModule} module - The component module
168
+ * @param {CoraliteCollectionItem} moduleComponent - The parent module component
169
+ * @param {CoralitePage} page - The current page
170
+ * @param {string} instanceId - The unique instance id
171
+ * @returns {CoraliteError} The generated error object
172
+ */
173
+ readonly _createExecutionError: (error: Error, module: CoraliteModule, moduleComponent: CoraliteCollectionItem, page: CoralitePage, instanceId: string) => CoraliteError;
165
174
  /**
166
175
  * Creates a render context for the build process.
167
176
  * @internal
168
177
  * @param {string} [buildId] - The unique identifier for the build process.
169
178
  * @returns {Object}
170
179
  */
171
- _createRenderContext(buildId?: string): any;
180
+ readonly _createRenderContext: (buildId?: string) => any;
172
181
  /**
173
182
  * Compiles specified page(s) by rendering their document content and measuring render time.
174
183
  * Processes pages based on provided path(s), replacing custom elements with components,
@@ -177,10 +186,25 @@ export class Coralite {
177
186
  * @internal
178
187
  *
179
188
  * @param {string | string[]} [path] - Path to a single page or array of page paths relative to the pages directory. If omitted, compiles all pages.
180
- * @param {Object} [properties] - Properties to be passed to the page
189
+ * @param {Object} [state] - Properties to be passed to the page
181
190
  * @returns {AsyncGenerator<CoraliteResult>}
182
191
  */
183
- _generatePages(path?: string | string[], properties?: any): AsyncGenerator<CoraliteResult>;
192
+ /**
193
+ * Processes custom elements found within a generated page context
194
+ * @internal
195
+ * @param {CoraliteComponent & CoraliteComponentResult} mappedComponent - The compiled component instance
196
+ * @param {CoraliteComponentResult} originalDocument - The original document mapping
197
+ * @param {Object} state - Local component state
198
+ * @param {Object} mappedRenderContextObject - Global rendering state
199
+ * @returns {Promise<void>} Resolves when the elements are processed
200
+ */
201
+ readonly _processCustomElementsInPage: (mappedComponent: CoraliteComponent & CoraliteComponentResult, originalDocument: CoraliteComponentResult, state: any, mappedRenderContextObject: any, pageContext: any) => Promise<void>;
202
+ readonly _generatePages: (path: any, state?: {}) => AsyncGenerator<{
203
+ type: string;
204
+ path: import("../types/core.js").CoralitePath & import("../types/core.js").CoraliteFilePath;
205
+ content: string;
206
+ duration: number;
207
+ }, void, unknown>;
184
208
  outputFiles: {};
185
209
  /**
186
210
  * Compiles pages and collects the results with controlled concurrency.
@@ -459,14 +483,14 @@ export class Coralite {
459
483
  * @param {Object} renderContext - The current build render context.
460
484
  * @param {CoralitePage} page - The global page object
461
485
  * @param {CoraliteComponentRoot} root - The root element of the component
462
- * @param {Object} properties - The current token properties and state available
486
+ * @param {Object} state - The current token state and state available
463
487
  * @returns {Promise<void>}
464
488
  */
465
- _processDependentComponents(componentIds: string[], renderContext: any, page: CoralitePage, root: CoraliteComponentRoot, properties?: any): Promise<void>;
489
+ readonly _processDependentComponents: (componentIds: string[], renderContext: any, page: CoralitePage, root: CoraliteComponentRoot, state?: any) => Promise<void>;
466
490
  /**
467
491
  * @param {Object} options
468
492
  * @param {string} options.id - id - Unique identifier for the component
469
- * @param {CoraliteModuleDefinitions} [options.properties={}] - Token properties available for replacement
493
+ * @param {CoraliteModuleDefinitions} [options.state={}] - Token state available for replacement
470
494
  * @param {CoraliteElement} [options.element] - Mapping of component IDs to their module definitions
471
495
  * @param {CoralitePage} options.page - The global page object
472
496
  * @param {CoraliteComponentRoot} options.root - The root element of the component
@@ -476,9 +500,9 @@ export class Coralite {
476
500
  * @param {boolean} [head=true] - Indicates if the current function call is for the head of the recursion
477
501
  * @returns {Promise<CoraliteElement | void>}
478
502
  */
479
- createComponentElement({ id, properties, element, page, root, contextId, index, renderContext }: {
503
+ createComponentElement({ id, state, element, page, root, contextId, index, renderContext }: {
480
504
  id: string;
481
- properties?: CoraliteModuleDefinitions;
505
+ state?: CoraliteModuleDefinitions;
482
506
  element?: CoraliteElement;
483
507
  page: CoralitePage;
484
508
  root: CoraliteComponentRoot;
@@ -486,11 +510,26 @@ export class Coralite {
486
510
  index?: number;
487
511
  renderContext?: any;
488
512
  }, head?: boolean): Promise<CoraliteElement | void>;
513
+ /**
514
+ * Replaces slot elements in a component with provided content
515
+ * @internal
516
+ * @param {string} id - Component ID
517
+ * @param {CoraliteElement} element - The original Custom Element node
518
+ * @param {CoraliteModule} module - The component module configuration
519
+ * @param {string} contextId - Instance context ID
520
+ * @param {Object} state - The component state
521
+ * @param {CoralitePage} page - Active page object
522
+ * @param {CoraliteComponentRoot} root - The component root element
523
+ * @param {number} index - Index of element
524
+ * @param {Object} renderContext - Rendering state
525
+ * @returns {Promise<void>} Resolves when slots are successfully replaced
526
+ */
527
+ readonly _replaceSlots: (id: string, element: CoraliteElement, module: CoraliteModule, contextId: string, state: any, page: CoralitePage, root: CoraliteComponentRoot, index: number, renderContext: any) => Promise<void>;
489
528
  /**
490
529
  * Generates a custom module linker callback for the Node.js VM context.
491
530
  * This linker is responsible for resolving `import` statements inside evaluated
492
531
  * component scripts. It intercepts specific specifiers to provide synthetic modules
493
- * for `coralite` and `coralite/plugins`, correctly resolves relative paths against
532
+ * for `coralite` and plugins, correctly resolves relative paths against
494
533
  * the component's directory, and safely bridges external Node.js modules into the VM sandbox.
495
534
  *
496
535
  * @internal
@@ -498,9 +537,9 @@ export class Coralite {
498
537
  * @param {Object.<string, any>} context - Contextual rendering data and state to be exposed when a script imports `'coralite'`.
499
538
  * @returns {(specifier: string, referencingModule: import('node:vm').Module, extra: { attributes: any }) => Promise<import('node:vm').Module>} The async linker function used by the VM module.
500
539
  */
501
- _moduleLinker(path: CoraliteFilePath, context: {
540
+ readonly _moduleLinker: (path: CoraliteFilePath, context: {
502
541
  [x: string]: any;
503
- }): (specifier: string, referencingModule: import("node:vm").Module, extra: {
542
+ }) => (specifier: string, referencingModule: import("node:vm").Module, extra: {
504
543
  attributes: any;
505
544
  }) => Promise<import("node:vm").Module>;
506
545
  /**
@@ -508,7 +547,7 @@ export class Coralite {
508
547
  *
509
548
  * @param {Object} data
510
549
  * @param {CoraliteModule} data.module - The Coralite module to parse
511
- * @param {CoraliteModuleDefinitions} data.properties - Replacement tokens for the component
550
+ * @param {CoraliteModuleDefinitions} data.state - Replacement tokens for the component
512
551
  * @param {CoralitePage} data.page - The global page object
513
552
  * @param {CoraliteElement} data.root - The Coralite module to parse
514
553
  * @param {string} data.contextId - Context Id
@@ -516,21 +555,21 @@ export class Coralite {
516
555
  *
517
556
  * @returns {Promise<CoraliteModuleDefinitions>}
518
557
  */
519
- _evaluateDevelopment({ module, properties, page, root, contextId, renderContext }: {
558
+ readonly _evaluateDevelopment: ({ module, state, page, root, contextId, renderContext }: {
520
559
  module: CoraliteModule;
521
- properties: CoraliteModuleDefinitions;
560
+ state: CoraliteModuleDefinitions;
522
561
  page: CoralitePage;
523
562
  root: CoraliteElement;
524
563
  contextId: string;
525
564
  renderContext: any;
526
- }): Promise<CoraliteModuleDefinitions>;
565
+ }) => Promise<CoraliteModuleDefinitions>;
527
566
  /**
528
567
  * Parses a Coralite module script and compiles it into JavaScript using esbuild.
529
568
  * Replaces node:vm SourceTextModule for better performance and memory management.
530
569
  *
531
570
  * @param {Object} data
532
571
  * @param {CoraliteModule} data.module - The Coralite module to parse
533
- * @param {CoraliteModuleDefinitions} data.properties - Replacement tokens for the component
572
+ * @param {CoraliteModuleDefinitions} data.state - Replacement tokens for the component
534
573
  * @param {CoralitePage} data.page - The global page object
535
574
  * @param {CoraliteElement} data.root - The Coralite module to parse
536
575
  * @param {string} data.contextId - Context Id
@@ -538,21 +577,21 @@ export class Coralite {
538
577
  *
539
578
  * @returns {Promise<CoraliteModuleDefinitions>}
540
579
  */
541
- _evaluateProduction({ module, properties, page, root, contextId, renderContext }: {
580
+ readonly _evaluateProduction: ({ module, state, page, root, contextId, renderContext }: {
542
581
  module: CoraliteModule;
543
- properties: CoraliteModuleDefinitions;
582
+ state: CoraliteModuleDefinitions;
544
583
  page: CoralitePage;
545
584
  root: CoraliteElement;
546
585
  contextId: string;
547
586
  renderContext: any;
548
- }): Promise<CoraliteModuleDefinitions>;
587
+ }) => Promise<CoraliteModuleDefinitions>;
549
588
  /**
550
589
  * Parses a Coralite module script and compiles it into JavaScript using esbuild.
551
590
  * Replaces node:vm SourceTextModule for better performance and memory management.
552
591
  *
553
592
  * @param {Object} data -
554
593
  * @param {CoraliteModule} data.module - The Coralite module to parse
555
- * @param {CoraliteModuleDefinitions} data.properties - Replacement tokens for the component
594
+ * @param {CoraliteModuleDefinitions} data.state - Replacement tokens for the component
556
595
  * @param {CoralitePage} data.page - The global page object
557
596
  * @param {CoraliteElement} data.element - The Coralite module to parse
558
597
  * @param {string} data.contextId - Context Id
@@ -560,7 +599,7 @@ export class Coralite {
560
599
  *
561
600
  * @returns {Promise<CoraliteModuleDefinitions>}
562
601
  */
563
- _evaluate(options: any): Promise<CoraliteModuleDefinitions>;
602
+ readonly _evaluate: (options: any) => Promise<CoraliteModuleDefinitions>;
564
603
  /**
565
604
  * Executes a collecting plugin hook where the results are aggregated.
566
605
  * Useful for hooks like `onAfterPageRender` that return new pages to be added to the build.
@@ -570,7 +609,15 @@ export class Coralite {
570
609
  * @param {any} contextData - Context to pass to the callbacks (not mutated by this function).
571
610
  * @returns {Promise<any[]>} A flattened array of all results returned by the plugins.
572
611
  */
573
- _triggerPluginAggregateHook(name: string, contextData: any): Promise<any[]>;
612
+ readonly _triggerPluginAggregateHook: (name: string, contextData: any) => Promise<any[]>;
613
+ /**
614
+ * @internal Executes Phase 1 of plugin exports with the given context.
615
+ *
616
+ * @param {Object} plugins - The plugins object
617
+ * @param {Object} context - The context object to pass to Phase 1
618
+ * @returns {Object} The Phase 2 functions
619
+ */
620
+ readonly _bindPlugins: (plugins: any, context: any) => any;
574
621
  /**
575
622
  * @template T
576
623
  *
@@ -582,7 +629,7 @@ export class Coralite {
582
629
  * @param {T} initialData - Data to pass to each callback function.
583
630
  * @returns {Promise<T>} A promise that resolves to the merged data.
584
631
  */
585
- _triggerPluginHook<T>(name: "onPageSet" | "onPageUpdate" | "onPageDelete" | "onComponentSet" | "onComponentUpdate" | "onComponentDelete" | "onBeforePageRender" | "onAfterPageRender" | "onBeforeBuild" | "onAfterBuild", initialData: T): Promise<T>;
632
+ readonly _triggerPluginHook: <T>(name: "onPageSet" | "onPageUpdate" | "onPageDelete" | "onComponentSet" | "onComponentUpdate" | "onComponentDelete" | "onBeforePageRender" | "onAfterPageRender" | "onBeforeBuild" | "onAfterBuild", initialData: T) => Promise<T>;
586
633
  /**
587
634
  * Registers a callback function under the specified hook name.
588
635
  *
@@ -591,7 +638,31 @@ export class Coralite {
591
638
  * @param {'onPageSet'|'onPageUpdate'|'onPageDelete'|'onComponentSet'|'onComponentUpdate'|'onComponentDelete'|'onBeforePageRender'|'onAfterPageRender'|'onBeforeBuild'|'onAfterBuild'} name - The name of the hook to register the callback with.
592
639
  * @param {Function} callback - The callback function to be executed when the hook is triggered.
593
640
  */
594
- _addPluginHook(name: "onPageSet" | "onPageUpdate" | "onPageDelete" | "onComponentSet" | "onComponentUpdate" | "onComponentDelete" | "onBeforePageRender" | "onAfterPageRender" | "onBeforeBuild" | "onAfterBuild", callback: Function): void;
641
+ readonly _addPluginHook: (name: "onPageSet" | "onPageUpdate" | "onPageDelete" | "onComponentSet" | "onComponentUpdate" | "onComponentDelete" | "onBeforePageRender" | "onAfterPageRender" | "onBeforeBuild" | "onAfterBuild", callback: Function) => void;
642
+ /**
643
+ * Replaces a custom element with its template content.
644
+ * @internal
645
+ * @param {CoraliteElement} coraliteElement - The custom element to be replaced.
646
+ * @param {CoraliteElement} element - The target element to replace the tokens with.
647
+ */
648
+ readonly _replaceCustomElementWithTemplate: (coraliteElement: CoraliteElement, element: CoraliteElement) => void;
649
+ /**
650
+ * Process a token value - parse HTML strings and handle custom elements
651
+ * @internal
652
+ * @param {any} value - The value to process
653
+ * @param {Object} context - Processing context
654
+ * @returns {Promise<any>} - Processed value
655
+ */
656
+ readonly _processTokenValue: (value: any, context: any) => Promise<any>;
657
+ /**
658
+ * This function defines a component for the Coralite framework.
659
+ * It is used to register components with their associated state and scripts.
660
+ * @internal
661
+ * @param {Object} options - Configuration options for the component
662
+ * @param {Object} context - The evaluation context
663
+ * @returns {Promise<Object>} A promise resolving to the module state associated with this component.
664
+ */
665
+ readonly _defineComponent: (options: any, context: any) => Promise<any>;
595
666
  }
596
667
  export default Coralite;
597
668
  export type BuildPageHandler = (result: CoraliteResult) => Promise<any> | any;
@@ -605,10 +676,13 @@ import type { CoraliteComponentRoot } from '../types/index.js';
605
676
  import type { CoraliteAnyNode } from '../types/index.js';
606
677
  import type { DomSerializerOptions } from 'dom-serializer';
607
678
  import CoraliteCollection from './collection.js';
608
- import type { CoraliteResult } from '../types/index.js';
679
+ import type { CoraliteModule } from '../types/index.js';
609
680
  import type { CoralitePage } from '../types/index.js';
681
+ import { CoraliteError } from './errors.js';
682
+ import type { CoraliteComponent } from '../types/index.js';
683
+ import type { CoraliteComponentResult } from '../types/index.js';
684
+ import type { CoraliteResult } from '../types/index.js';
610
685
  import type { CoraliteModuleDefinitions } from '../types/index.js';
611
686
  import type { CoraliteElement } from '../types/index.js';
612
687
  import type { CoraliteFilePath } from '../types/index.js';
613
- import type { CoraliteModule } from '../types/index.js';
614
688
  //# sourceMappingURL=coralite.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"coralite.d.ts","sourceRoot":"","sources":["../../lib/coralite.js"],"names":[],"mappings":"AAsBA;;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Ae,GAAC,cAAc,8BAGpJ;IAUjC;;;;;OAKG;IACH,8DAHW,eAAe,WACf,eAAe,UAE0B;IAapD;;;;;;OAMG;IACH,qCAJW,GAAG,mBAED,OAAO,CAAC,GAAG,CAAC,CAEY;IAyCrC;;;;;;;OAOG;IACH,2DAFa,OAAO,KAAQ,CAEO;;;wCA1gDxB,cAAc,KACZ,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;oCA/8BrB,mBAAmB;4CAAnB,mBAAmB;8BAvCC,qBAAqB;6BALU,WAAW;4BAAX,WAAW;+BAGF,YAAY;2CAyCxE,mBAAmB;qCAAnB,mBAAmB;0CAIU,gBAAgB;+BAzBxB,iBAAiB;oCAqBtC,mBAAmB;kCAAnB,mBAAmB;8BA3BC,aAAa;uCA2BjC,mBAAmB;6CAAnB,mBAAmB;oCAAnB,mBAAmB;+CAAnB,mBAAmB;qCAAnB,mBAAmB;sCAAnB,mBAAmB"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ *
3
+ */
4
+ export class CoraliteError extends Error {
5
+ /**
6
+ *
7
+ */
8
+ constructor(message: any, options?: {});
9
+ isCoraliteError: boolean;
10
+ componentId: any;
11
+ filePath: any;
12
+ instanceId: any;
13
+ pagePath: any;
14
+ cause: any;
15
+ }
16
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../lib/errors.js"],"names":[],"mappings":"AAAA;;GAEG;AACH;IACE;;OAEG;IACH,wCAaC;IAVC,yBAA2B;IAC3B,iBAAsC;IACtC,cAAgC;IAChC,gBAAoC;IACpC,cAAgC;IAI9B,WAA0B;CAG/B"}
@@ -16,6 +16,7 @@
16
16
  * @param {CoraliteCollectionEventDelete} [options.onFileDelete]
17
17
  * @param {CoraliteCollection} [options.collection] - Optional collection instance to populate
18
18
  * @param {import('p-limit').LimitFunction} [options.limit] - Optional concurrency limiter
19
+ * @param {boolean} [options.discoverOnly=false] - Whether to skip reading file content and only discover paths
19
20
  * @returns {Promise<CoraliteCollection>} Array of HTML file data including parent path, name, and content
20
21
  *
21
22
  * @example
@@ -26,7 +27,7 @@
26
27
  * exclude: ['index.html', 'subdir/file2.html']
27
28
  * })
28
29
  */
29
- export function getHtmlFiles({ path, type, recursive, exclude, onFileSet, onFileUpdate, onFileDelete, collection, limit }: {
30
+ export function getHtmlFiles({ path, type, recursive, exclude, discoverOnly, onFileSet, onFileUpdate, onFileDelete, collection, limit }: {
30
31
  path: string;
31
32
  type: "page" | "component";
32
33
  recursive?: boolean;
@@ -36,7 +37,27 @@ export function getHtmlFiles({ path, type, recursive, exclude, onFileSet, onFile
36
37
  onFileDelete?: CoraliteCollectionEventDelete;
37
38
  collection?: CoraliteCollection;
38
39
  limit?: import("p-limit").LimitFunction;
40
+ discoverOnly?: boolean;
39
41
  }): Promise<CoraliteCollection>;
42
+ /**
43
+ * Generator that yields HTML files found in a directory.
44
+ * Useful for lazy discovery and memory-efficient processing of many files.
45
+ *
46
+ * @param {Object} options - Options for searching HTML files
47
+ * @param {string} options.path - Path to the directory containing HTML files
48
+ * @param {'page' | 'component'} options.type - Document types
49
+ * @param {boolean} [options.recursive=false] - Whether to search recursively
50
+ * @param {string[]} [options.exclude=[]] - Files or directories to exclude
51
+ * @param {boolean} [options.discoverOnly=false] - Whether to skip reading file content
52
+ * @yields {Promise<{ type: 'page' | 'component', content: string | undefined, path: { pathname: string, filename: string, dirname: string } }>}
53
+ */
54
+ export function discoverHtmlFiles({ path, type, recursive, exclude, discoverOnly }: {
55
+ path: string;
56
+ type: "page" | "component";
57
+ recursive?: boolean;
58
+ exclude?: string[];
59
+ discoverOnly?: boolean;
60
+ }): any;
40
61
  /**
41
62
  * Reads an HTML file and returns its content as a string.
42
63
  * @param {string} pathname - The path to the HTML file.
@@ -1 +1 @@
1
- {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../lib/html.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;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BAAmB;mDAAnB,mBAAmB;mDAAnB,mBAAmB;+BAN7B,iBAAiB"}
@@ -4,6 +4,7 @@ export * from "./utils.js";
4
4
  export * from "./plugin.js";
5
5
  export * from "./config.js";
6
6
  export * from "./type-helper.js";
7
+ export * from "./errors.js";
7
8
  export * from "./script-manager.js";
8
9
  export * from "#plugins";
9
10
  export { Coralite };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.js"],"names":[],"mappings":";;;;;;;;;;qBAAqB,eAAe"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.js"],"names":[],"mappings":";;;;;;;;;;;qBAAqB,eAAe"}