coralite 0.34.0 → 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.
- package/README.md +2 -2
- package/dist/lib/coralite.d.ts +96 -20
- package/dist/lib/coralite.d.ts.map +1 -1
- package/dist/lib/html.d.ts +22 -1
- package/dist/lib/html.d.ts.map +1 -1
- package/dist/lib/index.js +795 -570
- package/dist/lib/index.js.map +4 -4
- package/dist/lib/parse.d.ts.map +1 -1
- package/dist/lib/plugin.d.ts +17 -13
- package/dist/lib/plugin.d.ts.map +1 -1
- package/dist/lib/script-manager.d.ts.map +1 -1
- package/dist/plugins/index.d.ts +0 -1
- package/dist/plugins/index.js +0 -1
- package/dist/plugins/metadata.d.ts +1 -1
- package/dist/plugins/metadata.d.ts.map +1 -1
- package/dist/plugins/metadata.js +45 -40
- package/dist/plugins/refs.d.ts +2 -2
- package/dist/plugins/refs.d.ts.map +1 -1
- package/dist/plugins/refs.js +2 -5
- package/dist/plugins/static-assets.d.ts +1 -1
- package/dist/plugins/static-assets.d.ts.map +1 -1
- package/dist/plugins/static-assets.js +18 -8
- package/dist/plugins/testing.d.ts +1 -1
- package/dist/plugins/testing.d.ts.map +1 -1
- package/dist/plugins/testing.js +9 -7
- package/dist/types/collection.d.ts +4 -0
- package/dist/types/collection.d.ts.map +1 -1
- package/dist/types/core.d.ts +4 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +18 -73
- package/dist/types/plugin.d.ts.map +1 -1
- package/llms.txt +294 -26
- package/package.json +1 -1
- package/dist/plugins/define-component.d.ts +0 -21
- package/dist/plugins/define-component.d.ts.map +0 -1
- package/dist/plugins/define-component.js +0 -219
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
|
|
86
|
+
import { defineConfig } from 'coralite'
|
|
87
87
|
import myCustomPlugin from './plugins/my-plugin.js'
|
|
88
88
|
|
|
89
89
|
export default defineConfig({
|
|
@@ -205,7 +205,7 @@ Coralite is built to be extended. The `definePlugin` API lets you tap directly i
|
|
|
205
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.
|
|
206
206
|
|
|
207
207
|
```javascript
|
|
208
|
-
import { definePlugin } from 'coralite
|
|
208
|
+
import { definePlugin } from 'coralite'
|
|
209
209
|
import { parseHTML } from 'coralite/utils'
|
|
210
210
|
|
|
211
211
|
export default function seoPlugin(options = {}) {
|
package/dist/lib/coralite.d.ts
CHANGED
|
@@ -142,11 +142,11 @@ export class Coralite {
|
|
|
142
142
|
* @param {string} data.message
|
|
143
143
|
* @param {Error} [data.error]
|
|
144
144
|
*/
|
|
145
|
-
_defaultOnError({ level, message, error }: {
|
|
145
|
+
readonly _defaultOnError: ({ level, message, error }: {
|
|
146
146
|
level: "WARN" | "ERR" | "LOG";
|
|
147
147
|
message: string;
|
|
148
148
|
error?: Error;
|
|
149
|
-
})
|
|
149
|
+
}) => void;
|
|
150
150
|
/**
|
|
151
151
|
* Internal error handler for the Coralite instance.
|
|
152
152
|
* @internal
|
|
@@ -155,18 +155,29 @@ export class Coralite {
|
|
|
155
155
|
* @param {string} data.message - The descriptive message to be logged or thrown.
|
|
156
156
|
* @param {Error} [data.error] - An optional Error instance providing a stack trace.
|
|
157
157
|
*/
|
|
158
|
-
_handleError(data: {
|
|
158
|
+
readonly _handleError: (data: {
|
|
159
159
|
level: "WARN" | "ERR" | "LOG";
|
|
160
160
|
message: string;
|
|
161
161
|
error?: Error;
|
|
162
|
-
})
|
|
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;
|
|
163
174
|
/**
|
|
164
175
|
* Creates a render context for the build process.
|
|
165
176
|
* @internal
|
|
166
177
|
* @param {string} [buildId] - The unique identifier for the build process.
|
|
167
178
|
* @returns {Object}
|
|
168
179
|
*/
|
|
169
|
-
_createRenderContext(buildId?: string)
|
|
180
|
+
readonly _createRenderContext: (buildId?: string) => any;
|
|
170
181
|
/**
|
|
171
182
|
* Compiles specified page(s) by rendering their document content and measuring render time.
|
|
172
183
|
* Processes pages based on provided path(s), replacing custom elements with components,
|
|
@@ -178,7 +189,22 @@ export class Coralite {
|
|
|
178
189
|
* @param {Object} [state] - Properties to be passed to the page
|
|
179
190
|
* @returns {AsyncGenerator<CoraliteResult>}
|
|
180
191
|
*/
|
|
181
|
-
|
|
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>;
|
|
182
208
|
outputFiles: {};
|
|
183
209
|
/**
|
|
184
210
|
* Compiles pages and collects the results with controlled concurrency.
|
|
@@ -460,7 +486,7 @@ export class Coralite {
|
|
|
460
486
|
* @param {Object} state - The current token state and state available
|
|
461
487
|
* @returns {Promise<void>}
|
|
462
488
|
*/
|
|
463
|
-
_processDependentComponents(componentIds: string[], renderContext: any, page: CoralitePage, root: CoraliteComponentRoot, state?: any)
|
|
489
|
+
readonly _processDependentComponents: (componentIds: string[], renderContext: any, page: CoralitePage, root: CoraliteComponentRoot, state?: any) => Promise<void>;
|
|
464
490
|
/**
|
|
465
491
|
* @param {Object} options
|
|
466
492
|
* @param {string} options.id - id - Unique identifier for the component
|
|
@@ -484,11 +510,26 @@ export class Coralite {
|
|
|
484
510
|
index?: number;
|
|
485
511
|
renderContext?: any;
|
|
486
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>;
|
|
487
528
|
/**
|
|
488
529
|
* Generates a custom module linker callback for the Node.js VM context.
|
|
489
530
|
* This linker is responsible for resolving `import` statements inside evaluated
|
|
490
531
|
* component scripts. It intercepts specific specifiers to provide synthetic modules
|
|
491
|
-
* for `coralite` and
|
|
532
|
+
* for `coralite` and plugins, correctly resolves relative paths against
|
|
492
533
|
* the component's directory, and safely bridges external Node.js modules into the VM sandbox.
|
|
493
534
|
*
|
|
494
535
|
* @internal
|
|
@@ -496,9 +537,9 @@ export class Coralite {
|
|
|
496
537
|
* @param {Object.<string, any>} context - Contextual rendering data and state to be exposed when a script imports `'coralite'`.
|
|
497
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.
|
|
498
539
|
*/
|
|
499
|
-
_moduleLinker(path: CoraliteFilePath, context: {
|
|
540
|
+
readonly _moduleLinker: (path: CoraliteFilePath, context: {
|
|
500
541
|
[x: string]: any;
|
|
501
|
-
})
|
|
542
|
+
}) => (specifier: string, referencingModule: import("node:vm").Module, extra: {
|
|
502
543
|
attributes: any;
|
|
503
544
|
}) => Promise<import("node:vm").Module>;
|
|
504
545
|
/**
|
|
@@ -514,14 +555,14 @@ export class Coralite {
|
|
|
514
555
|
*
|
|
515
556
|
* @returns {Promise<CoraliteModuleDefinitions>}
|
|
516
557
|
*/
|
|
517
|
-
_evaluateDevelopment({ module, state, page, root, contextId, renderContext }: {
|
|
558
|
+
readonly _evaluateDevelopment: ({ module, state, page, root, contextId, renderContext }: {
|
|
518
559
|
module: CoraliteModule;
|
|
519
560
|
state: CoraliteModuleDefinitions;
|
|
520
561
|
page: CoralitePage;
|
|
521
562
|
root: CoraliteElement;
|
|
522
563
|
contextId: string;
|
|
523
564
|
renderContext: any;
|
|
524
|
-
})
|
|
565
|
+
}) => Promise<CoraliteModuleDefinitions>;
|
|
525
566
|
/**
|
|
526
567
|
* Parses a Coralite module script and compiles it into JavaScript using esbuild.
|
|
527
568
|
* Replaces node:vm SourceTextModule for better performance and memory management.
|
|
@@ -536,14 +577,14 @@ export class Coralite {
|
|
|
536
577
|
*
|
|
537
578
|
* @returns {Promise<CoraliteModuleDefinitions>}
|
|
538
579
|
*/
|
|
539
|
-
_evaluateProduction({ module, state, page, root, contextId, renderContext }: {
|
|
580
|
+
readonly _evaluateProduction: ({ module, state, page, root, contextId, renderContext }: {
|
|
540
581
|
module: CoraliteModule;
|
|
541
582
|
state: CoraliteModuleDefinitions;
|
|
542
583
|
page: CoralitePage;
|
|
543
584
|
root: CoraliteElement;
|
|
544
585
|
contextId: string;
|
|
545
586
|
renderContext: any;
|
|
546
|
-
})
|
|
587
|
+
}) => Promise<CoraliteModuleDefinitions>;
|
|
547
588
|
/**
|
|
548
589
|
* Parses a Coralite module script and compiles it into JavaScript using esbuild.
|
|
549
590
|
* Replaces node:vm SourceTextModule for better performance and memory management.
|
|
@@ -558,7 +599,7 @@ export class Coralite {
|
|
|
558
599
|
*
|
|
559
600
|
* @returns {Promise<CoraliteModuleDefinitions>}
|
|
560
601
|
*/
|
|
561
|
-
_evaluate(options: any)
|
|
602
|
+
readonly _evaluate: (options: any) => Promise<CoraliteModuleDefinitions>;
|
|
562
603
|
/**
|
|
563
604
|
* Executes a collecting plugin hook where the results are aggregated.
|
|
564
605
|
* Useful for hooks like `onAfterPageRender` that return new pages to be added to the build.
|
|
@@ -568,7 +609,15 @@ export class Coralite {
|
|
|
568
609
|
* @param {any} contextData - Context to pass to the callbacks (not mutated by this function).
|
|
569
610
|
* @returns {Promise<any[]>} A flattened array of all results returned by the plugins.
|
|
570
611
|
*/
|
|
571
|
-
_triggerPluginAggregateHook(name: string, contextData: 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;
|
|
572
621
|
/**
|
|
573
622
|
* @template T
|
|
574
623
|
*
|
|
@@ -580,7 +629,7 @@ export class Coralite {
|
|
|
580
629
|
* @param {T} initialData - Data to pass to each callback function.
|
|
581
630
|
* @returns {Promise<T>} A promise that resolves to the merged data.
|
|
582
631
|
*/
|
|
583
|
-
_triggerPluginHook<T>(name: "onPageSet" | "onPageUpdate" | "onPageDelete" | "onComponentSet" | "onComponentUpdate" | "onComponentDelete" | "onBeforePageRender" | "onAfterPageRender" | "onBeforeBuild" | "onAfterBuild", initialData: T)
|
|
632
|
+
readonly _triggerPluginHook: <T>(name: "onPageSet" | "onPageUpdate" | "onPageDelete" | "onComponentSet" | "onComponentUpdate" | "onComponentDelete" | "onBeforePageRender" | "onAfterPageRender" | "onBeforeBuild" | "onAfterBuild", initialData: T) => Promise<T>;
|
|
584
633
|
/**
|
|
585
634
|
* Registers a callback function under the specified hook name.
|
|
586
635
|
*
|
|
@@ -589,7 +638,31 @@ export class Coralite {
|
|
|
589
638
|
* @param {'onPageSet'|'onPageUpdate'|'onPageDelete'|'onComponentSet'|'onComponentUpdate'|'onComponentDelete'|'onBeforePageRender'|'onAfterPageRender'|'onBeforeBuild'|'onAfterBuild'} name - The name of the hook to register the callback with.
|
|
590
639
|
* @param {Function} callback - The callback function to be executed when the hook is triggered.
|
|
591
640
|
*/
|
|
592
|
-
_addPluginHook(name: "onPageSet" | "onPageUpdate" | "onPageDelete" | "onComponentSet" | "onComponentUpdate" | "onComponentDelete" | "onBeforePageRender" | "onAfterPageRender" | "onBeforeBuild" | "onAfterBuild", callback: Function)
|
|
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>;
|
|
593
666
|
}
|
|
594
667
|
export default Coralite;
|
|
595
668
|
export type BuildPageHandler = (result: CoraliteResult) => Promise<any> | any;
|
|
@@ -603,10 +676,13 @@ import type { CoraliteComponentRoot } from '../types/index.js';
|
|
|
603
676
|
import type { CoraliteAnyNode } from '../types/index.js';
|
|
604
677
|
import type { DomSerializerOptions } from 'dom-serializer';
|
|
605
678
|
import CoraliteCollection from './collection.js';
|
|
606
|
-
import type {
|
|
679
|
+
import type { CoraliteModule } from '../types/index.js';
|
|
607
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';
|
|
608
685
|
import type { CoraliteModuleDefinitions } from '../types/index.js';
|
|
609
686
|
import type { CoraliteElement } from '../types/index.js';
|
|
610
687
|
import type { CoraliteFilePath } from '../types/index.js';
|
|
611
|
-
import type { CoraliteModule } from '../types/index.js';
|
|
612
688
|
//# sourceMappingURL=coralite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coralite.d.ts","sourceRoot":"","sources":["../../lib/coralite.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"coralite.d.ts","sourceRoot":"","sources":["../../lib/coralite.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;GAEG;AAEH;;;;;;;;;;;;GAYG;AACH,2IAXW,cAAc,QA4LxB;;IArND;;;;;;;;;;;;;;;;;OAiBG;IAEH;;OAEG;IAEH;;;;;;;;;;;;OAYG;IACH,8HAXW,cAAc,EA4LxB;IAnJC,6DAA+B;IAG/B;;;;;;;;;;;;;;MAWC;IAED,oDAAoD;IACpD,eADW,GAAG,CAAC,MAAM,EAAE,sBAAsB,EAAE,CAAC,CAClB;IAG9B;;;;;;;;;;;;;;MAcC;IAGD,8BAAqD;IAGrD;;;;;;;;8BA2oCS,qBAAqB,GAAG,eAAe,GAAG,eAAe,EAAE,YAC3D,oBAAoB,KAClB,MAAM;;;MAznChB;IAyFH;;;OAGG;IACH,cAFa,OAAO,CAAC,IAAI,CAAC,CA4UzB;IAzUC,+BAiDE;IAWF;;OAEG;IACH;;MAA6C;IAC7C;;OAEG;IACH;;MAA+C;IAyO/C,0BAKE;IA0BJ;;;;;;;OAOG;IACH,sDAJG;QAAqC,KAAK,EAAlC,MAAM,GAAG,KAAK,GAAG,KAAK;QACT,OAAO,EAApB,MAAM;QACO,KAAK,GAAlB,KAAK;KAAc,UAEI;IAalC;;;;;;;OAOG;IAC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ACH,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"}
|
package/dist/lib/html.d.ts
CHANGED
|
@@ -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.
|
package/dist/lib/html.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../lib/html.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AAEH
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../lib/html.js"],"names":[],"mappings":"AAOA;;;;;GAKG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,yIApBG;IAAwB,IAAI,EAApB,MAAM;IACwB,IAAI,EAAlC,MAAM,GAAG,WAAW;IACF,SAAS,GAA3B,OAAO;IACY,OAAO,GAA1B,MAAM,EAAE;IAC6B,SAAS,GAA9C,0BAA0B;IACc,YAAY,GAApD,6BAA6B;IACW,YAAY,GAApD,6BAA6B;IACA,UAAU,GAAvC,kBAAkB;IACwB,KAAK,GAA/C,OAAO,SAAS,EAAE,aAAa;IACb,YAAY,GAA9B,OAAO;CACf,GAAU,OAAO,CAAC,kBAAkB,CAAC,CAiGvC;AAED;;;;;;;;;;;GAWG;AACH,oFAPG;IAAwB,IAAI,EAApB,MAAM;IACwB,IAAI,EAAlC,MAAM,GAAG,WAAW;IACF,SAAS,GAA3B,OAAO;IACY,OAAO,GAA1B,MAAM,EAAE;IACU,YAAY,GAA9B,OAAO;CACf,OAwDF;AAED;;;;GAIG;AACH,0CAHW,MAAM,UAehB;AAED;;;;GAIG;AACH,sCAHW,MAAM,mBAehB;gDA3NwC,mBAAmB;mDAAnB,mBAAmB;mDAAnB,mBAAmB;+BAN7B,iBAAiB"}
|