coralite 0.28.2 → 0.28.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/coralite.js CHANGED
@@ -24,6 +24,7 @@ program
24
24
  .option('-s, --skip-render-attribute <key...>', 'Parse elements but exclude them from final render output', [])
25
25
  .option('-d, --dry-run', 'Run in dry-run mode')
26
26
  .option('--standalone <path>', 'Output directory for standalone client-side web components')
27
+ .option('-a, --assets <mapping...>', 'Static assets to copy. Format: pkg:path:dest (or pkg:path)')
27
28
 
28
29
  program.parse(process.argv)
29
30
  program.on('error', (err) => {
@@ -46,6 +47,25 @@ const options = program.opts()
46
47
  const pages = options.pages
47
48
  const output = options.output
48
49
  const ignoreByAttribute = []
50
+ let assets
51
+
52
+ if (options.assets) {
53
+ assets = []
54
+ for (const assetStr of options.assets) {
55
+ const parts = assetStr.split(':')
56
+ if (parts.length < 2) {
57
+ console.error('Failed to parse asset:', assetStr)
58
+ console.error('Invalid format. Expected pkg:path:dest or pkg:path')
59
+ process.exit(1)
60
+ }
61
+ const [pkg, path, dest] = parts
62
+ assets.push({
63
+ pkg,
64
+ path,
65
+ dest: dest || path
66
+ })
67
+ }
68
+ }
49
69
 
50
70
  const coraliteOptions = {
51
71
  components: options.components,
@@ -55,6 +75,7 @@ const coraliteOptions = {
55
75
  mode: options.mode,
56
76
  standaloneOutput: options.standalone,
57
77
  output,
78
+ assets,
58
79
  plugins: []
59
80
  }
60
81
 
@@ -26,6 +26,7 @@
26
26
  * @param {CoralitePluginInstance[]} [options.plugins=[]]
27
27
  * @param {string} options.pages - The path to the directory containing pages that will be rendered using the provided components.
28
28
  * @param {string} [options.mode='production'] - Build mode: "development" or "production"
29
+ * @param {import('../types/core.js').CoraliteStaticAsset[]} [options.assets] - Static assets to copy during build
29
30
  * @param {Array<string | Attribute>} [options.ignoreByAttribute] - Elements to ignore with attribute name value pair
30
31
  * @param {Array<string | Attribute>} [options.skipRenderByAttribute] - Element attributes to parse but exclude from final render output
31
32
  * @param {string} [options.standaloneOutput] - Output directory for standalone client-side web components
@@ -40,11 +41,12 @@
40
41
  * skipRenderByAttribute: ['data-skip-render']
41
42
  * });
42
43
  */
43
- export function Coralite({ components, pages, plugins, ignoreByAttribute, skipRenderByAttribute, mode, standaloneOutput, output }: {
44
+ export function Coralite({ components, pages, plugins, assets, ignoreByAttribute, skipRenderByAttribute, mode, standaloneOutput, output }: {
44
45
  components: string;
45
46
  plugins?: CoralitePluginInstance[];
46
47
  pages: string;
47
48
  mode?: string;
49
+ assets?: import("../types/core.js").CoraliteStaticAsset[];
48
50
  ignoreByAttribute?: Array<string | Attribute>;
49
51
  skipRenderByAttribute?: Array<string | Attribute>;
50
52
  standaloneOutput?: string;
@@ -79,6 +81,7 @@ export class Coralite {
79
81
  * @param {CoralitePluginInstance[]} [options.plugins=[]]
80
82
  * @param {string} options.pages - The path to the directory containing pages that will be rendered using the provided components.
81
83
  * @param {string} [options.mode='production'] - Build mode: "development" or "production"
84
+ * @param {import('../types/core.js').CoraliteStaticAsset[]} [options.assets] - Static assets to copy during build
82
85
  * @param {Array<string | Attribute>} [options.ignoreByAttribute] - Elements to ignore with attribute name value pair
83
86
  * @param {Array<string | Attribute>} [options.skipRenderByAttribute] - Element attributes to parse but exclude from final render output
84
87
  * @param {string} [options.standaloneOutput] - Output directory for standalone client-side web components
@@ -93,11 +96,12 @@ export class Coralite {
93
96
  * skipRenderByAttribute: ['data-skip-render']
94
97
  * });
95
98
  */
96
- constructor({ components, pages, plugins, ignoreByAttribute, skipRenderByAttribute, mode, standaloneOutput, output }: {
99
+ constructor({ components, pages, plugins, assets, ignoreByAttribute, skipRenderByAttribute, mode, standaloneOutput, output }: {
97
100
  components: string;
98
101
  plugins?: CoralitePluginInstance[];
99
102
  pages: string;
100
103
  mode?: string;
104
+ assets?: import("../types/core.js").CoraliteStaticAsset[];
101
105
  ignoreByAttribute?: Array<string | Attribute>;
102
106
  skipRenderByAttribute?: Array<string | Attribute>;
103
107
  standaloneOutput?: string;
@@ -107,6 +111,7 @@ export class Coralite {
107
111
  components: string;
108
112
  pages: string;
109
113
  plugins: CoralitePluginInstance[];
114
+ assets: import("../types/core.js").CoraliteStaticAsset[];
110
115
  ignoreByAttribute: (string | import("../types/document.js").Attribute)[];
111
116
  skipRenderByAttribute: (string | import("../types/document.js").Attribute)[];
112
117
  mode: string;
@@ -1 +1 @@
1
- {"version":3,"file":"coralite.d.ts","sourceRoot":"","sources":["../../lib/coralite.js"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;GAEG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,mIAlBG;IAAwB,UAAU,EAA1B,MAAM;IAC6B,OAAO,GAA1C,sBAAsB,EAAE;IACR,KAAK,EAArB,MAAM;IACW,IAAI,GAArB,MAAM;IAC8B,iBAAiB,GAArD,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;IACW,qBAAqB,GAAzD,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;IACR,gBAAgB,GAAjC,MAAM;IACW,MAAM,GAAvB,MAAM;CACd,QAmLF;;IArND;;;;;;;;;;;;;;;;;OAiBG;IAEH;;OAEG;IAEH;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,sHAlBG;QAAwB,UAAU,EAA1B,MAAM;QAC6B,OAAO,GAA1C,sBAAsB,EAAE;QACR,KAAK,EAArB,MAAM;QACW,IAAI,GAArB,MAAM;QAC8B,iBAAiB,GAArD,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;QACW,qBAAqB,GAAzD,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;QACR,gBAAgB,GAAjC,MAAM;QACW,MAAM,GAAvB,MAAM;KACd,EAmLF;IA5IC;;;;;;;;;;;;;MAUC;IAED,oDAAoD;IACpD,eADW,GAAG,CAAC,MAAM,EAAE,sBAAsB,EAAE,CAAC,CAClB;IAG9B;;;;;;;;;;;;;;MAcC;IAGD,8BAAyC;IAGzC;;;;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,GAAC,mBAAmB,GAAC,oBAAoB,GAAC,mBAAmB,GAAC,eAAe,GAAC,cAAc,QAC1K,CAAC,GACA,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAc5B;IAED;;;;;;;OAOG;IACH,qBAHW,WAAW,GAAC,cAAc,GAAC,cAAc,GAAC,gBAAgB,GAAC,mBAAmB,GAAC,mBAAmB,GAAC,oBAAoB,GAAC,mBAAmB,GAAC,eAAe,GAAC,cAAc,4BAapL;;;wCAxlCU,cAAc,KACZ,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG;4CApyBY,oBAAoB;+BAFrC,mBAAmB;4CAAnB,mBAAmB;8BA9Bf,qBAAqB;0BAFmB,YAAY;4BAAZ,YAAY;6BADxC,WAAW;4BAAX,WAAW;8BACiB,YAAY;+BAAZ,YAAY;0CAgCxD,mBAAmB;qCAAnB,mBAAmB;0CAMN,gBAAgB;+BAxBxB,iBAAiB;oCAkBtB,mBAAmB;0CAAnB,mBAAmB;qCAAnB,mBAAmB;sCAAnB,mBAAmB;oCAAnB,mBAAmB"}
package/dist/lib/index.js CHANGED
@@ -10578,6 +10578,7 @@ function createPlugin({
10578
10578
  // plugins/static-assets.js
10579
10579
  import { createRequire } from "node:module";
10580
10580
  import { dirname as dirname4, join as join2 } from "node:path";
10581
+ import { existsSync as existsSync2 } from "node:fs";
10581
10582
  import { cp, mkdir } from "node:fs/promises";
10582
10583
  var staticAssetPlugin = (assets = []) => {
10583
10584
  return createPlugin({
@@ -10585,13 +10586,32 @@ var staticAssetPlugin = (assets = []) => {
10585
10586
  onBeforeBuild: async function() {
10586
10587
  const outputDir = this.options.output || join2(process.cwd(), "dist");
10587
10588
  for (const asset of assets) {
10588
- if (!asset.pkg || !asset.path || !asset.dest) {
10589
- throw new Error("staticAssetPlugin requires assets to have pkg, path, and dest properties.");
10589
+ if (!asset.dest) {
10590
+ throw new Error("staticAssetPlugin requires assets to have a dest property.");
10591
+ }
10592
+ const dest = join2(outputDir, asset.dest);
10593
+ if (asset.src) {
10594
+ await mkdir(dirname4(dest), { recursive: true });
10595
+ await cp(asset.src, dest, { recursive: true });
10596
+ continue;
10597
+ }
10598
+ if (!asset.pkg || !asset.path) {
10599
+ throw new Error("staticAssetPlugin requires assets to have pkg and path properties when src is not provided.");
10590
10600
  }
10591
10601
  const require2 = createRequire(import.meta.url);
10592
- const pkgPath = dirname4(require2.resolve(`${asset.pkg}/package.json`));
10602
+ let pkgPath;
10603
+ try {
10604
+ pkgPath = dirname4(require2.resolve(`${asset.pkg}/package.json`));
10605
+ } catch (e) {
10606
+ pkgPath = dirname4(require2.resolve(asset.pkg));
10607
+ while (pkgPath !== "/" && !existsSync2(join2(pkgPath, "package.json"))) {
10608
+ pkgPath = dirname4(pkgPath);
10609
+ }
10610
+ if (pkgPath === "/") {
10611
+ throw new Error(`staticAssetPlugin could not resolve package.json for package: ${asset.pkg}`);
10612
+ }
10613
+ }
10593
10614
  const src = join2(pkgPath, asset.path);
10594
- const dest = join2(outputDir, asset.dest);
10595
10615
  await mkdir(dirname4(dest), { recursive: true });
10596
10616
  await cp(src, dest, { recursive: true });
10597
10617
  }
@@ -10663,6 +10683,7 @@ function Coralite({
10663
10683
  components,
10664
10684
  pages,
10665
10685
  plugins,
10686
+ assets,
10666
10687
  ignoreByAttribute,
10667
10688
  skipRenderByAttribute,
10668
10689
  mode = "production",
@@ -10686,6 +10707,7 @@ function Coralite({
10686
10707
  components,
10687
10708
  pages,
10688
10709
  plugins,
10710
+ assets,
10689
10711
  ignoreByAttribute,
10690
10712
  skipRenderByAttribute,
10691
10713
  mode,
@@ -10729,6 +10751,9 @@ function Coralite({
10729
10751
  }
10730
10752
  };
10731
10753
  plugins.unshift(defineComponent, refsPlugin, metadataPlugin);
10754
+ if (assets) {
10755
+ plugins.unshift(staticAssetPlugin(assets));
10756
+ }
10732
10757
  const source = this._source;
10733
10758
  for (let i = 0; i < plugins.length; i++) {
10734
10759
  const plugin = plugins[i];