bitwrench 2.0.16 → 2.0.18

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 (68) hide show
  1. package/README.md +127 -38
  2. package/dist/bitwrench-bccl.cjs.js +13 -9
  3. package/dist/bitwrench-bccl.cjs.min.js +2 -2
  4. package/dist/bitwrench-bccl.esm.js +13 -9
  5. package/dist/bitwrench-bccl.esm.min.js +2 -2
  6. package/dist/bitwrench-bccl.umd.js +13 -9
  7. package/dist/bitwrench-bccl.umd.min.js +2 -2
  8. package/dist/bitwrench-code-edit.cjs.js +1 -1
  9. package/dist/bitwrench-code-edit.cjs.min.js +1 -1
  10. package/dist/bitwrench-code-edit.es5.js +1 -1
  11. package/dist/bitwrench-code-edit.es5.min.js +1 -1
  12. package/dist/bitwrench-code-edit.esm.js +1 -1
  13. package/dist/bitwrench-code-edit.esm.min.js +1 -1
  14. package/dist/bitwrench-code-edit.umd.js +1 -1
  15. package/dist/bitwrench-code-edit.umd.min.js +1 -1
  16. package/dist/bitwrench-lean.cjs.js +1438 -920
  17. package/dist/bitwrench-lean.cjs.min.js +20 -20
  18. package/dist/bitwrench-lean.es5.js +1518 -1105
  19. package/dist/bitwrench-lean.es5.min.js +18 -18
  20. package/dist/bitwrench-lean.esm.js +1437 -920
  21. package/dist/bitwrench-lean.esm.min.js +20 -20
  22. package/dist/bitwrench-lean.umd.js +1438 -920
  23. package/dist/bitwrench-lean.umd.min.js +20 -20
  24. package/dist/bitwrench-util-css.cjs.js +236 -0
  25. package/dist/bitwrench-util-css.cjs.min.js +22 -0
  26. package/dist/bitwrench-util-css.es5.js +414 -0
  27. package/dist/bitwrench-util-css.es5.min.js +21 -0
  28. package/dist/bitwrench-util-css.esm.js +230 -0
  29. package/dist/bitwrench-util-css.esm.min.js +21 -0
  30. package/dist/bitwrench-util-css.umd.js +242 -0
  31. package/dist/bitwrench-util-css.umd.min.js +21 -0
  32. package/dist/bitwrench.cjs.js +1450 -928
  33. package/dist/bitwrench.cjs.min.js +21 -21
  34. package/dist/bitwrench.css +456 -132
  35. package/dist/bitwrench.es5.js +1563 -1140
  36. package/dist/bitwrench.es5.min.js +19 -19
  37. package/dist/bitwrench.esm.js +1450 -929
  38. package/dist/bitwrench.esm.min.js +21 -21
  39. package/dist/bitwrench.min.css +1 -1
  40. package/dist/bitwrench.umd.js +1450 -928
  41. package/dist/bitwrench.umd.min.js +21 -21
  42. package/dist/builds.json +178 -90
  43. package/dist/bwserve.cjs.js +528 -68
  44. package/dist/bwserve.esm.js +527 -69
  45. package/dist/sri.json +44 -36
  46. package/package.json +5 -2
  47. package/readme.html +136 -49
  48. package/src/bitwrench-bccl.js +12 -8
  49. package/src/bitwrench-color-utils.js +31 -9
  50. package/src/bitwrench-esm-entry.js +11 -0
  51. package/src/bitwrench-styles.js +439 -232
  52. package/src/bitwrench-util-css.js +229 -0
  53. package/src/bitwrench.js +979 -630
  54. package/src/bwserve/attach.js +57 -0
  55. package/src/bwserve/bwclient.js +141 -0
  56. package/src/bwserve/bwshell.js +102 -0
  57. package/src/bwserve/client.js +151 -1
  58. package/src/bwserve/index.js +139 -29
  59. package/src/cli/attach.js +555 -0
  60. package/src/cli/convert.js +2 -5
  61. package/src/cli/index.js +7 -0
  62. package/src/cli/inject.js +1 -1
  63. package/src/cli/layout-default.js +47 -32
  64. package/src/cli/serve.js +6 -2
  65. package/src/generate-css.js +11 -4
  66. package/src/vendor/html2canvas.min.js +20 -0
  67. package/src/version.js +3 -3
  68. package/src/bwserve/shell.js +0 -103
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Bitwrench CLI - Default page layout
3
- * Wraps converted content in a complete HTML document
3
+ * Wraps converted content in a complete HTML document.
4
+ * Delegates to bw.htmlPage() for document structure.
4
5
  */
