lilact 0.15.5 → 0.16.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 (113) hide show
  1. package/README.md +7 -6
  2. package/bin/bundle.cjs +148 -60
  3. package/dist/lilact.development.js +5332 -10263
  4. package/dist/lilact.development.js.map +7 -1
  5. package/dist/lilact.development.min.js +54 -11
  6. package/dist/lilact.development.min.js.map +7 -1
  7. package/dist/lilact.production.min.js +53 -10
  8. package/docs/assets/hierarchy.js +1 -1
  9. package/docs/classes/accessories.ErrorBoundary.html +11 -11
  10. package/docs/classes/accessories.Suspense.html +10 -10
  11. package/docs/classes/components.Component.html +11 -11
  12. package/docs/classes/components.HTMLComponent.html +11 -11
  13. package/docs/classes/components.RootComponent.html +11 -11
  14. package/docs/functions/accessories.DragHandle.html +1 -1
  15. package/docs/functions/accessories.Spinner.html +1 -1
  16. package/docs/functions/components.createComponent.html +1 -1
  17. package/docs/functions/components.createRoot.html +1 -1
  18. package/docs/functions/components.render.html +1 -1
  19. package/docs/functions/errors.globalErrorHandler.html +1 -1
  20. package/docs/functions/errors.traceError.html +1 -1
  21. package/docs/functions/hooks.createContext.html +1 -1
  22. package/docs/functions/hooks.useActionState.html +1 -1
  23. package/docs/functions/hooks.useCallback.html +1 -1
  24. package/docs/functions/hooks.useContext.html +1 -1
  25. package/docs/functions/hooks.useDeferredValue.html +1 -1
  26. package/docs/functions/hooks.useEffect.html +1 -1
  27. package/docs/functions/hooks.useHook.html +1 -1
  28. package/docs/functions/hooks.useId.html +1 -1
  29. package/docs/functions/hooks.useImperativeHandle.html +1 -1
  30. package/docs/functions/hooks.useLayoutEffect.html +1 -1
  31. package/docs/functions/hooks.useLocalStorage.html +1 -1
  32. package/docs/functions/hooks.useMemo.html +1 -1
  33. package/docs/functions/hooks.useReducer.html +1 -1
  34. package/docs/functions/hooks.useRef.html +1 -1
  35. package/docs/functions/hooks.useState.html +1 -1
  36. package/docs/functions/hooks.useTransition.html +1 -1
  37. package/docs/functions/misc.Fragment.html +2 -2
  38. package/docs/functions/misc.deepEqual.html +1 -1
  39. package/docs/functions/misc.findDOMNode.html +1 -1
  40. package/docs/functions/misc.forwardRef.html +1 -1
  41. package/docs/functions/misc.getComponentByPointer.html +1 -1
  42. package/docs/functions/misc.isAsync.html +1 -1
  43. package/docs/functions/misc.isClass.html +1 -1
  44. package/docs/functions/misc.isEmpty.html +1 -1
  45. package/docs/functions/misc.isError.html +1 -1
  46. package/docs/functions/misc.isThenable.html +1 -1
  47. package/docs/functions/misc.isValidElement.html +1 -1
  48. package/docs/functions/misc.shallowEqual.html +1 -1
  49. package/docs/functions/misc.toBool.html +1 -1
  50. package/docs/functions/redux.Provider.html +1 -1
  51. package/docs/functions/redux.combineReducers.html +1 -1
  52. package/docs/functions/redux.connect.html +1 -1
  53. package/docs/functions/redux.useDispatch.html +1 -1
  54. package/docs/functions/redux.useSelector.html +1 -1
  55. package/docs/functions/redux.useStore.html +1 -1
  56. package/docs/functions/router.HashRouter.html +1 -1
  57. package/docs/functions/router.Link.html +1 -1
  58. package/docs/functions/router.NavLink.html +1 -1
  59. package/docs/functions/router.Route.html +1 -1
  60. package/docs/functions/router.Routes.html +1 -1
  61. package/docs/functions/router.useLocation.html +1 -1
  62. package/docs/functions/router.useNavigate.html +1 -1
  63. package/docs/functions/run.lazy.html +1 -1
  64. package/docs/functions/run.require.html +1 -1
  65. package/docs/functions/run.run.html +1 -1
  66. package/docs/functions/run.runScripts.html +1 -1
  67. package/docs/functions/timers.animationFramePromise.html +1 -1
  68. package/docs/functions/timers.clearInterval.html +1 -1
  69. package/docs/functions/timers.clearTimeout.html +1 -1
  70. package/docs/functions/timers.grabTimers.html +1 -1
  71. package/docs/functions/timers.pauseTimers.html +1 -1
  72. package/docs/functions/timers.releaseTimers.html +1 -1
  73. package/docs/functions/timers.resetTimers.html +1 -1
  74. package/docs/functions/timers.resumeTimers.html +1 -1
  75. package/docs/functions/timers.setInterval.html +1 -1
  76. package/docs/functions/timers.setTimeout.html +1 -1
  77. package/docs/functions/timers.timeoutPromise.html +12 -12
  78. package/docs/functions/transition.CSSTransition.html +1 -1
  79. package/docs/functions/transition.SwitchTransition.html +1 -1
  80. package/docs/functions/transition.Transition.html +1 -1
  81. package/docs/functions/transition.TransitionGroup.html +1 -1
  82. package/docs/hierarchy.html +1 -1
  83. package/docs/index.html +8 -7
  84. package/docs/static/index.html +2 -0
  85. package/docs/static/lilact.development.js +5332 -10263
  86. package/docs/static/lilact.development.js.map +7 -0
  87. package/docs/static/lilact.development.min.js +54 -11
  88. package/docs/static/lilact.development.min.js.map +7 -0
  89. package/docs/static/lilact.production.min.js +53 -10
  90. package/docs/variables/accessories.SplitPane.html +1 -1
  91. package/docs/variables/misc.Children.html +2 -2
  92. package/package.json +11 -14
  93. package/root/index.html +2 -0
  94. package/root/lilact.development.js +5332 -10263
  95. package/root/lilact.development.js.map +7 -0
  96. package/root/lilact.development.min.js +54 -11
  97. package/root/lilact.development.min.js.map +7 -0
  98. package/root/lilact.production.min.js +53 -10
  99. package/{webpack.config.factory.cjs → scripts/build.mjs} +48 -73
  100. package/scripts/copy-dist-to-root.mjs +13 -0
  101. package/scripts/esbuild-preprocessor-plugin.cjs +29 -0
  102. package/scripts/preprocess.mjs +42 -0
  103. package/src/accessories.jsx +2 -28
  104. package/src/components.jsx +1 -1
  105. package/src/jsx.js +30 -26
  106. package/src/lilact.jsx +3 -2
  107. package/src/proptypes.jsx +407 -0
  108. package/tsconfig.json +1 -2
  109. package/typedoc.json +13 -13
  110. package/dist/lilact.development.min.js.LICENSE.txt +0 -83
  111. package/dist/lilact.production.min.js.map +0 -1
  112. package/src/loader.cjs +0 -59
  113. package/webpack.config.js +0 -206
