@rindo/core 2.16.0 → 2.17.0
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/cli/index.cjs +122 -16
- package/cli/index.js +122 -16
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/rindo.js +728 -263
- package/compiler/rindo.min.js +2 -2
- package/dependencies.json +1 -1
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +3 -3
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +4 -2
- package/internal/app-data/package.json +1 -1
- package/internal/client/css-shim.js +1 -1
- package/internal/client/dom.js +1 -1
- package/internal/client/index.js +1 -1
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/client/patch-esm.js +1 -1
- package/internal/client/shadow-css.js +1 -1
- package/internal/hydrate/index.js +3 -3
- package/internal/hydrate/package.json +1 -1
- package/internal/package.json +1 -1
- package/internal/rindo-private.d.ts +4 -0
- package/internal/rindo-public-compiler.d.ts +3 -2
- package/internal/testing/index.js +1 -1
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +142 -5
- package/mock-doc/index.d.ts +77 -1
- package/mock-doc/index.js +142 -5
- package/mock-doc/package.json +1 -1
- package/package.json +3 -1
- package/screenshot/index.js +2 -0
- package/screenshot/package.json +1 -1
- package/sys/node/index.js +325 -314
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.d.ts +1 -1
- package/testing/index.js +105 -62
- package/testing/mocks.d.ts +22 -2
- package/testing/package.json +1 -1
package/compiler/rindo.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Rindo Compiler v2.
|
|
2
|
+
Rindo Compiler v2.17.0 | MIT Licensed | https://rindojs.web.app
|
|
3
3
|
*/
|
|
4
4
|
(function(exports) {
|
|
5
5
|
'use strict';
|
|
@@ -717,7 +717,7 @@ const computeListenerFlags = (listener) => {
|
|
|
717
717
|
};
|
|
718
718
|
const trimFalsy = (data) => {
|
|
719
719
|
const arr = data;
|
|
720
|
-
for (
|
|
720
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
721
721
|
if (arr[i]) {
|
|
722
722
|
break;
|
|
723
723
|
}
|
|
@@ -826,136 +826,15 @@ const isGlob = (str) => {
|
|
|
826
826
|
};
|
|
827
827
|
|
|
828
828
|
/**
|
|
829
|
-
* Checks if the path is the OS root path, such as "/" or "C:\"
|
|
829
|
+
* Checks if the path is the Operating System (OS) root path, such as "/" or "C:\". This function does not take the OS
|
|
830
|
+
* the code is running on into account when performing this evaluation.
|
|
831
|
+
* @param p the path to check
|
|
832
|
+
* @returns `true` if the path is an OS root path, `false` otherwise
|
|
830
833
|
*/
|
|
831
834
|
const isRootPath = (p) => p === '/' || windowsPathRegex.test(p);
|
|
832
835
|
// https://github.com/nodejs/node/blob/5883a59b21a97e8b7339f435c977155a2c29ba8d/lib/path.js#L43
|
|
833
836
|
const windowsPathRegex = /^(?:[a-zA-Z]:|[\\/]{2}[^\\/]+[\\/]+[^\\/]+)?[\\/]$/;
|
|
834
837
|
|
|
835
|
-
/**
|
|
836
|
-
* Iterate through a series of diagnostics to provide minor fix-ups for various edge cases, deduplicate messages, etc.
|
|
837
|
-
* @param compilerCtx the current compiler context
|
|
838
|
-
* @param diagnostics the diagnostics to normalize
|
|
839
|
-
* @returns the normalize documents
|
|
840
|
-
*/
|
|
841
|
-
const normalizeDiagnostics = (compilerCtx, diagnostics) => {
|
|
842
|
-
const normalizedErrors = [];
|
|
843
|
-
const normalizedOthers = [];
|
|
844
|
-
const dups = new Set();
|
|
845
|
-
for (let i = 0; i < diagnostics.length; i++) {
|
|
846
|
-
const d = normalizeDiagnostic(compilerCtx, diagnostics[i]);
|
|
847
|
-
const key = d.absFilePath + d.code + d.messageText + d.type;
|
|
848
|
-
if (dups.has(key)) {
|
|
849
|
-
continue;
|
|
850
|
-
}
|
|
851
|
-
dups.add(key);
|
|
852
|
-
const total = normalizedErrors.length + normalizedOthers.length;
|
|
853
|
-
if (d.level === 'error') {
|
|
854
|
-
normalizedErrors.push(d);
|
|
855
|
-
}
|
|
856
|
-
else if (total < MAX_ERRORS) {
|
|
857
|
-
normalizedOthers.push(d);
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
return [...normalizedErrors, ...normalizedOthers];
|
|
861
|
-
};
|
|
862
|
-
/**
|
|
863
|
-
* Perform post-processing on a `Diagnostic` to handle a few message edge cases, massaging error message text and
|
|
864
|
-
* updating build failure contexts
|
|
865
|
-
* @param compilerCtx the current compiler
|
|
866
|
-
* @param diagnostic the diagnostic to normalize
|
|
867
|
-
* @returns the altered diagnostic
|
|
868
|
-
*/
|
|
869
|
-
const normalizeDiagnostic = (compilerCtx, diagnostic) => {
|
|
870
|
-
if (diagnostic.messageText) {
|
|
871
|
-
if (typeof diagnostic.messageText.message === 'string') {
|
|
872
|
-
diagnostic.messageText = diagnostic.messageText.message;
|
|
873
|
-
}
|
|
874
|
-
else if (typeof diagnostic.messageText === 'string' && diagnostic.messageText.indexOf('Error: ') === 0) {
|
|
875
|
-
diagnostic.messageText = diagnostic.messageText.slice(7);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
if (diagnostic.messageText) {
|
|
879
|
-
if (diagnostic.messageText.includes(`Cannot find name 'h'`)) {
|
|
880
|
-
diagnostic.header = `Missing "h" import for JSX types`;
|
|
881
|
-
diagnostic.messageText = `In order to load accurate JSX types for components, the "h" function must be imported from "@rindo/core" by each component using JSX. For example: import { Component, h } from '@rindo/core';`;
|
|
882
|
-
try {
|
|
883
|
-
const sourceText = compilerCtx.fs.readFileSync(diagnostic.absFilePath);
|
|
884
|
-
const srcLines = splitLineBreaks(sourceText);
|
|
885
|
-
for (let i = 0; i < srcLines.length; i++) {
|
|
886
|
-
const srcLine = srcLines[i];
|
|
887
|
-
if (srcLine.includes('@rindo/core')) {
|
|
888
|
-
const msgLines = [];
|
|
889
|
-
const beforeLineIndex = i - 1;
|
|
890
|
-
if (beforeLineIndex > -1) {
|
|
891
|
-
const beforeLine = {
|
|
892
|
-
lineIndex: beforeLineIndex,
|
|
893
|
-
lineNumber: beforeLineIndex + 1,
|
|
894
|
-
text: srcLines[beforeLineIndex],
|
|
895
|
-
errorCharStart: -1,
|
|
896
|
-
errorLength: -1,
|
|
897
|
-
};
|
|
898
|
-
msgLines.push(beforeLine);
|
|
899
|
-
}
|
|
900
|
-
const errorLine = {
|
|
901
|
-
lineIndex: i,
|
|
902
|
-
lineNumber: i + 1,
|
|
903
|
-
text: srcLine,
|
|
904
|
-
errorCharStart: 0,
|
|
905
|
-
errorLength: -1,
|
|
906
|
-
};
|
|
907
|
-
msgLines.push(errorLine);
|
|
908
|
-
diagnostic.lineNumber = errorLine.lineNumber;
|
|
909
|
-
diagnostic.columnNumber = srcLine.indexOf('}');
|
|
910
|
-
const afterLineIndex = i + 1;
|
|
911
|
-
if (afterLineIndex < srcLines.length) {
|
|
912
|
-
const afterLine = {
|
|
913
|
-
lineIndex: afterLineIndex,
|
|
914
|
-
lineNumber: afterLineIndex + 1,
|
|
915
|
-
text: srcLines[afterLineIndex],
|
|
916
|
-
errorCharStart: -1,
|
|
917
|
-
errorLength: -1,
|
|
918
|
-
};
|
|
919
|
-
msgLines.push(afterLine);
|
|
920
|
-
}
|
|
921
|
-
diagnostic.lines = msgLines;
|
|
922
|
-
break;
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
catch (e) { }
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
return diagnostic;
|
|
930
|
-
};
|
|
931
|
-
/**
|
|
932
|
-
* Split a corpus by newlines. Carriage returns are treated a newlines.
|
|
933
|
-
* @param sourceText the corpus to split
|
|
934
|
-
* @returns the split text
|
|
935
|
-
*/
|
|
936
|
-
const splitLineBreaks = (sourceText) => {
|
|
937
|
-
if (typeof sourceText !== 'string')
|
|
938
|
-
return [];
|
|
939
|
-
sourceText = sourceText.replace(/\\r/g, '\n');
|
|
940
|
-
return sourceText.split('\n');
|
|
941
|
-
};
|
|
942
|
-
const escapeHtml = (unsafe) => {
|
|
943
|
-
if (unsafe === undefined)
|
|
944
|
-
return 'undefined';
|
|
945
|
-
if (unsafe === null)
|
|
946
|
-
return 'null';
|
|
947
|
-
if (typeof unsafe !== 'string') {
|
|
948
|
-
unsafe = unsafe.toString();
|
|
949
|
-
}
|
|
950
|
-
return unsafe
|
|
951
|
-
.replace(/&/g, '&')
|
|
952
|
-
.replace(/</g, '<')
|
|
953
|
-
.replace(/>/g, '>')
|
|
954
|
-
.replace(/"/g, '"')
|
|
955
|
-
.replace(/'/g, ''');
|
|
956
|
-
};
|
|
957
|
-
const MAX_ERRORS = 25;
|
|
958
|
-
|
|
959
838
|
/**
|
|
960
839
|
* Builds a template `Diagnostic` entity for a build error. The created `Diagnostic` is returned, and have little
|
|
961
840
|
* detail attached to it regarding the specifics of the error - it is the responsibility of the caller of this method
|
|
@@ -1120,6 +999,130 @@ const shouldIgnoreError = (msg) => {
|
|
|
1120
999
|
};
|
|
1121
1000
|
const TASK_CANCELED_MSG = `task canceled`;
|
|
1122
1001
|
|
|
1002
|
+
/**
|
|
1003
|
+
* Iterate through a series of diagnostics to provide minor fix-ups for various edge cases, deduplicate messages, etc.
|
|
1004
|
+
* @param compilerCtx the current compiler context
|
|
1005
|
+
* @param diagnostics the diagnostics to normalize
|
|
1006
|
+
* @returns the normalize documents
|
|
1007
|
+
*/
|
|
1008
|
+
const normalizeDiagnostics = (compilerCtx, diagnostics) => {
|
|
1009
|
+
const maxErrorsToNormalize = 25;
|
|
1010
|
+
const normalizedErrors = [];
|
|
1011
|
+
const normalizedOthers = [];
|
|
1012
|
+
const dups = new Set();
|
|
1013
|
+
for (let i = 0; i < diagnostics.length; i++) {
|
|
1014
|
+
const d = normalizeDiagnostic(compilerCtx, diagnostics[i]);
|
|
1015
|
+
const key = d.absFilePath + d.code + d.messageText + d.type;
|
|
1016
|
+
if (dups.has(key)) {
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
dups.add(key);
|
|
1020
|
+
const total = normalizedErrors.length + normalizedOthers.length;
|
|
1021
|
+
if (d.level === 'error') {
|
|
1022
|
+
normalizedErrors.push(d);
|
|
1023
|
+
}
|
|
1024
|
+
else if (total < maxErrorsToNormalize) {
|
|
1025
|
+
normalizedOthers.push(d);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
return [...normalizedErrors, ...normalizedOthers];
|
|
1029
|
+
};
|
|
1030
|
+
/**
|
|
1031
|
+
* Perform post-processing on a `Diagnostic` to handle a few message edge cases, massaging error message text and
|
|
1032
|
+
* updating build failure contexts
|
|
1033
|
+
* @param compilerCtx the current compiler
|
|
1034
|
+
* @param diagnostic the diagnostic to normalize
|
|
1035
|
+
* @returns the altered diagnostic
|
|
1036
|
+
*/
|
|
1037
|
+
const normalizeDiagnostic = (compilerCtx, diagnostic) => {
|
|
1038
|
+
if (diagnostic.messageText) {
|
|
1039
|
+
if (typeof diagnostic.messageText.message === 'string') {
|
|
1040
|
+
diagnostic.messageText = diagnostic.messageText.message;
|
|
1041
|
+
}
|
|
1042
|
+
else if (typeof diagnostic.messageText === 'string' && diagnostic.messageText.indexOf('Error: ') === 0) {
|
|
1043
|
+
diagnostic.messageText = diagnostic.messageText.slice(7);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
if (diagnostic.messageText) {
|
|
1047
|
+
if (diagnostic.messageText.includes(`Cannot find name 'h'`)) {
|
|
1048
|
+
diagnostic.header = `Missing "h" import for JSX types`;
|
|
1049
|
+
diagnostic.messageText = `In order to load accurate JSX types for components, the "h" function must be imported from "@rindo/core" by each component using JSX. For example: import { Component, h } from '@rindo/core';`;
|
|
1050
|
+
try {
|
|
1051
|
+
const sourceText = compilerCtx.fs.readFileSync(diagnostic.absFilePath);
|
|
1052
|
+
const srcLines = splitLineBreaks(sourceText);
|
|
1053
|
+
for (let i = 0; i < srcLines.length; i++) {
|
|
1054
|
+
const srcLine = srcLines[i];
|
|
1055
|
+
if (srcLine.includes('@rindo/core')) {
|
|
1056
|
+
const msgLines = [];
|
|
1057
|
+
const beforeLineIndex = i - 1;
|
|
1058
|
+
if (beforeLineIndex > -1) {
|
|
1059
|
+
const beforeLine = {
|
|
1060
|
+
lineIndex: beforeLineIndex,
|
|
1061
|
+
lineNumber: beforeLineIndex + 1,
|
|
1062
|
+
text: srcLines[beforeLineIndex],
|
|
1063
|
+
errorCharStart: -1,
|
|
1064
|
+
errorLength: -1,
|
|
1065
|
+
};
|
|
1066
|
+
msgLines.push(beforeLine);
|
|
1067
|
+
}
|
|
1068
|
+
const errorLine = {
|
|
1069
|
+
lineIndex: i,
|
|
1070
|
+
lineNumber: i + 1,
|
|
1071
|
+
text: srcLine,
|
|
1072
|
+
errorCharStart: 0,
|
|
1073
|
+
errorLength: -1,
|
|
1074
|
+
};
|
|
1075
|
+
msgLines.push(errorLine);
|
|
1076
|
+
diagnostic.lineNumber = errorLine.lineNumber;
|
|
1077
|
+
diagnostic.columnNumber = srcLine.indexOf('}');
|
|
1078
|
+
const afterLineIndex = i + 1;
|
|
1079
|
+
if (afterLineIndex < srcLines.length) {
|
|
1080
|
+
const afterLine = {
|
|
1081
|
+
lineIndex: afterLineIndex,
|
|
1082
|
+
lineNumber: afterLineIndex + 1,
|
|
1083
|
+
text: srcLines[afterLineIndex],
|
|
1084
|
+
errorCharStart: -1,
|
|
1085
|
+
errorLength: -1,
|
|
1086
|
+
};
|
|
1087
|
+
msgLines.push(afterLine);
|
|
1088
|
+
}
|
|
1089
|
+
diagnostic.lines = msgLines;
|
|
1090
|
+
break;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
catch (e) { }
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
return diagnostic;
|
|
1098
|
+
};
|
|
1099
|
+
/**
|
|
1100
|
+
* Split a corpus by newlines. Carriage returns are treated a newlines.
|
|
1101
|
+
* @param sourceText the corpus to split
|
|
1102
|
+
* @returns the split text
|
|
1103
|
+
*/
|
|
1104
|
+
const splitLineBreaks = (sourceText) => {
|
|
1105
|
+
if (typeof sourceText !== 'string')
|
|
1106
|
+
return [];
|
|
1107
|
+
sourceText = sourceText.replace(/\\r/g, '\n');
|
|
1108
|
+
return sourceText.split('\n');
|
|
1109
|
+
};
|
|
1110
|
+
const escapeHtml = (unsafe) => {
|
|
1111
|
+
if (unsafe === undefined)
|
|
1112
|
+
return 'undefined';
|
|
1113
|
+
if (unsafe === null)
|
|
1114
|
+
return 'null';
|
|
1115
|
+
if (typeof unsafe !== 'string') {
|
|
1116
|
+
unsafe = unsafe.toString();
|
|
1117
|
+
}
|
|
1118
|
+
return unsafe
|
|
1119
|
+
.replace(/&/g, '&')
|
|
1120
|
+
.replace(/</g, '<')
|
|
1121
|
+
.replace(/>/g, '>')
|
|
1122
|
+
.replace(/"/g, '"')
|
|
1123
|
+
.replace(/'/g, ''');
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1123
1126
|
const loadRollupDiagnostics = (config, compilerCtx, buildCtx, rollupError) => {
|
|
1124
1127
|
const formattedCode = formatErrorCode(rollupError.code);
|
|
1125
1128
|
const diagnostic = {
|
|
@@ -1258,6 +1261,8 @@ const formatErrorCode = (errorCode) => {
|
|
|
1258
1261
|
* Forward-slash paths can be used in Windows as long as they're not
|
|
1259
1262
|
* extended-length paths and don't contain any non-ascii characters.
|
|
1260
1263
|
* This was created since the path methods in Node.js outputs \\ paths on Windows.
|
|
1264
|
+
* @param path the Windows-based path to convert
|
|
1265
|
+
* @returns the converted path
|
|
1261
1266
|
*/
|
|
1262
1267
|
const normalizePath$1 = (path) => {
|
|
1263
1268
|
if (typeof path !== 'string') {
|
|
@@ -1393,8 +1398,10 @@ const pathComponents = (path, rootLength) => {
|
|
|
1393
1398
|
return [root, ...rest];
|
|
1394
1399
|
};
|
|
1395
1400
|
/**
|
|
1396
|
-
* Same as normalizePath(), expect it'll also strip any
|
|
1401
|
+
* Same as normalizePath(), expect it'll also strip any query strings
|
|
1397
1402
|
* from the path name. So /dir/file.css?tag=cmp-a becomes /dir/file.css
|
|
1403
|
+
* @param p the path to normalize
|
|
1404
|
+
* @returns the normalized path, sans any query strings
|
|
1398
1405
|
*/
|
|
1399
1406
|
const normalizeFsPath = (p) => normalizePath$1(p.split('?')[0].replace(/\0/g, ''));
|
|
1400
1407
|
const normalizeFsPathQuery = (importPath) => {
|
|
@@ -1570,6 +1577,15 @@ const flattenDiagnosticMessageText = (tsDiagnostic, diag) => {
|
|
|
1570
1577
|
return result.trim();
|
|
1571
1578
|
};
|
|
1572
1579
|
|
|
1580
|
+
/**
|
|
1581
|
+
* Determines whether a string should be considered a remote url or not.
|
|
1582
|
+
*
|
|
1583
|
+
* This helper only checks the provided string to evaluate is one of a few pre-defined schemes, and should not be
|
|
1584
|
+
* considered all-encompassing
|
|
1585
|
+
*
|
|
1586
|
+
* @param p the string to evaluate
|
|
1587
|
+
* @returns `true` if the provided string is a remote url, `false` otherwise
|
|
1588
|
+
*/
|
|
1573
1589
|
const isRemoteUrl = (p) => {
|
|
1574
1590
|
if (isString$1(p)) {
|
|
1575
1591
|
p = p.toLowerCase();
|
|
@@ -1639,12 +1655,23 @@ ${docs.tags
|
|
|
1639
1655
|
.map((tag) => `@${tag.name} ${(tag.text || '').replace(lineBreakRegex, ' ')}`)
|
|
1640
1656
|
.join('\n')}`.trim();
|
|
1641
1657
|
}
|
|
1658
|
+
/**
|
|
1659
|
+
* Retrieve a project's dependencies from the current build context
|
|
1660
|
+
* @param buildCtx the current build context to query for a specific package
|
|
1661
|
+
* @returns a list of package names the project is dependent on
|
|
1662
|
+
*/
|
|
1642
1663
|
const getDependencies = (buildCtx) => {
|
|
1643
1664
|
if (buildCtx.packageJson != null && buildCtx.packageJson.dependencies != null) {
|
|
1644
1665
|
return Object.keys(buildCtx.packageJson.dependencies).filter((pkgName) => !SKIP_DEPS.includes(pkgName));
|
|
1645
1666
|
}
|
|
1646
1667
|
return [];
|
|
1647
1668
|
};
|
|
1669
|
+
/**
|
|
1670
|
+
* Utility to determine whether a project has a dependency on a package
|
|
1671
|
+
* @param buildCtx the current build context to query for a specific package
|
|
1672
|
+
* @param depName the name of the dependency/package
|
|
1673
|
+
* @returns `true` if the project has a dependency a packaged with the provided name, `false` otherwise
|
|
1674
|
+
*/
|
|
1648
1675
|
const hasDependency = (buildCtx, depName) => {
|
|
1649
1676
|
return getDependencies(buildCtx).includes(depName);
|
|
1650
1677
|
};
|
|
@@ -1670,38 +1697,30 @@ const readPackageJson = async (config, compilerCtx, buildCtx) => {
|
|
|
1670
1697
|
}
|
|
1671
1698
|
}
|
|
1672
1699
|
};
|
|
1700
|
+
/**
|
|
1701
|
+
* Parse a string read from a `package.json` file
|
|
1702
|
+
* @param pkgJsonStr the string read from a `package.json` file
|
|
1703
|
+
* @param pkgJsonFilePath the path to the already read `package.json` file
|
|
1704
|
+
* @returns the results of parsing the provided contents of the `package.json` file
|
|
1705
|
+
*/
|
|
1673
1706
|
const parsePackageJson = (pkgJsonStr, pkgJsonFilePath) => {
|
|
1674
|
-
|
|
1675
|
-
return parseJson(pkgJsonStr, pkgJsonFilePath);
|
|
1676
|
-
}
|
|
1677
|
-
return null;
|
|
1678
|
-
};
|
|
1679
|
-
const parseJson = (jsonStr, filePath) => {
|
|
1680
|
-
const rtn = {
|
|
1707
|
+
const parseResult = {
|
|
1681
1708
|
diagnostic: null,
|
|
1682
1709
|
data: null,
|
|
1683
|
-
filePath,
|
|
1710
|
+
filePath: pkgJsonFilePath,
|
|
1684
1711
|
};
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
rtn.data = JSON.parse(jsonStr);
|
|
1688
|
-
}
|
|
1689
|
-
catch (e) {
|
|
1690
|
-
rtn.diagnostic = buildError();
|
|
1691
|
-
rtn.diagnostic.absFilePath = filePath;
|
|
1692
|
-
rtn.diagnostic.header = `Error Parsing JSON`;
|
|
1693
|
-
if (e instanceof Error) {
|
|
1694
|
-
rtn.diagnostic.messageText = e.message;
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1712
|
+
try {
|
|
1713
|
+
parseResult.data = JSON.parse(pkgJsonStr);
|
|
1697
1714
|
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1715
|
+
catch (e) {
|
|
1716
|
+
parseResult.diagnostic = buildError();
|
|
1717
|
+
parseResult.diagnostic.absFilePath = isString$1(pkgJsonFilePath) ? pkgJsonFilePath : undefined;
|
|
1718
|
+
parseResult.diagnostic.header = `Error Parsing JSON`;
|
|
1719
|
+
if (e instanceof Error) {
|
|
1720
|
+
parseResult.diagnostic.messageText = e.message;
|
|
1721
|
+
}
|
|
1703
1722
|
}
|
|
1704
|
-
return
|
|
1723
|
+
return parseResult;
|
|
1705
1724
|
};
|
|
1706
1725
|
const SKIP_DEPS = ['@rindo/core'];
|
|
1707
1726
|
|
|
@@ -4523,7 +4542,7 @@ const createCustomResolverAsync = (sys, inMemoryFs, exts) => {
|
|
|
4523
4542
|
};
|
|
4524
4543
|
};
|
|
4525
4544
|
|
|
4526
|
-
const buildId = '
|
|
4545
|
+
const buildId = '20220812090622';
|
|
4527
4546
|
const minfyJsId = 'terser5.6.1_7';
|
|
4528
4547
|
const optimizeCssId = 'autoprefixer10.2.5_postcss8.4.16_7';
|
|
4529
4548
|
const parse5Version = '6.0.1';
|
|
@@ -4531,8 +4550,8 @@ const rollupVersion = '2.42.3';
|
|
|
4531
4550
|
const sizzleVersion = '2.42.3';
|
|
4532
4551
|
const terserVersion = '5.6.1';
|
|
4533
4552
|
const typescriptVersion = '4.5.4';
|
|
4534
|
-
const vermoji = '
|
|
4535
|
-
const version$3 = '2.
|
|
4553
|
+
const vermoji = '🏉';
|
|
4554
|
+
const version$3 = '2.17.0';
|
|
4536
4555
|
const versions = {
|
|
4537
4556
|
rindo: version$3,
|
|
4538
4557
|
parse5: parse5Version,
|
|
@@ -11477,6 +11496,16 @@ MagicString$2.prototype.trimStart = function trimStart (charType) {
|
|
|
11477
11496
|
return this;
|
|
11478
11497
|
};
|
|
11479
11498
|
|
|
11499
|
+
/**
|
|
11500
|
+
* Parse CSS docstrings that Rindo supports, as documented here:
|
|
11501
|
+
* https://rindojs.web.app/docs/docs-json#css-variables
|
|
11502
|
+
*
|
|
11503
|
+
* Docstrings found in the supplied style text will be added to the
|
|
11504
|
+
* `styleDocs` param
|
|
11505
|
+
*
|
|
11506
|
+
* @param styleDocs the array to hold formatted CSS docstrings
|
|
11507
|
+
* @param styleText the CSS text we're working with
|
|
11508
|
+
*/
|
|
11480
11509
|
function parseStyleDocs(styleDocs, styleText) {
|
|
11481
11510
|
if (typeof styleText !== 'string') {
|
|
11482
11511
|
return;
|
|
@@ -11493,10 +11522,18 @@ function parseStyleDocs(styleDocs, styleText) {
|
|
|
11493
11522
|
styleText = styleText.substring(endIndex + CSS_DOC_END.length);
|
|
11494
11523
|
}
|
|
11495
11524
|
}
|
|
11525
|
+
/**
|
|
11526
|
+
* Parse a CSS comment string and insert it into the provided array of
|
|
11527
|
+
* style docstrings.
|
|
11528
|
+
*
|
|
11529
|
+
* @param styleDocs an array which will be modified with the docstring
|
|
11530
|
+
* @param comment the comment string
|
|
11531
|
+
*/
|
|
11496
11532
|
function parseCssComment(styleDocs, comment) {
|
|
11497
11533
|
/**
|
|
11498
11534
|
* @prop --max-width: Max width of the alert
|
|
11499
11535
|
*/
|
|
11536
|
+
// (the above is an example of what these comments might look like)
|
|
11500
11537
|
const lines = comment.split(/\r?\n/).map((line) => {
|
|
11501
11538
|
line = line.trim();
|
|
11502
11539
|
while (line.startsWith('*')) {
|
|
@@ -11524,11 +11561,19 @@ function parseCssComment(styleDocs, comment) {
|
|
|
11524
11561
|
styleDocs.push(cssDoc);
|
|
11525
11562
|
}
|
|
11526
11563
|
});
|
|
11527
|
-
return styleDocs;
|
|
11528
11564
|
}
|
|
11529
|
-
|
|
11530
|
-
|
|
11531
|
-
|
|
11565
|
+
/**
|
|
11566
|
+
* Opening syntax for a CSS docstring
|
|
11567
|
+
*/
|
|
11568
|
+
const CSS_DOC_START = '/**';
|
|
11569
|
+
/**
|
|
11570
|
+
* Closing syntax for a CSS docstring
|
|
11571
|
+
*/
|
|
11572
|
+
const CSS_DOC_END = '*/';
|
|
11573
|
+
/**
|
|
11574
|
+
* The `@prop` annotation we support within CSS docstrings
|
|
11575
|
+
*/
|
|
11576
|
+
const CSS_PROP_ANNOTATION = '@prop';
|
|
11532
11577
|
|
|
11533
11578
|
/**
|
|
11534
11579
|
* @license
|
|
@@ -12017,6 +12062,53 @@ const stripCssComments = (input) => {
|
|
|
12017
12062
|
return returnValue;
|
|
12018
12063
|
};
|
|
12019
12064
|
|
|
12065
|
+
/**
|
|
12066
|
+
* A regular expression for matching CSS import statements
|
|
12067
|
+
*
|
|
12068
|
+
* According to https://developer.mozilla.org/en-US/docs/Web/CSS/@import
|
|
12069
|
+
* the formal grammar for CSS import statements is:
|
|
12070
|
+
*
|
|
12071
|
+
* ```
|
|
12072
|
+
* @import [ <url> | <string> ]
|
|
12073
|
+
* [ supports( [ <supports-condition> | <declaration> ] ) ]?
|
|
12074
|
+
* <media-query-list>? ;
|
|
12075
|
+
* ```
|
|
12076
|
+
*
|
|
12077
|
+
* Thus the string literal `"@import"` will be followed by a `<url>` or a
|
|
12078
|
+
* `<string>`, where a `<url>` may be a relative or absolute URL _or_ a `url()`
|
|
12079
|
+
* function.
|
|
12080
|
+
*
|
|
12081
|
+
* Thus the regular expression needs to match:
|
|
12082
|
+
*
|
|
12083
|
+
* - the string `"@import
|
|
12084
|
+
* - any amount of whitespace
|
|
12085
|
+
* - a URL, comprised of:
|
|
12086
|
+
* - an optional `url(` function opener
|
|
12087
|
+
* - a non-greedy match on any characters (to match the argument to the URL
|
|
12088
|
+
* function)
|
|
12089
|
+
* - an optional `)` closing paren on the `url()` function
|
|
12090
|
+
* - trailing characters after the URL, given by anything which doesn't match
|
|
12091
|
+
* the line-terminator `;`
|
|
12092
|
+
* - this can match media queries, support conditions, and so on
|
|
12093
|
+
* - a line-terminating semicolon
|
|
12094
|
+
*
|
|
12095
|
+
* The regex has 4 capture groups:
|
|
12096
|
+
*
|
|
12097
|
+
* 1. `@import`
|
|
12098
|
+
* 2. `url(`
|
|
12099
|
+
* 3. characters after `url(`
|
|
12100
|
+
* 4. all characters other than `;`, greedily matching
|
|
12101
|
+
*
|
|
12102
|
+
* We typically only care about group 4 here.
|
|
12103
|
+
*/
|
|
12104
|
+
const CSS_IMPORT_RE = /(@import)\s+(url\()?\s?(.*?)\s?\)?([^;]*);?/gi;
|
|
12105
|
+
/**
|
|
12106
|
+
* Our main entry point to this module. This performs an async transformation
|
|
12107
|
+
* of CSS input to ESM.
|
|
12108
|
+
*
|
|
12109
|
+
* @param input CSS input to be transformed to ESM
|
|
12110
|
+
* @returns a promise wrapping transformed ESM output
|
|
12111
|
+
*/
|
|
12020
12112
|
const transformCssToEsm = async (input) => {
|
|
12021
12113
|
const results = transformCssToEsmModule(input);
|
|
12022
12114
|
const optimizeResults = await optimizeCss$1({
|
|
@@ -12033,10 +12125,22 @@ const transformCssToEsm = async (input) => {
|
|
|
12033
12125
|
results.styleText = optimizeResults.output;
|
|
12034
12126
|
return generateTransformCssToEsm(input, results);
|
|
12035
12127
|
};
|
|
12128
|
+
/**
|
|
12129
|
+
* A sync function for transforming input CSS to ESM
|
|
12130
|
+
*
|
|
12131
|
+
* @param input the input CSS we're going to transform
|
|
12132
|
+
* @returns transformed ESM output
|
|
12133
|
+
*/
|
|
12036
12134
|
const transformCssToEsmSync = (input) => {
|
|
12037
12135
|
const results = transformCssToEsmModule(input);
|
|
12038
12136
|
return generateTransformCssToEsm(input, results);
|
|
12039
12137
|
};
|
|
12138
|
+
/**
|
|
12139
|
+
* Performs the actual transformation from CSS to ESM
|
|
12140
|
+
*
|
|
12141
|
+
* @param input input CSS to be transformed
|
|
12142
|
+
* @returns ESM output
|
|
12143
|
+
*/
|
|
12040
12144
|
const transformCssToEsmModule = (input) => {
|
|
12041
12145
|
const results = {
|
|
12042
12146
|
styleText: input.input,
|
|
@@ -12081,6 +12185,14 @@ const transformCssToEsmModule = (input) => {
|
|
|
12081
12185
|
}
|
|
12082
12186
|
return results;
|
|
12083
12187
|
};
|
|
12188
|
+
/**
|
|
12189
|
+
* Updated the `output` property on `results` with appropriate import statements for
|
|
12190
|
+
* the CSS import tree and the module type.
|
|
12191
|
+
*
|
|
12192
|
+
* @param input the CSS to ESM transform input
|
|
12193
|
+
* @param results the corresponding output
|
|
12194
|
+
* @returns the modified ESM output
|
|
12195
|
+
*/
|
|
12084
12196
|
const generateTransformCssToEsm = (input, results) => {
|
|
12085
12197
|
const s = new MagicString$2('');
|
|
12086
12198
|
if (input.module === 'cjs') {
|
|
@@ -12110,6 +12222,15 @@ const generateTransformCssToEsm = (input, results) => {
|
|
|
12110
12222
|
results.output = s.toString();
|
|
12111
12223
|
return results;
|
|
12112
12224
|
};
|
|
12225
|
+
/**
|
|
12226
|
+
* Get all of the CSS imports in a file
|
|
12227
|
+
*
|
|
12228
|
+
* @param varNames a set into which new names will be added
|
|
12229
|
+
* @param cssText the CSS text in question
|
|
12230
|
+
* @param filePath the file path to the file in question
|
|
12231
|
+
* @param modeName the current mode name
|
|
12232
|
+
* @returns an array of import objects
|
|
12233
|
+
*/
|
|
12113
12234
|
const getCssToEsmImports = (varNames, cssText, filePath, modeName) => {
|
|
12114
12235
|
const cssImports = [];
|
|
12115
12236
|
if (!cssText.includes('@import')) {
|
|
@@ -12151,10 +12272,22 @@ const getCssToEsmImports = (varNames, cssText, filePath, modeName) => {
|
|
|
12151
12272
|
}
|
|
12152
12273
|
return cssImports;
|
|
12153
12274
|
};
|
|
12154
|
-
|
|
12275
|
+
/**
|
|
12276
|
+
* Check if a module URL is a css node module
|
|
12277
|
+
*
|
|
12278
|
+
* @param url to check
|
|
12279
|
+
* @returns whether or not it's a Css node module
|
|
12280
|
+
*/
|
|
12155
12281
|
const isCssNodeModule$1 = (url) => {
|
|
12156
12282
|
return url.startsWith('~');
|
|
12157
12283
|
};
|
|
12284
|
+
/**
|
|
12285
|
+
* Check if a given import is a local import or not (i.e. check that it
|
|
12286
|
+
* is not importing from some other domain)
|
|
12287
|
+
*
|
|
12288
|
+
* @param srcImport the import to check
|
|
12289
|
+
* @returns whether it's local or not
|
|
12290
|
+
*/
|
|
12158
12291
|
const isLocalCssImport$1 = (srcImport) => {
|
|
12159
12292
|
srcImport = srcImport.toLowerCase();
|
|
12160
12293
|
if (srcImport.includes('url(')) {
|
|
@@ -12167,6 +12300,13 @@ const isLocalCssImport$1 = (srcImport) => {
|
|
|
12167
12300
|
}
|
|
12168
12301
|
return true;
|
|
12169
12302
|
};
|
|
12303
|
+
/**
|
|
12304
|
+
* Given a file path and a mode name, create an appropriate variable name
|
|
12305
|
+
*
|
|
12306
|
+
* @param filePath the path we want to use
|
|
12307
|
+
* @param modeName the name for the current style mode (i.e. `md` or `ios` on Navify)
|
|
12308
|
+
* @returns an appropriate Css var name
|
|
12309
|
+
*/
|
|
12170
12310
|
const createCssVarName = (filePath, modeName) => {
|
|
12171
12311
|
let varName = path$5.basename(filePath);
|
|
12172
12312
|
if (modeName && modeName !== DEFAULT_STYLE_MODE && !varName.includes(modeName)) {
|
|
@@ -12188,7 +12328,7 @@ const createWorkerMessageHandler = (sys) => {
|
|
|
12188
12328
|
const fnArgs = msgToWorker.args.slice(1);
|
|
12189
12329
|
const fn = workerCtx[fnName];
|
|
12190
12330
|
if (typeof fn === 'function') {
|
|
12191
|
-
return fn
|
|
12331
|
+
return fn(...fnArgs);
|
|
12192
12332
|
}
|
|
12193
12333
|
};
|
|
12194
12334
|
};
|
|
@@ -14306,8 +14446,8 @@ function generateBuildStats(config, buildCtx) {
|
|
|
14306
14446
|
/**
|
|
14307
14447
|
* Writes the files from the stats config to the file system
|
|
14308
14448
|
* @param config the project build configuration
|
|
14309
|
-
* @param
|
|
14310
|
-
*
|
|
14449
|
+
* @param data the information to write out to disk (as specified by each stats output target specified in the provided
|
|
14450
|
+
* config)
|
|
14311
14451
|
*/
|
|
14312
14452
|
async function writeBuildStats(config, data) {
|
|
14313
14453
|
const statsTargets = config.outputTargets.filter(isOutputTargetStats);
|
|
@@ -16158,6 +16298,9 @@ class MockElement extends MockNode {
|
|
|
16158
16298
|
this.shadowRoot = shadowRoot;
|
|
16159
16299
|
return shadowRoot;
|
|
16160
16300
|
}
|
|
16301
|
+
blur() {
|
|
16302
|
+
/**/
|
|
16303
|
+
}
|
|
16161
16304
|
get shadowRoot() {
|
|
16162
16305
|
return this.__shadowRoot || null;
|
|
16163
16306
|
}
|
|
@@ -16226,6 +16369,7 @@ class MockElement extends MockNode {
|
|
|
16226
16369
|
get firstElementChild() {
|
|
16227
16370
|
return this.children[0] || null;
|
|
16228
16371
|
}
|
|
16372
|
+
focus(_options) { }
|
|
16229
16373
|
getAttribute(attrName) {
|
|
16230
16374
|
if (attrName === 'style') {
|
|
16231
16375
|
if (this.__style != null && this.__style.length > 0) {
|
|
@@ -17129,7 +17273,28 @@ function createElementNS(ownerDocument, namespaceURI, tagName) {
|
|
|
17129
17273
|
return createElement(ownerDocument, tagName);
|
|
17130
17274
|
}
|
|
17131
17275
|
else if (namespaceURI === 'http://www.w3.org/2000/svg') {
|
|
17132
|
-
|
|
17276
|
+
switch (tagName.toLowerCase()) {
|
|
17277
|
+
case 'text':
|
|
17278
|
+
case 'tspan':
|
|
17279
|
+
case 'tref':
|
|
17280
|
+
case 'altglyph':
|
|
17281
|
+
case 'textpath':
|
|
17282
|
+
return new MockSVGTextContentElement(ownerDocument, tagName);
|
|
17283
|
+
case 'circle':
|
|
17284
|
+
case 'ellipse':
|
|
17285
|
+
case 'image':
|
|
17286
|
+
case 'line':
|
|
17287
|
+
case 'path':
|
|
17288
|
+
case 'polygon':
|
|
17289
|
+
case 'polyline':
|
|
17290
|
+
case 'rect':
|
|
17291
|
+
case 'use':
|
|
17292
|
+
return new MockSVGGraphicsElement(ownerDocument, tagName);
|
|
17293
|
+
case 'svg':
|
|
17294
|
+
return new MockSVGSVGElement(ownerDocument, tagName);
|
|
17295
|
+
default:
|
|
17296
|
+
return new MockSVGElement(ownerDocument, tagName);
|
|
17297
|
+
}
|
|
17133
17298
|
}
|
|
17134
17299
|
else {
|
|
17135
17300
|
return new MockElement(ownerDocument, tagName);
|
|
@@ -17276,6 +17441,98 @@ class MockScriptElement extends MockHTMLElement {
|
|
|
17276
17441
|
patchPropAttributes(MockScriptElement.prototype, {
|
|
17277
17442
|
type: String,
|
|
17278
17443
|
});
|
|
17444
|
+
class MockDOMMatrix {
|
|
17445
|
+
constructor() {
|
|
17446
|
+
this.a = 1;
|
|
17447
|
+
this.b = 0;
|
|
17448
|
+
this.c = 0;
|
|
17449
|
+
this.d = 1;
|
|
17450
|
+
this.e = 0;
|
|
17451
|
+
this.f = 0;
|
|
17452
|
+
this.m11 = 1;
|
|
17453
|
+
this.m12 = 0;
|
|
17454
|
+
this.m13 = 0;
|
|
17455
|
+
this.m14 = 0;
|
|
17456
|
+
this.m21 = 0;
|
|
17457
|
+
this.m22 = 1;
|
|
17458
|
+
this.m23 = 0;
|
|
17459
|
+
this.m24 = 0;
|
|
17460
|
+
this.m31 = 0;
|
|
17461
|
+
this.m32 = 0;
|
|
17462
|
+
this.m33 = 1;
|
|
17463
|
+
this.m34 = 0;
|
|
17464
|
+
this.m41 = 0;
|
|
17465
|
+
this.m42 = 0;
|
|
17466
|
+
this.m43 = 0;
|
|
17467
|
+
this.m44 = 1;
|
|
17468
|
+
this.is2D = true;
|
|
17469
|
+
this.isIdentity = true;
|
|
17470
|
+
}
|
|
17471
|
+
static fromMatrix() {
|
|
17472
|
+
return new MockDOMMatrix();
|
|
17473
|
+
}
|
|
17474
|
+
inverse() {
|
|
17475
|
+
return new MockDOMMatrix();
|
|
17476
|
+
}
|
|
17477
|
+
flipX() {
|
|
17478
|
+
return new MockDOMMatrix();
|
|
17479
|
+
}
|
|
17480
|
+
flipY() {
|
|
17481
|
+
return new MockDOMMatrix();
|
|
17482
|
+
}
|
|
17483
|
+
multiply() {
|
|
17484
|
+
return new MockDOMMatrix();
|
|
17485
|
+
}
|
|
17486
|
+
rotate() {
|
|
17487
|
+
return new MockDOMMatrix();
|
|
17488
|
+
}
|
|
17489
|
+
rotateAxisAngle() {
|
|
17490
|
+
return new MockDOMMatrix();
|
|
17491
|
+
}
|
|
17492
|
+
rotateFromVector() {
|
|
17493
|
+
return new MockDOMMatrix();
|
|
17494
|
+
}
|
|
17495
|
+
scale() {
|
|
17496
|
+
return new MockDOMMatrix();
|
|
17497
|
+
}
|
|
17498
|
+
scaleNonUniform() {
|
|
17499
|
+
return new MockDOMMatrix();
|
|
17500
|
+
}
|
|
17501
|
+
skewX() {
|
|
17502
|
+
return new MockDOMMatrix();
|
|
17503
|
+
}
|
|
17504
|
+
skewY() {
|
|
17505
|
+
return new MockDOMMatrix();
|
|
17506
|
+
}
|
|
17507
|
+
toJSON() { }
|
|
17508
|
+
toString() { }
|
|
17509
|
+
transformPoint() {
|
|
17510
|
+
return new MockDOMPoint();
|
|
17511
|
+
}
|
|
17512
|
+
translate() {
|
|
17513
|
+
return new MockDOMMatrix();
|
|
17514
|
+
}
|
|
17515
|
+
}
|
|
17516
|
+
class MockDOMPoint {
|
|
17517
|
+
constructor() {
|
|
17518
|
+
this.w = 1;
|
|
17519
|
+
this.x = 0;
|
|
17520
|
+
this.y = 0;
|
|
17521
|
+
this.z = 0;
|
|
17522
|
+
}
|
|
17523
|
+
toJSON() { }
|
|
17524
|
+
matrixTransform() {
|
|
17525
|
+
return new MockDOMMatrix();
|
|
17526
|
+
}
|
|
17527
|
+
}
|
|
17528
|
+
class MockSVGRect {
|
|
17529
|
+
constructor() {
|
|
17530
|
+
this.height = 10;
|
|
17531
|
+
this.width = 10;
|
|
17532
|
+
this.x = 0;
|
|
17533
|
+
this.y = 0;
|
|
17534
|
+
}
|
|
17535
|
+
}
|
|
17279
17536
|
class MockStyleElement extends MockHTMLElement {
|
|
17280
17537
|
constructor(ownerDocument) {
|
|
17281
17538
|
super(ownerDocument, 'style');
|
|
@@ -17308,9 +17565,6 @@ class MockSVGElement extends MockElement {
|
|
|
17308
17565
|
get viewportElement() {
|
|
17309
17566
|
return null;
|
|
17310
17567
|
}
|
|
17311
|
-
focus() {
|
|
17312
|
-
/**/
|
|
17313
|
-
}
|
|
17314
17568
|
onunload() {
|
|
17315
17569
|
/**/
|
|
17316
17570
|
}
|
|
@@ -17328,6 +17582,27 @@ class MockSVGElement extends MockElement {
|
|
|
17328
17582
|
return 0;
|
|
17329
17583
|
}
|
|
17330
17584
|
}
|
|
17585
|
+
class MockSVGGraphicsElement extends MockSVGElement {
|
|
17586
|
+
getBBox(_options) {
|
|
17587
|
+
return new MockSVGRect();
|
|
17588
|
+
}
|
|
17589
|
+
getCTM() {
|
|
17590
|
+
return new MockDOMMatrix();
|
|
17591
|
+
}
|
|
17592
|
+
getScreenCTM() {
|
|
17593
|
+
return new MockDOMMatrix();
|
|
17594
|
+
}
|
|
17595
|
+
}
|
|
17596
|
+
class MockSVGSVGElement extends MockSVGGraphicsElement {
|
|
17597
|
+
createSVGPoint() {
|
|
17598
|
+
return new MockDOMPoint();
|
|
17599
|
+
}
|
|
17600
|
+
}
|
|
17601
|
+
class MockSVGTextContentElement extends MockSVGGraphicsElement {
|
|
17602
|
+
getComputedTextLength() {
|
|
17603
|
+
return 0;
|
|
17604
|
+
}
|
|
17605
|
+
}
|
|
17331
17606
|
class MockBaseElement extends MockHTMLElement {
|
|
17332
17607
|
constructor(ownerDocument) {
|
|
17333
17608
|
super(ownerDocument, 'base');
|
|
@@ -41548,6 +41823,7 @@ const createComponentExport = (cmp) => {
|
|
|
41548
41823
|
* using the `dist-custom-elements` output target may have a single 'entry point' for each file containing a component.
|
|
41549
41824
|
* Each of those files will be independently resolved and loaded by this plugin for further processing by Rollup later
|
|
41550
41825
|
* in the bundling process.
|
|
41826
|
+
*
|
|
41551
41827
|
* @param entries the Rindo project files to process. It should be noted that the keys in this object may not
|
|
41552
41828
|
* necessarily be an absolute or relative path to a file, but may be a Rollup Virtual Module (which begin with \0).
|
|
41553
41829
|
* @returns the rollup plugin that loads and process a Rindo project's entry points
|
|
@@ -41716,9 +41992,9 @@ const fetchUrlSync = (url) => {
|
|
|
41716
41992
|
return undefined;
|
|
41717
41993
|
};
|
|
41718
41994
|
|
|
41719
|
-
const patchTsSystemFileSystem = (config,
|
|
41995
|
+
const patchTsSystemFileSystem = (config, compilerSys, inMemoryFs, tsSys) => {
|
|
41720
41996
|
const realpath = (path) => {
|
|
41721
|
-
const rp =
|
|
41997
|
+
const rp = compilerSys.realpathSync(path);
|
|
41722
41998
|
if (isString$1(rp)) {
|
|
41723
41999
|
return rp;
|
|
41724
42000
|
}
|
|
@@ -41726,7 +42002,7 @@ const patchTsSystemFileSystem = (config, rindoSys, inMemoryFs, tsSys) => {
|
|
|
41726
42002
|
};
|
|
41727
42003
|
const getAccessibleFileSystemEntries = (path) => {
|
|
41728
42004
|
try {
|
|
41729
|
-
const entries =
|
|
42005
|
+
const entries = compilerSys.readDirSync(path || '.').sort();
|
|
41730
42006
|
const files = [];
|
|
41731
42007
|
const directories = [];
|
|
41732
42008
|
for (const absPath of entries) {
|
|
@@ -41751,13 +42027,13 @@ const patchTsSystemFileSystem = (config, rindoSys, inMemoryFs, tsSys) => {
|
|
|
41751
42027
|
}
|
|
41752
42028
|
};
|
|
41753
42029
|
tsSys.createDirectory = (p) => {
|
|
41754
|
-
|
|
42030
|
+
compilerSys.createDirSync(p, { recursive: true });
|
|
41755
42031
|
};
|
|
41756
42032
|
tsSys.directoryExists = (p) => {
|
|
41757
42033
|
const s = inMemoryFs.statSync(p);
|
|
41758
42034
|
return s.isDirectory;
|
|
41759
42035
|
};
|
|
41760
|
-
tsSys.exit =
|
|
42036
|
+
tsSys.exit = compilerSys.exit;
|
|
41761
42037
|
tsSys.fileExists = (p) => {
|
|
41762
42038
|
let filePath = p;
|
|
41763
42039
|
if (isRemoteUrl(p)) {
|
|
@@ -41766,17 +42042,17 @@ const patchTsSystemFileSystem = (config, rindoSys, inMemoryFs, tsSys) => {
|
|
|
41766
42042
|
const s = inMemoryFs.statSync(filePath);
|
|
41767
42043
|
return !!(s && s.isFile);
|
|
41768
42044
|
};
|
|
41769
|
-
tsSys.getCurrentDirectory =
|
|
41770
|
-
tsSys.getExecutingFilePath =
|
|
42045
|
+
tsSys.getCurrentDirectory = compilerSys.getCurrentDirectory;
|
|
42046
|
+
tsSys.getExecutingFilePath = compilerSys.getCompilerExecutingPath;
|
|
41771
42047
|
tsSys.getDirectories = (p) => {
|
|
41772
|
-
const items =
|
|
42048
|
+
const items = compilerSys.readDirSync(p);
|
|
41773
42049
|
return items.filter((itemPath) => {
|
|
41774
42050
|
const s = inMemoryFs.statSync(itemPath);
|
|
41775
42051
|
return !!(s && s.exists && s.isDirectory);
|
|
41776
42052
|
});
|
|
41777
42053
|
};
|
|
41778
42054
|
tsSys.readDirectory = (path, extensions, exclude, include, depth) => {
|
|
41779
|
-
const cwd =
|
|
42055
|
+
const cwd = compilerSys.getCurrentDirectory();
|
|
41780
42056
|
// TODO: Replace `matchFiles` with a function that is publicly exposed
|
|
41781
42057
|
return t.matchFiles(path, extensions, exclude, include, IS_CASE_SENSITIVE_FILE_NAMES, cwd, depth, getAccessibleFileSystemEntries, realpath);
|
|
41782
42058
|
};
|
|
@@ -41803,9 +42079,9 @@ const patchTsSystemFileSystem = (config, rindoSys, inMemoryFs, tsSys) => {
|
|
|
41803
42079
|
tsSys.writeFile = (p, data) => inMemoryFs.writeFile(p, data);
|
|
41804
42080
|
return tsSys;
|
|
41805
42081
|
};
|
|
41806
|
-
const patchTsSystemWatch = (
|
|
42082
|
+
const patchTsSystemWatch = (compilerSystem, tsSys) => {
|
|
41807
42083
|
tsSys.watchDirectory = (p, cb, recursive) => {
|
|
41808
|
-
const watcher =
|
|
42084
|
+
const watcher = compilerSystem.watchDirectory(p, (filePath) => {
|
|
41809
42085
|
cb(filePath);
|
|
41810
42086
|
}, recursive);
|
|
41811
42087
|
return {
|
|
@@ -41815,7 +42091,7 @@ const patchTsSystemWatch = (rindoSys, tsSys) => {
|
|
|
41815
42091
|
};
|
|
41816
42092
|
};
|
|
41817
42093
|
tsSys.watchFile = (p, cb) => {
|
|
41818
|
-
const watcher =
|
|
42094
|
+
const watcher = compilerSystem.watchFile(p, (filePath, eventKind) => {
|
|
41819
42095
|
if (eventKind === 'fileAdd') {
|
|
41820
42096
|
cb(filePath, t.FileWatcherEventKind.Created);
|
|
41821
42097
|
}
|
|
@@ -55956,6 +56232,7 @@ const addDefineCustomElementFunction = (tagNames, newStatements, caseStatements)
|
|
|
55956
56232
|
* ```typescript
|
|
55957
56233
|
* defineCustomElement(MyPrincipalComponent);
|
|
55958
56234
|
* ```
|
|
56235
|
+
* @param componentName the component's class name to use as the first argument to `defineCustomElement`
|
|
55959
56236
|
* @returns the expression statement described above
|
|
55960
56237
|
*/
|
|
55961
56238
|
function createAutoDefinitionExpression(componentName) {
|
|
@@ -56065,6 +56342,9 @@ const updateRindoCoreImports = (updatedCoreImportPath) => {
|
|
|
56065
56342
|
};
|
|
56066
56343
|
};
|
|
56067
56344
|
};
|
|
56345
|
+
/**
|
|
56346
|
+
* A set of imports which we don't want to remove from an output file
|
|
56347
|
+
*/
|
|
56068
56348
|
const KEEP_IMPORTS = new Set([
|
|
56069
56349
|
'h',
|
|
56070
56350
|
'setMode',
|
|
@@ -56084,37 +56364,75 @@ const KEEP_IMPORTS = new Set([
|
|
|
56084
56364
|
'setErrorHandler',
|
|
56085
56365
|
]);
|
|
56086
56366
|
|
|
56367
|
+
/**
|
|
56368
|
+
* Main output target function for `dist-custom-elements`. This function just
|
|
56369
|
+
* does some organizational work to call the other functions in this module,
|
|
56370
|
+
* which do actual work of generating the rollup configuration, creating an
|
|
56371
|
+
* entry chunk, running, the build, etc.
|
|
56372
|
+
*
|
|
56373
|
+
* @param config the user-supplied compiler configuration we're using
|
|
56374
|
+
* @param compilerCtx the current compiler context
|
|
56375
|
+
* @param buildCtx the current build context
|
|
56376
|
+
* @returns an empty Promise which won't resolve until the work is done!
|
|
56377
|
+
*/
|
|
56087
56378
|
const outputCustomElements = async (config, compilerCtx, buildCtx) => {
|
|
56379
|
+
var _a;
|
|
56088
56380
|
if (!config.buildDist) {
|
|
56089
56381
|
return;
|
|
56090
56382
|
}
|
|
56091
|
-
const outputTargets = config.outputTargets.filter(isOutputTargetDistCustomElements);
|
|
56383
|
+
const outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).filter(isOutputTargetDistCustomElements);
|
|
56092
56384
|
if (outputTargets.length === 0) {
|
|
56093
56385
|
return;
|
|
56094
56386
|
}
|
|
56095
56387
|
const bundlingEventMessage = 'generate custom elements';
|
|
56096
56388
|
const timespan = buildCtx.createTimeSpan(`${bundlingEventMessage} started`);
|
|
56097
|
-
await Promise.all(outputTargets.map((
|
|
56389
|
+
await Promise.all(outputTargets.map((target) => bundleCustomElements$1(config, compilerCtx, buildCtx, target)));
|
|
56098
56390
|
timespan.finish(`${bundlingEventMessage} finished`);
|
|
56099
56391
|
};
|
|
56392
|
+
/**
|
|
56393
|
+
* Get bundle options for our current build and compiler context which we'll use
|
|
56394
|
+
* to generate a Rollup build and so on.
|
|
56395
|
+
*
|
|
56396
|
+
* @param config user-supplied Rindo configuration
|
|
56397
|
+
* @param buildCtx the current build context
|
|
56398
|
+
* @param compilerCtx the current compiler context
|
|
56399
|
+
* @param outputTarget the outputTarget we're currently dealing with
|
|
56400
|
+
* @returns bundle options suitable for generating a rollup configuration
|
|
56401
|
+
*/
|
|
56402
|
+
const getBundleOptions = (config, buildCtx, compilerCtx, outputTarget) => ({
|
|
56403
|
+
id: 'customElements',
|
|
56404
|
+
platform: 'client',
|
|
56405
|
+
conditionals: getCustomElementsBuildConditionals(config, buildCtx.components),
|
|
56406
|
+
customTransformers: getCustomElementCustomTransformer(config, compilerCtx, buildCtx.components, outputTarget),
|
|
56407
|
+
externalRuntime: !!outputTarget.externalRuntime,
|
|
56408
|
+
inlineWorkers: true,
|
|
56409
|
+
inputs: {
|
|
56410
|
+
// Here we prefix our index chunk with '\0' to tell Rollup that we're
|
|
56411
|
+
// going to be using virtual modules with this module. A leading '\0'
|
|
56412
|
+
// prevents other plugins from messing with the module. We generate a
|
|
56413
|
+
// string for the index chunk below in the `loader` property.
|
|
56414
|
+
//
|
|
56415
|
+
// @see {@link https://rollupjs.org/guide/en/#conventions} for more info.
|
|
56416
|
+
index: '\0core',
|
|
56417
|
+
},
|
|
56418
|
+
loader: {
|
|
56419
|
+
'\0core': generateEntryPoint$1(outputTarget),
|
|
56420
|
+
},
|
|
56421
|
+
inlineDynamicImports: outputTarget.inlineDynamicImports,
|
|
56422
|
+
preserveEntrySignatures: 'allow-extension',
|
|
56423
|
+
});
|
|
56424
|
+
/**
|
|
56425
|
+
* Get bundle options for rollup, run the rollup build, optionally minify the
|
|
56426
|
+
* output, and write files to disk.
|
|
56427
|
+
* @param config user-supplied Rindo configuration
|
|
56428
|
+
* @param buildCtx the current build context
|
|
56429
|
+
* @param compilerCtx the current compiler context
|
|
56430
|
+
* @param outputTarget the outputTarget we're currently dealing with
|
|
56431
|
+
* @returns an empty promise
|
|
56432
|
+
*/
|
|
56100
56433
|
const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarget) => {
|
|
56101
56434
|
try {
|
|
56102
|
-
const bundleOpts =
|
|
56103
|
-
id: 'customElements',
|
|
56104
|
-
platform: 'client',
|
|
56105
|
-
conditionals: getCustomElementsBuildConditionals(config, buildCtx.components),
|
|
56106
|
-
customTransformers: getCustomElementCustomTransformer(config, compilerCtx, buildCtx.components, outputTarget),
|
|
56107
|
-
externalRuntime: !!outputTarget.externalRuntime,
|
|
56108
|
-
inlineWorkers: true,
|
|
56109
|
-
inputs: {
|
|
56110
|
-
index: '\0core',
|
|
56111
|
-
},
|
|
56112
|
-
loader: {
|
|
56113
|
-
'\0core': generateEntryPoint$1(outputTarget),
|
|
56114
|
-
},
|
|
56115
|
-
inlineDynamicImports: outputTarget.inlineDynamicImports,
|
|
56116
|
-
preserveEntrySignatures: 'allow-extension',
|
|
56117
|
-
};
|
|
56435
|
+
const bundleOpts = getBundleOptions(config, buildCtx, compilerCtx, outputTarget);
|
|
56118
56436
|
addCustomElementInputs(buildCtx, bundleOpts);
|
|
56119
56437
|
const build = await bundleOutput(config, compilerCtx, buildCtx, bundleOpts);
|
|
56120
56438
|
if (build) {
|
|
@@ -56127,6 +56445,18 @@ const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarge
|
|
|
56127
56445
|
hoistTransitiveImports: false,
|
|
56128
56446
|
preferConst: true,
|
|
56129
56447
|
});
|
|
56448
|
+
// the output target should have been validated at this point - as a result, we expect this field
|
|
56449
|
+
// to have been backfilled if it wasn't provided
|
|
56450
|
+
const outputTargetDir = outputTarget.dir;
|
|
56451
|
+
// besides, if it isn't here we do a diagnostic and an early return
|
|
56452
|
+
if (!isString$1(outputTargetDir)) {
|
|
56453
|
+
buildCtx.diagnostics.push({
|
|
56454
|
+
level: 'error',
|
|
56455
|
+
type: 'build',
|
|
56456
|
+
messageText: 'dist-custom-elements output target provided with no output target directory!',
|
|
56457
|
+
});
|
|
56458
|
+
return;
|
|
56459
|
+
}
|
|
56130
56460
|
const minify = outputTarget.externalRuntime || outputTarget.minify !== true ? false : config.minifyJs;
|
|
56131
56461
|
const files = rollupOutput.output.map(async (bundle) => {
|
|
56132
56462
|
if (bundle.type === 'chunk') {
|
|
@@ -56141,15 +56471,15 @@ const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarge
|
|
|
56141
56471
|
buildCtx.diagnostics.push(...optimizeResults.diagnostics);
|
|
56142
56472
|
if (!hasError(optimizeResults.diagnostics) && typeof optimizeResults.output === 'string') {
|
|
56143
56473
|
code = optimizeResults.output;
|
|
56144
|
-
sourceMap = optimizeResults.sourceMap;
|
|
56145
56474
|
}
|
|
56146
|
-
if (sourceMap) {
|
|
56475
|
+
if (optimizeResults.sourceMap) {
|
|
56476
|
+
sourceMap = optimizeResults.sourceMap;
|
|
56147
56477
|
code = code + getSourceMappingUrlForEndOfFile(bundle.fileName);
|
|
56148
|
-
await compilerCtx.fs.writeFile(join(
|
|
56478
|
+
await compilerCtx.fs.writeFile(join(outputTargetDir, bundle.fileName + '.map'), JSON.stringify(sourceMap), {
|
|
56149
56479
|
outputTargetType: outputTarget.type,
|
|
56150
56480
|
});
|
|
56151
56481
|
}
|
|
56152
|
-
await compilerCtx.fs.writeFile(join(
|
|
56482
|
+
await compilerCtx.fs.writeFile(join(outputTargetDir, bundle.fileName), code, {
|
|
56153
56483
|
outputTargetType: outputTarget.type,
|
|
56154
56484
|
});
|
|
56155
56485
|
}
|
|
@@ -56168,6 +56498,8 @@ const bundleCustomElements$1 = async (config, compilerCtx, buildCtx, outputTarge
|
|
|
56168
56498
|
*/
|
|
56169
56499
|
const addCustomElementInputs = (buildCtx, bundleOpts) => {
|
|
56170
56500
|
const components = buildCtx.components;
|
|
56501
|
+
// an array to store the imports of these modules that we're going to add to our entry chunk
|
|
56502
|
+
const indexImports = [];
|
|
56171
56503
|
components.forEach((cmp) => {
|
|
56172
56504
|
const exp = [];
|
|
56173
56505
|
const exportName = dashToPascalCase$1(cmp.tagName);
|
|
@@ -56176,16 +56508,25 @@ const addCustomElementInputs = (buildCtx, bundleOpts) => {
|
|
|
56176
56508
|
const coreKey = `\0${exportName}`;
|
|
56177
56509
|
if (cmp.isPlain) {
|
|
56178
56510
|
exp.push(`export { ${importName} as ${exportName} } from '${cmp.sourceFilePath}';`);
|
|
56511
|
+
indexImports.push(`export { {${exportName} } from '${coreKey}';`);
|
|
56179
56512
|
}
|
|
56180
56513
|
else {
|
|
56181
56514
|
// the `importName` may collide with the `exportName`, alias it just in case it does with `importAs`
|
|
56182
56515
|
exp.push(`import { ${importName} as ${importAs}, defineCustomElement as cmpDefCustomEle } from '${cmp.sourceFilePath}';`);
|
|
56183
56516
|
exp.push(`export const ${exportName} = ${importAs};`);
|
|
56184
56517
|
exp.push(`export const defineCustomElement = cmpDefCustomEle;`);
|
|
56518
|
+
// Here we push an export (with a rename for `defineCustomElement` for
|
|
56519
|
+
// this component onto our array which references the `coreKey` (prefixed
|
|
56520
|
+
// with `\0`). We have to do this so that our import is referencing the
|
|
56521
|
+
// correct virtual module, if we instead referenced, for instance,
|
|
56522
|
+
// `cmp.sourceFilePath`, we would end up with duplicated modules in our
|
|
56523
|
+
// output.
|
|
56524
|
+
indexImports.push(`export { ${exportName}, defineCustomElement as defineCustomElement${exportName} } from '${coreKey}';`);
|
|
56185
56525
|
}
|
|
56186
56526
|
bundleOpts.inputs[cmp.tagName] = coreKey;
|
|
56187
56527
|
bundleOpts.loader[coreKey] = exp.join('\n');
|
|
56188
56528
|
});
|
|
56529
|
+
bundleOpts.loader['\0core'] += indexImports.join('\n');
|
|
56189
56530
|
};
|
|
56190
56531
|
/**
|
|
56191
56532
|
* Generate the entrypoint (`index.ts` file) contents for the `dist-custom-elements` output target
|
|
@@ -56203,6 +56544,7 @@ const generateEntryPoint$1 = (outputTarget) => {
|
|
|
56203
56544
|
/**
|
|
56204
56545
|
* Get the series of custom transformers that will be applied to a Rindo project's source code during the TypeScript
|
|
56205
56546
|
* transpilation process
|
|
56547
|
+
*
|
|
56206
56548
|
* @param config the configuration for the Rindo project
|
|
56207
56549
|
* @param compilerCtx the current compiler context
|
|
56208
56550
|
* @param components the components that will be compiled as a part of the current build
|
|
@@ -57331,9 +57673,15 @@ const addLazyElementGetter = (classMembers, moduleFile, cmp) => {
|
|
|
57331
57673
|
|
|
57332
57674
|
/**
|
|
57333
57675
|
* Adds static "style" getter within the class
|
|
57676
|
+
* ```typescript
|
|
57334
57677
|
* const MyComponent = class {
|
|
57335
57678
|
* static get style() { return "styles"; }
|
|
57336
57679
|
* }
|
|
57680
|
+
* ```
|
|
57681
|
+
* @param classMembers a class to existing members of a class. **this parameter will be mutated** rather than returning
|
|
57682
|
+
* a cloned version
|
|
57683
|
+
* @param cmp the metadata associated with the component being evaluated
|
|
57684
|
+
* @param commentOriginalSelector if `true`, add a comment with the original CSS selector to the style.
|
|
57337
57685
|
*/
|
|
57338
57686
|
const addStaticStyleGetterWithinClass = (classMembers, cmp, commentOriginalSelector) => {
|
|
57339
57687
|
const styleLiteral = getStyleLiteral(cmp, commentOriginalSelector);
|
|
@@ -57343,11 +57691,15 @@ const addStaticStyleGetterWithinClass = (classMembers, cmp, commentOriginalSelec
|
|
|
57343
57691
|
};
|
|
57344
57692
|
/**
|
|
57345
57693
|
* Adds static "style" property to the class variable.
|
|
57694
|
+
* ```typescript
|
|
57346
57695
|
* const MyComponent = class {}
|
|
57347
57696
|
* MyComponent.style = "styles";
|
|
57697
|
+
* ```
|
|
57698
|
+
* @param styleStatements a list of statements containing style assignments to a class
|
|
57699
|
+
* @param cmp the metadata associated with the component being evaluated
|
|
57348
57700
|
*/
|
|
57349
|
-
const addStaticStylePropertyToClass = (styleStatements, cmp
|
|
57350
|
-
const styleLiteral = getStyleLiteral(cmp,
|
|
57701
|
+
const addStaticStylePropertyToClass = (styleStatements, cmp) => {
|
|
57702
|
+
const styleLiteral = getStyleLiteral(cmp, false);
|
|
57351
57703
|
if (styleLiteral) {
|
|
57352
57704
|
const statement = t.createStatement(t.createAssignment(t.createPropertyAccess(t.createIdentifier(cmp.componentClassName), 'style'), styleLiteral));
|
|
57353
57705
|
styleStatements.push(statement);
|
|
@@ -57949,7 +58301,7 @@ const updateLazyComponentMembers = (transformOpts, styleStatements, classNode, m
|
|
|
57949
58301
|
addWatchers(classMembers, cmp);
|
|
57950
58302
|
transformHostData(classMembers, moduleFile);
|
|
57951
58303
|
if (transformOpts.style === 'static') {
|
|
57952
|
-
addStaticStylePropertyToClass(styleStatements, cmp
|
|
58304
|
+
addStaticStylePropertyToClass(styleStatements, cmp);
|
|
57953
58305
|
}
|
|
57954
58306
|
return classMembers;
|
|
57955
58307
|
};
|
|
@@ -60184,29 +60536,38 @@ const relDts$1 = (fromPath, dtsPath) => {
|
|
|
60184
60536
|
* @param config the Rindo configuration associated with the project being compiled
|
|
60185
60537
|
* @param compilerCtx the current compiler context
|
|
60186
60538
|
* @param buildCtx the context associated with the current build
|
|
60187
|
-
* @param
|
|
60188
|
-
* This path is not necessarily the `components.d.ts` file that is found in the root of a project's `src` directory.
|
|
60539
|
+
* @param typesDir the path to the directory where type declarations are saved
|
|
60189
60540
|
*/
|
|
60190
|
-
const generateCustomElementsTypes = async (config, compilerCtx, buildCtx,
|
|
60191
|
-
|
|
60192
|
-
|
|
60541
|
+
const generateCustomElementsTypes = async (config, compilerCtx, buildCtx, typesDir) => {
|
|
60542
|
+
var _a;
|
|
60543
|
+
const outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).filter(isOutputTargetDistCustomElements);
|
|
60544
|
+
await Promise.all(outputTargets.map((outputTarget) => generateCustomElementsTypesOutput(config, compilerCtx, buildCtx, typesDir, outputTarget)));
|
|
60193
60545
|
};
|
|
60194
60546
|
/**
|
|
60195
60547
|
* Generates types for a single `dist-custom-elements` output target definition in a Rindo project's configuration
|
|
60548
|
+
*
|
|
60196
60549
|
* @param config the Rindo configuration associated with the project being compiled
|
|
60197
60550
|
* @param compilerCtx the current compiler context
|
|
60198
60551
|
* @param buildCtx the context associated with the current build
|
|
60199
|
-
* @param
|
|
60200
|
-
* This path is not necessarily the `components.d.ts` file that is found in the root of a project's `src` directory.
|
|
60552
|
+
* @param typesDir path to the directory where type declarations are saved
|
|
60201
60553
|
* @param outputTarget the output target for which types are being currently generated
|
|
60202
60554
|
*/
|
|
60203
|
-
const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx,
|
|
60555
|
+
const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx, typesDir, outputTarget) => {
|
|
60556
|
+
// the path where we're going to write the typedef for the whole dist-custom-elements output
|
|
60204
60557
|
const customElementsDtsPath = join(outputTarget.dir, 'index.d.ts');
|
|
60205
|
-
|
|
60558
|
+
// the directory where types for the individual components are written
|
|
60559
|
+
const componentsTypeDirectoryPath = relative$1(outputTarget.dir, join(typesDir, 'components'));
|
|
60560
|
+
const components = buildCtx.components.filter((m) => !m.isCollectionDependency);
|
|
60206
60561
|
const code = [
|
|
60207
60562
|
`/* ${config.namespace} custom elements */`,
|
|
60208
|
-
|
|
60209
|
-
|
|
60563
|
+
...components.map((component) => {
|
|
60564
|
+
const exportName = dashToPascalCase$1(component.tagName);
|
|
60565
|
+
const importName = component.componentClassName;
|
|
60566
|
+
// typedefs for individual components can be found under paths like
|
|
60567
|
+
// $TYPES_DIR/components/my-component/my-component.d.ts
|
|
60568
|
+
const componentDTSPath = join(componentsTypeDirectoryPath, component.tagName, component.tagName);
|
|
60569
|
+
return `export { ${importName} as ${exportName} } from '${componentDTSPath}';`;
|
|
60570
|
+
}),
|
|
60210
60571
|
``,
|
|
60211
60572
|
`/**`,
|
|
60212
60573
|
` * Used to manually set the base path where assets can be found.`,
|
|
@@ -60226,10 +60587,8 @@ const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx,
|
|
|
60226
60587
|
` rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;`,
|
|
60227
60588
|
`}`,
|
|
60228
60589
|
`export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;`,
|
|
60229
|
-
``,
|
|
60230
|
-
`export type { Components, JSX };`,
|
|
60231
|
-
``,
|
|
60232
60590
|
];
|
|
60591
|
+
const componentsDtsRelPath = relDts(outputTarget.dir, join(typesDir, 'components.d.ts'));
|
|
60233
60592
|
const usersIndexJsPath = join(config.srcDir, 'index.ts');
|
|
60234
60593
|
const hasUserIndex = await compilerCtx.fs.access(usersIndexJsPath);
|
|
60235
60594
|
if (hasUserIndex) {
|
|
@@ -60242,7 +60601,6 @@ const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx,
|
|
|
60242
60601
|
await compilerCtx.fs.writeFile(customElementsDtsPath, code.join('\n') + `\n`, {
|
|
60243
60602
|
outputTargetType: outputTarget.type,
|
|
60244
60603
|
});
|
|
60245
|
-
const components = buildCtx.components.filter((m) => !m.isCollectionDependency);
|
|
60246
60604
|
await Promise.all(components.map(async (cmp) => {
|
|
60247
60605
|
const dtsCode = generateCustomElementType(componentsDtsRelPath, cmp);
|
|
60248
60606
|
const fileName = `${cmp.tagName}.d.ts`;
|
|
@@ -60316,20 +60674,21 @@ const generateTypesOutput = async (config, compilerCtx, buildCtx, outputTarget)
|
|
|
60316
60674
|
const srcDtsFiles = srcDirItems.filter((srcItem) => srcItem.isFile && isDtsFile$1(srcItem.absPath));
|
|
60317
60675
|
// Copy .d.ts files from src to dist
|
|
60318
60676
|
// In addition, all references to @rindo/core are replaced
|
|
60319
|
-
|
|
60320
|
-
await Promise.all(srcDtsFiles.map(async (srcDtsFile) => {
|
|
60677
|
+
const copiedDTSFilePaths = await Promise.all(srcDtsFiles.map(async (srcDtsFile) => {
|
|
60321
60678
|
const relPath = relative$1(config.srcDir, srcDtsFile.absPath);
|
|
60322
60679
|
const distPath = join(outputTarget.typesDir, relPath);
|
|
60323
60680
|
const originalDtsContent = await compilerCtx.fs.readFile(srcDtsFile.absPath);
|
|
60324
60681
|
const distDtsContent = updateRindoTypesImports(outputTarget.typesDir, distPath, originalDtsContent);
|
|
60325
60682
|
await compilerCtx.fs.writeFile(distPath, distDtsContent);
|
|
60326
|
-
|
|
60683
|
+
return distPath;
|
|
60327
60684
|
}));
|
|
60685
|
+
const distDtsFilePath = copiedDTSFilePaths.slice(-1)[0];
|
|
60328
60686
|
const distPath = outputTarget.typesDir;
|
|
60329
60687
|
await generateAppTypes(config, compilerCtx, buildCtx, distPath);
|
|
60688
|
+
const { typesDir } = outputTarget;
|
|
60330
60689
|
if (distDtsFilePath) {
|
|
60331
|
-
await generateCustomElementsTypes(config, compilerCtx, buildCtx, distDtsFilePath);
|
|
60332
60690
|
await generateCustomElementsBundleTypes(config, compilerCtx, buildCtx, distDtsFilePath);
|
|
60691
|
+
await generateCustomElementsTypes(config, compilerCtx, buildCtx, typesDir);
|
|
60333
60692
|
}
|
|
60334
60693
|
};
|
|
60335
60694
|
|
|
@@ -62800,7 +63159,7 @@ const getRelativeDts = (config, srcPath, emitDtsPath) => {
|
|
|
62800
63159
|
emitDtsPath = join(emitDtsPath, '..');
|
|
62801
63160
|
srcPath = normalizePath$1(join(srcPath, '..'));
|
|
62802
63161
|
}
|
|
62803
|
-
return join
|
|
63162
|
+
return join(...parts.reverse());
|
|
62804
63163
|
};
|
|
62805
63164
|
|
|
62806
63165
|
const outputServiceWorkers = async (config, buildCtx) => {
|
|
@@ -63278,9 +63637,16 @@ const createInMemoryFs = (sys) => {
|
|
|
63278
63637
|
return data.exists;
|
|
63279
63638
|
};
|
|
63280
63639
|
/**
|
|
63281
|
-
* Synchronous!!! Do not use
|
|
63640
|
+
* **Synchronous!!! Do not use!!!**
|
|
63282
63641
|
* (Only typescript transpiling is allowed to use)
|
|
63283
|
-
*
|
|
63642
|
+
*
|
|
63643
|
+
* Synchronously get information about a file from a provided path. This function will attempt to use an in-memory
|
|
63644
|
+
* cache before performing a blocking read.
|
|
63645
|
+
*
|
|
63646
|
+
* In the event of a cache hit, the content from the cache will be returned and skip the read.
|
|
63647
|
+
*
|
|
63648
|
+
* @param filePath the path to the file to read
|
|
63649
|
+
* @returns `true` if the file exists, `false` otherwise
|
|
63284
63650
|
*/
|
|
63285
63651
|
const accessSync = (filePath) => {
|
|
63286
63652
|
const item = getItem(filePath);
|
|
@@ -63452,9 +63818,19 @@ const createInMemoryFs = (sys) => {
|
|
|
63452
63818
|
return fileText;
|
|
63453
63819
|
};
|
|
63454
63820
|
/**
|
|
63455
|
-
* Synchronous!!! Do not use
|
|
63821
|
+
* **Synchronous!!! Do not use!!!**
|
|
63456
63822
|
* (Only typescript transpiling is allowed to use)
|
|
63457
|
-
*
|
|
63823
|
+
*
|
|
63824
|
+
* Synchronously read a file from a provided path. This function will attempt to use an in-memory cache before
|
|
63825
|
+
* performing a blocking read in the following circumstances:
|
|
63826
|
+
* - no `opts` are provided
|
|
63827
|
+
* - the `useCache` member on `opts` is set to `true`, or is not set
|
|
63828
|
+
*
|
|
63829
|
+
* In the event of a cache hit, the content from the cache will be returned and skip the read.
|
|
63830
|
+
*
|
|
63831
|
+
* @param filePath the path to the file to read
|
|
63832
|
+
* @param opts a configuration to use when reading a file
|
|
63833
|
+
* @returns the contents of the file (read from either disk or the cache).
|
|
63458
63834
|
*/
|
|
63459
63835
|
const readFileSync = (filePath, opts) => {
|
|
63460
63836
|
if (opts == null || opts.useCache === true || opts.useCache === undefined) {
|
|
@@ -63547,10 +63923,13 @@ const createInMemoryFs = (sys) => {
|
|
|
63547
63923
|
};
|
|
63548
63924
|
};
|
|
63549
63925
|
/**
|
|
63550
|
-
* Synchronous!!! Do not use
|
|
63551
|
-
* Always returns an object, does not throw errors.
|
|
63926
|
+
* **Synchronous!!! Do not use!!!**
|
|
63552
63927
|
* (Only typescript transpiling is allowed to use)
|
|
63553
|
-
*
|
|
63928
|
+
*
|
|
63929
|
+
* Searches an in-memory cache for an item at the provided path. Always returns an object, **does not throw errors**.
|
|
63930
|
+
*
|
|
63931
|
+
* @param itemPath the path to the file to read
|
|
63932
|
+
* @returns an object describing the item found at the provided `itemPath`
|
|
63554
63933
|
*/
|
|
63555
63934
|
const statSync = (itemPath) => {
|
|
63556
63935
|
const item = getItem(itemPath);
|
|
@@ -64104,37 +64483,76 @@ const filesChanged = (buildCtx) => {
|
|
|
64104
64483
|
// files changed include updated, added and deleted
|
|
64105
64484
|
return unique([...buildCtx.filesUpdated, ...buildCtx.filesAdded, ...buildCtx.filesDeleted]).sort();
|
|
64106
64485
|
};
|
|
64107
|
-
|
|
64108
|
-
|
|
64109
|
-
|
|
64110
|
-
|
|
64111
|
-
|
|
64112
|
-
|
|
64113
|
-
|
|
64114
|
-
|
|
64115
|
-
const
|
|
64116
|
-
|
|
64117
|
-
|
|
64118
|
-
|
|
64119
|
-
|
|
64120
|
-
|
|
64121
|
-
|
|
64122
|
-
};
|
|
64123
|
-
const hasScriptChanges = (buildCtx) => {
|
|
64124
|
-
return buildCtx.filesChanged.some((f) => {
|
|
64125
|
-
const ext = getExt(f);
|
|
64126
|
-
return SCRIPT_EXT.includes(ext);
|
|
64127
|
-
});
|
|
64128
|
-
};
|
|
64129
|
-
const hasStyleChanges = (buildCtx) => {
|
|
64130
|
-
return buildCtx.filesChanged.some((f) => {
|
|
64131
|
-
const ext = getExt(f);
|
|
64132
|
-
return STYLE_EXT.includes(ext);
|
|
64133
|
-
});
|
|
64134
|
-
};
|
|
64486
|
+
/**
|
|
64487
|
+
* Unary helper function mapping string to string and wrapping `basename`,
|
|
64488
|
+
* which normally takes two string arguments. This means it cannot be passed
|
|
64489
|
+
* to `Array.prototype.map`, but this little helper can!
|
|
64490
|
+
*
|
|
64491
|
+
* @param filePath a filepath to check out
|
|
64492
|
+
* @returns the basename for that filepath
|
|
64493
|
+
*/
|
|
64494
|
+
const unaryBasename = (filePath) => basename(filePath);
|
|
64495
|
+
/**
|
|
64496
|
+
* Get the file extension for a path
|
|
64497
|
+
*
|
|
64498
|
+
* @param filePath a path
|
|
64499
|
+
* @returns the file extension (well, characters after the last `'.'`)
|
|
64500
|
+
*/
|
|
64135
64501
|
const getExt = (filePath) => filePath.split('.').pop().toLowerCase();
|
|
64502
|
+
/**
|
|
64503
|
+
* Script extensions which we want to be able to recognize
|
|
64504
|
+
*/
|
|
64136
64505
|
const SCRIPT_EXT = ['ts', 'tsx', 'js', 'jsx'];
|
|
64506
|
+
/**
|
|
64507
|
+
* Helper to check if a filepath has a script extension
|
|
64508
|
+
*
|
|
64509
|
+
* @param filePath a file extension
|
|
64510
|
+
* @returns whether the filepath has a script extension or not
|
|
64511
|
+
*/
|
|
64512
|
+
const hasScriptExt = (filePath) => SCRIPT_EXT.includes(getExt(filePath));
|
|
64137
64513
|
const STYLE_EXT = ['css', 'scss', 'sass', 'pcss', 'styl', 'stylus', 'less'];
|
|
64514
|
+
/**
|
|
64515
|
+
* Helper to check if a filepath has a style extension
|
|
64516
|
+
*
|
|
64517
|
+
* @param filePath a file extension to check
|
|
64518
|
+
* @returns whether the filepath has a style extension or not
|
|
64519
|
+
*/
|
|
64520
|
+
const hasStyleExt = (filePath) => STYLE_EXT.includes(getExt(filePath));
|
|
64521
|
+
/**
|
|
64522
|
+
* Get all scripts from a build context that were added
|
|
64523
|
+
*
|
|
64524
|
+
* @param buildCtx the build context
|
|
64525
|
+
* @returns an array of filepaths that were added
|
|
64526
|
+
*/
|
|
64527
|
+
const scriptsAdded = (buildCtx) => buildCtx.filesAdded.filter(hasScriptExt).map(unaryBasename);
|
|
64528
|
+
/**
|
|
64529
|
+
* Get all scripts from a build context that were deleted
|
|
64530
|
+
*
|
|
64531
|
+
* @param buildCtx the build context
|
|
64532
|
+
* @returns an array of deleted filepaths
|
|
64533
|
+
*/
|
|
64534
|
+
const scriptsDeleted = (buildCtx) => buildCtx.filesDeleted.filter(hasScriptExt).map(unaryBasename);
|
|
64535
|
+
/**
|
|
64536
|
+
* Check whether a build has script changes
|
|
64537
|
+
*
|
|
64538
|
+
* @param buildCtx the build context
|
|
64539
|
+
* @returns whether or not there are script changes
|
|
64540
|
+
*/
|
|
64541
|
+
const hasScriptChanges = (buildCtx) => buildCtx.filesChanged.some(hasScriptExt);
|
|
64542
|
+
/**
|
|
64543
|
+
* Check whether a build has style changes
|
|
64544
|
+
*
|
|
64545
|
+
* @param buildCtx the build context
|
|
64546
|
+
* @returns whether or not there are style changes
|
|
64547
|
+
*/
|
|
64548
|
+
const hasStyleChanges = (buildCtx) => buildCtx.filesChanged.some(hasStyleExt);
|
|
64549
|
+
/**
|
|
64550
|
+
* Check whether a build has html changes
|
|
64551
|
+
*
|
|
64552
|
+
* @param config the current config
|
|
64553
|
+
* @param buildCtx the build context
|
|
64554
|
+
* @returns whether or not HTML files were changed
|
|
64555
|
+
*/
|
|
64138
64556
|
const hasHtmlChanges = (config, buildCtx) => {
|
|
64139
64557
|
const anyHtmlChanged = buildCtx.filesChanged.some((f) => f.toLowerCase().endsWith('.html'));
|
|
64140
64558
|
if (anyHtmlChanged) {
|
|
@@ -65061,7 +65479,7 @@ const getComponentPathContent = (componentGraph, outputTarget) => {
|
|
|
65061
65479
|
const dependencies = [
|
|
65062
65480
|
{
|
|
65063
65481
|
name: "@rindo/core",
|
|
65064
|
-
version: "2.
|
|
65482
|
+
version: "2.17.0",
|
|
65065
65483
|
main: "compiler/rindo.js",
|
|
65066
65484
|
resources: [
|
|
65067
65485
|
"package.json",
|
|
@@ -66439,7 +66857,7 @@ const validateConfig = (userConfig = {}) => {
|
|
|
66439
66857
|
setBooleanConfig(config, 'sourceMap', null, typeof config.sourceMap === 'undefined' ? false : config.sourceMap);
|
|
66440
66858
|
setBooleanConfig(config, 'watch', 'watch', false);
|
|
66441
66859
|
setBooleanConfig(config, 'buildDocs', 'docs', !config.devMode);
|
|
66442
|
-
setBooleanConfig(config, 'buildDist',
|
|
66860
|
+
setBooleanConfig(config, 'buildDist', 'esm', !config.devMode || config.buildEs5);
|
|
66443
66861
|
setBooleanConfig(config, 'profile', 'profile', config.devMode);
|
|
66444
66862
|
setBooleanConfig(config, 'writeLog', 'log', false);
|
|
66445
66863
|
setBooleanConfig(config, 'buildAppCore', null, true);
|
|
@@ -66659,6 +67077,21 @@ const createDefaultTsConfig = (config) => JSON.stringify({
|
|
|
66659
67077
|
const hasSrcDirectoryInclude = (includeProp, src) => Array.isArray(includeProp) && includeProp.includes(src);
|
|
66660
67078
|
const hasRindoConfigInclude = (includeProp) => Array.isArray(includeProp) && includeProp.includes('rindo.config.ts');
|
|
66661
67079
|
|
|
67080
|
+
/**
|
|
67081
|
+
* Load and validate a configuration to use throughout the lifetime of any Rindo task (build, test, etc.).
|
|
67082
|
+
*
|
|
67083
|
+
* Users can provide configurations multiple ways simultaneously:
|
|
67084
|
+
* - as an object of the `init` argument to this function
|
|
67085
|
+
* - through a path to a configuration file that exists on disk
|
|
67086
|
+
*
|
|
67087
|
+
* In the case of both being present, the two configurations will be merged. The fields of the former will take precedence
|
|
67088
|
+
* over the fields of the latter.
|
|
67089
|
+
*
|
|
67090
|
+
* @param init the initial configuration provided by the user (or generated by Rindo) used to bootstrap configuration
|
|
67091
|
+
* loading and validation
|
|
67092
|
+
* @returns the results of loading a configuration
|
|
67093
|
+
* @public
|
|
67094
|
+
*/
|
|
66662
67095
|
const loadConfig = async (init = {}) => {
|
|
66663
67096
|
const results = {
|
|
66664
67097
|
config: null,
|
|
@@ -66730,6 +67163,15 @@ const loadConfig = async (init = {}) => {
|
|
|
66730
67163
|
}
|
|
66731
67164
|
return results;
|
|
66732
67165
|
};
|
|
67166
|
+
/**
|
|
67167
|
+
* Load a Rindo configuration file from disk
|
|
67168
|
+
* @param sys the underlying System entity to use to interact with the operating system
|
|
67169
|
+
* @param diagnostics a series of diagnostics used to track errors & warnings throughout the loading process. Entries
|
|
67170
|
+
* may be added to this list in the event of an error.
|
|
67171
|
+
* @param configPath the path to the configuration file to load
|
|
67172
|
+
* @returns an unvalidated configuration. In the event of an error, additional diagnostics may be pushed to the
|
|
67173
|
+
* provided `diagnostics` argument and `null` will be returned.
|
|
67174
|
+
*/
|
|
66733
67175
|
const loadConfigFile = async (sys, diagnostics, configPath) => {
|
|
66734
67176
|
let config = null;
|
|
66735
67177
|
if (isString$1(configPath)) {
|
|
@@ -66749,6 +67191,15 @@ const loadConfigFile = async (sys, diagnostics, configPath) => {
|
|
|
66749
67191
|
}
|
|
66750
67192
|
return config;
|
|
66751
67193
|
};
|
|
67194
|
+
/**
|
|
67195
|
+
* Load the configuration file, based on the environment that Rindo is being run in
|
|
67196
|
+
* @param sys the underlying System entity to use to interact with the operating system
|
|
67197
|
+
* @param diagnostics a series of diagnostics used to track errors & warnings throughout the loading process. Entries
|
|
67198
|
+
* may be added to this list in the event of an error.
|
|
67199
|
+
* @param configFilePath the path to the configuration file to load
|
|
67200
|
+
* @returns an unvalidated configuration. In the event of an error, additional diagnostics may be pushed to the
|
|
67201
|
+
* provided `diagnostics` argument and `null` will be returned.
|
|
67202
|
+
*/
|
|
66752
67203
|
const evaluateConfigFile = async (sys, diagnostics, configFilePath) => {
|
|
66753
67204
|
let configFileData = null;
|
|
66754
67205
|
try {
|
|
@@ -66773,6 +67224,16 @@ const evaluateConfigFile = async (sys, diagnostics, configFilePath) => {
|
|
|
66773
67224
|
}
|
|
66774
67225
|
return configFileData;
|
|
66775
67226
|
};
|
|
67227
|
+
/**
|
|
67228
|
+
* Transpiles the provided TypeScript source text into JavaScript.
|
|
67229
|
+
*
|
|
67230
|
+
* This function is intended to be used on a `rindo.config.ts` file
|
|
67231
|
+
*
|
|
67232
|
+
* @param diagnostics a collection of compiler diagnostics to check as a part of the compilation process
|
|
67233
|
+
* @param sourceText the text to transpile
|
|
67234
|
+
* @param filePath the name of the file to transpile
|
|
67235
|
+
* @returns the transpiled text. If there are any diagnostics in the provided collection, the provided source is returned
|
|
67236
|
+
*/
|
|
66776
67237
|
const transpileTypedConfig = (diagnostics, sourceText, filePath) => {
|
|
66777
67238
|
// let's transpile an awesome rindo.config.ts file into
|
|
66778
67239
|
// a boring rindo.config.js file
|
|
@@ -66974,6 +67435,10 @@ const convertStaticToMeta = (config, compilerCtx, buildCtx, typeChecker, collect
|
|
|
66974
67435
|
|
|
66975
67436
|
/**
|
|
66976
67437
|
* Stand-alone compiling of a single string
|
|
67438
|
+
* @param config the Rindo configuration to use in the compilation process
|
|
67439
|
+
* @param input the string to compile
|
|
67440
|
+
* @param transformOpts a configuration object for how the string is compiled
|
|
67441
|
+
* @returns the results of compiling the provided input string
|
|
66977
67442
|
*/
|
|
66978
67443
|
const transpileModule = (config, input, transformOpts) => {
|
|
66979
67444
|
if (!config.logger) {
|