@trebco/treb 25.2.0 → 25.4.2
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/{.eslintrc.js → .eslintrc.cjs} +4 -0
- package/api-generator/api-generator.ts +25 -55
- package/dist/treb-spreadsheet.mjs +9 -9
- package/dist/treb.d.ts +1 -1
- package/esbuild-custom-element.mjs +5 -264
- package/esbuild-utils.mjs +273 -0
- package/package.json +2 -2
- package/treb-base-types/src/cell.ts +23 -22
- package/treb-base-types/src/cells.ts +55 -2
- package/treb-base-types/src/union.ts +2 -1
- package/treb-calculator/src/calculator.ts +8 -5
- package/treb-calculator/src/dag/array-vertex.ts +22 -22
- package/treb-calculator/src/dag/graph.ts +25 -23
- package/treb-calculator/src/dag/leaf_vertex.ts +23 -22
- package/treb-calculator/src/dag/spreadsheet_vertex.ts +25 -23
- package/treb-calculator/src/expression-calculator.ts +23 -22
- package/treb-calculator/src/function-error.ts +23 -22
- package/treb-calculator/src/functions/base-functions.ts +3 -2
- package/treb-calculator/src/functions/checkbox.ts +23 -22
- package/treb-calculator/src/functions/complex-functions.ts +2 -1
- package/treb-calculator/src/functions/finance-functions.ts +22 -22
- package/treb-calculator/src/functions/information-functions.ts +22 -22
- package/treb-calculator/src/functions/matrix-functions.ts +2 -1
- package/treb-calculator/src/functions/statistics-functions.ts +22 -22
- package/treb-calculator/src/functions/text-functions.ts +23 -22
- package/treb-calculator/src/primitives.ts +23 -22
- package/treb-calculator/src/utilities.ts +23 -24
- package/treb-charts/src/chart-functions.ts +22 -22
- package/treb-charts/src/chart.ts +6 -3
- package/treb-charts/src/renderer.ts +25 -23
- package/treb-charts/src/util.ts +23 -22
- package/treb-embed/modern.tsconfig.json +3 -2
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +10 -14
- package/treb-embed/src/embedded-spreadsheet.ts +53 -44
- package/treb-embed/src/progress-dialog.ts +0 -3
- package/treb-embed/src/types.ts +13 -3
- package/treb-embed/style/layout.scss +32 -29
- package/treb-export/src/drawing2/chart2.ts +2 -2
- package/treb-export/src/drawing2/drawing2.ts +6 -4
- package/treb-export/src/export-worker/export-worker.ts +22 -24
- package/treb-export/src/export-worker/index-modern.ts +2 -1
- package/treb-export/src/export2.ts +15 -8
- package/treb-export/src/import2.ts +10 -5
- package/treb-export/src/workbook-sheet2.ts +2 -1
- package/treb-format/src/format.ts +23 -22
- package/treb-format/src/format_parser.ts +23 -22
- package/treb-format/src/value_parser.ts +23 -22
- package/treb-grid/src/editors/formula_bar.ts +2 -1
- package/treb-grid/src/editors/formula_editor_base.ts +4 -2
- package/treb-grid/src/editors/overlay_editor.ts +2 -1
- package/treb-grid/src/index.ts +12 -9
- package/treb-grid/src/layout/base_layout.ts +4 -2
- package/treb-grid/src/render/selection-renderer.ts +25 -23
- package/treb-grid/src/render/tile_renderer.ts +6 -4
- package/treb-grid/src/types/annotation.ts +33 -37
- package/treb-grid/src/types/data_model.ts +30 -22
- package/treb-grid/src/types/grid.ts +55 -584
- package/treb-grid/src/types/grid_base.ts +401 -7
- package/treb-grid/src/types/grid_events.ts +3 -0
- package/treb-grid/src/types/grid_selection.ts +22 -22
- package/treb-grid/src/types/named_range.ts +22 -22
- package/treb-grid/src/types/sheet.ts +8 -7
- package/treb-grid/src/types/sheet_types.ts +11 -7
- package/treb-grid/src/types/tab_bar.ts +1 -1
- package/treb-parser/src/parser.ts +5 -4
- package/tsproject.json +3 -4
- package/tsconfig.json +0 -10
- /package/treb-embed/src/{custom-element/content-types.d.ts → content-types.d.ts} +0 -0
package/dist/treb.d.ts
CHANGED
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
import * as esbuild from 'esbuild';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import sass from 'sass';
|
|
8
|
-
import cssnano from 'cssnano';
|
|
9
|
-
import postcss from 'postcss';
|
|
4
|
+
|
|
5
|
+
import { SassPlugin, WorkerPlugin, NotifyPlugin, HTMLPlugin } from './esbuild-utils.mjs';
|
|
10
6
|
|
|
11
7
|
import pkg from './package.json' assert { type: 'json' };
|
|
12
8
|
|
|
13
|
-
/** @type {import('html-minifier').Options} */
|
|
14
|
-
const html_minifier_options = {
|
|
15
|
-
removeComments: true,
|
|
16
|
-
collapseWhitespace: true,
|
|
17
|
-
};
|
|
18
9
|
|
|
19
10
|
/**
|
|
20
11
|
* @typedef {Object} Options
|
|
@@ -41,256 +32,6 @@ const options = {
|
|
|
41
32
|
output_filename: 'treb-spreadsheet.mjs',
|
|
42
33
|
};
|
|
43
34
|
|
|
44
|
-
/**
|
|
45
|
-
* @function
|
|
46
|
-
* @param {string} [label] - optional label for build messages
|
|
47
|
-
* @returns {esbuild.Plugin}
|
|
48
|
-
*
|
|
49
|
-
* add notifications on build start/end. we also want to use this
|
|
50
|
-
* to notify worker sub-builds, so we can be sure they're working
|
|
51
|
-
* properly.
|
|
52
|
-
*/
|
|
53
|
-
const NotifyPlugin = (label) => {
|
|
54
|
-
return {
|
|
55
|
-
name: 'notify',
|
|
56
|
-
setup(build) {
|
|
57
|
-
build.onStart(() => {
|
|
58
|
-
console.info(`${label ? `${label} ` : ''}build started @ ${new Date().toLocaleTimeString()}`);
|
|
59
|
-
});
|
|
60
|
-
build.onEnd(result => {
|
|
61
|
-
if (!result.errors.length) {
|
|
62
|
-
|
|
63
|
-
const keys = Object.keys(result.metafile?.outputs||{});
|
|
64
|
-
const bytes = keys.length ? result.metafile?.outputs[keys[0]]?.bytes : 0;
|
|
65
|
-
const size = bytes ? `; build size: ${FormatSize(bytes, 2)}` : '';
|
|
66
|
-
|
|
67
|
-
console.info(`${label ? `${label} ` : ''}build complete @ ${new Date().toLocaleTimeString()}${size}`);
|
|
68
|
-
// console.info(result.metafile);
|
|
69
|
-
}
|
|
70
|
-
if (!label) {
|
|
71
|
-
console.info('');
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @function
|
|
80
|
-
* @param {number} size - size in bytes
|
|
81
|
-
* @returns {string} - size as a human readable string
|
|
82
|
-
*/
|
|
83
|
-
const FormatSize = (size, precision = 1) => {
|
|
84
|
-
|
|
85
|
-
const units = ['B', 'KB', 'MB'];
|
|
86
|
-
let index = 0;
|
|
87
|
-
|
|
88
|
-
for (let i = 0; i < units.length; i++) {
|
|
89
|
-
if (size > 1024) {
|
|
90
|
-
size = size / 1024;
|
|
91
|
-
index++;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return `${size.toFixed(precision)} ${units[index]}`;
|
|
96
|
-
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* @type esbuild.Plugin
|
|
101
|
-
*
|
|
102
|
-
* inlining the worker build. this works out well with one limitation:
|
|
103
|
-
* at the moment, we're not caching the build for watching. OTOH esbuild
|
|
104
|
-
* is so fast it doesn't really matter at the moment.
|
|
105
|
-
*
|
|
106
|
-
* if you import a worker script like this
|
|
107
|
-
* ```
|
|
108
|
-
* import worker_script from 'worker:path/to/worker.ts';
|
|
109
|
-
* ```
|
|
110
|
-
* the plugin will compile the target (with esbuild) and then return the
|
|
111
|
-
* compiled script as a string. the child build inherits minify settings
|
|
112
|
-
* from the parent build.
|
|
113
|
-
*
|
|
114
|
-
* you can then use it in the containing script by creating a worker:
|
|
115
|
-
* ```
|
|
116
|
-
* const worker = new Worker(URL.createObjectURL(new Blob([worker_script], { type: 'application/javascript' })));
|
|
117
|
-
* ```
|
|
118
|
-
*
|
|
119
|
-
* this might cause problems with CSP. if so, we'll sort that out separately.
|
|
120
|
-
*
|
|
121
|
-
*/
|
|
122
|
-
const worker_plugin = {
|
|
123
|
-
name: 'worker',
|
|
124
|
-
setup(build) {
|
|
125
|
-
|
|
126
|
-
build.onResolve({ filter: /^worker:/}, async (args) => {
|
|
127
|
-
args.path = args.path.substring(7);
|
|
128
|
-
const result = await build.resolve(args.path, {
|
|
129
|
-
kind: args.kind,
|
|
130
|
-
resolveDir: args.resolveDir,
|
|
131
|
-
});
|
|
132
|
-
return { path: result.path, namespace: 'worker', };
|
|
133
|
-
}),
|
|
134
|
-
|
|
135
|
-
// for some reason I can't get the filter to work here, but using
|
|
136
|
-
// namespace works. as long as we don't collide with anybody else.
|
|
137
|
-
//
|
|
138
|
-
// with the assumption that esbuild will eventually have a solution
|
|
139
|
-
// for inlining workers, we might want to use a more distinctive
|
|
140
|
-
// namespace that has less possibility of collision in the future.
|
|
141
|
-
// of course if that happens we will probably use the native version,
|
|
142
|
-
// so maybe it doesn't matter.
|
|
143
|
-
|
|
144
|
-
build.onLoad({ filter: /./, namespace: 'worker' }, async(args) => {
|
|
145
|
-
|
|
146
|
-
if (options.verbose) {
|
|
147
|
-
console.info('worker:', args.path);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
try {
|
|
151
|
-
|
|
152
|
-
const result = await esbuild.build({
|
|
153
|
-
|
|
154
|
-
entryPoints: [ args.path ],
|
|
155
|
-
|
|
156
|
-
// we can use this as a key later
|
|
157
|
-
outfile: 'worker',
|
|
158
|
-
|
|
159
|
-
// inherit options
|
|
160
|
-
minify: options.minify,
|
|
161
|
-
bundle: true,
|
|
162
|
-
format: 'esm',
|
|
163
|
-
|
|
164
|
-
// don't write to filesystem
|
|
165
|
-
write: false,
|
|
166
|
-
|
|
167
|
-
// use the metafile to get deps
|
|
168
|
-
metafile: true,
|
|
169
|
-
|
|
170
|
-
// write to stdout
|
|
171
|
-
plugins: [
|
|
172
|
-
NotifyPlugin('- worker'),
|
|
173
|
-
],
|
|
174
|
-
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
if (options.verbose) {
|
|
178
|
-
console.info(' worker build size: ' + FormatSize(result.outputFiles[0].text.length));
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// here's where we use that name as a key
|
|
182
|
-
|
|
183
|
-
const inputs = result.metafile.outputs['worker'].inputs;
|
|
184
|
-
const watchFiles = Object.keys(inputs).map(relative => path.resolve(relative));
|
|
185
|
-
|
|
186
|
-
return {
|
|
187
|
-
errors: result.errors,
|
|
188
|
-
warnings: result.warnings,
|
|
189
|
-
loader: 'text',
|
|
190
|
-
contents: result.outputFiles[0].text,
|
|
191
|
-
watchFiles,
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
catch (err) {
|
|
196
|
-
|
|
197
|
-
// on error, we pass the file that threw as a dependency so we can
|
|
198
|
-
// watch updates and trigger a rebuild (nice that this works, btw)
|
|
199
|
-
|
|
200
|
-
const watchFiles = [];
|
|
201
|
-
for (const error of err.errors) {
|
|
202
|
-
if (error.location?.file) {
|
|
203
|
-
watchFiles.push(path.resolve(error.location.file));
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
errors: err.errors,
|
|
208
|
-
watchFiles,
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* @type esbuild.Plugin
|
|
219
|
-
*
|
|
220
|
-
* html -> string, optionally minified
|
|
221
|
-
*/
|
|
222
|
-
const html_plugin = {
|
|
223
|
-
name: 'html',
|
|
224
|
-
setup(build) {
|
|
225
|
-
build.onLoad({ filter: /\.html$/ }, async (args) => {
|
|
226
|
-
|
|
227
|
-
if (options.verbose) {
|
|
228
|
-
console.info('html:', args.path);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const text = await fs.readFile(args.path, 'utf8');
|
|
232
|
-
return {
|
|
233
|
-
contents: options.minify ? minify(text, html_minifier_options) : text,
|
|
234
|
-
loader: 'text',
|
|
235
|
-
};
|
|
236
|
-
});
|
|
237
|
-
},
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* @type esbuild.Plugin
|
|
242
|
-
*
|
|
243
|
-
* sass -> string, optionally minified
|
|
244
|
-
*/
|
|
245
|
-
const sass_plugin = {
|
|
246
|
-
name: 'sass',
|
|
247
|
-
setup(build) {
|
|
248
|
-
build.onLoad({ filter: /\.scss$/ }, async (args) => {
|
|
249
|
-
|
|
250
|
-
if (options.verbose) {
|
|
251
|
-
console.info('sass:', args.path);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
try {
|
|
255
|
-
|
|
256
|
-
const result = await sass.compile(args.path, {
|
|
257
|
-
loadPaths: ['.'],
|
|
258
|
-
// charset: false,
|
|
259
|
-
// style: 'compressed',
|
|
260
|
-
});
|
|
261
|
-
const files = (result.loadedUrls || []).map(url => url.pathname);
|
|
262
|
-
|
|
263
|
-
let contents = result.css;
|
|
264
|
-
if (options.minify) {
|
|
265
|
-
const minified = await postcss([cssnano]).process(result.css, { from: undefined });
|
|
266
|
-
contents = minified.css;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return {
|
|
270
|
-
contents,
|
|
271
|
-
loader: 'text',
|
|
272
|
-
watchFiles: files,
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
catch (err) {
|
|
277
|
-
const watchFiles = [];
|
|
278
|
-
if (err.span?.file?.url?.path) {
|
|
279
|
-
watchFiles.push(path.resolve(err.span.file.url.path));
|
|
280
|
-
}
|
|
281
|
-
return {
|
|
282
|
-
errors: [{
|
|
283
|
-
text: err.message,
|
|
284
|
-
// ...location...
|
|
285
|
-
}],
|
|
286
|
-
watchFiles,
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
});
|
|
291
|
-
},
|
|
292
|
-
};
|
|
293
|
-
|
|
294
35
|
//------------------------------------------------------------------------------
|
|
295
36
|
//
|
|
296
37
|
// runtime
|
|
@@ -338,9 +79,9 @@ const build_options = {
|
|
|
338
79
|
},
|
|
339
80
|
plugins: [
|
|
340
81
|
NotifyPlugin(),
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
82
|
+
WorkerPlugin(options),
|
|
83
|
+
HTMLPlugin(options),
|
|
84
|
+
SassPlugin(options),
|
|
344
85
|
],
|
|
345
86
|
};
|
|
346
87
|
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
|
|
2
|
+
// @ts-check
|
|
3
|
+
|
|
4
|
+
import * as esbuild from 'esbuild';
|
|
5
|
+
import { promises as fs } from 'fs';
|
|
6
|
+
import { minify } from 'html-minifier';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import sass from 'sass';
|
|
9
|
+
import cssnano from 'cssnano';
|
|
10
|
+
import postcss from 'postcss';
|
|
11
|
+
|
|
12
|
+
/** @type {import('html-minifier').Options} */
|
|
13
|
+
const html_minifier_options = {
|
|
14
|
+
removeComments: true,
|
|
15
|
+
collapseWhitespace: true,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @function
|
|
20
|
+
* @param {string} [label] - optional label for build messages
|
|
21
|
+
* @returns {esbuild.Plugin}
|
|
22
|
+
*
|
|
23
|
+
* add notifications on build start/end. we also want to use this
|
|
24
|
+
* to notify worker sub-builds, so we can be sure they're working
|
|
25
|
+
* properly.
|
|
26
|
+
*/
|
|
27
|
+
export const NotifyPlugin = (label) => {
|
|
28
|
+
return {
|
|
29
|
+
name: 'notify',
|
|
30
|
+
setup(build) {
|
|
31
|
+
build.onStart(() => {
|
|
32
|
+
console.info(`${label ? `${label} ` : ''}build started @ ${new Date().toLocaleTimeString()}`);
|
|
33
|
+
});
|
|
34
|
+
build.onEnd(result => {
|
|
35
|
+
if (!result.errors.length) {
|
|
36
|
+
|
|
37
|
+
const keys = Object.keys(result.metafile?.outputs||{});
|
|
38
|
+
const bytes = keys.length ? result.metafile?.outputs[keys[0]]?.bytes : 0;
|
|
39
|
+
const size = bytes ? `; build size: ${FormatSize(bytes, 2)}` : '';
|
|
40
|
+
|
|
41
|
+
console.info(`${label ? `${label} ` : ''}build complete @ ${new Date().toLocaleTimeString()}${size}`);
|
|
42
|
+
// console.info(result.metafile);
|
|
43
|
+
}
|
|
44
|
+
if (!label) {
|
|
45
|
+
console.info('');
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @function
|
|
54
|
+
* @param {number} size - size in bytes
|
|
55
|
+
* @returns {string} - size as a human readable string
|
|
56
|
+
*/
|
|
57
|
+
export const FormatSize = (size, precision = 1) => {
|
|
58
|
+
|
|
59
|
+
const units = ['B', 'KB', 'MB'];
|
|
60
|
+
let index = 0;
|
|
61
|
+
|
|
62
|
+
for (let i = 0; i < units.length; i++) {
|
|
63
|
+
if (size > 1024) {
|
|
64
|
+
size = size / 1024;
|
|
65
|
+
index++;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return `${size.toFixed(precision)} ${units[index]}`;
|
|
70
|
+
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @function
|
|
75
|
+
* @param {{verbose?: boolean, minify?: boolean}} [options]
|
|
76
|
+
* @returns {esbuild.Plugin}
|
|
77
|
+
*
|
|
78
|
+
* inlining the worker build. this works out well with one limitation:
|
|
79
|
+
* at the moment, we're not caching the build for watching. OTOH esbuild
|
|
80
|
+
* is so fast it doesn't really matter at the moment.
|
|
81
|
+
*
|
|
82
|
+
* if you import a worker script like this
|
|
83
|
+
* ```
|
|
84
|
+
* import worker_script from 'worker://path/to/worker.ts';
|
|
85
|
+
* ```
|
|
86
|
+
* the plugin will compile the target (with esbuild) and then return the
|
|
87
|
+
* compiled script as a string. the child build inherits minify settings
|
|
88
|
+
* from the parent build.
|
|
89
|
+
*
|
|
90
|
+
* you can then use it in the containing script by creating a worker:
|
|
91
|
+
* ```
|
|
92
|
+
* const worker = new Worker(URL.createObjectURL(new Blob([worker_script], { type: 'application/javascript' })));
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* this might cause problems with CSP. if so, we'll sort that out separately.
|
|
96
|
+
*
|
|
97
|
+
*/
|
|
98
|
+
export const WorkerPlugin = (options) => ({
|
|
99
|
+
name: 'worker',
|
|
100
|
+
setup(build) {
|
|
101
|
+
|
|
102
|
+
build.onResolve({ filter: /^worker:\/\//}, async (args) => {
|
|
103
|
+
args.path = args.path.substring(9);
|
|
104
|
+
const result = await build.resolve(args.path, {
|
|
105
|
+
kind: args.kind,
|
|
106
|
+
resolveDir: args.resolveDir,
|
|
107
|
+
});
|
|
108
|
+
return { path: result.path, namespace: 'worker', };
|
|
109
|
+
}),
|
|
110
|
+
|
|
111
|
+
// for some reason I can't get the filter to work here, but using
|
|
112
|
+
// namespace works. as long as we don't collide with anybody else.
|
|
113
|
+
//
|
|
114
|
+
// with the assumption that esbuild will eventually have a solution
|
|
115
|
+
// for inlining workers, we might want to use a more distinctive
|
|
116
|
+
// namespace that has less possibility of collision in the future.
|
|
117
|
+
// of course if that happens we will probably use the native version,
|
|
118
|
+
// so maybe it doesn't matter.
|
|
119
|
+
|
|
120
|
+
build.onLoad({ filter: /./, namespace: 'worker' }, async(args) => {
|
|
121
|
+
|
|
122
|
+
if (options?.verbose) {
|
|
123
|
+
console.info('worker:', args.path);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
|
|
128
|
+
const result = await esbuild.build({
|
|
129
|
+
|
|
130
|
+
entryPoints: [ args.path ],
|
|
131
|
+
|
|
132
|
+
// we can use this as a key later
|
|
133
|
+
outfile: 'worker',
|
|
134
|
+
|
|
135
|
+
// inherit options
|
|
136
|
+
minify: options?.minify,
|
|
137
|
+
bundle: true,
|
|
138
|
+
format: 'esm',
|
|
139
|
+
|
|
140
|
+
// don't write to filesystem
|
|
141
|
+
write: false,
|
|
142
|
+
|
|
143
|
+
// use the metafile to get deps
|
|
144
|
+
metafile: true,
|
|
145
|
+
|
|
146
|
+
// write to stdout
|
|
147
|
+
plugins: [
|
|
148
|
+
NotifyPlugin('- worker'),
|
|
149
|
+
],
|
|
150
|
+
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
if (options?.verbose) {
|
|
154
|
+
console.info(' worker build size: ' + FormatSize(result.outputFiles[0].text.length));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// here's where we use that name as a key
|
|
158
|
+
|
|
159
|
+
const inputs = result.metafile.outputs['worker'].inputs;
|
|
160
|
+
const watchFiles = Object.keys(inputs).map(relative => path.resolve(relative));
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
errors: result.errors,
|
|
164
|
+
warnings: result.warnings,
|
|
165
|
+
loader: 'text',
|
|
166
|
+
contents: result.outputFiles[0].text,
|
|
167
|
+
watchFiles,
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
|
|
173
|
+
// on error, we pass the file that threw as a dependency so we can
|
|
174
|
+
// watch updates and trigger a rebuild (nice that this works, btw)
|
|
175
|
+
|
|
176
|
+
const watchFiles = [];
|
|
177
|
+
for (const error of err.errors) {
|
|
178
|
+
if (error.location?.file) {
|
|
179
|
+
watchFiles.push(path.resolve(error.location.file));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
errors: err.errors,
|
|
184
|
+
watchFiles,
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @function
|
|
195
|
+
* @param {{verbose?: boolean, minify?: boolean}} [options]
|
|
196
|
+
* @returns {esbuild.Plugin}
|
|
197
|
+
*
|
|
198
|
+
* plugin loads html as string, optionally minified
|
|
199
|
+
*
|
|
200
|
+
*/
|
|
201
|
+
export const HTMLPlugin = (options) => ({
|
|
202
|
+
name: 'html',
|
|
203
|
+
setup(build) {
|
|
204
|
+
build.onLoad({ filter: /\.html$/ }, async (args) => {
|
|
205
|
+
|
|
206
|
+
if (options?.verbose) {
|
|
207
|
+
console.info('html:', args.path);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const text = await fs.readFile(args.path, 'utf8');
|
|
211
|
+
return {
|
|
212
|
+
contents: options?.minify ? minify(text, html_minifier_options) : text,
|
|
213
|
+
loader: 'text',
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @function
|
|
221
|
+
* @param {{verbose?: boolean, minify?: boolean}} [options]
|
|
222
|
+
* @returns {esbuild.Plugin}
|
|
223
|
+
*
|
|
224
|
+
* plugin compiles sass and returns generated css as string, optionally minified
|
|
225
|
+
*/
|
|
226
|
+
export const SassPlugin = (options) => ({
|
|
227
|
+
name: 'sass',
|
|
228
|
+
setup(build) {
|
|
229
|
+
build.onLoad({ filter: /\.scss$/ }, async (args) => {
|
|
230
|
+
|
|
231
|
+
if (options?.verbose) {
|
|
232
|
+
console.info('sass:', args.path);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
try {
|
|
236
|
+
|
|
237
|
+
const result = await sass.compile(args.path, {
|
|
238
|
+
loadPaths: ['.'],
|
|
239
|
+
// charset: false,
|
|
240
|
+
// style: 'compressed',
|
|
241
|
+
});
|
|
242
|
+
const files = (result.loadedUrls || []).map(url => url.pathname);
|
|
243
|
+
|
|
244
|
+
let contents = result.css;
|
|
245
|
+
if (options?.minify) {
|
|
246
|
+
const minified = await postcss([cssnano]).process(result.css, { from: undefined });
|
|
247
|
+
contents = minified.css;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
contents,
|
|
252
|
+
loader: 'text',
|
|
253
|
+
watchFiles: files,
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
const watchFiles = [];
|
|
259
|
+
if (err.span?.file?.url?.path) {
|
|
260
|
+
watchFiles.push(path.resolve(err.span.file.url.path));
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
errors: [{
|
|
264
|
+
text: err.message,
|
|
265
|
+
// ...location...
|
|
266
|
+
}],
|
|
267
|
+
watchFiles,
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
});
|
|
272
|
+
},
|
|
273
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trebco/treb",
|
|
3
|
-
"version": "25.2
|
|
3
|
+
"version": "25.4.2",
|
|
4
4
|
"license": "LGPL-3.0-or-later",
|
|
5
5
|
"homepage": "https://treb.app",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"treb-utils": "file:treb-utils",
|
|
33
33
|
"ts-node-dev": "^2.0.0",
|
|
34
34
|
"tslib": "^2.2.0",
|
|
35
|
-
"typescript": "^
|
|
35
|
+
"typescript": "^5.0.2"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "node esbuild-custom-element.mjs",
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of TREB.
|
|
3
|
-
*
|
|
4
|
-
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
-
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
-
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
-
* later version.
|
|
8
|
-
*
|
|
9
|
-
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
-
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
-
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
-
* details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU General Public License along
|
|
15
|
-
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
*
|
|
17
|
-
* Copyright 2022-2023 trebco, llc.
|
|
18
|
-
* info@treb.app
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of TREB.
|
|
3
|
+
*
|
|
4
|
+
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
+
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
+
* later version.
|
|
8
|
+
*
|
|
9
|
+
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
+
* details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License along
|
|
15
|
+
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
* Copyright 2022-2023 trebco, llc.
|
|
18
|
+
* info@treb.app
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
22
|
// import { Parser } from 'treb-parser';
|
|
23
23
|
|
|
24
24
|
import type { Area, IArea } from './area';
|
|
25
25
|
import type { Style } from './style';
|
|
26
26
|
import type { TextPart } from './text_part';
|
|
27
|
-
import {
|
|
27
|
+
import type { Complex } from './value-type';
|
|
28
|
+
import { ValueType, GetValueType } from './value-type';
|
|
28
29
|
import type { CellValue, UnionValue } from './union';
|
|
29
30
|
import type { PreparedText } from './render_text';
|
|
30
31
|
import type { Table } from './table';
|