solarite 0.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.
Files changed (63) hide show
  1. package/build/build.bat +3 -0
  2. package/build/build.js +139 -0
  3. package/build/lib/rollup.min.js +11 -0
  4. package/build/lib/source-map.min.js +1 -0
  5. package/build/lib/terser.min.js +1 -0
  6. package/dist/Solarite-debug.js +4143 -0
  7. package/dist/Solarite.js +3740 -0
  8. package/dist/Solarite.min.js +4 -0
  9. package/docs/index.md +423 -0
  10. package/docs/js/Playground.js +184 -0
  11. package/docs/js/codemirror/codemirror6.js +32036 -0
  12. package/docs/js/codemirror/themeSolarIce.js +312 -0
  13. package/docs/js/documentation.js +32 -0
  14. package/docs/js/ui/CodeEditor.js +840 -0
  15. package/docs/js/ui/DarkToggle.js +52 -0
  16. package/docs/js/ui/FlexResizer.js +142 -0
  17. package/docs/js/util/Draggable2.js +151 -0
  18. package/docs/js/util/Errors.js +9 -0
  19. package/docs/js/util/Html.js +147 -0
  20. package/docs/js/util/Icons.js +623 -0
  21. package/docs/js/util/Input.js +253 -0
  22. package/docs/js/util/Util.js +88 -0
  23. package/docs/js/util/delve.js +43 -0
  24. package/docs/media/FiraCode400.woff2 +0 -0
  25. package/docs/media/cabin-latin-700.woff2 +0 -0
  26. package/docs/media/documentation.css +93 -0
  27. package/docs/media/eternium.css +1123 -0
  28. package/docs/media/solarite-machine.webp +0 -0
  29. package/index.html +325 -0
  30. package/package.json +33 -0
  31. package/readme.md +3 -0
  32. package/src/solarite/ExprPath.js +554 -0
  33. package/src/solarite/MultiValueMap.js +65 -0
  34. package/src/solarite/NodeGroup.js +706 -0
  35. package/src/solarite/NodeGroupManager.js +582 -0
  36. package/src/solarite/Shell.js +307 -0
  37. package/src/solarite/Solarite.js +19 -0
  38. package/src/solarite/Template.js +85 -0
  39. package/src/solarite/Util.js +264 -0
  40. package/src/solarite/createSolarite.js +267 -0
  41. package/src/solarite/getArg.js +99 -0
  42. package/src/solarite/hash.js +101 -0
  43. package/src/solarite/r.js +143 -0
  44. package/src/solarite/udomdiff.js +233 -0
  45. package/src/solarite/watch.js +302 -0
  46. package/src/solarite/watch2.js +439 -0
  47. package/src/unused/FastLookupArray.js +54 -0
  48. package/src/unused/Hashes.js +339 -0
  49. package/src/unused/InUse.test.js +92 -0
  50. package/src/unused/InUseMap.js +98 -0
  51. package/src/unused/LinkedList.js +117 -0
  52. package/src/unused/LinkedList.test.js +115 -0
  53. package/src/unused/Perf.js +47 -0
  54. package/src/unused/Template.js +108 -0
  55. package/src/util/Errors.js +9 -0
  56. package/src/util/Util.js +88 -0
  57. package/src/util/delve.js +43 -0
  58. package/tests/Benchmark.test.js +319 -0
  59. package/tests/NodeGroup.test.js +115 -0
  60. package/tests/Shell.test.js +75 -0
  61. package/tests/Solarite.test.js +2896 -0
  62. package/tests/Testimony.js +602 -0
  63. package/tests/index.html +75 -0