package/README.md CHANGED
@@ -29,7 +29,7 @@ If you find Lilact useful, please consider sponsoring. Your support funds ongoin
29
29
 
30
30
  ## Overview
31
31
 
32
- `Lilact` is a very lightweight implementation of the React API designed to run in the browser. It can be used as a single script that is around `98kb` minified and around `32kb` gzipped, and includes its whole API.
32
+ `Lilact` is a very lightweight implementation of the React API designed to run in the browser. It can be used as a single script that is around `90kb` minified and around `32kb` gzipped, and includes its whole API.
33
33
 
34
34
  `Lilact` is very fast, uses minimal resources, and handles memory very efficiently.
35
35
 
@@ -51,7 +51,7 @@ There is a `transpile.js` helper in the `bin` directory to demonstrate how to us
51
51
 
52
52
  `Lilact` implements both the **legacy class-based** API and the **modern hook-based** API, and it includes almost everything you need.
53
53
 
54
- In addition to the API itself, it bundles the official `Redux` and `PropTypes` libraries (see the `redux.jsx` and `proptypes.jsx` demos). As a result, it has Redux support and provides many functions and hooks, including `connect` and `useDispatch`.
54
+ In addition to the API itself, it bundles the official `Redux` library (see the `redux.jsx` example). As a result, it has Redux support and provides all necessary functions and hooks for working with it.
55
55
 
56
56
  It also includes the amazing `@emotion/css` library to ease working with styles. You can access it via `Lilact.emotion`.
57
57
 
@@ -62,6 +62,7 @@ For convenience, it already includes components such as:
62
62
  - `Suspense`
63
63
  - `CSSTransition`
64
64
  - `SwitchTransition`
65
+ - `PropTypes`
65
66
 
66
67
  and helper components like:
67
68
 
@@ -78,9 +79,9 @@ Note: modules are separated in the documentation to improve structure, but in pr
78
79
 
79
80
  ---
80
81
 
81
- ## Webpack-based Bundler
82
+ ## ESBuild-based Bundler
82
83
 
