lilact 0.15.4 → 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 (114) hide show
  1. package/README.md +7 -6
  2. package/bin/bundle.cjs +148 -60
  3. package/dist/lilact.development.js +5332 -10264
  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 -10264
  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 -10264
  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/hooks.jsx +5 -6
  106. package/src/jsx.js +30 -26
  107. package/src/lilact.jsx +3 -2
  108. package/src/proptypes.jsx +407 -0
  109. package/tsconfig.json +1 -2
  110. package/typedoc.json +13 -13
  111. package/dist/lilact.development.min.js.LICENSE.txt +0 -83
  112. package/dist/lilact.production.min.js.map +0 -1
  113. package/src/loader.cjs +0 -59
  114. package/webpack.config.js +0 -206
@@ -1,65 +1,18 @@
1
- const path = require("path");
2
- const webpack = require('webpack');
3
-
4
- module.exports = function webpackConfigFactory({
5
- entry,
6
- outputPath,
7
- mode,
8
- name
9
- }) {
10
- const entryAbs = path.isAbsolute(entry) ? entry : path.resolve(entry);
11
- const lilactRoot = path.dirname(require.resolve("lilact/package.json"));
12
-
13
- return {
14
- mode,
15
- target: "web",
16
-
17
- entry: entryAbs,
18
-
19
- output: {
20
- path: outputPath,
21
- filename: name,
22
- clean: true
23
- },
24
-
25
- resolve: {
26
- extensions: [".js", ".cjs", ".mjs", ".json", ".css", ".jsx"]
27
- },
28
-
29
- module: {
30
- rules: [
31
- {
32
- test: /\.jsx$/,
33
- exclude: /node_modules/,
34
- use: [{
35
- loader: path.join(lilactRoot, 'src/loader.cjs'),
36
- options: {
37
- mode
38
- }
39
- }]
40
- },
41
- {
42
- test: /\.css$/i,
43
- use: [
44
- {
45
- loader: "style-loader"
46
- },
47
- {
48
- loader: "css-loader",
49
- options: {
50
- // keeps behavior simple; you can enable modules if you want
51
- modules: false,
52
- importLoaders: 0
53
- }
54
- }
55
- ]
56
- }
57
- ]
58
- },
59
- plugins: [
60
- new webpack.BannerPlugin({
61
- banner: `Lilact
62
- Copyright (C) 2024-2025 Arash Kazemi <contact.arash.kazemi@gmail.com>
1
+ import esbuild from "esbuild";
2
+
3
+ const mode = process.env.MODE === "production" ? "production" : "development";
4
+ const minify = process.env.MINIFY === "true";
5
+
6
+ const DEBUG = mode === "development";
7
+
8
+ const suffix = mode === "development" ? ".development" : ".production";
9
+ const minSuffix = minify ? ".min" : "";
10
+ const outFile = `lilact.${mode}${minSuffix}.js`;
11
+
12
+
13
+ const licenseBanner = `/*!
14
+ Lilact
15
+ Copyright (C) 2024-2026 Arash Kazemi <contact.arash.kazemi@gmail.com>
63
16
  All rights reserved.
64
17
 
65
18
  BSD-2-Clause
@@ -82,10 +35,6 @@ the Lilact object:
82
35
  Copyright (c) Emotion team and other contributors
83
36
  MIT License
84
37
 
85
- prop-types:
86
- Copyright (c) 2013-present, Facebook, Inc.
87
- MIT License
88
-
89
38
  redux:
90
39
  Copyright (c) 2015-present Dan Abramov
91
40
  MIT License
@@ -115,10 +64,36 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
115
64
  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
116
65
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
117
66
  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
118
- `,
119
- raw: false, // treat banner as text
120
- entryOnly: false, // apply to all chunks; set true for entry only
121
- }),
122
- ]
123
- };
124
- };
67
+ */
68
+ `;
69
+
70
+
71
+ await esbuild.build({
72
+ entryPoints: [".tmp/src/lilact.jsx"],
73
+ bundle: true,
74
+ format: "esm",
75
+ platform: "browser",
76
+
77
+ outfile: `dist/${outFile}`,
78
+ target: "es2018",
79
+ sourcemap: mode === "development",
80
+
81
+ minify,
82
+
83
+ define: {
84
+ DEBUG: JSON.stringify(DEBUG),
85
+ },
86
+
87
+ loader: {
88
+ ".js": "js",
89
+ ".jsx": "jsx",
90
+ },
91
+
92
+ logOverride: {
93
+ "direct-eval": "silent",
94
+ },
95
+
96
+ banner: {
97
+ js: licenseBanner, // prepended to the top of the generated JS
98
+ },
99
+ });
@@ -0,0 +1,13 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+
4
+ const root = path.resolve(process.cwd(), "root");
5
+ const dist = path.resolve(process.cwd(), "dist");
6
+
7
+ fs.mkdirSync(root, { recursive: true });
8
+
9
+ for (const name of fs.readdirSync(dist)) {
10
+ const src = path.join(dist, name);
11
+ const dst = path.join(root, name);
12
+ if (fs.statSync(src).isFile()) fs.copyFileSync(src, dst);
13
+ }
@@ -0,0 +1,29 @@
1
+ // scripts/esbuild-preprocessor-plugin.cjs
2
+ const fs = require("fs/promises");
3
+ const path = require("path");
4
+ const { transpileJSX } = require("../src/jsx.js");
5
+
6
+ function createLilactJsxPlugin({ mode }) {
7
+ const DEBUG = mode !== "production";
8
+
9
+ return {
10
+ name: "lilact-transpile-jsx",
11
+ setup(build) {
12
+ build.onLoad({ filter: /\.jsx$/ }, async (args) => {
13
+ const source = await fs.readFile(args.path, "utf8");
14
+
15
+ const out = transpileJSX(source, {
16
+ path: args.path,
17
+ appendSourcemap: DEBUG,
18
+ });
19
+
20
+ return { contents: out, loader: "js" };
21
+ });
22
+
23
+ // Optional: if you want .js files through your transpiler too, add another onLoad:
24
+ // build.onLoad({ filter: /\.js$/ }, async (args) => { ... })
25
+ },
26
+ };
27
+ }
28
+
29
+ module.exports = { createLilactJsxPlugin };
@@ -0,0 +1,42 @@
1
+ // scripts/preprocess.mjs
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import fg from "fast-glob";
5
+ import { fileURLToPath } from "url";
6
+ import { transpileJSX } from "../src/jsx.js";
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+ const projectRoot = path.resolve(__dirname, "..");
11
+
12
+ const mode = process.env.MODE === "production" ? "production" : "development";
13
+ const DEBUG = mode === "development";
14
+
15
+ const outDir = path.resolve(projectRoot, ".tmp");
16
+
17
+ const files = await fg(["src/**/*.jsx", "src/**/*.js"], {
18
+ cwd: projectRoot,
19
+ onlyFiles: true,
20
+ });
21
+
22
+ await Promise.all(
23
+ files.map(async (rel) => {
24
+ const inPath = path.resolve(projectRoot, rel);
25
+
26
+ const outRel = rel; //.replace(/\.(jsx|js)$/i, ".js");
27
+ const outPath = path.resolve(outDir, outRel);
28
+
29
+ await fs.promises.mkdir(path.dirname(outPath), { recursive: true });
30
+
31
+ const source = await fs.promises.readFile(inPath, "utf8");
32
+
33
+ const compiled = transpileJSX(source, {
34
+ path: inPath,
35
+ appendSourcemap: DEBUG,
36
+ });
37
+
38
+ await fs.promises.writeFile(outPath, compiled, "utf8");
39
+ })
40
+ );
41
+
42
+ console.log("Preprocessing done.");
@@ -173,30 +173,9 @@ export class Suspense extends Component
173
173
  }
174
174
 
175
175
  /** @ignore */
176
- componentDidCatch(error) {
176
+ componentDidCatch(error, info) {
177
177
  if (!isThenable(error)) return;
178
-
179
- const promise = error;
180
-
181
- if (this._pending.has(promise)) return;
182
-
183
- // Add to set of pending promises
184
- this._pending.add(promise);
185
-
186
- // Start delay timer only when this is the first pending promise
187
- if (this._pending.size === 1) {
188
- const delay = Math.max(0, this.props.minDelay);
189
- // Ensure no leftover timers
190
- if (this._delayTimer) {
191
- clearTimeout(this._delayTimer);
192
- this._delayTimer = null;
193
- }
194
- this._delayTimer = setTimeout(() => {
195
- this._delayTimer = null;
196
- this._fallbackShownAt = Date.now();
197
- this.setState({ showingFallback: true });
198
- }, delay);
199
- }
178
+ this._attachPromise(error);
200
179
  }
201
180
 
202
181
  /** @ignore */
@@ -274,11 +253,6 @@ export class Suspense extends Component
274
253
  promise.then(onSettled, onSettled);
275
254
  }
276
255
 
277
- /** @ignore */
278
- componentDidCatch(error, info) {
279
- if (!isThenable(error)) return;
280
- this._attachPromise(error);
281
- }
282
256
 
283
257
  /** @ignore */
284
258
  render() {
@@ -33,7 +33,7 @@ import Lilact from './lilact.jsx';
33
33
  import { CORE, COMPONENT, TEXT, IS_ZOMBIE, IDX, CHILD_CLASS_ADDENDUM, MEMOIZED } from "./symbols.jsx"
34
34
  import { shallowEqual, toBool, isClass } from "./misc.jsx";
35
35
 
36
- import PropTypes from 'prop-types';
36
+ import { PropTypes } from './proptypes.jsx';
37
37
 
38
38
  /*
39
39
  ComponentCache is for internal use. It is the heart of the JSX runtime,
package/src/hooks.jsx CHANGED
@@ -480,11 +480,10 @@ export function useImperativeHandle(ref, factory, deps=undefined)
480
480
 
481
481
  ref.deps = deps;
482
482
 
483
- Lilact.setTimeout( ()=>{
484
- if(typeof ref?.current !== 'object') {
485
- ref.current = {};
486
- }
487
- Object.assign( ref.current, factory(), 0 );
488
- }, 0);
483
+ if(typeof ref?.current !== 'object') {
484
+ ref.current = {};
485
+ }
486
+ Object.assign( ref.current, factory(), 0 );
487
+
489
488
  }
490
489
 
package/src/jsx.js CHANGED
@@ -34,7 +34,7 @@
34
34
  // It is not very fast, the xml look-ahead can be quite expensive, but it is not
35
35
  // slow at all.
36
36
 
37
- // Check the webpack config and also the transpiler.js helper script for
37
+ // Check the esbuild config and also the transpiler.js helper script for
38
38
  // usage outside Lilact. Also make sure to check the default configuration.
39
39
 
40
40
  // There are some situations that are solved with tricks, as some aspects of
@@ -46,11 +46,11 @@
46
46
  // note: JSX or preprocessors are not processed inside template strings
47
47
  // todo: injected string try catchs should be generated by a function
48
48
 
49
- import * as jsxAddons from './jsx.addons.js';
49
+ //import * as jsxAddons from './jsx.addons.js';
50
50
 
51
51
  /** @ignore */
52
52
  export const transpilerConfig = {
53
- addons: jsxAddons,
53
+ //addons: jsxAddons, // addons are not used anymore
54
54
  setBlockLabels: true,
55
55
  enableLabelStack: false,
56
56
  injectLabels: true,
@@ -87,7 +87,7 @@ function parseRegex(code, index, container)
87
87
  // todo: i have doubts about including preprocessorDelimiter
88
88
 
89
89
  let i = index;
90
- const dels = `;=,([{}!^~&|:?*%-+/<>${transpilerConfig.preprocessorDelimiter}`;
90
+ let dels = `;=,([{}!^~&|:?*%-+/<>${transpilerConfig.preprocessorDelimiter}`;
91
91
  while(--i>0) {
92
92
  if( ' \t\r'.indexOf(code[i])!==-1 ) continue;
93
93
  if(code[i]==='\n' ) {
@@ -230,7 +230,8 @@ function preprocessPragmas(node, context)
230
230
  {
231
231
  const all_nodes = [];
232
232
 
233
- var segments = ["const {" + Object.keys(jsxAddons).join(', ') + "} = transpilerConfig.addons;"];
233
+ var segments = []; //["const {" + Object.keys(jsxAddons).join(', ') + "} = transpilerConfig.addons;"];
234
+ // addons are not used anymore
234
235
 
235
236
  var scope_stack = [];
236
237
  var last_block = null;
@@ -582,23 +583,25 @@ function parseXML(code, index, container, look_behind=false)
582
583
  break;
583
584
 
584
585
  case '>':
585
- const i = parseXMLContent(code, index, b);
586
+ {
587
+ const i = parseXMLContent(code, index, b);
586
588
 
587
- // not xml
588
- // todo: side effects must be checked
589
- if(i===null) return;
589
+ // not xml
590
+ // todo: side effects must be checked
591
+ if(i===null) return;
590
592
 
591
- if(i>index) index = i;
592
- else index++;
593
+ if(i>index) index = i;
594
+ else index++;
593
595
 
594
- if(b.end) {
595
- if(container) container.children.push(b);
596
- return b;
597
- }
598
- else {
599
- index++;
596
+ if(b.end) {
597
+ if(container) container.children.push(b);
598
+ return b;
599
+ }
600
+ else {
601
+ index++;
602
+ }
603
+ break;
600
604
  }
601
- break;
602
605
 
603
606
  case ' ':
604
607
  case '\t':
@@ -1182,14 +1185,15 @@ export function transpileJSX( jsx, {
1182
1185
  out += inline_sm;
1183
1186
  }
1184
1187
 
1185
- if(globalThis[TRANSPILER_OUTPUT]) {
1186
- try {
1187
- const fs = import('fs');
1188
- fs.writeFileSync(globalThis[TRANSPILER_OUTPUT], out);
1189
- }
1190
- catch(e) {}
1191
- globalThis[TRANSPILER_OUTPUT] = undefined;
1192
- }
1188
+ // if(globalThis[TRANSPILER_OUTPUT]) {
1189
+ // try {
1190
+ // const fs = import('fs');
1191
+ // fs.writeFileSync(globalThis[TRANSPILER_OUTPUT], out);
1192
+ // }
1193
+ // catch(e) {}
1194
+ // globalThis[TRANSPILER_OUTPUT] = undefined;
1195
+ // }
1196
+
1193
1197
  //console.log(out);
1194
1198
 
1195
1199
  return out;
package/src/lilact.jsx CHANGED
@@ -50,7 +50,7 @@
50
50
 
51
51
  import * as redux from "redux";
52
52
  import * as emotion from "@emotion/css";
53
- import PropTypes from 'prop-types';
53
+ import { PropTypes } from './proptypes.jsx';
54
54
 
55
55
  import * as components from './components.jsx';
56
56
  import * as hooks from './hooks.jsx';
@@ -92,7 +92,7 @@ export {transpileJSX, transpilerConfig} from "./jsx";
92
92
  export const Lilact =
93
93
  {
94
94
 
95
- VERSION: "beta.15",
95
+ VERSION: "beta.16",
96
96
 
97
97
  // Configuration
98
98
 
@@ -124,6 +124,7 @@ export const Lilact =
124
124
  emotion,
125
125
 
126
126
  }
127
+
127
128
  globalThis.Lilact = Lilact;
128
129
  globalThis.createComponent = Lilact.createComponent;
129
130
  globalThis.Fragment = Lilact.Fragment;