5
6
 
6
7
  import bw from '../bitwrench.js';
@@ -77,7 +78,11 @@ const BASE_PAGE_CSS = `
77
78
  `;
78
79
 
79
80
  /**
80
- * Build a complete HTML page from content and options
81
+ * Build a complete HTML page from content and options.
82
+ * Delegates to bw.htmlPage() for document structure, adding CLI-specific
83
+ * concerns: .bw_cli_page wrapper, generator meta tag, highlight.js, and
84
+ * pre-resolved injection strings from inject.js.
85
+ *
81
86
  * @param {Object} opts
82
87
  * @param {string} opts.title - Page title
83
88
  * @param {string} opts.bodyHTML - Rendered HTML content for the body
@@ -99,44 +104,54 @@ export function makePageLayout(opts) {
99
104
  highlight = false
100
105
  } = opts;
101
106
 
102
- const safeTitle = bw.escapeHTML(title);
103
- const version = bw.version;
107
+ const version = bw.getVersion().version;
104
108
 
105
- let faviconTag = '';
106
- if (favicon) {
107
- // Only escape quotes and angle brackets for attribute safety, not slashes
108
- const safeFavicon = favicon.replace(/[&<>"']/g, c => ({
109
- '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;'
110
- })[c]);
111
- faviconTag = `<link rel="icon" href="${safeFavicon}">`;
109
+ // Build extra <head> elements: generator meta, injection script, highlight.js CSS
110
+ const headElements = [];
111
+
112
+ // Generator meta tag (CLI-specific)
113
+ headElements.push({
114
+ t: 'meta', a: { name: 'generator', content: 'bitwrench v' + version }
115
+ });
116
+
117
+ // Injection script from inject.js (already pre-built HTML string)
118
+ if (headInjection) {
119
+ headElements.push(bw.raw(headInjection));
112
120
  }
113
121
 
114
- let highlightHead = '';
115
- let highlightBodyEnd = '';
122
+ // Highlight.js CSS
116
123
  if (highlight) {
117
- highlightHead = '<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11/build/styles/github.min.css">';
118
- highlightBodyEnd = '<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11/build/highlight.min.js"></script>\n<script>hljs.highlightAll();</script>';
124
+ headElements.push({
125
+ t: 'link', a: {
126
+ rel: 'stylesheet',
127
+ href: 'https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11/build/styles/github.min.css'
128
+ }
129
+ });
119
130
  }
120
131
 
132
+ // Wrap body content in .bw_cli_page div (CLI-specific)
133
+ const wrappedBody = '<div class="bw_cli_page">\n' + bodyHTML + '\n</div>';
134
+
135
+ // Build body-end injection (highlight.js init)
136
+ let fullBodyEnd = bodyEndInjection || '';
137
+ if (highlight) {
138
+ fullBodyEnd += '<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11/build/highlight.min.js"></script>\n<script>hljs.highlightAll();</script>';
139
+ }
140
+
141
+ // Combine all CSS
121
142
  const allCSS = BASE_PAGE_CSS + (css ? '\n' + css : '');
122
143
 
123
- return `<!DOCTYPE html>
124
- <html lang="en">
125
- <head>
126
- <meta charset="UTF-8">
127
- <meta name="viewport" content="width=device-width, initial-scale=1">
128
- <meta name="generator" content="bitwrench v${version}">
129
- <title>${safeTitle}</title>
130
- ${faviconTag}${headInjection}${highlightHead}
131
- <style>${allCSS}</style>
132
- </head>
133
- <body>
134
- <div class="bw_cli_page">
135
- ${bodyHTML}
136
- </div>
137
- ${bodyEndInjection}${highlightBodyEnd}
138
- </body>
139
- </html>`;
144
+ // Use bw.htmlPage() with runtime:'none' since CLI handles injection itself
145
+ var page = bw.htmlPage({
146
+ title: title,
147
+ body: wrappedBody + (fullBodyEnd ? '\n' + fullBodyEnd : ''),
148
+ css: allCSS,
149
+ head: headElements,
150
+ favicon: favicon,
151
+ runtime: 'none'
152
+ });
153
+
154
+ return page;
140
155
  }
141
156
 
142
157
  export { BASE_PAGE_CSS };
package/src/cli/serve.js CHANGED
@@ -29,6 +29,7 @@ Options:
29
29
  --stdin Read protocol messages from stdin (newline-delimited JSON)
30
30
  -t, --theme <name> Theme preset or hex colors ("#pri,#sec")
31
31
  --title <string> Page title (default: "bwcli serve")
32
+ --allow-exec Enable exec messages (runs JS in browser, use for dev only)
32
33
  --open Open browser on start
33
34
  -v, --verbose Verbose output
34
35
  -h, --help Print this help
@@ -148,6 +149,7 @@ export function runServe(argv) {
148
149
  stdin: { type: 'boolean' },
149
150
  theme: { type: 'string', short: 't' },
150
151
  title: { type: 'string' },
152
+ 'allow-exec': { type: 'boolean' },
151
153
  open: { type: 'boolean' },
152
154
  verbose: { type: 'boolean', short: 'v' },
153
155
  help: { type: 'boolean', short: 'h' }
@@ -193,7 +195,8 @@ export function runServe(argv) {
193
195
  theme: theme,
194
196
  title: title,
195
197
  verbose: verbose,
196
- open: !!values.open
198
+ open: !!values.open,
199
+ allowExec: !!values['allow-exec']
197
200
  });
198
201
  }).catch(function(err) {
199
202
  console.error('Failed to load bwserve: ' + err.message);
@@ -209,7 +212,8 @@ function startServer(bwserve, opts) {
209
212
  port: opts.webPort,
210
213
  title: opts.title,
211
214
  static: opts.dir,
212
- theme: opts.theme
215
+ theme: opts.theme,
216
+ allowExec: opts.allowExec
213
217
  });
214
218
 
215
219
  // Register a passthrough page handler — just keeps clients alive
@@ -8,16 +8,23 @@ import { getAllStyles, getStructuralStyles, generateThemedCSS,
8
8
  import { derivePalette } from './bitwrench-color-utils.js';
9
9
  import fs from 'fs';
10
10
  import path from 'path';
11
+ import { createRequire } from 'module';
12
+ const require = createRequire(import.meta.url);
13
+ const pkg = require('../package.json');
11
14
 
12
15
  // Convert styles object to CSS string
13
16
  function stylesToCSS(styles) {
14
17
  let css = `/**
15
- * Bitwrench v2 CSS
16
- * Class-based styles to prevent framework collisions
17
- * Generated from bitwrench-styles.js
18
+ * bitwrench.css v${pkg.version} — AUTO-GENERATED, DO NOT EDIT
19
+ *
20
+ * Generated by src/generate-css.js from bitwrench-styles.js
21
+ * This is a static snapshot of what bw.loadStyles() produces
22
+ * at runtime. Use one or the other, not both.
23
+ *
24
+ * To regenerate: npm run build:css
25
+ * ${pkg.homepage}
18
26
  */
19
27
 
20
- /* Base styles with .bw namespace */
21
28
  `;
22
29
 
23
30
  // Process each style rule