@trebco/treb 25.8.0 → 25.9.1

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/treb.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /*! API v25.8. Copyright 2018-2023 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
1
+ /*! API v25.9. Copyright 2018-2023 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
2
2
 
3
3
  /**
4
4
  * add our tag to the map
package/esbuild-utils.mjs CHANGED
@@ -81,17 +81,25 @@ export const FormatSize = (size, precision = 1) => {
81
81
  *
82
82
  * if you import a worker script like this
83
83
  * ```
84
- * import worker_script from 'worker://path/to/worker.ts';
84
+ * import * as worker_script from 'worker:path/to/worker';
85
85
  * ```
86
86
  * the plugin will compile the target (with esbuild) and then return the
87
87
  * compiled script as a string. the child build inherits minify settings
88
88
  * from the parent build.
89
89
  *
90
+ * note the `import *` syntax; we can't just import the script, because
91
+ * tsc will complain about a missing default export (and you can't have
92
+ * a default export, or it will break when it runs).
93
+ *
90
94
  * you can then use it in the containing script by creating a worker:
91
95
  * ```
92
- * const worker = new Worker(URL.createObjectURL(new Blob([worker_script], { type: 'application/javascript' })));
96
+ * const worker = new Worker(URL.createObjectURL(new Blob([(worker_script as any).default], { type: 'application/javascript' })));
93
97
  * ```
94
98
  *
99
+ * here we have to use `any`, for the time being, because when tsc reads
100
+ * this it will note (correctly) that there's no default. but for our
101
+ * esbuild import, we will have a default string.
102
+ *
95
103
  * this might cause problems with CSP. if so, we'll sort that out separately.
96
104
  *
97
105
  */
@@ -99,8 +107,8 @@ export const WorkerPlugin = (options) => ({
99
107
  name: 'worker',
100
108
  setup(build) {
101
109
 
102
- build.onResolve({ filter: /^worker:\/\//}, async (args) => {
103
- args.path = args.path.substring(9);
110
+ build.onResolve({ filter: /^worker:/}, async (args) => {
111
+ args.path = args.path.substring(7);
104
112
  const result = await build.resolve(args.path, {
105
113
  kind: args.kind,
106
114
  resolveDir: args.resolveDir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trebco/treb",
3
- "version": "25.8.0",
3
+ "version": "25.9.1",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "homepage": "https://treb.app",
6
6
  "repository": {
@@ -26,6 +26,7 @@
26
26
  "treb-base-types": "file:treb-base-types",
27
27
  "treb-calculator": "file:treb-calculator",
28
28
  "treb-charts": "file:treb-charts",
29
+ "treb-export": "file:treb-export",
29
30
  "treb-format": "file:treb-format",
30
31
  "treb-grid": "file:treb-grid",
31
32
  "treb-parser": "file:treb-parser",
@@ -6,6 +6,7 @@
6
6
  "../treb-utils/**/*.ts",
7
7
  "../treb-grid/**/*.ts",
8
8
  "../treb-charts/**/*.ts",
9
+ "../treb-export/**/*.ts",
9
10
  "../treb-format/**/*.ts",
10
11
  "../treb-parser/**/*.ts",
11
12
  "../treb-calculator/**/*.ts",
@@ -75,17 +75,11 @@ import type { SetRangeOptions } from 'treb-grid';
75
75
  // --- worker ------------------------------------------------------------------
76
76
 
77
77
  /**
78
- * note the clumsy URI-like syntax. if typescript can see that the thing
79
- * is a ts file, even if we have a prefix and a type defined for that
80
- * prefix, it will still try to read it.
81
- *
82
- * this is not a great solution. I was thinking about letting ts read it.
83
- * That won't impact esbuild, and it has the helpful side effect of type
84
- * checking the worker when we run tsc. but it doesn't like the .ts extension.
85
- * also it actually tries to import the file, which means you have to export
86
- * some junk value.
78
+ * import the worker as a script file. tsc will read this on typecheck but
79
+ * that's actually to the good; when we build with esbuild we will inline
80
+ * the script so we can run it as a worker.
87
81
  */
88
- import export_worker_script from 'worker://../../treb-export/src/export-worker/index-modern.ts';
82
+ import * as export_worker_script from 'worker:../../treb-export/src/export-worker/index.worker';
89
83
 
90
84
  // --- types -------------------------------------------------------------------
91
85
 
@@ -2813,7 +2807,7 @@ export class EmbeddedSpreadsheet {
2813
2807
  }
2814
2808
 
2815
2809
  if (text && filename) {
2816
- const blob = new Blob([text], { type: 'text/plain;charset=utf-8' });
2810
+ const blob = new Blob([text as any], { type: 'text/plain;charset=utf-8' });
2817
2811
  /*
2818
2812
  // FileSaver.saveAs(blob, filename, { autoBom: false });
2819
2813
  const a = document.createElement('a');
@@ -5327,7 +5321,7 @@ export class EmbeddedSpreadsheet {
5327
5321
  if (export_worker_script) {
5328
5322
  try {
5329
5323
  const worker = new Worker(
5330
- URL.createObjectURL(new Blob([export_worker_script], { type: 'application/javascript' })));
5324
+ URL.createObjectURL(new Blob([(export_worker_script as any).default], { type: 'application/javascript' })));
5331
5325
  return worker;
5332
5326
  }
5333
5327
  catch (err) {
@@ -21,3 +21,12 @@
21
21
 
22
22
  import './export-worker';
23
23
 
24
+ /**
25
+ * default export so tsc will allow us to import it. we use a string
26
+ * because when actually running (via the esbuild build) it will be
27
+ * the code as text. HOWEVER, this will break if we actually try to
28
+ * run it in a browser, so we need to clean it up in the compiler.
29
+ */
30
+ // export default '';
31
+
32
+
@@ -122,7 +122,7 @@ export abstract class BaseLayout {
122
122
  * an event we can trap for that. it might be necessary to test this
123
123
  * periodically.
124
124
  */
125
- public dpr = Math.max(1, self.devicePixelRatio || 1);
125
+ public dpr = 1; // Math.max(1, self.devicePixelRatio || 1);
126
126
 
127
127
  /** separate scale, user-controlled (testing...) */
128
128
  public scale = 1;
@@ -193,6 +193,8 @@ export abstract class BaseLayout {
193
193
  return;
194
194
  }
195
195
 
196
+ this.dpr = Math.max(1, self.devicePixelRatio || 1);
197
+
196
198
  // now attaching to node... no longer global
197
199
  // actually if we are not in a web component, we might as well
198
200
  // use global...
@@ -196,7 +196,7 @@ export class MDParser {
196
196
  const followed_by_punctuation = following && following.type === 'text' && /^[^\w\d]/.test(following.text);
197
197
 
198
198
  token.left_flanking = ((!followed_by_whitespace) && ((!followed_by_punctuation) || preceded_by_whitespace));
199
- token.right_flanking = ((!preceded_by_whitespace) && ((!preceded_by_punctuation) || followed_by_whitespace));
199
+ token.right_flanking = ((!preceded_by_whitespace) && ((!preceded_by_punctuation) || (followed_by_whitespace || followed_by_punctuation)));
200
200
 
201
201
  }
202
202
  }