@trebco/treb 30.2.14 → 30.3.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/dist/treb-export-worker.mjs +2 -0
- package/dist/treb-spreadsheet.mjs +11 -11
- package/dist/treb.d.ts +1 -1
- package/{esbuild-custom-element.mjs → esbuild-composite.mjs} +6 -23
- package/esbuild-utils.mjs +28 -3
- package/eslint.config.js +2 -1
- package/package.json +7 -8
- package/treb-embed/modern.tsconfig.json +0 -1
- package/treb-embed/src/embedded-spreadsheet.ts +12 -37
- package/treb-embed/src/export-worker.ts +44 -0
- package/treb-export/src/{export-worker/export-worker.ts → index.worker.ts} +2 -2
- package/dist/treb-spreadsheet-light.mjs +0 -16
- package/treb-export/src/export-worker/index.worker.ts +0 -32
package/dist/treb.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import * as esbuild from 'esbuild';
|
|
6
6
|
|
|
7
|
-
import { SassPlugin, WorkerPlugin, NotifyPlugin, HTMLPlugin } from './esbuild-utils.mjs';
|
|
7
|
+
import { SassPlugin, WorkerPlugin, NotifyPlugin, HTMLPlugin, RewriteIgnoredImports } from './esbuild-utils.mjs';
|
|
8
8
|
import { promises as fs } from 'fs';
|
|
9
9
|
|
|
10
10
|
import pkg from './package.json' with { type: 'json' };
|
|
@@ -32,7 +32,7 @@ const options = {
|
|
|
32
32
|
minify: true,
|
|
33
33
|
verbose: false,
|
|
34
34
|
xlsx_support: true,
|
|
35
|
-
output_filename: 'treb-spreadsheet
|
|
35
|
+
output_filename: 'treb-spreadsheet',
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
//------------------------------------------------------------------------------
|
|
@@ -60,36 +60,19 @@ for (let i = 0; i < process.argv.length; i++) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
/**
|
|
64
|
-
* thanks to
|
|
65
|
-
* https://github.com/evanw/esbuild/issues/3337#issuecomment-2085394950
|
|
66
|
-
*/
|
|
67
|
-
function RewriteIgnoredImports() {
|
|
68
|
-
return {
|
|
69
|
-
name: 'RewriteIgnoredImports',
|
|
70
|
-
setup(build) {
|
|
71
|
-
build.onEnd(async (result) => {
|
|
72
|
-
if (result.outputFiles) {
|
|
73
|
-
for (const file of result.outputFiles) {
|
|
74
|
-
const { path, text } = file;
|
|
75
|
-
await fs.writeFile(path, text.replace(/esbuild-ignore-import:/, ''));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
63
|
|
|
83
64
|
/** @type esbuild.BuildOptions */
|
|
84
65
|
const build_options = {
|
|
85
66
|
entryPoints: [
|
|
86
|
-
'treb-embed/src/index.ts',
|
|
67
|
+
{ in: 'treb-embed/src/index.ts', out: options.output_filename },
|
|
68
|
+
{ in: 'treb-embed/src/export-worker.ts', out: 'treb-export-worker' },
|
|
87
69
|
],
|
|
88
70
|
banner: {
|
|
89
71
|
js: `/*! TREB v${pkg.version}. Copyright 2018-${new Date().getFullYear()} trebco, llc. All rights reserved. LGPL: https://treb.app/license */`
|
|
90
72
|
},
|
|
91
73
|
bundle: true,
|
|
92
|
-
|
|
74
|
+
outdir: 'dist',
|
|
75
|
+
// outfile: 'dist/' + options.output_filename,
|
|
93
76
|
outExtension: { '.js': '.mjs' },
|
|
94
77
|
minify: options.minify,
|
|
95
78
|
metafile: true,
|
package/esbuild-utils.mjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import * as esbuild from 'esbuild';
|
|
7
7
|
import { promises as fs } from 'fs';
|
|
8
|
-
import { minify } from 'html-minifier';
|
|
8
|
+
import { minify } from 'html-minifier-terser';
|
|
9
9
|
import path from 'path';
|
|
10
10
|
import * as sass from 'sass';
|
|
11
11
|
import cssnano from 'cssnano';
|
|
@@ -116,7 +116,7 @@ export const WorkerPlugin = (options) => ({
|
|
|
116
116
|
resolveDir: args.resolveDir,
|
|
117
117
|
});
|
|
118
118
|
return { path: result.path, namespace: 'worker', };
|
|
119
|
-
})
|
|
119
|
+
});
|
|
120
120
|
|
|
121
121
|
// for some reason I can't get the filter to work here, but using
|
|
122
122
|
// namespace works. as long as we don't collide with anybody else.
|
|
@@ -219,10 +219,14 @@ export const HTMLPlugin = (options) => ({
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
const text = await fs.readFile(args.path, 'utf8');
|
|
222
|
+
|
|
222
223
|
return {
|
|
223
|
-
contents: options?.minify ? minify(text, html_minifier_options) : text,
|
|
224
|
+
contents: options?.minify ? await minify(text, html_minifier_options) : text,
|
|
224
225
|
loader: 'text',
|
|
225
226
|
};
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
226
230
|
});
|
|
227
231
|
},
|
|
228
232
|
});
|
|
@@ -282,3 +286,24 @@ export const SassPlugin = (options) => ({
|
|
|
282
286
|
});
|
|
283
287
|
},
|
|
284
288
|
});
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* thanks to
|
|
292
|
+
* https://github.com/evanw/esbuild/issues/3337#issuecomment-2085394950
|
|
293
|
+
*/
|
|
294
|
+
export const RewriteIgnoredImports = () => {
|
|
295
|
+
return {
|
|
296
|
+
name: 'RewriteIgnoredImports',
|
|
297
|
+
setup(build) {
|
|
298
|
+
build.onEnd(async (result) => {
|
|
299
|
+
if (result.outputFiles) {
|
|
300
|
+
for (const file of result.outputFiles) {
|
|
301
|
+
const { path, text } = file;
|
|
302
|
+
await fs.writeFile(path, text.replace(/esbuild-ignore-import:/g, ''));
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
|
package/eslint.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trebco/treb",
|
|
3
|
-
"version": "30.2
|
|
3
|
+
"version": "30.3.2",
|
|
4
4
|
"license": "LGPL-3.0-or-later",
|
|
5
5
|
"homepage": "https://treb.app",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"esbuild": "^0.23.0",
|
|
20
20
|
"eslint": "^9.8.0",
|
|
21
21
|
"fast-xml-parser": "^4.0.7",
|
|
22
|
-
"html-minifier": "^
|
|
22
|
+
"html-minifier-terser": "^7.2.0",
|
|
23
23
|
"sass": "^1.69.3",
|
|
24
24
|
"treb-base-types": "file:treb-base-types",
|
|
25
25
|
"treb-calculator": "file:treb-calculator",
|
|
@@ -37,17 +37,16 @@
|
|
|
37
37
|
"uzip": "^0.20201231.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
|
-
"build": "node esbuild-
|
|
41
|
-
"
|
|
42
|
-
"dev": "node esbuild-custom-element.mjs --dev",
|
|
40
|
+
"build": "node esbuild-composite.mjs",
|
|
41
|
+
"dev": "node esbuild-composite.mjs --dev",
|
|
43
42
|
"clean": "rm -fr build dist declaration",
|
|
44
|
-
"watch": "node --watch esbuild-
|
|
45
|
-
"watch-production": "node --watch esbuild-
|
|
43
|
+
"watch": "node --watch esbuild-composite.mjs --watch --dev",
|
|
44
|
+
"watch-production": "node --watch esbuild-composite.mjs --watch",
|
|
46
45
|
"tsc": "tsc -b treb-embed/modern.tsconfig.json",
|
|
47
46
|
"rebuild-tsc": "tsc -b --force treb-embed/modern.tsconfig.json",
|
|
48
47
|
"watch-tsc": "tsc -b treb-embed/modern.tsconfig.json -w",
|
|
49
48
|
"watch-api": "ts-node-dev --respawn api-generator/api-generator.ts --config api-config.json",
|
|
50
49
|
"generate-api": "ts-node-dev api-generator/api-generator.ts --config api-config.json",
|
|
51
|
-
"release": "npm run rebuild-tsc && npm run build && npm run generate-api
|
|
50
|
+
"release": "npm run rebuild-tsc && npm run build && npm run generate-api"
|
|
52
51
|
}
|
|
53
52
|
}
|
|
@@ -107,13 +107,6 @@ import type { StateLeafVertex } from 'treb-calculator';
|
|
|
107
107
|
*/
|
|
108
108
|
import './content-types.d.ts';
|
|
109
109
|
|
|
110
|
-
/**
|
|
111
|
-
* import the worker as a script file. tsc will read this on typecheck but
|
|
112
|
-
* that's actually to the good; when we build with esbuild we will inline
|
|
113
|
-
* the script so we can run it as a worker.
|
|
114
|
-
*/
|
|
115
|
-
import * as export_worker_script from 'worker:../../treb-export/src/export-worker/index.worker';
|
|
116
|
-
|
|
117
110
|
// --- types -------------------------------------------------------------------
|
|
118
111
|
|
|
119
112
|
/**
|
|
@@ -6162,39 +6155,21 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
6162
6155
|
}
|
|
6163
6156
|
|
|
6164
6157
|
/**
|
|
6165
|
-
*
|
|
6166
|
-
*
|
|
6158
|
+
* worker now uses a dynamic import with a module built separately.
|
|
6159
|
+
* see `export-worker.ts` (in this directory) for more detail.
|
|
6167
6160
|
*/
|
|
6168
6161
|
protected async LoadWorker(): Promise<Worker> {
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
if (export_worker_script) {
|
|
6180
|
-
try {
|
|
6181
|
-
const worker = new Worker(
|
|
6182
|
-
URL.createObjectURL(new Blob([(export_worker_script as {default: string}).default], { type: 'application/javascript' })));
|
|
6183
|
-
return worker;
|
|
6184
|
-
}
|
|
6185
|
-
catch (err) {
|
|
6186
|
-
console.info('embedded worker failed');
|
|
6187
|
-
console.error(err);
|
|
6188
|
-
}
|
|
6189
|
-
}
|
|
6190
|
-
|
|
6191
|
-
}
|
|
6192
|
-
else {
|
|
6193
|
-
console.warn('this build does not include xlsx support.');
|
|
6162
|
+
try {
|
|
6163
|
+
const worker = `export`;
|
|
6164
|
+
const mod = await import(`esbuild-ignore-import:./treb-${worker}-worker.mjs`) as {
|
|
6165
|
+
CreateWorker: () => Promise<Worker>;
|
|
6166
|
+
};
|
|
6167
|
+
return await mod.CreateWorker();
|
|
6168
|
+
}
|
|
6169
|
+
catch (err) {
|
|
6170
|
+
console.error(err);
|
|
6171
|
+
throw(err);
|
|
6194
6172
|
}
|
|
6195
|
-
|
|
6196
|
-
throw new Error('creating worker failed');
|
|
6197
|
-
|
|
6198
6173
|
}
|
|
6199
6174
|
|
|
6200
6175
|
/**
|
|
@@ -0,0 +1,44 @@
|
|
|
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-2024 trebco, llc.
|
|
18
|
+
* info@treb.app
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
// this is a new entrypoint for the worker, as a module. while we can't
|
|
23
|
+
// just create a worker script, if we create this as a module and embed
|
|
24
|
+
// the worker script we can still get the benefits of dynamic loading.
|
|
25
|
+
|
|
26
|
+
// why can't we create a worker script? it's OK for direct embedding but
|
|
27
|
+
// breaks when embedding in a bundler (vite is OK, but webpack is not).
|
|
28
|
+
// but all bundlers seem ok with local modules (knock on wood).
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* import the worker as text so it will be embedded in this module
|
|
32
|
+
*/
|
|
33
|
+
import * as export_worker_script from 'worker:../../treb-export/src/index.worker';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* create the worker by loading the embedded text
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
export const CreateWorker = async (): Promise<Worker> => {
|
|
40
|
+
const worker = new Worker(
|
|
41
|
+
URL.createObjectURL(new Blob([(export_worker_script as {default: string}).default], { type: 'application/javascript' })));
|
|
42
|
+
return worker;
|
|
43
|
+
};
|
|
44
|
+
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
import type { ImportedSheetData } from 'treb-base-types';
|
|
23
23
|
import type { SerializedModel } from 'treb-data-model';
|
|
24
24
|
|
|
25
|
-
import { Exporter } from '
|
|
26
|
-
import { Importer } from '
|
|
25
|
+
import { Exporter } from './export';
|
|
26
|
+
import { Importer } from './import2';
|
|
27
27
|
|
|
28
28
|
const ctx: Worker = self as unknown as Worker;
|
|
29
29
|
const exporter = new Exporter();
|