@htmlplus/element 3.0.0 → 3.1.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/dist/bundlers.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { KEY } from './constants.js';
2
2
  import { transformer } from './transformer.js';
3
3
  import 'fs-extra';
4
+ import 'glob';
4
5
  import '@babel/template';
5
6
  import '@babel/types';
6
7
  import 'change-case';
7
8
  import '@babel/traverse';
8
9
  import '@babel/parser';
9
- import 'glob';
10
10
  import '@babel/generator';
11
11
  import path from 'node:path';
12
12
  import 'ora';
@@ -1,6 +1,6 @@
1
1
  import 'react';
2
2
 
3
- type WithPart<K> = React.JSX.IntrinsicElements[K] & { part?: string };
3
+ type WithPart<K extends keyof React.JSX.IntrinsicElements> = React.JSX.IntrinsicElements[K] & { part?: string };
4
4
 
5
5
  declare namespace JSX {
6
6
  interface IntrinsicElements {
@@ -62,6 +62,7 @@ declare const ASSETS_OPTIONS: Partial<AssetsOptions>;
62
62
  interface AssetsOptions {
63
63
  destination?: (context: TransformerPluginContext) => string;
64
64
  source?: (context: TransformerPluginContext) => string;
65
+ json?: (context: TransformerPluginContext) => string;
65
66
  }
66
67
  declare const assets: (options?: AssetsOptions) => TransformerPlugin;
67
68
 
@@ -95,12 +96,7 @@ interface ParseOptions extends ParserOptions {
95
96
  }
96
97
  declare const parse: (options?: ParseOptions) => TransformerPlugin;
97
98
 
98
- declare const READ_OPTIONS: Partial<ReadOptions>;
99
- interface ReadOptions {
100
- encoding: 'utf8' | 'ascii' | 'utf-8' | 'utf16le' | 'utf-16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
101
- flag?: string | undefined;
102
- }
103
- declare const read: (options?: ReadOptions) => TransformerPlugin;
99
+ declare const read: () => TransformerPlugin;
104
100
 
105
101
  declare const README_OPTIONS: Partial<ReadmeOptions>;
106
102
  interface ReadmeOptions {
@@ -134,4 +130,4 @@ interface WebTypesOptions {
134
130
  }
135
131
  declare const webTypes: (options?: WebTypesOptions) => TransformerPlugin;
136
132
 
137
- export { ASSETS_OPTIONS, type AssetsOptions, COPY_OPTIONS, CUSTOM_ELEMENT_OPTIONS, type CopyOptions, type CustomElementOptions, DOCUMENT_OPTIONS, type DocumentOptions, PARSE_OPTIONS, type ParseOptions, README_OPTIONS, READ_OPTIONS, type ReadOptions, type ReadmeOptions, STYLE_OPTIONS, type StyleOptions, type TransformerPlugin, type TransformerPluginContext, type TransformerPluginGlobal, VISUAL_STUDIO_CODE_OPTIONS, type VisualStudioCodeOptions, WEB_TYPES_OPTIONS, type WebTypesOptions, assets, copy, customElement, document, extract, parse, read, readme, style, transformer, validate, visualStudioCode, webTypes };
133
+ export { ASSETS_OPTIONS, type AssetsOptions, COPY_OPTIONS, CUSTOM_ELEMENT_OPTIONS, type CopyOptions, type CustomElementOptions, DOCUMENT_OPTIONS, type DocumentOptions, PARSE_OPTIONS, type ParseOptions, README_OPTIONS, type ReadmeOptions, STYLE_OPTIONS, type StyleOptions, type TransformerPlugin, type TransformerPluginContext, type TransformerPluginGlobal, VISUAL_STUDIO_CODE_OPTIONS, type VisualStudioCodeOptions, WEB_TYPES_OPTIONS, type WebTypesOptions, assets, copy, customElement, document, extract, parse, read, readme, style, transformer, validate, visualStudioCode, webTypes };
@@ -86,6 +86,9 @@ const ASSETS_OPTIONS = {
86
86
  },
87
87
  source(context) {
88
88
  return path.join(context.directoryPath, 'assets');
89
+ },
90
+ json(context) {
91
+ return path.join('dist', 'assets', context.fileName + '.json');
89
92
  }
90
93
  };
91
94
  const assets = (options) => {
@@ -100,6 +103,12 @@ const assets = (options) => {
100
103
  if (!fs.existsSync(context.assetsSource))
101
104
  continue;
102
105
  fs.copySync(context.assetsSource, context.assetsDestination);
106
+ const json = options.json?.(context);
107
+ if (!json)
108
+ continue;
109
+ fs.ensureDirSync(path.dirname(json));
110
+ const files = glob.sync('**/*.*', { cwd: context.assetsDestination });
111
+ fs.writeJSONSync(json, files, { encoding: 'utf8', spaces: 2 });
103
112
  }
104
113
  };
105
114
  return { name, finish };
@@ -385,6 +394,9 @@ const hasDecorator = (node, name) => {
385
394
 
386
395
  // TODO: add options
387
396
  const print = (ast) => {
397
+ // TODO: the `ast` should not be undefined
398
+ if (!ast)
399
+ return '';
388
400
  return (generator.default || generator)(ast, { decoratorsBeforeExport: true }).code;
389
401
  };
390
402
 
@@ -992,16 +1004,12 @@ const parse = (options) => {
992
1004
  return { name, run };
993
1005
  };
994
1006
 
995
- const READ_OPTIONS = {
996
- encoding: 'utf8'
997
- };
998
- const read = (options) => {
1007
+ const read = () => {
999
1008
  const name = 'read';
1000
- options = Object.assign({}, READ_OPTIONS, options);
1001
1009
  const run = (context) => {
1002
1010
  if (!context.filePath)
1003
1011
  return;
1004
- context.fileContent = fs.readFileSync(context.filePath, options);
1012
+ context.fileContent = fs.readFileSync(context.filePath, 'utf8');
1005
1013
  context.fileExtension = path.extname(context.filePath);
1006
1014
  context.fileName = path.basename(context.filePath, context.fileExtension);
1007
1015
  context.directoryPath = path.dirname(context.filePath);
@@ -1250,4 +1258,4 @@ const webTypes = (options) => {
1250
1258
  return { name, finish };
1251
1259
  };
1252
1260
 
1253
- export { ASSETS_OPTIONS, COPY_OPTIONS, CUSTOM_ELEMENT_OPTIONS, DOCUMENT_OPTIONS, PARSE_OPTIONS, README_OPTIONS, READ_OPTIONS, STYLE_OPTIONS, VISUAL_STUDIO_CODE_OPTIONS, WEB_TYPES_OPTIONS, assets, copy, customElement, document, extract, parse, read, readme, style, transformer, validate, visualStudioCode, webTypes };
1261
+ export { ASSETS_OPTIONS, COPY_OPTIONS, CUSTOM_ELEMENT_OPTIONS, DOCUMENT_OPTIONS, PARSE_OPTIONS, README_OPTIONS, STYLE_OPTIONS, VISUAL_STUDIO_CODE_OPTIONS, WEB_TYPES_OPTIONS, assets, copy, customElement, document, extract, parse, read, readme, style, transformer, validate, visualStudioCode, webTypes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlplus/element",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "author": "Masood Abdolian <m.abdolian@gmail.com>",
@@ -38,8 +38,9 @@
38
38
  },
39
39
  "./jsx-runtime": "./dist/jsx-runtime.d.ts"
40
40
  },
41
+ "funding": [],
41
42
  "engines": {
42
- "node": ">= 20.10.0"
43
+ "node": ">= 22.10.0"
43
44
  },
44
45
  "keywords": [
45
46
  "components",
@@ -56,38 +57,38 @@
56
57
  },
57
58
  "homepage": "https://github.com/htmlplus/element#readme",
58
59
  "dependencies": {
59
- "@babel/generator": "^7.24.10",
60
- "@babel/parser": "^7.24.8",
61
- "@babel/template": "^7.24.7",
62
- "@babel/traverse": "^7.24.8",
63
- "@babel/types": "^7.24.9",
64
- "@types/node": "^20.14.10",
65
- "@types/react": "^18.3.3",
60
+ "@babel/generator": "^7.26.0",
61
+ "@babel/parser": "^7.26.1",
62
+ "@babel/template": "^7.25.9",
63
+ "@babel/traverse": "^7.25.9",
64
+ "@babel/types": "^7.26.0",
65
+ "@types/node": "^20.17.1",
66
+ "@types/react": "^18.3.12",
66
67
  "change-case": "^5.4.4",
67
68
  "fs-extra": "^11.2.0",
68
69
  "glob": "^11.0.0",
69
- "ora": "^8.0.1",
70
- "typescript": "^5.5.3"
70
+ "ora": "^8.1.0",
71
+ "typescript": "^5.6.3"
71
72
  },
72
73
  "devDependencies": {
73
- "@rollup/plugin-typescript": "^11.1.6",
74
+ "@rollup/plugin-typescript": "^12.1.1",
74
75
  "@semantic-release/changelog": "^6.0.3",
75
76
  "@semantic-release/commit-analyzer": "^13.0.0",
76
77
  "@semantic-release/git": "^10.0.1",
77
- "@semantic-release/github": "^10.1.0",
78
+ "@semantic-release/github": "^11.0.0",
78
79
  "@semantic-release/npm": "^12.0.1",
79
80
  "@semantic-release/release-notes-generator": "^14.0.1",
80
81
  "@trivago/prettier-plugin-sort-imports": "^4.3.0",
81
82
  "conventional-changelog-conventionalcommits": "^8.0.0",
82
- "cpy": "^11.0.1",
83
+ "cpy": "^11.1.0",
83
84
  "prettier": "^3.3.3",
84
85
  "rimraf": "^6.0.1",
85
- "rollup": "^4.20.0",
86
+ "rollup": "^4.24.2",
86
87
  "rollup-plugin-copy": "^3.5.0",
87
88
  "rollup-plugin-dts": "^6.1.1",
88
- "rollup-plugin-node-externals": "^7.1.2",
89
- "semantic-release": "^24.0.0",
90
- "tslib": "^2.6.3",
91
- "vite": "^5.3.4"
89
+ "rollup-plugin-node-externals": "^7.1.3",
90
+ "semantic-release": "^24.2.0",
91
+ "tslib": "^2.8.0",
92
+ "vite": "^5.4.10"
92
93
  }
93
94
  }