@rindo/core 2.17.1 → 2.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/config-flags.d.ts +12 -4
- package/cli/index.cjs +113 -73
- package/cli/index.d.ts +1 -1
- package/cli/index.js +113 -73
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/rindo.js +348 -61
- 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 +2 -2
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +2 -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/package.json +1 -1
- package/internal/package.json +1 -1
- package/internal/rindo-private.d.ts +12 -2
- package/internal/rindo-public-compiler.d.ts +1 -1
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +41 -3
- package/mock-doc/index.d.ts +15 -0
- package/mock-doc/index.js +41 -3
- package/mock-doc/package.json +1 -1
- package/package.json +1 -1
- package/screenshot/package.json +1 -1
- package/sys/node/index.js +1 -1
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +37 -22
- package/testing/mocks.d.ts +7 -6
- package/testing/package.json +1 -1
package/compiler/rindo.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Rindo Compiler v2.17.
|
|
2
|
+
Rindo Compiler v2.17.2 | MIT Licensed | https://rindojs.web.app
|
|
3
3
|
*/
|
|
4
4
|
(function(exports) {
|
|
5
5
|
'use strict';
|
|
@@ -898,24 +898,37 @@ const buildWarn = (diagnostics) => {
|
|
|
898
898
|
diagnostics.push(diagnostic);
|
|
899
899
|
return diagnostic;
|
|
900
900
|
};
|
|
901
|
-
|
|
901
|
+
/**
|
|
902
|
+
* Create a diagnostic message suited for representing an error in a JSON
|
|
903
|
+
* file. This includes information about the exact lines in the JSON file which
|
|
904
|
+
* caused the error and the path to the file.
|
|
905
|
+
*
|
|
906
|
+
* @param compilerCtx the current compiler context
|
|
907
|
+
* @param diagnostics a list of diagnostics used as a return param
|
|
908
|
+
* @param jsonFilePath the path to the JSON file where the error occurred
|
|
909
|
+
* @param msg the error message
|
|
910
|
+
* @param jsonField the key for the field which caused the error, used for finding
|
|
911
|
+
* the error line in the original JSON file
|
|
912
|
+
* @returns a reference to the newly-created diagnostic
|
|
913
|
+
*/
|
|
914
|
+
const buildJsonFileError = (compilerCtx, diagnostics, jsonFilePath, msg, jsonField) => {
|
|
902
915
|
const err = buildError(diagnostics);
|
|
903
916
|
err.messageText = msg;
|
|
904
917
|
err.absFilePath = jsonFilePath;
|
|
905
|
-
if (typeof
|
|
918
|
+
if (typeof jsonField === 'string') {
|
|
906
919
|
try {
|
|
907
920
|
const jsonStr = compilerCtx.fs.readFileSync(jsonFilePath);
|
|
908
921
|
const lines = jsonStr.replace(/\r/g, '\n').split('\n');
|
|
909
922
|
for (let i = 0; i < lines.length; i++) {
|
|
910
923
|
const txtLine = lines[i];
|
|
911
|
-
const txtIndex = txtLine.indexOf(
|
|
924
|
+
const txtIndex = txtLine.indexOf(jsonField);
|
|
912
925
|
if (txtIndex > -1) {
|
|
913
926
|
const warnLine = {
|
|
914
927
|
lineIndex: i,
|
|
915
928
|
lineNumber: i + 1,
|
|
916
929
|
text: txtLine,
|
|
917
930
|
errorCharStart: txtIndex,
|
|
918
|
-
errorLength:
|
|
931
|
+
errorLength: jsonField.length,
|
|
919
932
|
};
|
|
920
933
|
err.lineNumber = warnLine.lineNumber;
|
|
921
934
|
err.columnNumber = txtIndex + 1;
|
|
@@ -4575,7 +4588,7 @@ const createCustomResolverAsync = (sys, inMemoryFs, exts) => {
|
|
|
4575
4588
|
};
|
|
4576
4589
|
};
|
|
4577
4590
|
|
|
4578
|
-
const buildId = '
|
|
4591
|
+
const buildId = '20230111114107';
|
|
4579
4592
|
const minfyJsId = 'terser5.6.1_7';
|
|
4580
4593
|
const optimizeCssId = 'autoprefixer10.2.5_postcss8.4.16_7';
|
|
4581
4594
|
const parse5Version = '6.0.1';
|
|
@@ -4583,8 +4596,8 @@ const rollupVersion = '2.42.3';
|
|
|
4583
4596
|
const sizzleVersion = '2.42.3';
|
|
4584
4597
|
const terserVersion = '5.6.1';
|
|
4585
4598
|
const typescriptVersion = '4.5.4';
|
|
4586
|
-
const vermoji = '
|
|
4587
|
-
const version$3 = '2.17.
|
|
4599
|
+
const vermoji = '⚽️';
|
|
4600
|
+
const version$3 = '2.17.2';
|
|
4588
4601
|
const versions = {
|
|
4589
4602
|
rindo: version$3,
|
|
4590
4603
|
parse5: parse5Version,
|
|
@@ -15460,6 +15473,25 @@ class MockMouseEvent extends MockEvent {
|
|
|
15460
15473
|
}
|
|
15461
15474
|
}
|
|
15462
15475
|
}
|
|
15476
|
+
class MockUIEvent extends MockEvent {
|
|
15477
|
+
constructor(type, uiEventInitDic) {
|
|
15478
|
+
super(type);
|
|
15479
|
+
this.detail = null;
|
|
15480
|
+
this.view = null;
|
|
15481
|
+
if (uiEventInitDic != null) {
|
|
15482
|
+
Object.assign(this, uiEventInitDic);
|
|
15483
|
+
}
|
|
15484
|
+
}
|
|
15485
|
+
}
|
|
15486
|
+
class MockFocusEvent extends MockUIEvent {
|
|
15487
|
+
constructor(type, focusEventInitDic) {
|
|
15488
|
+
super(type);
|
|
15489
|
+
this.relatedTarget = null;
|
|
15490
|
+
if (focusEventInitDic != null) {
|
|
15491
|
+
Object.assign(this, focusEventInitDic);
|
|
15492
|
+
}
|
|
15493
|
+
}
|
|
15494
|
+
}
|
|
15463
15495
|
class MockEventListener {
|
|
15464
15496
|
constructor(type, handler) {
|
|
15465
15497
|
this.type = type;
|
|
@@ -16374,7 +16406,7 @@ class MockElement extends MockNode {
|
|
|
16374
16406
|
return shadowRoot;
|
|
16375
16407
|
}
|
|
16376
16408
|
blur() {
|
|
16377
|
-
|
|
16409
|
+
dispatchEvent(this, new MockFocusEvent('blur', { relatedTarget: null, bubbles: true, cancelable: true, composed: true }));
|
|
16378
16410
|
}
|
|
16379
16411
|
get shadowRoot() {
|
|
16380
16412
|
return this.__shadowRoot || null;
|
|
@@ -16444,7 +16476,9 @@ class MockElement extends MockNode {
|
|
|
16444
16476
|
get firstElementChild() {
|
|
16445
16477
|
return this.children[0] || null;
|
|
16446
16478
|
}
|
|
16447
|
-
focus(_options) {
|
|
16479
|
+
focus(_options) {
|
|
16480
|
+
dispatchEvent(this, new MockFocusEvent('focus', { relatedTarget: null, bubbles: true, cancelable: true, composed: true }));
|
|
16481
|
+
}
|
|
16448
16482
|
getAttribute(attrName) {
|
|
16449
16483
|
if (attrName === 'style') {
|
|
16450
16484
|
if (this.__style != null && this.__style.length > 0) {
|
|
@@ -16789,6 +16823,9 @@ class MockElement extends MockNode {
|
|
|
16789
16823
|
set title(value) {
|
|
16790
16824
|
this.setAttributeNS(null, 'title', value);
|
|
16791
16825
|
}
|
|
16826
|
+
animate() {
|
|
16827
|
+
/**/
|
|
16828
|
+
}
|
|
16792
16829
|
onanimationstart() {
|
|
16793
16830
|
/**/
|
|
16794
16831
|
}
|
|
@@ -17053,6 +17090,18 @@ class MockElement extends MockNode {
|
|
|
17053
17090
|
onwheel() {
|
|
17054
17091
|
/**/
|
|
17055
17092
|
}
|
|
17093
|
+
requestFullscreen() {
|
|
17094
|
+
/**/
|
|
17095
|
+
}
|
|
17096
|
+
scrollBy() {
|
|
17097
|
+
/**/
|
|
17098
|
+
}
|
|
17099
|
+
scrollTo() {
|
|
17100
|
+
/**/
|
|
17101
|
+
}
|
|
17102
|
+
scrollIntoView() {
|
|
17103
|
+
/**/
|
|
17104
|
+
}
|
|
17056
17105
|
toString(opts) {
|
|
17057
17106
|
return serializeNodeToHtml(this, opts);
|
|
17058
17107
|
}
|
|
@@ -18094,6 +18143,7 @@ const GLOBAL_CONSTRUCTORS = [
|
|
|
18094
18143
|
['CustomEvent', MockCustomEvent],
|
|
18095
18144
|
['Event', MockEvent],
|
|
18096
18145
|
['Headers', MockHeaders],
|
|
18146
|
+
['FocusEvent', MockFocusEvent],
|
|
18097
18147
|
['KeyboardEvent', MockKeyboardEvent],
|
|
18098
18148
|
['MouseEvent', MockMouseEvent],
|
|
18099
18149
|
['Request', MockRequest],
|
|
@@ -55107,6 +55157,23 @@ const isMemberPrivate = (member) => {
|
|
|
55107
55157
|
}
|
|
55108
55158
|
return false;
|
|
55109
55159
|
};
|
|
55160
|
+
/**
|
|
55161
|
+
* Convert a JavaScript value to the TypeScript Intermediate Representation
|
|
55162
|
+
* (IR) for a literal Abstract Syntax Tree (AST) node with that same value. The
|
|
55163
|
+
* value to convert may be a primitive type like `string`, `boolean`, etc or
|
|
55164
|
+
* may be an `Object`, `Array`, etc.
|
|
55165
|
+
*
|
|
55166
|
+
* Note that this function takes a param (`refs`) with a default value,
|
|
55167
|
+
* normally a value should _not_ be passed for this parameter since it is
|
|
55168
|
+
* intended to be used for recursive calls.
|
|
55169
|
+
*
|
|
55170
|
+
* @param val the value to convert
|
|
55171
|
+
* @param refs a set of references, used in recursive calls to avoid
|
|
55172
|
+
* circular references when creating object literal IR instances. **note that
|
|
55173
|
+
* you shouldn't pass this parameter unless you know what you're doing!**
|
|
55174
|
+
* @returns TypeScript IR for a literal corresponding to the JavaScript value
|
|
55175
|
+
* with which the function was called
|
|
55176
|
+
*/
|
|
55110
55177
|
const convertValueToLiteral = (val, refs = null) => {
|
|
55111
55178
|
if (refs == null) {
|
|
55112
55179
|
refs = new WeakSet();
|
|
@@ -55137,12 +55204,39 @@ const convertValueToLiteral = (val, refs = null) => {
|
|
|
55137
55204
|
}
|
|
55138
55205
|
return t.createLiteral(val);
|
|
55139
55206
|
};
|
|
55207
|
+
/**
|
|
55208
|
+
* Convert a JavaScript Array instance to TypeScript's Intermediate
|
|
55209
|
+
* Representation (IR) for an array literal. This is done by recursively using
|
|
55210
|
+
* {@link convertValueToLiteral} to create a new array consisting of the
|
|
55211
|
+
* TypeScript IR of each element in the array to be converted, and then creating
|
|
55212
|
+
* the TypeScript IR for _that_ array.
|
|
55213
|
+
*
|
|
55214
|
+
* @param list the array instance to convert
|
|
55215
|
+
* @param refs a set of references to objects, used when converting objects to
|
|
55216
|
+
* avoid circular references
|
|
55217
|
+
* @returns TypeScript IR for the array we want to convert
|
|
55218
|
+
*/
|
|
55140
55219
|
const arrayToArrayLiteral = (list, refs) => {
|
|
55141
55220
|
const newList = list.map((l) => {
|
|
55142
55221
|
return convertValueToLiteral(l, refs);
|
|
55143
55222
|
});
|
|
55144
55223
|
return t.createArrayLiteral(newList);
|
|
55145
55224
|
};
|
|
55225
|
+
/**
|
|
55226
|
+
* Convert a JavaScript object (i.e. an object existing at runtime) to the
|
|
55227
|
+
* corresponding TypeScript Intermediate Representation (IR)
|
|
55228
|
+
* ({@see ts.ObjectLiteralExpression}) for an object literal. This function
|
|
55229
|
+
* takes an argument holding a `WeakSet` of references to objects which is
|
|
55230
|
+
* used to avoid circular references. Objects that are converted in this
|
|
55231
|
+
* function are added to the set, and if an object is already present then an
|
|
55232
|
+
* `undefined` literal (in TypeScript IR) is returned instead of another
|
|
55233
|
+
* object literal, as continuing to convert a circular reference would, well,
|
|
55234
|
+
* never end!
|
|
55235
|
+
*
|
|
55236
|
+
* @param obj the JavaScript object to convert to TypeScript IR
|
|
55237
|
+
* @param refs a set of references to objects, used to avoid circular references
|
|
55238
|
+
* @returns a TypeScript object literal expression
|
|
55239
|
+
*/
|
|
55146
55240
|
const objectToObjectLiteral = (obj, refs) => {
|
|
55147
55241
|
if (refs.has(obj)) {
|
|
55148
55242
|
return t.createIdentifier('undefined');
|
|
@@ -56510,17 +56604,16 @@ const KEEP_IMPORTS = new Set([
|
|
|
56510
56604
|
* which do actual work of generating the rollup configuration, creating an
|
|
56511
56605
|
* entry chunk, running, the build, etc.
|
|
56512
56606
|
*
|
|
56513
|
-
* @param config the
|
|
56607
|
+
* @param config the validated compiler configuration we're using
|
|
56514
56608
|
* @param compilerCtx the current compiler context
|
|
56515
56609
|
* @param buildCtx the current build context
|
|
56516
56610
|
* @returns an empty Promise which won't resolve until the work is done!
|
|
56517
56611
|
*/
|
|
56518
56612
|
const outputCustomElements = async (config, compilerCtx, buildCtx) => {
|
|
56519
|
-
var _a;
|
|
56520
56613
|
if (!config.buildDist) {
|
|
56521
56614
|
return;
|
|
56522
56615
|
}
|
|
56523
|
-
const outputTargets =
|
|
56616
|
+
const outputTargets = config.outputTargets.filter(isOutputTargetDistCustomElements);
|
|
56524
56617
|
if (outputTargets.length === 0) {
|
|
56525
56618
|
return;
|
|
56526
56619
|
}
|
|
@@ -56533,7 +56626,7 @@ const outputCustomElements = async (config, compilerCtx, buildCtx) => {
|
|
|
56533
56626
|
* Get bundle options for our current build and compiler context which we'll use
|
|
56534
56627
|
* to generate a Rollup build and so on.
|
|
56535
56628
|
*
|
|
56536
|
-
* @param config
|
|
56629
|
+
* @param config a validated Rindo configuration object
|
|
56537
56630
|
* @param buildCtx the current build context
|
|
56538
56631
|
* @param compilerCtx the current compiler context
|
|
56539
56632
|
* @param outputTarget the outputTarget we're currently dealing with
|
|
@@ -56564,9 +56657,10 @@ const getBundleOptions = (config, buildCtx, compilerCtx, outputTarget) => ({
|
|
|
56564
56657
|
/**
|
|
56565
56658
|
* Get bundle options for rollup, run the rollup build, optionally minify the
|
|
56566
56659
|
* output, and write files to disk.
|
|
56567
|
-
*
|
|
56568
|
-
* @param
|
|
56660
|
+
*
|
|
56661
|
+
* @param config the validated Rindo configuration we're using
|
|
56569
56662
|
* @param compilerCtx the current compiler context
|
|
56663
|
+
* @param buildCtx the current build context
|
|
56570
56664
|
* @param outputTarget the outputTarget we're currently dealing with
|
|
56571
56665
|
* @returns an empty promise
|
|
56572
56666
|
*/
|
|
@@ -56655,7 +56749,7 @@ const addCustomElementInputs = (buildCtx, bundleOpts) => {
|
|
|
56655
56749
|
exp.push(`import { ${importName} as ${importAs}, defineCustomElement as cmpDefCustomEle } from '${cmp.sourceFilePath}';`);
|
|
56656
56750
|
exp.push(`export const ${exportName} = ${importAs};`);
|
|
56657
56751
|
exp.push(`export const defineCustomElement = cmpDefCustomEle;`);
|
|
56658
|
-
// Here we push an export (with a rename for `defineCustomElement` for
|
|
56752
|
+
// Here we push an export (with a rename for `defineCustomElement`) for
|
|
56659
56753
|
// this component onto our array which references the `coreKey` (prefixed
|
|
56660
56754
|
// with `\0`). We have to do this so that our import is referencing the
|
|
56661
56755
|
// correct virtual module, if we instead referenced, for instance,
|
|
@@ -60690,8 +60784,7 @@ const relDts$1 = (fromPath, dtsPath) => {
|
|
|
60690
60784
|
* @param typesDir the path to the directory where type declarations are saved
|
|
60691
60785
|
*/
|
|
60692
60786
|
const generateCustomElementsTypes = async (config, compilerCtx, buildCtx, typesDir) => {
|
|
60693
|
-
|
|
60694
|
-
const outputTargets = ((_a = config.outputTargets) !== null && _a !== void 0 ? _a : []).filter(isOutputTargetDistCustomElements);
|
|
60787
|
+
const outputTargets = config.outputTargets.filter(isOutputTargetDistCustomElements);
|
|
60695
60788
|
await Promise.all(outputTargets.map((outputTarget) => generateCustomElementsTypesOutput(config, compilerCtx, buildCtx, typesDir, outputTarget)));
|
|
60696
60789
|
};
|
|
60697
60790
|
/**
|
|
@@ -60707,7 +60800,7 @@ const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx,
|
|
|
60707
60800
|
// the path where we're going to write the typedef for the whole dist-custom-elements output
|
|
60708
60801
|
const customElementsDtsPath = join(outputTarget.dir, 'index.d.ts');
|
|
60709
60802
|
// the directory where types for the individual components are written
|
|
60710
|
-
const
|
|
60803
|
+
const componentsTypeDirectoryRelPath = relative$1(outputTarget.dir, typesDir);
|
|
60711
60804
|
const components = buildCtx.components.filter((m) => !m.isCollectionDependency);
|
|
60712
60805
|
const code = [
|
|
60713
60806
|
`/* ${config.namespace} custom elements */`,
|
|
@@ -60716,7 +60809,14 @@ const generateCustomElementsTypesOutput = async (config, compilerCtx, buildCtx,
|
|
|
60716
60809
|
const importName = component.componentClassName;
|
|
60717
60810
|
// typedefs for individual components can be found under paths like
|
|
60718
60811
|
// $TYPES_DIR/components/my-component/my-component.d.ts
|
|
60719
|
-
|
|
60812
|
+
//
|
|
60813
|
+
// To construct this path we:
|
|
60814
|
+
//
|
|
60815
|
+
// - get the relative path to the component's source file from the source directory
|
|
60816
|
+
// - join that relative path to the relative path from the `index.d.ts` file to the
|
|
60817
|
+
// directory where typedefs are saved
|
|
60818
|
+
const componentSourceRelPath = relative$1(config.srcDir, component.sourceFilePath).replace('.tsx', '');
|
|
60819
|
+
const componentDTSPath = join(componentsTypeDirectoryRelPath, componentSourceRelPath);
|
|
60720
60820
|
return `export { ${importName} as ${exportName} } from '${componentDTSPath}';`;
|
|
60721
60821
|
}),
|
|
60722
60822
|
``,
|
|
@@ -62619,6 +62719,16 @@ const parseModuleImport = (config, compilerCtx, buildCtx, moduleFile, dirPath, i
|
|
|
62619
62719
|
}
|
|
62620
62720
|
};
|
|
62621
62721
|
|
|
62722
|
+
/**
|
|
62723
|
+
* Update an instance of TypeScript's Intermediate Representation (IR) for a
|
|
62724
|
+
* class declaration ({@link ts.ClassDeclaration}) with a static getter for the
|
|
62725
|
+
* compiler metadata that we produce as part of the compilation process.
|
|
62726
|
+
*
|
|
62727
|
+
* @param cmpNode an instance of the TypeScript IR for a class declaration (i.e.
|
|
62728
|
+
* a rindo component) to be updated
|
|
62729
|
+
* @param cmpMeta the component metadata corresponding to that component
|
|
62730
|
+
* @returns the updated typescript class declaration
|
|
62731
|
+
*/
|
|
62622
62732
|
const addComponentMetaStatic = (cmpNode, cmpMeta) => {
|
|
62623
62733
|
const publicCompilerMeta = getPublicCompilerMeta(cmpMeta);
|
|
62624
62734
|
const cmpMetaStaticProp = createStaticGetter('COMPILER_META', convertValueToLiteral(publicCompilerMeta));
|
|
@@ -62750,6 +62860,14 @@ const parseStaticEvents = (staticMembers) => {
|
|
|
62750
62860
|
});
|
|
62751
62861
|
};
|
|
62752
62862
|
|
|
62863
|
+
/**
|
|
62864
|
+
* Parse a list of {@link ts.ClassElement} objects representing static props
|
|
62865
|
+
* into a list of our own Intermediate Representation (IR) of properties on
|
|
62866
|
+
* components.
|
|
62867
|
+
*
|
|
62868
|
+
* @param staticMembers TypeScript IR for the properties on our component
|
|
62869
|
+
* @returns a manifest of compiler properties in our own Rindo IR
|
|
62870
|
+
*/
|
|
62753
62871
|
const parseStaticProps = (staticMembers) => {
|
|
62754
62872
|
const parsedProps = getStaticValue(staticMembers, 'properties');
|
|
62755
62873
|
if (!parsedProps) {
|
|
@@ -62986,7 +63104,22 @@ const setComponentBuildConditionals = (cmpMeta) => {
|
|
|
62986
63104
|
!cmpMeta.hasMember && !cmpMeta.hasStyle && !cmpMeta.hasLifecycle && !cmpMeta.hasListener && !cmpMeta.hasVdomRender;
|
|
62987
63105
|
};
|
|
62988
63106
|
|
|
62989
|
-
|
|
63107
|
+
/**
|
|
63108
|
+
* Given an instance of TypeScript's Intermediate Representation (IR) for a
|
|
63109
|
+
* class declaration ({@see ts.ClassDeclaration}) which represents a Rindo
|
|
63110
|
+
* component class declaration, parse and format various pieces of data about
|
|
63111
|
+
* static class members which we use in the compilation process
|
|
63112
|
+
*
|
|
63113
|
+
* @param compilerCtx the current compiler context
|
|
63114
|
+
* @param typeChecker a TypeScript type checker instance
|
|
63115
|
+
* @param cmpNode the TypeScript class declaration for the component
|
|
63116
|
+
* @param moduleFile Rindo's IR for a module, used here as an out param
|
|
63117
|
+
* @param transformOpts options which control various aspects of the
|
|
63118
|
+
* transformation
|
|
63119
|
+
* @returns the TypeScript class declaration IR instance with which the
|
|
63120
|
+
* function was called
|
|
63121
|
+
*/
|
|
63122
|
+
const parseStaticComponentMeta = (compilerCtx, typeChecker, cmpNode, moduleFile, transformOpts) => {
|
|
62990
63123
|
if (cmpNode.members == null) {
|
|
62991
63124
|
return cmpNode;
|
|
62992
63125
|
}
|
|
@@ -63103,7 +63236,7 @@ const parseStaticComponentMeta = (compilerCtx, typeChecker, cmpNode, moduleFile,
|
|
|
63103
63236
|
// add to module map
|
|
63104
63237
|
moduleFile.cmps.push(cmp);
|
|
63105
63238
|
// add to node map
|
|
63106
|
-
nodeMap.set(cmpNode, cmp);
|
|
63239
|
+
compilerCtx.nodeMap.set(cmpNode, cmp);
|
|
63107
63240
|
return cmpNode;
|
|
63108
63241
|
};
|
|
63109
63242
|
const parseVirtualProps = (docs) => {
|
|
@@ -63171,7 +63304,7 @@ const updateModule = (config, compilerCtx, buildCtx, tsSourceFile, sourceFileTex
|
|
|
63171
63304
|
compilerCtx.changedModules.add(moduleFile.sourceFilePath);
|
|
63172
63305
|
const visitNode = (node) => {
|
|
63173
63306
|
if (t.isClassDeclaration(node)) {
|
|
63174
|
-
parseStaticComponentMeta(compilerCtx, typeChecker, node, moduleFile
|
|
63307
|
+
parseStaticComponentMeta(compilerCtx, typeChecker, node, moduleFile);
|
|
63175
63308
|
return;
|
|
63176
63309
|
}
|
|
63177
63310
|
else if (t.isImportDeclaration(node)) {
|
|
@@ -63332,6 +63465,15 @@ const outputServiceWorkers = async (config, buildCtx) => {
|
|
|
63332
63465
|
}
|
|
63333
63466
|
};
|
|
63334
63467
|
|
|
63468
|
+
/**
|
|
63469
|
+
* Validate the package.json file for a project, checking that various fields
|
|
63470
|
+
* are set correctly for the currently-configured output targets.
|
|
63471
|
+
*
|
|
63472
|
+
* @param config the user-supplied Rindo config
|
|
63473
|
+
* @param compilerCtx the compiler context
|
|
63474
|
+
* @param buildCtx the build context
|
|
63475
|
+
* @returns an empty Promise
|
|
63476
|
+
*/
|
|
63335
63477
|
const validateBuildPackageJson = async (config, compilerCtx, buildCtx) => {
|
|
63336
63478
|
if (config.watch) {
|
|
63337
63479
|
return;
|
|
@@ -63339,26 +63481,41 @@ const validateBuildPackageJson = async (config, compilerCtx, buildCtx) => {
|
|
|
63339
63481
|
if (buildCtx.packageJson == null) {
|
|
63340
63482
|
return;
|
|
63341
63483
|
}
|
|
63342
|
-
const
|
|
63484
|
+
const distCollectionOutputTargets = config.outputTargets.filter(isOutputTargetDistCollection);
|
|
63343
63485
|
const typesOutputTargets = config.outputTargets.filter(isOutputTargetDistTypes);
|
|
63344
63486
|
await Promise.all([
|
|
63345
|
-
...
|
|
63346
|
-
|
|
63347
|
-
|
|
63348
|
-
...typesOutputTargets.map((outputTarget) => {
|
|
63349
|
-
return validateTypes(config, compilerCtx, buildCtx, outputTarget);
|
|
63350
|
-
}),
|
|
63487
|
+
...distCollectionOutputTargets.map((distCollectionOT) => validateDistCollectionPkgJson(config, compilerCtx, buildCtx, distCollectionOT)),
|
|
63488
|
+
...typesOutputTargets.map((typesOT) => validateTypes(config, compilerCtx, buildCtx, typesOT)),
|
|
63489
|
+
validateModule(config, compilerCtx, buildCtx),
|
|
63351
63490
|
]);
|
|
63352
63491
|
};
|
|
63353
|
-
|
|
63492
|
+
/**
|
|
63493
|
+
* Validate package.json contents for the `DIST_COLLECTION` output target,
|
|
63494
|
+
* checking that various fields like `files`, `main`, and so on are set
|
|
63495
|
+
* correctly.
|
|
63496
|
+
*
|
|
63497
|
+
* @param config the rindo config
|
|
63498
|
+
* @param compilerCtx the current compiler context
|
|
63499
|
+
* @param buildCtx the current build context
|
|
63500
|
+
* @param outputTarget a DIST_COLLECTION output target
|
|
63501
|
+
*/
|
|
63502
|
+
const validateDistCollectionPkgJson = async (config, compilerCtx, buildCtx, outputTarget) => {
|
|
63354
63503
|
await Promise.all([
|
|
63355
63504
|
validatePackageFiles(config, compilerCtx, buildCtx, outputTarget),
|
|
63356
63505
|
validateMain(config, compilerCtx, buildCtx, outputTarget),
|
|
63357
|
-
validateModule(config, compilerCtx, buildCtx, outputTarget),
|
|
63358
63506
|
validateCollection$1(config, compilerCtx, buildCtx, outputTarget),
|
|
63359
63507
|
validateBrowser(config, compilerCtx, buildCtx),
|
|
63360
63508
|
]);
|
|
63361
63509
|
};
|
|
63510
|
+
/**
|
|
63511
|
+
* Validate that the `files` field in `package.json` contains directories and
|
|
63512
|
+
* files that are necessary for the `DIST_COLLECTION` output target.
|
|
63513
|
+
*
|
|
63514
|
+
* @param config the rindo config
|
|
63515
|
+
* @param compilerCtx the current compiler context
|
|
63516
|
+
* @param buildCtx the current build context
|
|
63517
|
+
* @param outputTarget a DIST_COLLECTION output target
|
|
63518
|
+
*/
|
|
63362
63519
|
const validatePackageFiles = async (config, compilerCtx, buildCtx, outputTarget) => {
|
|
63363
63520
|
if (!config.devMode && Array.isArray(buildCtx.packageJson.files)) {
|
|
63364
63521
|
const actualDistDir = normalizePath$1(relative$1(config.rootDir, outputTarget.dir));
|
|
@@ -63382,6 +63539,15 @@ const validatePackageFiles = async (config, compilerCtx, buildCtx, outputTarget)
|
|
|
63382
63539
|
}));
|
|
63383
63540
|
}
|
|
63384
63541
|
};
|
|
63542
|
+
/**
|
|
63543
|
+
* Check that the `main` field is set correctly in `package.json` for the
|
|
63544
|
+
* `DIST_COLLECTION` output target.
|
|
63545
|
+
*
|
|
63546
|
+
* @param config the rindo config
|
|
63547
|
+
* @param compilerCtx the current compiler context
|
|
63548
|
+
* @param buildCtx the current build context
|
|
63549
|
+
* @param outputTarget a DIST_COLLECTION output target
|
|
63550
|
+
*/
|
|
63385
63551
|
const validateMain = (config, compilerCtx, buildCtx, outputTarget) => {
|
|
63386
63552
|
const mainAbs = join(outputTarget.dir, 'index.cjs.js');
|
|
63387
63553
|
const mainRel = relative$1(config.rootDir, mainAbs);
|
|
@@ -63394,26 +63560,76 @@ const validateMain = (config, compilerCtx, buildCtx, outputTarget) => {
|
|
|
63394
63560
|
packageJsonWarn(config, compilerCtx, buildCtx, msg, `"main"`);
|
|
63395
63561
|
}
|
|
63396
63562
|
};
|
|
63397
|
-
|
|
63398
|
-
|
|
63563
|
+
/**
|
|
63564
|
+
* Validate the package.json 'module' field, taking into account output targets
|
|
63565
|
+
* and other configuration details. This will look for a value for the `module`
|
|
63566
|
+
* field. If not present it will set a relevant warning message with an
|
|
63567
|
+
* output-target specific recommended value. If it is present and is not equal
|
|
63568
|
+
* to that recommended value it will set a different warning message.
|
|
63569
|
+
*
|
|
63570
|
+
* @param config the current user-supplied configuration
|
|
63571
|
+
* @param compilerCtx the compiler context
|
|
63572
|
+
* @param buildCtx the build context
|
|
63573
|
+
* @returns an empty Promise
|
|
63574
|
+
*/
|
|
63575
|
+
const validateModule = async (config, compilerCtx, buildCtx) => {
|
|
63399
63576
|
const currentModule = buildCtx.packageJson.module;
|
|
63400
|
-
const
|
|
63401
|
-
const distRel = relative$1(config.rootDir, distAbs);
|
|
63402
|
-
let recommendedRelPath = distRel;
|
|
63403
|
-
if (customElementsOutput) {
|
|
63404
|
-
const customElementsAbs = join(customElementsOutput.dir, 'index.js');
|
|
63405
|
-
recommendedRelPath = relative$1(config.rootDir, customElementsAbs);
|
|
63406
|
-
}
|
|
63577
|
+
const recommendedRelPath = recommendedModulePath(config);
|
|
63407
63578
|
if (!isString$1(currentModule)) {
|
|
63408
|
-
|
|
63579
|
+
let msg = 'package.json "module" property is required when generating a distribution.';
|
|
63580
|
+
if (recommendedRelPath !== null) {
|
|
63581
|
+
msg += ` It's recommended to set the "module" property to: ${normalizePath$1(recommendedRelPath)}`;
|
|
63582
|
+
}
|
|
63409
63583
|
packageJsonWarn(config, compilerCtx, buildCtx, msg, `"module"`);
|
|
63584
|
+
return;
|
|
63410
63585
|
}
|
|
63411
|
-
|
|
63412
|
-
|
|
63413
|
-
const msg = `package.json "module" property is set to "${currentModule}". It's recommended to set the "module" property to: ${recommendedRelPath}`;
|
|
63586
|
+
if (recommendedRelPath !== null && normalizePath$1(recommendedRelPath) !== normalizePath$1(currentModule)) {
|
|
63587
|
+
const msg = `package.json "module" property is set to "${currentModule}". It's recommended to set the "module" property to: ${normalizePath$1(recommendedRelPath)}`;
|
|
63414
63588
|
packageJsonWarn(config, compilerCtx, buildCtx, msg, `"module"`);
|
|
63415
63589
|
}
|
|
63416
63590
|
};
|
|
63591
|
+
/**
|
|
63592
|
+
* Get the recommended `"module"` path for `package.json` given the output
|
|
63593
|
+
* targets that a user has set on their config.
|
|
63594
|
+
*
|
|
63595
|
+
* @param config the user-supplied Rindo configuration
|
|
63596
|
+
* @returns a recommended module path or a null value to indicate no default
|
|
63597
|
+
* value is supplied
|
|
63598
|
+
*/
|
|
63599
|
+
function recommendedModulePath(config) {
|
|
63600
|
+
const customElementsBundleOT = config.outputTargets.find(isOutputTargetDistCustomElementsBundle);
|
|
63601
|
+
const customElementsOT = config.outputTargets.find(isOutputTargetDistCustomElements);
|
|
63602
|
+
const distCollectionOT = config.outputTargets.find(isOutputTargetDistCollection);
|
|
63603
|
+
// If we're using `dist-custom-elements` then the preferred "module" field
|
|
63604
|
+
// value is `$OUTPUT_DIR/components/index.js`
|
|
63605
|
+
//
|
|
63606
|
+
// Additionally, the `DIST_CUSTOM_ELEMENTS` output target should override
|
|
63607
|
+
// `DIST_CUSTOM_ELEMENTS_BUNDLE` and `DIST_COLLECTION` output targets if
|
|
63608
|
+
// they're also set, so we return first with this one.
|
|
63609
|
+
if (customElementsOT) {
|
|
63610
|
+
const componentsIndexAbs = join(customElementsOT.dir, 'components', 'index.js');
|
|
63611
|
+
return relative$1(config.rootDir, componentsIndexAbs);
|
|
63612
|
+
}
|
|
63613
|
+
if (customElementsBundleOT) {
|
|
63614
|
+
const customElementsAbs = join(customElementsBundleOT.dir, 'index.js');
|
|
63615
|
+
return relative$1(config.rootDir, customElementsAbs);
|
|
63616
|
+
}
|
|
63617
|
+
if (distCollectionOT) {
|
|
63618
|
+
return relative$1(config.rootDir, join(distCollectionOT.dir, 'index.js'));
|
|
63619
|
+
}
|
|
63620
|
+
// if no output target for which we define a recommended output target is set
|
|
63621
|
+
// we return `null`
|
|
63622
|
+
return null;
|
|
63623
|
+
}
|
|
63624
|
+
/**
|
|
63625
|
+
* Check that the `types` field is set correctly in `package.json` for the
|
|
63626
|
+
* `DIST_COLLECTION` output target.
|
|
63627
|
+
*
|
|
63628
|
+
* @param config the rindo config
|
|
63629
|
+
* @param compilerCtx the current compiler context
|
|
63630
|
+
* @param buildCtx the current build context
|
|
63631
|
+
* @param outputTarget a DIST_COLLECTION output target
|
|
63632
|
+
*/
|
|
63417
63633
|
const validateTypes = async (config, compilerCtx, buildCtx, outputTarget) => {
|
|
63418
63634
|
const typesAbs = getComponentsDtsTypesFilePath(outputTarget);
|
|
63419
63635
|
const recommendedPath = relative$1(config.rootDir, typesAbs);
|
|
@@ -63437,6 +63653,15 @@ const validateTypes = async (config, compilerCtx, buildCtx, outputTarget) => {
|
|
|
63437
63653
|
}
|
|
63438
63654
|
}
|
|
63439
63655
|
};
|
|
63656
|
+
/**
|
|
63657
|
+
* Check that the `collection` field is set correctly in `package.json` for the
|
|
63658
|
+
* `DIST_COLLECTION` output target.
|
|
63659
|
+
*
|
|
63660
|
+
* @param config the rindo config
|
|
63661
|
+
* @param compilerCtx the current compiler context
|
|
63662
|
+
* @param buildCtx the current build context
|
|
63663
|
+
* @param outputTarget a DIST_COLLECTION output target
|
|
63664
|
+
*/
|
|
63440
63665
|
const validateCollection$1 = (config, compilerCtx, buildCtx, outputTarget) => {
|
|
63441
63666
|
if (outputTarget.collectionDir) {
|
|
63442
63667
|
const collectionRel = join(relative$1(config.rootDir, outputTarget.collectionDir), COLLECTION_MANIFEST_FILE_NAME);
|
|
@@ -63446,19 +63671,51 @@ const validateCollection$1 = (config, compilerCtx, buildCtx, outputTarget) => {
|
|
|
63446
63671
|
}
|
|
63447
63672
|
}
|
|
63448
63673
|
};
|
|
63674
|
+
/**
|
|
63675
|
+
* Check that the `browser` field is set correctly in `package.json` for the
|
|
63676
|
+
* `DIST_COLLECTION` output target.
|
|
63677
|
+
*
|
|
63678
|
+
* @param config the rindo config
|
|
63679
|
+
* @param compilerCtx the current compiler context
|
|
63680
|
+
* @param buildCtx the current build context
|
|
63681
|
+
*/
|
|
63449
63682
|
const validateBrowser = (config, compilerCtx, buildCtx) => {
|
|
63450
63683
|
if (isString$1(buildCtx.packageJson.browser)) {
|
|
63451
63684
|
const msg = `package.json "browser" property is set to "${buildCtx.packageJson.browser}". However, for maximum compatibility with all bundlers it's recommended to not set the "browser" property and instead ensure both "module" and "main" properties are set.`;
|
|
63452
63685
|
packageJsonWarn(config, compilerCtx, buildCtx, msg, `"browser"`);
|
|
63453
63686
|
}
|
|
63454
63687
|
};
|
|
63455
|
-
|
|
63456
|
-
|
|
63688
|
+
/**
|
|
63689
|
+
* Build a diagnostic for an error resulting from a particular field in a
|
|
63690
|
+
* package.json file
|
|
63691
|
+
*
|
|
63692
|
+
* @param config the rindo config
|
|
63693
|
+
* @param compilerCtx the current compiler context
|
|
63694
|
+
* @param buildCtx the current build context
|
|
63695
|
+
* @param msg an error string
|
|
63696
|
+
* @param jsonField the key for the field which caused the error, used for
|
|
63697
|
+
* finding the error line in the original JSON file
|
|
63698
|
+
* @returns a diagnostic object
|
|
63699
|
+
*/
|
|
63700
|
+
const packageJsonError = (config, compilerCtx, buildCtx, msg, jsonField) => {
|
|
63701
|
+
const err = buildJsonFileError(compilerCtx, buildCtx.diagnostics, config.packageJsonFilePath, msg, jsonField);
|
|
63457
63702
|
err.header = `Package Json`;
|
|
63458
63703
|
return err;
|
|
63459
63704
|
};
|
|
63460
|
-
|
|
63461
|
-
|
|
63705
|
+
/**
|
|
63706
|
+
* Build a diagnostic for a warning resulting from a particular field in a
|
|
63707
|
+
* package.json file
|
|
63708
|
+
*
|
|
63709
|
+
* @param config the rindo config
|
|
63710
|
+
* @param compilerCtx the current compiler context
|
|
63711
|
+
* @param buildCtx the current build context
|
|
63712
|
+
* @param msg an error string
|
|
63713
|
+
* @param jsonField the key for the field which caused the error, used for
|
|
63714
|
+
* finding the error line in the original JSON file
|
|
63715
|
+
* @returns a diagnostic object
|
|
63716
|
+
*/
|
|
63717
|
+
const packageJsonWarn = (config, compilerCtx, buildCtx, msg, jsonField) => {
|
|
63718
|
+
const warn = buildJsonFileError(compilerCtx, buildCtx.diagnostics, config.packageJsonFilePath, msg, jsonField);
|
|
63462
63719
|
warn.header = `Package Json`;
|
|
63463
63720
|
warn.level = 'warn';
|
|
63464
63721
|
return warn;
|
|
@@ -64917,14 +65174,37 @@ const updateCompilerCtxCache = (config, compilerCtx, path, kind) => {
|
|
|
64917
65174
|
}
|
|
64918
65175
|
};
|
|
64919
65176
|
|
|
65177
|
+
/**
|
|
65178
|
+
* All the Boolean options supported by the Rindo CLI
|
|
65179
|
+
*/
|
|
65180
|
+
/**
|
|
65181
|
+
* Helper function for initializing a `ConfigFlags` object. Provide any overrides
|
|
65182
|
+
* for default values and off you go!
|
|
65183
|
+
*
|
|
65184
|
+
* @param init an object with any overrides for default values
|
|
65185
|
+
* @returns a complete CLI flag object
|
|
65186
|
+
*/
|
|
65187
|
+
const createConfigFlags = (init = {}) => {
|
|
65188
|
+
const flags = {
|
|
65189
|
+
task: null,
|
|
65190
|
+
args: [],
|
|
65191
|
+
knownArgs: [],
|
|
65192
|
+
unknownArgs: [],
|
|
65193
|
+
...init,
|
|
65194
|
+
};
|
|
65195
|
+
return flags;
|
|
65196
|
+
};
|
|
65197
|
+
|
|
64920
65198
|
const getConfig = (userConfig) => {
|
|
64921
|
-
var _a, _b;
|
|
64922
|
-
const
|
|
64923
|
-
const
|
|
64924
|
-
|
|
64925
|
-
|
|
64926
|
-
|
|
64927
|
-
|
|
65199
|
+
var _a, _b, _c, _d;
|
|
65200
|
+
const logger = (_a = userConfig.logger) !== null && _a !== void 0 ? _a : createLogger();
|
|
65201
|
+
const config = {
|
|
65202
|
+
...userConfig,
|
|
65203
|
+
flags: createConfigFlags((_b = userConfig.flags) !== null && _b !== void 0 ? _b : {}),
|
|
65204
|
+
logger,
|
|
65205
|
+
outputTargets: (_c = userConfig.outputTargets) !== null && _c !== void 0 ? _c : [],
|
|
65206
|
+
sys: (_d = userConfig.sys) !== null && _d !== void 0 ? _d : createSystem({ logger }),
|
|
65207
|
+
};
|
|
64928
65208
|
setPlatformPath(config.sys.platformPath);
|
|
64929
65209
|
if (config.flags.debug || config.flags.verbose) {
|
|
64930
65210
|
config.logLevel = 'debug';
|
|
@@ -65630,7 +65910,7 @@ const getComponentPathContent = (componentGraph, outputTarget) => {
|
|
|
65630
65910
|
const dependencies = [
|
|
65631
65911
|
{
|
|
65632
65912
|
name: "@rindo/core",
|
|
65633
|
-
version: "2.17.
|
|
65913
|
+
version: "2.17.2",
|
|
65634
65914
|
main: "compiler/rindo.js",
|
|
65635
65915
|
resources: [
|
|
65636
65916
|
"package.json",
|
|
@@ -66983,7 +67263,8 @@ const validateWorkers = (config) => {
|
|
|
66983
67263
|
* @returns an object with config and diagnostics props
|
|
66984
67264
|
*/
|
|
66985
67265
|
const validateConfig = (userConfig = {}, bootstrapConfig) => {
|
|
66986
|
-
|
|
67266
|
+
var _a, _b, _c;
|
|
67267
|
+
const config = Object.assign({}, userConfig); // not positive it's json safe
|
|
66987
67268
|
const diagnostics = [];
|
|
66988
67269
|
const logger = bootstrapConfig.logger || config.logger || createLogger();
|
|
66989
67270
|
const validatedConfig = {
|
|
@@ -66991,6 +67272,8 @@ const validateConfig = (userConfig = {}, bootstrapConfig) => {
|
|
|
66991
67272
|
// flags _should_ be JSON safe
|
|
66992
67273
|
flags: JSON.parse(JSON.stringify(config.flags || {})),
|
|
66993
67274
|
logger,
|
|
67275
|
+
outputTargets: (_a = config.outputTargets) !== null && _a !== void 0 ? _a : [],
|
|
67276
|
+
sys: (_c = (_b = config.sys) !== null && _b !== void 0 ? _b : bootstrapConfig.sys) !== null && _c !== void 0 ? _c : createSystem({ logger }),
|
|
66994
67277
|
};
|
|
66995
67278
|
// default devMode false
|
|
66996
67279
|
if (validatedConfig.flags.prod) {
|
|
@@ -67257,6 +67540,7 @@ const hasRindoConfigInclude = (includeProp) => Array.isArray(includeProp) && inc
|
|
|
67257
67540
|
* @public
|
|
67258
67541
|
*/
|
|
67259
67542
|
const loadConfig = async (init = {}) => {
|
|
67543
|
+
var _a;
|
|
67260
67544
|
const results = {
|
|
67261
67545
|
config: null,
|
|
67262
67546
|
diagnostics: [],
|
|
@@ -67271,9 +67555,12 @@ const loadConfig = async (init = {}) => {
|
|
|
67271
67555
|
};
|
|
67272
67556
|
const unknownConfig = {};
|
|
67273
67557
|
try {
|
|
67274
|
-
const sys = init.sys || createSystem();
|
|
67275
67558
|
const config = init.config || {};
|
|
67276
67559
|
let configPath = init.configPath || config.configPath;
|
|
67560
|
+
// Pull the {@link CompilerSystem} out of the initialization object, or create one if it does not exist.
|
|
67561
|
+
// This entity is needed to load the project's configuration (and therefore needs to be created before it can be
|
|
67562
|
+
// attached to a configuration entity, validated or otherwise)
|
|
67563
|
+
const sys = (_a = init.sys) !== null && _a !== void 0 ? _a : createSystem();
|
|
67277
67564
|
const loadedConfigFile = await loadConfigFile(sys, results.diagnostics, configPath);
|
|
67278
67565
|
if (hasError(results.diagnostics)) {
|
|
67279
67566
|
return results;
|
|
@@ -67566,7 +67853,7 @@ const convertStaticToMeta = (config, compilerCtx, buildCtx, typeChecker, collect
|
|
|
67566
67853
|
let moduleFile;
|
|
67567
67854
|
const visitNode = (node) => {
|
|
67568
67855
|
if (t.isClassDeclaration(node)) {
|
|
67569
|
-
return parseStaticComponentMeta(compilerCtx, typeChecker, node, moduleFile,
|
|
67856
|
+
return parseStaticComponentMeta(compilerCtx, typeChecker, node, moduleFile, transformOpts);
|
|
67570
67857
|
}
|
|
67571
67858
|
else if (t.isImportDeclaration(node)) {
|
|
67572
67859
|
parseModuleImport(config, compilerCtx, buildCtx, moduleFile, dirPath, node, !transformOpts.isolatedModules);
|