83
- A `webpack` based bundler is available in the `bin` directory. It can be used like this:
84
+ A `ESBuild` based bundler is available in the `bin` directory. It can be used like this:
84
85
 
85
86
  ```bash
86
87
  npx lilact-bundle --entry client/App.jsx --mode production --name bundle.js --out public/dist
@@ -196,10 +197,10 @@ render(<App/>, document.body);
196
197
 
197
198
  ---
198
199
 
199
- ## Learn More / Demos / Beta Status
200
+ ## Learn More / Examples / Beta Status
200
201
 
201
202
  To know more about using `Lilact`, see the included examples:
202
- [Lilact Demo Examples](https://arashkazemi.github.io/lilact/static)
203
+ [Lilact Examples](https://arashkazemi.github.io/lilact/static)
203
204
 
204
205
  For the details, see the documentation.
205
206
 
package/bin/bundle.cjs CHANGED
@@ -30,21 +30,82 @@
30
30
  */
31
31
 
32
32
  const path = require("path");
33
- const webpack = require("webpack");
33
+ const esbuild = require("esbuild");
34
+
35
+ const { createLilactJsxPlugin } = require("../scripts/esbuild-preprocessor-plugin.cjs");
36
+
37
+
38
+ const licenseBanner = `/*!
39
+ Lilact
40
+ Copyright (C) 2024-2026 Arash Kazemi <contact.arash.kazemi@gmail.com>
41
+ All rights reserved.
42
+
43
+ BSD-2-Clause
44
+
45
+ Redistribution and use in source and binary forms, with or without
46
+ modification, are permitted provided that the following conditions are met:
47
+
48
+ * Redistributions of source code must retain the above copyright
49
+ notice, this list of conditions and the following disclaimer.
50
+ * Redistributions in binary form must reproduce the above copyright
51
+ notice, this list of conditions and the following disclaimer in the
52
+ documentation and/or other materials provided with the distribution.
53
+
54
+ --------------------------------------------------------------------------------
55
+
56
+ Lilact also includes the following libraries accessible as members of
57
+ the Lilact object:
58
+
59
+ @emotion/css:
60
+ Copyright (c) Emotion team and other contributors
61
+ MIT License
62
+
63
+ redux:
64
+ Copyright (c) 2015-present Dan Abramov
65
+ MIT License
66
+
67
+
68
+ * MIT License Notice:
69
+
70
+ Permission is hereby granted, free of charge, to any person obtaining a copy
71
+ of this software and associated documentation files (the "Software"), to deal
72
+ in the Software without restriction, including without limitation the rights
73
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
74
+ copies of the Software, and to permit persons to whom the Software is
75
+ furnished to do so, subject to the following conditions:
76
+
77
+ The above copyright notice and this permission notice shall be included in all
78
+ copies or substantial portions of the Software.
79
+
80
+ --------------------------------------------------------------------------------
81
+
82
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
83
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
84
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
85
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
86
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
87
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
88
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
89
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
90
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
91
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
92
+ */
93
+ `;
94
+
34
95
 
35
96
  function parseArgs(argv) {
36
97
  const args = {};
37
98
  for (let i = 2; i < argv.length; i++) {
38
99
  const k = argv[i];
39
- if (!k.startsWith("--")) continue;
100
+ if (!k || !k.startsWith("--")) continue;
40
101
  const key = k.slice(2);
41
- if(key==='watch') {
102
+
103
+ if (key === "watch") {
42
104
  args[key] = true;
105
+ continue;
43
106
  }
44
- else {
45
- const v = argv[++i];
46
- args[key] = v;
47
- }
107
+
108
+ args[key] = argv[++i];
48
109
  }
49
110
  return args;
50
111
  }
@@ -52,77 +113,104 @@ function parseArgs(argv) {
52
113
  async function run() {
53
114
  const args = parseArgs(process.argv);
54
115
 
55
- const userProjectRoot = process.cwd(); // MUST be user's project root
116
+ const userProjectRoot = process.cwd();
56
117
  const userEntry = args.entry ? path.resolve(userProjectRoot, args.entry) : null;
57
118
 
58
119
  if (!userEntry) {
59
120
  console.error(
60
- "Usage: lilact-bundler --watch --entry ./path/to/entry.js --mode production --out ./dist/out --name bundle.js"
61
- );
121
+ "Usage: lilact-bundler --watch --entry ./path/to/entry.js --mode production --out ./dist --name bundle.js"
122
+ );
62
123
  process.exit(1);
63
124
  }
64
125
 
65
126
  const name = args.name ?? "bundle.js";
66
127
  const mode = args.mode ?? "production";
67
- const watch = args?.watch===true;
68
-
69
- const lilactRoot = path.dirname(require.resolve("lilact/package.json"));
70
- const configFactoryPath = path.join(lilactRoot, "webpack.config.factory.cjs");
71
- const configFactory = require(configFactoryPath);
128
+ const watch = args.watch === true;
72
129
 
73
130
  const userOutDir = args.out
74
- ? path.resolve(userProjectRoot, args.out)
75
- : path.resolve(userProjectRoot, "dist");
76
-
77
- const baseConfig = configFactory({
78
- entry: userEntry,
79
- outputPath: userOutDir,
80
- userProjectRoot,
81
- mode,
82
- name
83
- });
131
+ ? path.resolve(userProjectRoot, args.out)
132
+ : path.resolve(userProjectRoot, "dist");
133
+
134
+ const outFile = path.join(userOutDir, name);
135
+
136
+ const define = {
137
+ DEBUG: JSON.stringify(mode === "development"),
138
+ };
139
+
140
+
141
+
142
+ const logOnBuildPlugin = {
143
+ name: "log-on-build",
144
+ setup(build) {
145
+ build.onStart(() => {
146
+ console.log(`Rebuilt: ${outFile} (${new Date().toISOString()})`);
147
+ });
148
+ },
149
+ };
84
150
 
85
- // ---- Critical: ensure resolution happens from user's project ----
86
- baseConfig.context = userProjectRoot;
87
- baseConfig.resolve = baseConfig.resolve || {};
88
- baseConfig.resolve.modules = [path.join(userProjectRoot, "node_modules"), "node_modules"];
151
+ const ctx = await esbuild.context({
152
+ entryPoints: [userEntry],
153
+ bundle: true,
154
+ format: "esm",
155
+ platform: "browser",
89
156
 
90
- const compiler = webpack(baseConfig);
157
+ outfile: outFile,
158
+ sourcemap: mode === "development",
159
+ target: ["es2018"],
91
160
 
92
- const watching = compiler.watch(
93
- {
94
- // You can tweak these; leaving as defaults usually works.
95
- // aggregateTimeout: 300,
96
- // poll: 1000
161
+ minify: mode === "production",
162
+ define,
163
+
164
+ absWorkingDir: userProjectRoot,
165
+
166
+ resolveExtensions: [".js", ".jsx", ".json"],
167
+
168
+ loader: {
169
+ ".js": "js",
170
+ ".jsx": "jsx",
171
+ ".css": "css",
97
172
  },
98
- (err, stats) => {
99
- if (err) {
100
- console.error(err);
101
- return; // keep watching
102
- }
103
-
104
- if (stats?.hasErrors?.()) {
105
- console.error(stats.toString("errors-only"));
106
- return; // keep watching
107
- }
108
-
109
- console.log(
110
- stats?.toString?.({
111
- colors: true,
112
- chunks: false
113
- }) || "Build finished."
114
- );
115
173
 
116
- if(!watch) process.exit(1);
174
+ plugins: [
175
+ createLilactJsxPlugin({ mode }),
176
+ logOnBuildPlugin
177
+ ],
178
+ });
179
+
180
+ const buildOpts = {
181
+ entryPoints: [userEntry],
182
+ bundle: true,
183
+ format: "esm",
184
+ platform: "browser",
185
+ outfile: outFile,
186
+ sourcemap: mode === "development",
187
+ target: ["es2018"],
188
+ minify: mode === "production",
189
+ define,
190
+ loader: { ".js": "js", ".jsx": "jsx", ".css": "css" },
191
+ resolveExtensions: [".js", ".jsx", ".json"],
192
+ absWorkingDir: userProjectRoot,
193
+ plugins: [createLilactJsxPlugin({ mode })],
194
+ banner: { js: licenseBanner },
195
+ };
196
+
197
+ if (watch) {
198
+ await ctx.watch();
199
+ console.log(`Watching... output: ${outFile}`);
200
+ } else {
201
+ await ctx.rebuild();
202
+ }
203
+
204
+ const shutdown = async () => {
205
+ try {
206
+ await ctx.dispose();
207
+ } finally {
208
+ process.exit(0);
117
209
  }
118
- );
210
+ };
119
211
 
120
- process.on("SIGINT", () => {
121
- watching.close(() => process.exit(0));
122
- });
123
- process.on("SIGTERM", () => {
124
- watching.close(() => process.exit(0));
125
- });
212
+ process.on("SIGINT", shutdown);
213
+ process.on("SIGTERM", shutdown);
126
214
  }
127
215
 
128
216
  run().catch((e) => {