tungsten 0.2.21 → 0.2.23
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/bin/commands/compile.d.ts.map +1 -1
- package/dist/bin/commands/compile.js +1 -1
- package/dist/build/bundle.js +3 -1
- package/dist/build/clientModuleAliases.d.ts +1 -3
- package/dist/build/clientModuleAliases.d.ts.map +1 -1
- package/dist/build/clientModuleAliases.js +4 -3
- package/dist/build/compileJavascript.d.ts.map +1 -1
- package/dist/build/compileJavascript.js +4 -3
- package/dist/build/compileStyles.d.ts.map +1 -1
- package/dist/build/compileStyles.js +15 -19
- package/dist/build/devBundle.rollup.config.d.ts.map +1 -1
- package/dist/build/devBundle.rollup.config.js +1 -2
- package/dist/build/rollup.user.prod.config.d.ts.map +1 -1
- package/dist/build/rollup.user.prod.config.js +1 -2
- package/dist/postcssPlugins/parseSelectorsRich.d.ts.map +1 -1
- package/dist/postcssPlugins/parseSelectorsRich.js +5 -4
- package/dist/postcssPlugins/parseSelectorsRich.sxyt.js +22 -0
- package/dist/settings.d.ts +1 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +1 -0
- package/dist/staticGen/staticGen.d.ts.map +1 -1
- package/dist/staticGen/staticGen.js +5 -3
- package/dist/style/styleContentSxy.d.ts.map +1 -1
- package/dist/style/styleContentSxy.js +7 -5
- package/dist/style/unusedStyles.d.ts +1 -3
- package/dist/style/unusedStyles.d.ts.map +1 -1
- package/dist/style/unusedStyles.js +25 -15
- package/package.json +3 -23
- package/types/modules.d.ts +32 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/compile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/bin/commands/compile.ts"],"names":[],"mappings":"AAgRA,OAAO,EAAE,CAAA"}
|
|
@@ -18,7 +18,7 @@ const targetOptions = {
|
|
|
18
18
|
'--public': 'public'
|
|
19
19
|
};
|
|
20
20
|
const args = process.argv.slice(3);
|
|
21
|
-
const usage = 'Usage: tungsten compile [targets] [--all] [--watch] [--no-clean] [--output <dir>]';
|
|
21
|
+
const usage = 'Usage: tungsten compile [targets] [--all] [--watch] [--no-clean] [--output <dir>]' + ' [--ready-file <file>] [--quiet] [--ignore-dirs <dir>] [--ignore-patterns <pattern>]';
|
|
22
22
|
if (args.includes('--help') || args.includes('-h')) {
|
|
23
23
|
cliOut(usage);
|
|
24
24
|
cliOut('Targets: --js, --css, --client, --assets, --public');
|
package/dist/build/bundle.js
CHANGED
|
@@ -13,7 +13,9 @@ export async function bundle(projectDir /*, appConfig: FrameworkConfigComplete*/
|
|
|
13
13
|
// let rootComponent = appConfig.rootComponent as string
|
|
14
14
|
// if (rootComponent.endsWith('.jsx')) rootComponent = rootComponent.slice(0, -1)
|
|
15
15
|
// }
|
|
16
|
-
const externalModules = [
|
|
16
|
+
const externalModules = [
|
|
17
|
+
//'node-fetch'
|
|
18
|
+
];
|
|
17
19
|
const command = `cd ${frameworkDir} && npx rollup` + ` --input "${join(projectDir, prodBuildFolder, clientFolder, 'client.js')}"` + ` --file "${join(projectDir, bundleFolder, 'client.js')}"` + ` --config "${join(frameworkDir, frameworkDistFolder, 'build/rollup.user.prod.config.js')}"` + (externalModules.length > 0 ? ` --external ${externalModules.join(',')}` : ``) + ` --inlineDynamicImports --format iife`;
|
|
18
20
|
cliLog('bundle command:', command);
|
|
19
21
|
const subProcess = spawnShellCommand(command, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientModuleAliases.d.ts","sourceRoot":"","sources":["../../src/build/clientModuleAliases.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clientModuleAliases.d.ts","sourceRoot":"","sources":["../../src/build/clientModuleAliases.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export const clientModulesAliases = {
|
|
2
|
-
|
|
3
|
-
}
|
|
1
|
+
// export const clientModulesAliases = {
|
|
2
|
+
// 'redaxios': 'tungsten/node_modules/redaxios/dist/redaxios.js'
|
|
3
|
+
// }
|
|
4
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileJavascript.d.ts","sourceRoot":"","sources":["../../src/build/compileJavascript.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAO/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAetC,KAAK,uBAAuB,GAAG;IAC3B,OAAO,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;IAClC,WAAW,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;IACtC,aAAa,EAAE,aAAa,CAAA;IAC5B,cAAc,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACnC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,eAAe,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,0BAA0B,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAA;CAC9F,CAAA;AAKD,wBAAsB,iBAAiB,CACnC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EACtD,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EACrE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,UAAO,EAC1E,OAAO,GAAE,wBAA6B,GACvC,OAAO,CAAC,uBAAuB,CAAC,
|
|
1
|
+
{"version":3,"file":"compileJavascript.d.ts","sourceRoot":"","sources":["../../src/build/compileJavascript.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAO/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAetC,KAAK,uBAAuB,GAAG;IAC3B,OAAO,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;IAClC,WAAW,EAAE,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAA;IACtC,aAAa,EAAE,aAAa,CAAA;IAC5B,cAAc,EAAE,OAAO,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACrC,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG;IACnC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,eAAe,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,0BAA0B,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAA;CAC9F,CAAA;AAKD,wBAAsB,iBAAiB,CACnC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,uBAAuB,EACtD,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EACrE,aAAa,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,UAAO,EAC1E,OAAO,GAAE,wBAA6B,GACvC,OAAO,CAAC,uBAAuB,CAAC,CA2TlC"}
|
|
@@ -148,10 +148,11 @@ export async function compileJavascript(projectDir, appConfig, codeLocation, sou
|
|
|
148
148
|
});
|
|
149
149
|
const transformResults = await Promise.allSettled(transformPromises);
|
|
150
150
|
const transformFailures = transformResults.filter(result => result.status === 'rejected').map(result => result.reason);
|
|
151
|
-
let deferredWorkPosition = 0;
|
|
152
151
|
const settleDeferredWork = async () => {
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
// splice out (rather than slice+advance-a-pointer) so settled entries are freed for GC -
|
|
153
|
+
// otherwise every package-dependency promise ever pushed stays reachable for the life of
|
|
154
|
+
// the watch process, leaking memory until it OOMs on long-running `--watch` sessions
|
|
155
|
+
const currentPromises = promises.splice(0, promises.length);
|
|
155
156
|
const deferredResults = await Promise.allSettled(currentPromises);
|
|
156
157
|
return deferredResults.filter(result => result.status === 'rejected').map(result => result.reason);
|
|
157
158
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileStyles.d.ts","sourceRoot":"","sources":["../../src/build/compileStyles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compileStyles.d.ts","sourceRoot":"","sources":["../../src/build/compileStyles.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAgOpE,wBAAsB,aAAa,CAC/B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,uBAAuB,EAC/B,eAAe,EAAE,MAAM,EACvB,aAAa,EAAE,MAAM,EACrB,KAAK,UAAO,oBA8Ff"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import slash from 'slash';
|
|
2
2
|
import chokidar from 'chokidar';
|
|
3
3
|
import { join, dirname, resolve } from 'path';
|
|
4
|
+
import { pathToFileURL } from 'url';
|
|
4
5
|
import { promises as fsPromises, utimesSync } from 'fs';
|
|
5
6
|
import * as sass from 'sass';
|
|
6
7
|
import { globby } from 'globby';
|
|
@@ -19,16 +20,13 @@ function arrayToObjectTrue(array) {
|
|
|
19
20
|
}
|
|
20
21
|
function sassToCss(data, file, importBase) {
|
|
21
22
|
try {
|
|
22
|
-
return sass.
|
|
23
|
-
|
|
24
|
-
file,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}).css.toString();
|
|
23
|
+
return sass.compileString(data, {
|
|
24
|
+
syntax: 'indented',
|
|
25
|
+
url: pathToFileURL(file),
|
|
26
|
+
importers: [{
|
|
27
|
+
findFileUrl: url => pathToFileURL(resolveSassImport(url, file, importBase))
|
|
28
|
+
}]
|
|
29
|
+
}).css;
|
|
32
30
|
} catch (error) {
|
|
33
31
|
if (error instanceof Error) {
|
|
34
32
|
return error;
|
|
@@ -40,15 +38,13 @@ function sassToCss(data, file, importBase) {
|
|
|
40
38
|
}
|
|
41
39
|
function scssToCss(data, file, importBase) {
|
|
42
40
|
try {
|
|
43
|
-
return sass.
|
|
44
|
-
|
|
45
|
-
file,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
}).css.toString();
|
|
41
|
+
return sass.compileString(data, {
|
|
42
|
+
syntax: 'scss',
|
|
43
|
+
url: pathToFileURL(file),
|
|
44
|
+
importers: [{
|
|
45
|
+
findFileUrl: url => pathToFileURL(resolveScssImport(url, file, importBase))
|
|
46
|
+
}]
|
|
47
|
+
}).css;
|
|
52
48
|
} catch (error) {
|
|
53
49
|
if (error instanceof Error) {
|
|
54
50
|
return error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devBundle.rollup.config.d.ts","sourceRoot":"","sources":["../../src/build/devBundle.rollup.config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"devBundle.rollup.config.d.ts","sourceRoot":"","sources":["../../src/build/devBundle.rollup.config.ts"],"names":[],"mappings":"AAUA,KAAK,YAAY,GAAG;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AAED,QAAA,MAAM,YAAY,EAAE,YAkBnB,CAAA;AAED,eAAe,YAAY,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
2
2
|
import commonjs from "@rollup/plugin-commonjs";
|
|
3
3
|
//import { babel } from "@rollup/plugin-babel"
|
|
4
|
-
import
|
|
5
|
-
//import terser from "@rollup/plugin-terser" // to do
|
|
4
|
+
import terser from "@rollup/plugin-terser";
|
|
6
5
|
//import gzip from "rollup-plugin-gzip"
|
|
7
6
|
import jsonModule from "@rollup/plugin-json";
|
|
8
7
|
const json = typeof jsonModule === "function" ? jsonModule : jsonModule.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.user.prod.config.d.ts","sourceRoot":"","sources":["../../src/build/rollup.user.prod.config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rollup.user.prod.config.d.ts","sourceRoot":"","sources":["../../src/build/rollup.user.prod.config.ts"],"names":[],"mappings":"AAaA,KAAK,YAAY,GAAG;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACrB,CAAA;AAeD,QAAA,MAAM,YAAY,EAAE,YAkBnB,CAAA;AAED,eAAe,YAAY,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
2
2
|
import commonjs from "@rollup/plugin-commonjs";
|
|
3
3
|
import { babel } from "@rollup/plugin-babel";
|
|
4
|
-
import
|
|
5
|
-
//import terser from "@rollup/plugin-terser" // to do
|
|
4
|
+
import terser from "@rollup/plugin-terser";
|
|
6
5
|
//import gzip from "rollup-plugin-gzip"
|
|
7
6
|
import jsonModule from "@rollup/plugin-json";
|
|
8
7
|
import { MakeBabelTransformRemoveServerBlocks } from "../babelPlugins/BabelTransformRemoveServerBlocks.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseSelectorsRich.d.ts","sourceRoot":"","sources":["../../src/postcssPlugins/parseSelectorsRich.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS,GAAG,KAAK,GAAG,IAAI,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"parseSelectorsRich.d.ts","sourceRoot":"","sources":["../../src/postcssPlugins/parseSelectorsRich.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS,GAAG,KAAK,GAAG,IAAI,GAAG,OAAO,GACrF,cAAc,GAAG,gBAAgB,GAAG,WAAW,CAAA;AAE/C,MAAM,MAAM,QAAQ,GAAG;IACnB,IAAI,EAAE,YAAY,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;CACjB,CAAA;AAOD,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,cAqPvD"}
|
|
@@ -160,7 +160,8 @@ export function parseSelectorsRich(selectorGroup) {
|
|
|
160
160
|
// TODO -- handle pseudo with brackets
|
|
161
161
|
case 'pseudo':
|
|
162
162
|
{
|
|
163
|
-
if (/[a-zA-Z]/.test(char)) {
|
|
163
|
+
if (/[a-zA-Z-_]/.test(char)) {
|
|
164
|
+
// leading - / _ for vendor prefixes, e.g. :-moz-focusring
|
|
164
165
|
//console.log('its a pseudo class')
|
|
165
166
|
selectorObject.type = 'pseudo-class';
|
|
166
167
|
selectorObject.content += char;
|
|
@@ -169,7 +170,7 @@ export function parseSelectorsRich(selectorGroup) {
|
|
|
169
170
|
mode = 'pseudo-class';
|
|
170
171
|
pos++;
|
|
171
172
|
} else if (char === ':') {
|
|
172
|
-
selectorObject.type
|
|
173
|
+
selectorObject.type = 'pseudo-element';
|
|
173
174
|
selectorObject.content += char;
|
|
174
175
|
mode = 'pseudo-element';
|
|
175
176
|
pos++;
|
|
@@ -228,8 +229,8 @@ export function parseSelectorsRich(selectorGroup) {
|
|
|
228
229
|
{
|
|
229
230
|
if (selectorObject.content.length === 2) {
|
|
230
231
|
// first char after ::
|
|
231
|
-
if (/[a-zA-Z0-9]/.test(char)) {
|
|
232
|
-
//
|
|
232
|
+
if (/[a-zA-Z0-9-_]/.test(char)) {
|
|
233
|
+
// leading - / _ for vendor prefixes, e.g. ::-webkit-details-marker
|
|
233
234
|
selectorObject.content += char;
|
|
234
235
|
selectorObject.valid = true;
|
|
235
236
|
pos++;
|
|
@@ -28,6 +28,13 @@ function pseudoSelector(pesudo) {
|
|
|
28
28
|
valid: true
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
+
function pseudoElementSelector(pseudoElement) {
|
|
32
|
+
return {
|
|
33
|
+
type: 'pseudo-element',
|
|
34
|
+
content: pseudoElement,
|
|
35
|
+
valid: true
|
|
36
|
+
};
|
|
37
|
+
}
|
|
31
38
|
function attributeSelector(attribute) {
|
|
32
39
|
return {
|
|
33
40
|
type: 'attribute',
|
|
@@ -130,4 +137,19 @@ describe('parseSelectorsRich()', ({
|
|
|
130
137
|
const selectors = parseSelectorsRich(input13);
|
|
131
138
|
selectors.should.deep.equal([tagSelector('html'), whitespace(), pseudoSelector(':i(div)')]);
|
|
132
139
|
});
|
|
140
|
+
const input14 = 'summary::before';
|
|
141
|
+
it(`parses out a pseudo-element from '${input14}'`, () => {
|
|
142
|
+
const selectors = parseSelectorsRich(input14);
|
|
143
|
+
selectors.should.deep.equal([tagSelector('summary'), pseudoElementSelector('::before')]);
|
|
144
|
+
});
|
|
145
|
+
const input15 = 'summary::-webkit-details-marker';
|
|
146
|
+
it(`parses out a vendor prefixed pseudo-element from '${input15}'`, () => {
|
|
147
|
+
const selectors = parseSelectorsRich(input15);
|
|
148
|
+
selectors.should.deep.equal([tagSelector('summary'), pseudoElementSelector('::-webkit-details-marker')]);
|
|
149
|
+
});
|
|
150
|
+
const input16 = 'input:-moz-focusring';
|
|
151
|
+
it(`parses out a vendor prefixed pseudo-class from '${input16}'`, () => {
|
|
152
|
+
const selectors = parseSelectorsRich(input16);
|
|
153
|
+
selectors.should.deep.equal([tagSelector('input'), pseudoSelector(':-moz-focusring')]);
|
|
154
|
+
});
|
|
133
155
|
});
|
package/dist/settings.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare const assetsFolder = ".assets";
|
|
|
16
16
|
export declare const componentCssFolder = ".componentCss";
|
|
17
17
|
export declare const componentCssFile = "ccss.css";
|
|
18
18
|
export declare const packagesFolder = ".packages";
|
|
19
|
+
export declare const unusedStyleReporting: boolean;
|
|
19
20
|
export declare const packageName = "tungsten";
|
|
20
21
|
export declare const packageNameCapitalized = "Tungsten";
|
|
21
22
|
export declare const frameworkClientFolder = "_client";
|
package/dist/settings.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,cAAc,CAAA;AACtC,eAAO,MAAM,gBAAgB,SAAS,CAAA;AACtC,eAAO,MAAM,mBAAmB,kBAAuB,CAAA;AACvD,eAAO,MAAM,cAAc,uBAA+C,CAAA;AAC1E,eAAO,MAAM,eAAe,mBAAwB,CAAA;AACpD,eAAO,MAAM,mBAAmB,wBAA2C,CAAA;AAC3E,eAAO,MAAM,YAAY,2BAA+B,CAAA;AACxD,eAAO,MAAM,gBAAgB,yBAA8B,CAAA;AAC3D,eAAO,MAAM,mBAAmB,4BAAiC,CAAA;AACjE,eAAO,MAAM,qBAAqB,cAAc,CAAA;AAChD,eAAO,MAAM,YAAY,WAAW,CAAA;AAEpC,eAAO,MAAM,YAAY,YAAY,CAAA;AACrC,eAAO,MAAM,YAAY,YAAY,CAAA;AACrC,eAAO,MAAM,YAAY,YAAY,CAAA;AACrC,eAAO,MAAM,YAAY,YAAY,CAAA;AACrC,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AACjD,eAAO,MAAM,gBAAgB,aAAa,CAAA;AAC1C,eAAO,MAAM,cAAc,cAAc,CAAA;AAEzC,eAAO,MAAM,WAAW,aAAa,CAAA;AACrC,eAAO,MAAM,sBAAsB,aAAa,CAAA;AAChD,eAAO,MAAM,qBAAqB,YAAY,CAAA;AAC9C,eAAO,MAAM,mBAAmB,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,cAAc,CAAA;AACtC,eAAO,MAAM,gBAAgB,SAAS,CAAA;AACtC,eAAO,MAAM,mBAAmB,kBAAuB,CAAA;AACvD,eAAO,MAAM,cAAc,uBAA+C,CAAA;AAC1E,eAAO,MAAM,eAAe,mBAAwB,CAAA;AACpD,eAAO,MAAM,mBAAmB,wBAA2C,CAAA;AAC3E,eAAO,MAAM,YAAY,2BAA+B,CAAA;AACxD,eAAO,MAAM,gBAAgB,yBAA8B,CAAA;AAC3D,eAAO,MAAM,mBAAmB,4BAAiC,CAAA;AACjE,eAAO,MAAM,qBAAqB,cAAc,CAAA;AAChD,eAAO,MAAM,YAAY,WAAW,CAAA;AAEpC,eAAO,MAAM,YAAY,YAAY,CAAA;AACrC,eAAO,MAAM,YAAY,YAAY,CAAA;AACrC,eAAO,MAAM,YAAY,YAAY,CAAA;AACrC,eAAO,MAAM,YAAY,YAAY,CAAA;AACrC,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AACjD,eAAO,MAAM,gBAAgB,aAAa,CAAA;AAC1C,eAAO,MAAM,cAAc,cAAc,CAAA;AAEzC,eAAO,MAAM,oBAAoB,EAAE,OAAe,CAAA;AAElD,eAAO,MAAM,WAAW,aAAa,CAAA;AACrC,eAAO,MAAM,sBAAsB,aAAa,CAAA;AAChD,eAAO,MAAM,qBAAqB,YAAY,CAAA;AAC9C,eAAO,MAAM,mBAAmB,SAAS,CAAA"}
|
package/dist/settings.js
CHANGED
|
@@ -17,6 +17,7 @@ export const assetsFolder = '.assets';
|
|
|
17
17
|
export const componentCssFolder = '.componentCss';
|
|
18
18
|
export const componentCssFile = 'ccss.css';
|
|
19
19
|
export const packagesFolder = '.packages';
|
|
20
|
+
export const unusedStyleReporting = false;
|
|
20
21
|
export const packageName = 'tungsten';
|
|
21
22
|
export const packageNameCapitalized = 'Tungsten';
|
|
22
23
|
export const frameworkClientFolder = '_client';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staticGen.d.ts","sourceRoot":"","sources":["../../src/staticGen/staticGen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"staticGen.d.ts","sourceRoot":"","sources":["../../src/staticGen/staticGen.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAiBhD,wBAAsB,SAAS,CAAC,SAAS,EAAE,SAAS,iBA2LnD"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { existsSync, promises as fsPromises } from 'fs';
|
|
2
2
|
import { join, dirname } from 'path';
|
|
3
3
|
import fsExtra from 'fs-extra';
|
|
4
|
-
import axios from 'axios';
|
|
5
4
|
//import type { SxyFrameworkConfigComplete } from '../FrameworkConfig.js'
|
|
6
5
|
import { staticSiteFolder, staticFolder, assetsFolder, publicFolder, bundleFolder, componentCssFolder } from "../settings.js";
|
|
7
6
|
import { getAppRoutes } from "./getAppRoutes.js";
|
|
@@ -86,8 +85,11 @@ export async function staticGen(framework) {
|
|
|
86
85
|
let links;
|
|
87
86
|
try {
|
|
88
87
|
console.log('get URL', url);
|
|
89
|
-
const response = await
|
|
90
|
-
|
|
88
|
+
const response = await fetch(url);
|
|
89
|
+
// fetch, unlike axios, resolves on non-2xx - so check explicitly, or we'd
|
|
90
|
+
// write error pages out as static HTML
|
|
91
|
+
if (!response.ok) throwError('renderPath', `Get request to ${url} returned an invalid status: ${response.status}`);
|
|
92
|
+
let result = await response.text();
|
|
91
93
|
links = findLinks(result);
|
|
92
94
|
const newPaths = [];
|
|
93
95
|
for (const link of links) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styleContentSxy.d.ts","sourceRoot":"","sources":["../../src/style/styleContentSxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EACH,KAAK,WAAW,EACnB,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"styleContentSxy.d.ts","sourceRoot":"","sources":["../../src/style/styleContentSxy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EACH,KAAK,WAAW,EACnB,MAAM,mBAAmB,CAAA;AAc1B,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,eAIrE"}
|
|
@@ -5,13 +5,14 @@ import { TungstenError } from "../TungstenError.js";
|
|
|
5
5
|
import { componentBumpClass } from "../componentClassName.js";
|
|
6
6
|
import { $props, $type } from "../contentNodeSymbols.js";
|
|
7
7
|
import { isDev } from "../isDev.js";
|
|
8
|
+
import { unusedStyleReporting } from "../settings.js";
|
|
8
9
|
import { getStyleUsage } from "./unusedStyles.js";
|
|
9
10
|
function debug(...texts) {
|
|
10
11
|
//console.log(...texts)
|
|
11
12
|
}
|
|
12
13
|
export function styleContentSxy(content, styles) {
|
|
13
14
|
if (count(styles.tags) === 0 && count(styles.classes) === 0) return content; // optimization short circuit
|
|
14
|
-
processItem(content, styles, isDev ? getStyleUsage(styles) : undefined);
|
|
15
|
+
processItem(content, styles, isDev && unusedStyleReporting ? getStyleUsage(styles) : undefined);
|
|
15
16
|
return content;
|
|
16
17
|
}
|
|
17
18
|
function processItem(element, styles, usage) {
|
|
@@ -89,7 +90,7 @@ function processItem(element, styles, usage) {
|
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
debug('--tagName', tagName, element);
|
|
92
|
-
if (!Object.getOwnPropertySymbols(element).includes($props)
|
|
93
|
+
if (!Object.getOwnPropertySymbols(element).includes($props) /*|| element[$props] === undefined*/) {
|
|
93
94
|
//throw new TungstenError(`Error, element has no props. ${element}`)
|
|
94
95
|
warn(`Warning, element has no props. ${typeof element}:`, element);
|
|
95
96
|
// in one instance, the element is a function
|
|
@@ -97,8 +98,9 @@ function processItem(element, styles, usage) {
|
|
|
97
98
|
element[$props] = {};
|
|
98
99
|
}
|
|
99
100
|
let newClassName = '';
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
const tagClass = styles.tags[tagName];
|
|
102
|
+
if (tagClass !== undefined) {
|
|
103
|
+
newClassName += ' ' + componentBumpClass + ' ' + tagClass;
|
|
102
104
|
usage?.usedTags.add(tagName);
|
|
103
105
|
}
|
|
104
106
|
//console.log(element.props.className)
|
|
@@ -135,7 +137,7 @@ function processItem(element, styles, usage) {
|
|
|
135
137
|
// )
|
|
136
138
|
// }
|
|
137
139
|
function getComponentName(element) {
|
|
138
|
-
return element[$type].tagName || element[$type].constructor.name;
|
|
140
|
+
return element[$type].tagName || element[$type].constructor.name; // eslint-disable-line @typescript-eslint/strict-boolean-expressions -- has worked so far, leaving it
|
|
139
141
|
//// I don't think we have these things in our framework yet
|
|
140
142
|
// if ( element.type['$$typeof'] === Symbol.for('react.forward_ref') ) {
|
|
141
143
|
// return element.type.render.tagName || element.type.render.displayName || element.type.render.name
|
|
@@ -3,9 +3,7 @@ export type StyleUsage = {
|
|
|
3
3
|
styles: CssNames;
|
|
4
4
|
usedTags: Set<string>;
|
|
5
5
|
usedClasses: Set<string>;
|
|
6
|
-
reportedTags: Set<string>;
|
|
7
|
-
reportedClasses: Set<string>;
|
|
8
6
|
};
|
|
9
7
|
export declare function getStyleUsage(styles: CssNames): StyleUsage;
|
|
10
|
-
export declare function reportUnusedStyles(): void
|
|
8
|
+
export declare function reportUnusedStyles(): Promise<void>;
|
|
11
9
|
//# sourceMappingURL=unusedStyles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unusedStyles.d.ts","sourceRoot":"","sources":["../../src/style/unusedStyles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unusedStyles.d.ts","sourceRoot":"","sources":["../../src/style/unusedStyles.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAa9C,MAAM,MAAM,UAAU,GAAG;IACrB,MAAM,EAAE,QAAQ,CAAA;IAChB,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACrB,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAC3B,CAAA;AAUD,wBAAgB,aAAa,CAAC,MAAM,EAAE,QAAQ,cAQ7C;AA2BD,wBAAsB,kBAAkB,kBAgBvC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { warn } from "../output.js";
|
|
1
|
+
import { warn as safeWarn } from "../output.js";
|
|
2
2
|
// component stylesheets are module level singletons, so holding them here is not a leak
|
|
3
3
|
const usageByStyles = new Map();
|
|
4
4
|
// wait for render activity to settle before reporting, so that content rendered a little
|
|
5
5
|
// later (async components, route changes) doesn't get reported as unused
|
|
6
|
-
const reportDelayMs =
|
|
6
|
+
const reportDelayMs = 1000;
|
|
7
7
|
let reportHandle;
|
|
8
8
|
export function getStyleUsage(styles) {
|
|
9
9
|
let usage = usageByStyles.get(styles);
|
|
@@ -11,9 +11,7 @@ export function getStyleUsage(styles) {
|
|
|
11
11
|
usage = {
|
|
12
12
|
styles,
|
|
13
13
|
usedTags: new Set(),
|
|
14
|
-
usedClasses: new Set()
|
|
15
|
-
reportedTags: new Set(),
|
|
16
|
-
reportedClasses: new Set()
|
|
14
|
+
usedClasses: new Set()
|
|
17
15
|
};
|
|
18
16
|
usageByStyles.set(styles, usage);
|
|
19
17
|
}
|
|
@@ -26,18 +24,30 @@ function scheduleUnusedStylesReport() {
|
|
|
26
24
|
// don't hold a node process open just for the report
|
|
27
25
|
if (typeof reportHandle === 'object' && typeof reportHandle.unref === 'function') reportHandle.unref();
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
// cliOutput pulls in chalk, which is node only, so it must not enter the browser's module
|
|
28
|
+
// graph. A promise rather than top level await: awaiting here would make this an async
|
|
29
|
+
// module, and with it every importer of styleContentSxy.
|
|
30
|
+
// In the prod client bundle the whole conditional folds to the Promise.resolve() branch,
|
|
31
|
+
// so the import() is not emitted at all.
|
|
32
|
+
// const warnPromise: Promise<(...texts: unknown[]) => void> = (isServer)
|
|
33
|
+
// ? import('../cliOutput.js').then(module => module.cliWarn)
|
|
34
|
+
// : Promise.resolve(safeWarn)
|
|
35
|
+
const warnPromise = Promise.resolve(safeWarn);
|
|
36
|
+
// names in the stylesheet that nothing has matched, marking them so that they are only
|
|
37
|
+
// reported once. Without that, every later render repeats the same warning
|
|
38
|
+
function takeUnmatched(names, used) {
|
|
39
|
+
const unmatched = Object.keys(names).filter(name => !used.has(name));
|
|
40
|
+
for (const name of unmatched) used.add(name);
|
|
41
|
+
return unmatched;
|
|
42
|
+
}
|
|
43
|
+
export async function reportUnusedStyles() {
|
|
44
|
+
clearTimeout(reportHandle);
|
|
45
|
+
reportHandle = undefined;
|
|
46
|
+
const warn = await warnPromise;
|
|
34
47
|
for (const usage of usageByStyles.values()) {
|
|
35
|
-
const tags =
|
|
36
|
-
const classes =
|
|
48
|
+
const tags = takeUnmatched(usage.styles.tags, usage.usedTags);
|
|
49
|
+
const classes = takeUnmatched(usage.styles.classes, usage.usedClasses);
|
|
37
50
|
if (tags.length === 0 && classes.length === 0) continue;
|
|
38
|
-
// only report each selector once, otherwise every later render repeats the warning
|
|
39
|
-
for (const tag of tags) usage.reportedTags.add(tag);
|
|
40
|
-
for (const className of classes) usage.reportedClasses.add(className);
|
|
41
51
|
warn(`Tungsten dev: styles in module "${usage.styles.moduleName}" have not matched any content:` + (tags.length > 0 ? `\n tag/component names: ${tags.join(', ')}` : '') + (classes.length > 0 ? `\n class names: ${classes.join(', ')}` : ''));
|
|
42
52
|
}
|
|
43
53
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tungsten",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.23",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -36,9 +36,8 @@
|
|
|
36
36
|
"@rollup/plugin-commonjs": "^22.0.2",
|
|
37
37
|
"@rollup/plugin-json": "^6.1.0",
|
|
38
38
|
"@rollup/plugin-node-resolve": "^14.1.0",
|
|
39
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
39
40
|
"arktype": "^2.2.0",
|
|
40
|
-
"axios": "^0.27.2",
|
|
41
|
-
"babel-loader": "^8.4.1",
|
|
42
41
|
"babel-plugin-css-to-js": "^0.0.4",
|
|
43
42
|
"babel-plugin-sxy-module-resolver": "^4.1.9",
|
|
44
43
|
"babel-plugin-sxy-transform-cjs-to-esm": "^0.2.6",
|
|
@@ -48,7 +47,6 @@
|
|
|
48
47
|
"chokidar": "^3.6.0",
|
|
49
48
|
"cjs-module-lexer": "^1.4.3",
|
|
50
49
|
"cjstoesm": "^2.1.2",
|
|
51
|
-
"compression-webpack-plugin": "^10.0.0",
|
|
52
50
|
"cookie-parser": "^1.4.7",
|
|
53
51
|
"cross-env": "^7.0.3",
|
|
54
52
|
"decamelize": "^6.0.1",
|
|
@@ -59,26 +57,18 @@
|
|
|
59
57
|
"fs-extra": "^10.1.0",
|
|
60
58
|
"globby": "^13.2.2",
|
|
61
59
|
"hono": "^4.12.8",
|
|
62
|
-
"html-webpack-plugin": "^5.6.6",
|
|
63
60
|
"import-meta-resolve": "^2.2.2",
|
|
64
61
|
"ini": "^4.1.3",
|
|
65
|
-
"install": "^0.13.0",
|
|
66
62
|
"lodash.clonedeep": "^4.5.0",
|
|
67
|
-
"mini-css-extract-plugin": "^2.10.1",
|
|
68
|
-
"node-fetch": "^3.3.2",
|
|
69
|
-
"npm": "^11.12.0",
|
|
70
63
|
"npm-run-all": "^4.1.5",
|
|
71
64
|
"open": "^8.4.2",
|
|
72
65
|
"path-to-regexp": "^6.3.0",
|
|
73
66
|
"postcss": "^8.5.8",
|
|
74
67
|
"precinct": "^12.2.0",
|
|
75
68
|
"react-router": "^6.30.3",
|
|
76
|
-
"redaxios": "^0.5.1",
|
|
77
69
|
"require-resolve-hook": "^1.1.0",
|
|
78
|
-
"rmfr": "^2.0.0",
|
|
79
70
|
"rollup": "^2.80.0",
|
|
80
71
|
"rollup-plugin-gzip": "^3.1.2",
|
|
81
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
82
72
|
"sass": "^1.98.0",
|
|
83
73
|
"serialize-javascript": "^6.0.2",
|
|
84
74
|
"slash": "^4.0.0",
|
|
@@ -88,8 +78,6 @@
|
|
|
88
78
|
"sxy-lib-object-copy": "^2.0.5",
|
|
89
79
|
"sxy-loader": "^3.1.0",
|
|
90
80
|
"sxy-package-investigator": "^1.0.0",
|
|
91
|
-
"terser-webpack-plugin": "^5.4.0",
|
|
92
|
-
"util": "^0.12.5",
|
|
93
81
|
"zod": "^4.3.6"
|
|
94
82
|
},
|
|
95
83
|
"devDependencies": {
|
|
@@ -98,7 +86,6 @@
|
|
|
98
86
|
"@types/babel-types": "^7.0.16",
|
|
99
87
|
"@types/babel__core": "^7.20.5",
|
|
100
88
|
"@types/babel__generator": "^7.27.0",
|
|
101
|
-
"@types/bcrypt": "^5.0.2",
|
|
102
89
|
"@types/bcryptjs": "^2.4.6",
|
|
103
90
|
"@types/chai": "^4.3.20",
|
|
104
91
|
"@types/cookie-parser": "^1.4.10",
|
|
@@ -119,25 +106,18 @@
|
|
|
119
106
|
"babel-plugin-sxy-transform-import-extensions": "^1.0.5",
|
|
120
107
|
"babel-plugin-transform-import-extension": "^1.0.3",
|
|
121
108
|
"chai": "^4.5.0",
|
|
122
|
-
"chai-subset": "^1.6.0",
|
|
123
109
|
"csstype": "^3.2.3",
|
|
124
110
|
"eslint": "^8.57.1",
|
|
125
111
|
"eslint-import-resolver-typescript": "^2.7.1",
|
|
126
112
|
"eslint-plugin-import": "^2.32.0",
|
|
127
113
|
"eslint-plugin-no-type-assertion": "^1.3.0",
|
|
128
114
|
"happy-dom": "^20.10.6",
|
|
129
|
-
"progress-webpack-plugin": "^1.0.16",
|
|
130
115
|
"prop-types": "^15.8.1",
|
|
131
116
|
"rimraf": "^5.0.10",
|
|
132
|
-
"rmrf": "^2.0.4",
|
|
133
117
|
"rollup-plugin-visualizer": "^5.14.0",
|
|
134
|
-
"supertest": "^6.3.4",
|
|
135
118
|
"sxy-test-runner": "^2.2.2",
|
|
136
119
|
"sxy-types": "^1.0.23",
|
|
137
|
-
"typescript": "^6.0.3"
|
|
138
|
-
"webpack-bundle-analyzer": "^4.10.2",
|
|
139
|
-
"webpack-cli": "^4.10.0",
|
|
140
|
-
"webpack-stats-plugin": "^1.1.3"
|
|
120
|
+
"typescript": "^6.0.3"
|
|
141
121
|
},
|
|
142
122
|
"peerDependencies": {
|
|
143
123
|
"react": "^18.2.0 || ^19.0.0",
|
package/types/modules.d.ts
CHANGED
|
@@ -4,4 +4,35 @@ declare module 'babel-plugin-css-to-js'
|
|
|
4
4
|
declare module '@babel/plugin-transform-class-properties'
|
|
5
5
|
declare module '@rollup/plugin-node-resolve'
|
|
6
6
|
declare module '@rollup/plugin-commonjs'
|
|
7
|
-
|
|
7
|
+
// Its shipped types resolve as CJS under NodeNext (no "type":"module", no import/require
|
|
8
|
+
// conditions in its exports map), so tsc sees a namespace and the default export isn't
|
|
9
|
+
// callable. Redeclared here instead. terser's own types aren't reachable -- it's a
|
|
10
|
+
// transitive dep, so pnpm keeps it out of the top-level node_modules -- hence the
|
|
11
|
+
// hand-written option list; nested option objects are left loose on purpose.
|
|
12
|
+
declare module '@rollup/plugin-terser' {
|
|
13
|
+
import type { Plugin } from 'rollup'
|
|
14
|
+
|
|
15
|
+
type TerserNested = Record<string, unknown>
|
|
16
|
+
|
|
17
|
+
export interface Options {
|
|
18
|
+
compress?: boolean | TerserNested
|
|
19
|
+
ecma?: 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
|
|
20
|
+
enclose?: boolean | string
|
|
21
|
+
format?: TerserNested
|
|
22
|
+
ie8?: boolean
|
|
23
|
+
keep_classnames?: boolean | RegExp
|
|
24
|
+
keep_fnames?: boolean | RegExp
|
|
25
|
+
mangle?: boolean | TerserNested
|
|
26
|
+
module?: boolean
|
|
27
|
+
parse?: TerserNested
|
|
28
|
+
safari10?: boolean
|
|
29
|
+
sourceMap?: boolean | TerserNested
|
|
30
|
+
toplevel?: boolean
|
|
31
|
+
/** Added by the plugin, not terser itself. */
|
|
32
|
+
nameCache?: Record<string, unknown>
|
|
33
|
+
/** Added by the plugin, not terser itself. */
|
|
34
|
+
maxWorkers?: number
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default function terser(options?: Options): Plugin
|
|
38
|
+
}
|