@@ -0,0 +1,3 @@
1
+ node build ../src/solarite/Solarite.js ../dist/Solarite.js
2
+ rem copy "..\dist\Solarite.min.js" "..\js-framework-benchmark\keyed\solarite\Solarite.min.js"
3
+ rem copy "..\dist\Solarite.min.js" "..\js-framework-benchmark\non-keyed\solarite\Solarite.min.js"
package/build/build.js ADDED
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Run rollup and terser on a javascript file and all of its dependencies.
3
+ *
4
+ * @example
5
+ * # Creates output.js and output.min.js
6
+ * node build input.js output.js
7
+ *
8
+ * ------------------------
9
+ * How to create the dependencies for build.js Tested with Rollup v2.23.0 and Terser 5.3.2
10
+ * 1. Start in a blank folder.
11
+ * 2. npm install rollup terser
12
+ * 3. npm install -g rollup terser
13
+ * 4. rollup node_modules/rollup/dist/shared/rollup.js > ./rollup2.js
14
+ * 5. terser ./rollup2.js > rollup.min.js
15
+ * 6. del rollup2.js
16
+ * 7. terser node_modules/terser/dist/bundle.min.js > ./terser.min.js
17
+ * 8. Modify line 2 of terser.min.js to replace require('source-map') with require('./source-map.min.js')
18
+ * 9. npm uninstall -g rollup terser
19
+ * 10. Copy terser.min.js, rollup.min.js, and source-map.min.js to the lib folder, and delete our temporary working folder.
20
+ *
21
+ * After that, node.js is the only external dependency needed to build.
22
+ */
23
+
24
+ const rollupOptions = {
25
+ onwarn: function (message) { // Suppress messages about external dependencies.
26
+ if (message.code !== 'CIRCULAR_DEPENDENCY' && message.code !== 'EVAL')
27
+ console.error(message);
28
+ },
29
+ treeshake: { // does nothing!
30
+ preset: 'smallest',
31
+ manualPureFunctions: ['assert']
32
+ }
33
+ };
34
+ const terserOptions = {
35
+ ecma: 8, // Decreases size.
36
+ format: {
37
+ preamble: `// Version ${timestamp()}\r\n// License: MIT\r\n// https://github.com/vorticode/Solarite`,
38
+ },
39
+ compress: { // https://github.com/terser/terser#compress-options
40
+ passes: 5,
41
+ //hoist_funs: true, // Increases size
42
+ //hoist_vars: true, // Increases size
43
+ pure_getters: true,
44
+ unsafe: true,
45
+ unsafe_arrows: true,
46
+ unsafe_comps: true,
47
+ unsafe_Function: true,
48
+ unsafe_math: true,
49
+ unsafe_methods: true,
50
+ unsafe_proto: true,
51
+ unsafe_regexp: true,
52
+ unsafe_undefined: true,
53
+ },
54
+ mangle: { // https://github.com/terser/terser#mangle-options
55
+ //eval: true, // We use reserved words to not mangle names used in eval.
56
+ toplevel: true, // Does nothing?
57
+ properties: {
58
+ regex: /_$/,
59
+ undeclared: true, // Does nothing?
60
+ }
61
+ //module: true, // Does nothing?
62
+ }
63
+ }
64
+
65
+
66
+
67
+ // Code starts here:
68
+
69
+ const input = process.argv[2];
70
+ const output = process.argv[3];
71
+ const outputDebug = output.replace(/\.js$/, '-debug.js');
72
+ const outputMin = output.replace(/\.js$/, '.min.js');
73
+
74
+ const fs = require('fs');
75
+ const Rollup = require('./lib/rollup.min.js');
76
+ const Terser = require("./lib/terser.min.js");
77
+
78
+ /*
79
+ // Deno version (Unsupported)
80
+ const input = Deno.args[0];
81
+ const output = Deno.args[1];
82
+ const outputMin = output.replace(/\.js$/, '.min.js');
83
+
84
+ import './lib/rollup.min.js';
85
+ import "./lib/terser.min.js";
86
+ */
87
+
88
+ async function rollup(input, output, options) {
89
+ options.input = input;
90
+ const bundle = await Rollup.rollup(options);
91
+ await bundle.write({ // https://rollupjs.org/guide/en/
92
+ file: output,
93
+ format: 'es'
94
+ });
95
+ }
96
+
97
+ function timestamp() {
98
+ let d = new Date();
99
+ return d.getUTCFullYear() +
100
+ '.' + (d.getUTCMonth()+1) +
101
+ '.' + d.getUTCDate() +
102
+ '.' + (d.getUTCHours()+'').padStart(2, '0') + (d.getUTCMinutes()+'').padStart(2, '0')
103
+ }
104
+
105
+ async function terser(options) {
106
+ var code = [fs.readFileSync(outputDebug)].join('');
107
+
108
+ // Remove //#IFDEV blocks.
109
+ code = code.replace(/\/\/#IFDEV[\s\S]*?\/\/#ENDIF/gm, '');
110
+ code = code.replace(/\/\*#IFDEV\*\/[\s\S]*?\/\*#ENDIF\*\//gm, '');
111
+
112
+ fs.writeFileSync(output, code);
113
+
114
+ let idx = code.indexOf('#IFDEV')
115
+ if (idx !== -1) {
116
+ console.log(idx);
117
+ console.log(code.slice(Math.max(idx-50, 0), idx+50));
118
+ throw new Error('Unmatched #IFDEV block');
119
+ }
120
+ idx = code.indexOf('#ENDIF');
121
+ if (idx !== -1) {
122
+ console.log(code.slice(Math.max(idx-50, 0), idx+50));
123
+ throw new Error('Unmatched #ENDIF block');
124
+ }
125
+
126
+
127
+ var result = await Terser.minify(code, options);
128
+ fs.writeFileSync(outputMin, result.code);
129
+
130
+ let stats = fs.statSync(output);
131
+ let statsMin = fs.statSync(outputMin);
132
+ console.log(`Successfully created ${output} (${stats.size.toLocaleString()} bytes) ` +
133
+ `and ${outputMin} (${statsMin.size.toLocaleString()} bytes).` );
134
+ }
135
+
136
+
137
+ rollup(input, outputDebug, rollupOptions).then(() => {
138
+ terser(terserOptions);
139
+ });