svelte2tsx 0.5.20 → 0.5.22
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/index.js +48 -38
- package/index.mjs +48 -38
- package/package.json +2 -2
- package/svelte-html-do-not-use.d.ts +5 -4
- package/svelte-jsx.d.ts +5 -4
- package/svelte-shims.d.ts +11 -3
package/index.js
CHANGED
|
@@ -1808,9 +1808,10 @@ function handleAttribute$1(htmlx, str, attr, parent, preserveCase) {
|
|
|
1808
1808
|
if (parent.type == 'Element') {
|
|
1809
1809
|
const sapperLinkActions = ['sapper:prefetch', 'sapper:noscroll'];
|
|
1810
1810
|
const sveltekitLinkActions = [
|
|
1811
|
-
'sveltekit
|
|
1812
|
-
'sveltekit
|
|
1813
|
-
'sveltekit
|
|
1811
|
+
'data-sveltekit-preload-code',
|
|
1812
|
+
'data-sveltekit-preload-data',
|
|
1813
|
+
'data-sveltekit-noscroll',
|
|
1814
|
+
'data-sveltekit-reload'
|
|
1814
1815
|
];
|
|
1815
1816
|
// skip Attribute shorthand, that is handled below
|
|
1816
1817
|
if ((attr.value !== true &&
|
|
@@ -3440,6 +3441,10 @@ const voidTags = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,tra
|
|
|
3440
3441
|
* ```
|
|
3441
3442
|
*/
|
|
3442
3443
|
class Element {
|
|
3444
|
+
get name() {
|
|
3445
|
+
this.referencedName = true;
|
|
3446
|
+
return this._name;
|
|
3447
|
+
}
|
|
3443
3448
|
/**
|
|
3444
3449
|
* @param str The MagicString instance used to manipulate the text
|
|
3445
3450
|
* @param node The Svelte AST node that represents this element
|
|
@@ -3504,10 +3509,6 @@ class Element {
|
|
|
3504
3509
|
}
|
|
3505
3510
|
}
|
|
3506
3511
|
}
|
|
3507
|
-
get name() {
|
|
3508
|
-
this.referencedName = true;
|
|
3509
|
-
return this._name;
|
|
3510
|
-
}
|
|
3511
3512
|
/**
|
|
3512
3513
|
* attribute={foo} --> "attribute": foo,
|
|
3513
3514
|
* @param name Attribute name
|
|
@@ -3721,6 +3722,13 @@ class Element {
|
|
|
3721
3722
|
* ```
|
|
3722
3723
|
*/
|
|
3723
3724
|
class InlineComponent {
|
|
3725
|
+
get name() {
|
|
3726
|
+
if (this.addNameConstDeclaration) {
|
|
3727
|
+
this.addNameConstDeclaration();
|
|
3728
|
+
this.addNameConstDeclaration = undefined;
|
|
3729
|
+
}
|
|
3730
|
+
return this._name;
|
|
3731
|
+
}
|
|
3724
3732
|
constructor(str, node, parent) {
|
|
3725
3733
|
this.str = str;
|
|
3726
3734
|
this.node = node;
|
|
@@ -3759,9 +3767,14 @@ class InlineComponent {
|
|
|
3759
3767
|
// is actually a proper Svelte component, which would lead to errors
|
|
3760
3768
|
// when accessing things like $$prop_def. Therefore widen the type
|
|
3761
3769
|
// here, falling back to a any-typed component to ensure the user doesn't
|
|
3762
|
-
// get weird
|
|
3770
|
+
// get weird followup-errors all over the place. The diagnostic error
|
|
3763
3771
|
// will be on the __sveltets_2_ensureComponent part, giving a more helpful message
|
|
3764
|
-
|
|
3772
|
+
// The name is reversed here so that when the component is undeclared,
|
|
3773
|
+
// TypeScript won't suggest the undeclared variable to be a misspelling of the generated variable
|
|
3774
|
+
this._name =
|
|
3775
|
+
'$$_' +
|
|
3776
|
+
Array.from(sanitizePropName(this.node.name)).reverse().join('') +
|
|
3777
|
+
this.computeDepth();
|
|
3765
3778
|
const constructorName = this._name + 'C';
|
|
3766
3779
|
const nodeNameStart = isSvelteComponentTag
|
|
3767
3780
|
? this.node.expression.start
|
|
@@ -3774,13 +3787,6 @@ class InlineComponent {
|
|
|
3774
3787
|
this.startEndTransformation.push('}});');
|
|
3775
3788
|
}
|
|
3776
3789
|
}
|
|
3777
|
-
get name() {
|
|
3778
|
-
if (this.addNameConstDeclaration) {
|
|
3779
|
-
this.addNameConstDeclaration();
|
|
3780
|
-
this.addNameConstDeclaration = undefined;
|
|
3781
|
-
}
|
|
3782
|
-
return this._name;
|
|
3783
|
-
}
|
|
3784
3790
|
/**
|
|
3785
3791
|
* prop={foo} --> "prop": foo,
|
|
3786
3792
|
* @param name Property name
|
|
@@ -3949,7 +3955,7 @@ function handleAttribute(str, attr, parent, preserveCase, element) {
|
|
|
3949
3955
|
}
|
|
3950
3956
|
const addAttribute = element instanceof Element
|
|
3951
3957
|
? (name, value) => {
|
|
3952
|
-
if (attr.name.startsWith('data-')) {
|
|
3958
|
+
if (attr.name.startsWith('data-') && !attr.name.startsWith('data-sveltekit-')) {
|
|
3953
3959
|
// any attribute prefixed with data- is valid, but we can't
|
|
3954
3960
|
// type that statically, so we need this workaround
|
|
3955
3961
|
name.unshift('...__sveltets_2_empty({');
|
|
@@ -4947,17 +4953,17 @@ function is$$EventsDeclaration(node) {
|
|
|
4947
4953
|
* - If no, track all invocations of it to get the event names
|
|
4948
4954
|
*/
|
|
4949
4955
|
class ComponentEvents {
|
|
4956
|
+
get eventsClass() {
|
|
4957
|
+
return this.componentEventsInterface.isPresent()
|
|
4958
|
+
? this.componentEventsInterface
|
|
4959
|
+
: this.componentEventsFromEventsMap;
|
|
4960
|
+
}
|
|
4950
4961
|
constructor(eventHandler, strictEvents, str) {
|
|
4951
4962
|
this.strictEvents = strictEvents;
|
|
4952
4963
|
this.str = str;
|
|
4953
4964
|
this.componentEventsInterface = new ComponentEventsFromInterface();
|
|
4954
4965
|
this.componentEventsFromEventsMap = new ComponentEventsFromEventsMap(eventHandler);
|
|
4955
4966
|
}
|
|
4956
|
-
get eventsClass() {
|
|
4957
|
-
return this.componentEventsInterface.isPresent()
|
|
4958
|
-
? this.componentEventsInterface
|
|
4959
|
-
: this.componentEventsFromEventsMap;
|
|
4960
|
-
}
|
|
4961
4967
|
/**
|
|
4962
4968
|
* Collect state and create the API which will be part
|
|
4963
4969
|
* of the return object of the `svelte2tsx` function.
|
|
@@ -5260,11 +5266,12 @@ class EventHandler {
|
|
|
5260
5266
|
// pass-through/ bubble
|
|
5261
5267
|
if (!node.expression) {
|
|
5262
5268
|
if (parent.type === 'InlineComponent') {
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5269
|
+
if (parent.name !== 'svelte:self') {
|
|
5270
|
+
this.handleEventHandlerBubble(parent, eventName);
|
|
5271
|
+
}
|
|
5272
|
+
return;
|
|
5267
5273
|
}
|
|
5274
|
+
this.bubbledEvents.set(eventName, getEventDefExpressionForNonComponent(eventName, parent));
|
|
5268
5275
|
}
|
|
5269
5276
|
}
|
|
5270
5277
|
handleIdentifier(node, parent, prop) {
|
|
@@ -5297,7 +5304,7 @@ class EventHandler {
|
|
|
5297
5304
|
this.bubbledEvents.set(eventName, exist ? [].concat(exist, exp) : exp);
|
|
5298
5305
|
}
|
|
5299
5306
|
}
|
|
5300
|
-
function
|
|
5307
|
+
function getEventDefExpressionForNonComponent(eventName, ele) {
|
|
5301
5308
|
switch (ele.type) {
|
|
5302
5309
|
case 'Element':
|
|
5303
5310
|
return `__sveltets_1_mapElementEvent('${eventName}')`;
|
|
@@ -5481,13 +5488,13 @@ class ExportedNames {
|
|
|
5481
5488
|
}
|
|
5482
5489
|
createClassGetters() {
|
|
5483
5490
|
return Array.from(this.getters)
|
|
5484
|
-
.map((name) =>
|
|
5491
|
+
.map((name) =>
|
|
5492
|
+
// getters are const/classes/functions, which are always defined.
|
|
5493
|
+
// We have to remove the `| undefined` from the type here because it was necessary to
|
|
5494
|
+
// be added in a previous step so people are not expected to provide these as props.
|
|
5495
|
+
`\n get ${name}() { return __sveltets_2_nonNullable(this.$$prop_def.${name}) }`)
|
|
5485
5496
|
.join('');
|
|
5486
5497
|
}
|
|
5487
|
-
createRenderFunctionGetterStr() {
|
|
5488
|
-
const properties = Array.from(this.getters).map((name) => `${name}: ${name}`);
|
|
5489
|
-
return `{${properties.join(', ')}}`;
|
|
5490
|
-
}
|
|
5491
5498
|
createClassAccessors() {
|
|
5492
5499
|
const accessors = [];
|
|
5493
5500
|
for (const value of this.exports.values()) {
|
|
@@ -5497,7 +5504,7 @@ class ExportedNames {
|
|
|
5497
5504
|
accessors.push(value.identifierText);
|
|
5498
5505
|
}
|
|
5499
5506
|
return accessors
|
|
5500
|
-
.map((name) => `\n get ${name}() { return
|
|
5507
|
+
.map((name) => `\n get ${name}() { return this.$$prop_def.${name} }` +
|
|
5501
5508
|
`\n /**accessor*/\n set ${name}(_) {}`)
|
|
5502
5509
|
.join('');
|
|
5503
5510
|
}
|
|
@@ -5605,12 +5612,16 @@ class ExportedNames {
|
|
|
5605
5612
|
this.createReturnElementsType(others).join(',') +
|
|
5606
5613
|
'}}');
|
|
5607
5614
|
}
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5615
|
+
if (names.length === 0) {
|
|
5616
|
+
// Necessary, because {} roughly equals to any
|
|
5617
|
+
return isTsFile
|
|
5618
|
+
? '{} as Record<string, never>'
|
|
5619
|
+
: '/** @type {Record<string, never>} */ ({})';
|
|
5620
|
+
}
|
|
5621
|
+
const dontAddTypeDef = !isTsFile || names.every(([_, value]) => !value.type && value.required);
|
|
5611
5622
|
const returnElements = this.createReturnElements(names, dontAddTypeDef);
|
|
5612
5623
|
if (dontAddTypeDef) {
|
|
5613
|
-
//
|
|
5624
|
+
// Only `typeof` exports -> omit the `as {...}` completely.
|
|
5614
5625
|
// If not TS, omit the types to not have a "cannot use types in jsx" error.
|
|
5615
5626
|
return `{${returnElements.join(' , ')}}`;
|
|
5616
5627
|
}
|
|
@@ -6899,7 +6910,6 @@ function createRenderFunction({ str, scriptTag, scriptDestination, slots, events
|
|
|
6899
6910
|
'}';
|
|
6900
6911
|
const returnString = `\nreturn { props: ${exportedNames.createPropsStr(isTsFile)}` +
|
|
6901
6912
|
`, slots: ${slotsAsDef}` +
|
|
6902
|
-
`, getters: ${exportedNames.createRenderFunctionGetterStr()}` +
|
|
6903
6913
|
`, events: ${events.toDefString()} }}`;
|
|
6904
6914
|
// wrap template with callback
|
|
6905
6915
|
if (useNewTransformation) {
|
package/index.mjs
CHANGED
|
@@ -1778,9 +1778,10 @@ function handleAttribute$1(htmlx, str, attr, parent, preserveCase) {
|
|
|
1778
1778
|
if (parent.type == 'Element') {
|
|
1779
1779
|
const sapperLinkActions = ['sapper:prefetch', 'sapper:noscroll'];
|
|
1780
1780
|
const sveltekitLinkActions = [
|
|
1781
|
-
'sveltekit
|
|
1782
|
-
'sveltekit
|
|
1783
|
-
'sveltekit
|
|
1781
|
+
'data-sveltekit-preload-code',
|
|
1782
|
+
'data-sveltekit-preload-data',
|
|
1783
|
+
'data-sveltekit-noscroll',
|
|
1784
|
+
'data-sveltekit-reload'
|
|
1784
1785
|
];
|
|
1785
1786
|
// skip Attribute shorthand, that is handled below
|
|
1786
1787
|
if ((attr.value !== true &&
|
|
@@ -3410,6 +3411,10 @@ const voidTags = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,tra
|
|
|
3410
3411
|
* ```
|
|
3411
3412
|
*/
|
|
3412
3413
|
class Element {
|
|
3414
|
+
get name() {
|
|
3415
|
+
this.referencedName = true;
|
|
3416
|
+
return this._name;
|
|
3417
|
+
}
|
|
3413
3418
|
/**
|
|
3414
3419
|
* @param str The MagicString instance used to manipulate the text
|
|
3415
3420
|
* @param node The Svelte AST node that represents this element
|
|
@@ -3474,10 +3479,6 @@ class Element {
|
|
|
3474
3479
|
}
|
|
3475
3480
|
}
|
|
3476
3481
|
}
|
|
3477
|
-
get name() {
|
|
3478
|
-
this.referencedName = true;
|
|
3479
|
-
return this._name;
|
|
3480
|
-
}
|
|
3481
3482
|
/**
|
|
3482
3483
|
* attribute={foo} --> "attribute": foo,
|
|
3483
3484
|
* @param name Attribute name
|
|
@@ -3691,6 +3692,13 @@ class Element {
|
|
|
3691
3692
|
* ```
|
|
3692
3693
|
*/
|
|
3693
3694
|
class InlineComponent {
|
|
3695
|
+
get name() {
|
|
3696
|
+
if (this.addNameConstDeclaration) {
|
|
3697
|
+
this.addNameConstDeclaration();
|
|
3698
|
+
this.addNameConstDeclaration = undefined;
|
|
3699
|
+
}
|
|
3700
|
+
return this._name;
|
|
3701
|
+
}
|
|
3694
3702
|
constructor(str, node, parent) {
|
|
3695
3703
|
this.str = str;
|
|
3696
3704
|
this.node = node;
|
|
@@ -3729,9 +3737,14 @@ class InlineComponent {
|
|
|
3729
3737
|
// is actually a proper Svelte component, which would lead to errors
|
|
3730
3738
|
// when accessing things like $$prop_def. Therefore widen the type
|
|
3731
3739
|
// here, falling back to a any-typed component to ensure the user doesn't
|
|
3732
|
-
// get weird
|
|
3740
|
+
// get weird followup-errors all over the place. The diagnostic error
|
|
3733
3741
|
// will be on the __sveltets_2_ensureComponent part, giving a more helpful message
|
|
3734
|
-
|
|
3742
|
+
// The name is reversed here so that when the component is undeclared,
|
|
3743
|
+
// TypeScript won't suggest the undeclared variable to be a misspelling of the generated variable
|
|
3744
|
+
this._name =
|
|
3745
|
+
'$$_' +
|
|
3746
|
+
Array.from(sanitizePropName(this.node.name)).reverse().join('') +
|
|
3747
|
+
this.computeDepth();
|
|
3735
3748
|
const constructorName = this._name + 'C';
|
|
3736
3749
|
const nodeNameStart = isSvelteComponentTag
|
|
3737
3750
|
? this.node.expression.start
|
|
@@ -3744,13 +3757,6 @@ class InlineComponent {
|
|
|
3744
3757
|
this.startEndTransformation.push('}});');
|
|
3745
3758
|
}
|
|
3746
3759
|
}
|
|
3747
|
-
get name() {
|
|
3748
|
-
if (this.addNameConstDeclaration) {
|
|
3749
|
-
this.addNameConstDeclaration();
|
|
3750
|
-
this.addNameConstDeclaration = undefined;
|
|
3751
|
-
}
|
|
3752
|
-
return this._name;
|
|
3753
|
-
}
|
|
3754
3760
|
/**
|
|
3755
3761
|
* prop={foo} --> "prop": foo,
|
|
3756
3762
|
* @param name Property name
|
|
@@ -3919,7 +3925,7 @@ function handleAttribute(str, attr, parent, preserveCase, element) {
|
|
|
3919
3925
|
}
|
|
3920
3926
|
const addAttribute = element instanceof Element
|
|
3921
3927
|
? (name, value) => {
|
|
3922
|
-
if (attr.name.startsWith('data-')) {
|
|
3928
|
+
if (attr.name.startsWith('data-') && !attr.name.startsWith('data-sveltekit-')) {
|
|
3923
3929
|
// any attribute prefixed with data- is valid, but we can't
|
|
3924
3930
|
// type that statically, so we need this workaround
|
|
3925
3931
|
name.unshift('...__sveltets_2_empty({');
|
|
@@ -4917,17 +4923,17 @@ function is$$EventsDeclaration(node) {
|
|
|
4917
4923
|
* - If no, track all invocations of it to get the event names
|
|
4918
4924
|
*/
|
|
4919
4925
|
class ComponentEvents {
|
|
4926
|
+
get eventsClass() {
|
|
4927
|
+
return this.componentEventsInterface.isPresent()
|
|
4928
|
+
? this.componentEventsInterface
|
|
4929
|
+
: this.componentEventsFromEventsMap;
|
|
4930
|
+
}
|
|
4920
4931
|
constructor(eventHandler, strictEvents, str) {
|
|
4921
4932
|
this.strictEvents = strictEvents;
|
|
4922
4933
|
this.str = str;
|
|
4923
4934
|
this.componentEventsInterface = new ComponentEventsFromInterface();
|
|
4924
4935
|
this.componentEventsFromEventsMap = new ComponentEventsFromEventsMap(eventHandler);
|
|
4925
4936
|
}
|
|
4926
|
-
get eventsClass() {
|
|
4927
|
-
return this.componentEventsInterface.isPresent()
|
|
4928
|
-
? this.componentEventsInterface
|
|
4929
|
-
: this.componentEventsFromEventsMap;
|
|
4930
|
-
}
|
|
4931
4937
|
/**
|
|
4932
4938
|
* Collect state and create the API which will be part
|
|
4933
4939
|
* of the return object of the `svelte2tsx` function.
|
|
@@ -5230,11 +5236,12 @@ class EventHandler {
|
|
|
5230
5236
|
// pass-through/ bubble
|
|
5231
5237
|
if (!node.expression) {
|
|
5232
5238
|
if (parent.type === 'InlineComponent') {
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5239
|
+
if (parent.name !== 'svelte:self') {
|
|
5240
|
+
this.handleEventHandlerBubble(parent, eventName);
|
|
5241
|
+
}
|
|
5242
|
+
return;
|
|
5237
5243
|
}
|
|
5244
|
+
this.bubbledEvents.set(eventName, getEventDefExpressionForNonComponent(eventName, parent));
|
|
5238
5245
|
}
|
|
5239
5246
|
}
|
|
5240
5247
|
handleIdentifier(node, parent, prop) {
|
|
@@ -5267,7 +5274,7 @@ class EventHandler {
|
|
|
5267
5274
|
this.bubbledEvents.set(eventName, exist ? [].concat(exist, exp) : exp);
|
|
5268
5275
|
}
|
|
5269
5276
|
}
|
|
5270
|
-
function
|
|
5277
|
+
function getEventDefExpressionForNonComponent(eventName, ele) {
|
|
5271
5278
|
switch (ele.type) {
|
|
5272
5279
|
case 'Element':
|
|
5273
5280
|
return `__sveltets_1_mapElementEvent('${eventName}')`;
|
|
@@ -5451,13 +5458,13 @@ class ExportedNames {
|
|
|
5451
5458
|
}
|
|
5452
5459
|
createClassGetters() {
|
|
5453
5460
|
return Array.from(this.getters)
|
|
5454
|
-
.map((name) =>
|
|
5461
|
+
.map((name) =>
|
|
5462
|
+
// getters are const/classes/functions, which are always defined.
|
|
5463
|
+
// We have to remove the `| undefined` from the type here because it was necessary to
|
|
5464
|
+
// be added in a previous step so people are not expected to provide these as props.
|
|
5465
|
+
`\n get ${name}() { return __sveltets_2_nonNullable(this.$$prop_def.${name}) }`)
|
|
5455
5466
|
.join('');
|
|
5456
5467
|
}
|
|
5457
|
-
createRenderFunctionGetterStr() {
|
|
5458
|
-
const properties = Array.from(this.getters).map((name) => `${name}: ${name}`);
|
|
5459
|
-
return `{${properties.join(', ')}}`;
|
|
5460
|
-
}
|
|
5461
5468
|
createClassAccessors() {
|
|
5462
5469
|
const accessors = [];
|
|
5463
5470
|
for (const value of this.exports.values()) {
|
|
@@ -5467,7 +5474,7 @@ class ExportedNames {
|
|
|
5467
5474
|
accessors.push(value.identifierText);
|
|
5468
5475
|
}
|
|
5469
5476
|
return accessors
|
|
5470
|
-
.map((name) => `\n get ${name}() { return
|
|
5477
|
+
.map((name) => `\n get ${name}() { return this.$$prop_def.${name} }` +
|
|
5471
5478
|
`\n /**accessor*/\n set ${name}(_) {}`)
|
|
5472
5479
|
.join('');
|
|
5473
5480
|
}
|
|
@@ -5575,12 +5582,16 @@ class ExportedNames {
|
|
|
5575
5582
|
this.createReturnElementsType(others).join(',') +
|
|
5576
5583
|
'}}');
|
|
5577
5584
|
}
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5585
|
+
if (names.length === 0) {
|
|
5586
|
+
// Necessary, because {} roughly equals to any
|
|
5587
|
+
return isTsFile
|
|
5588
|
+
? '{} as Record<string, never>'
|
|
5589
|
+
: '/** @type {Record<string, never>} */ ({})';
|
|
5590
|
+
}
|
|
5591
|
+
const dontAddTypeDef = !isTsFile || names.every(([_, value]) => !value.type && value.required);
|
|
5581
5592
|
const returnElements = this.createReturnElements(names, dontAddTypeDef);
|
|
5582
5593
|
if (dontAddTypeDef) {
|
|
5583
|
-
//
|
|
5594
|
+
// Only `typeof` exports -> omit the `as {...}` completely.
|
|
5584
5595
|
// If not TS, omit the types to not have a "cannot use types in jsx" error.
|
|
5585
5596
|
return `{${returnElements.join(' , ')}}`;
|
|
5586
5597
|
}
|
|
@@ -6869,7 +6880,6 @@ function createRenderFunction({ str, scriptTag, scriptDestination, slots, events
|
|
|
6869
6880
|
'}';
|
|
6870
6881
|
const returnString = `\nreturn { props: ${exportedNames.createPropsStr(isTsFile)}` +
|
|
6871
6882
|
`, slots: ${slotsAsDef}` +
|
|
6872
|
-
`, getters: ${exportedNames.createRenderFunctionGetterStr()}` +
|
|
6873
6883
|
`, events: ${events.toDefString()} }}`;
|
|
6874
6884
|
// wrap template with callback
|
|
6875
6885
|
if (useNewTransformation) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte2tsx",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.22",
|
|
4
4
|
"description": "Convert Svelte components to TSX for type checking",
|
|
5
5
|
"author": "David Pershouse",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"svelte": "~3.49.0",
|
|
38
38
|
"tiny-glob": "^0.2.6",
|
|
39
39
|
"tslib": "^1.10.0",
|
|
40
|
-
"typescript": "^4.
|
|
40
|
+
"typescript": "^4.9.3"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"svelte": "^3.24",
|
|
@@ -87,7 +87,7 @@ export interface DOMAttributes<T extends EventTarget> {
|
|
|
87
87
|
'on:reset'?: FormEventHandler<T> | undefined | null;
|
|
88
88
|
'on:submit'?: EventHandler<Event, T> | undefined | null; // TODO make this SubmitEvent once we require TS>=4.4
|
|
89
89
|
'on:invalid'?: EventHandler<Event, T> | undefined | null;
|
|
90
|
-
|
|
90
|
+
'on:formdata'?: EventHandler<Event & { readonly formData: FormData; }, T> | undefined | null; // TODO make this FormDataEvent once we require TS>=4.4
|
|
91
91
|
|
|
92
92
|
// Image Events
|
|
93
93
|
'on:load'?: EventHandler | undefined | null;
|
|
@@ -559,9 +559,10 @@ export interface HTMLAnchorAttributes extends HTMLAttributes<HTMLAnchorElement>
|
|
|
559
559
|
referrerpolicy?: ReferrerPolicy | undefined | null;
|
|
560
560
|
|
|
561
561
|
// SvelteKit
|
|
562
|
-
'sveltekit
|
|
563
|
-
'sveltekit
|
|
564
|
-
'sveltekit
|
|
562
|
+
'data-sveltekit-noscroll'?: true | '' | 'off' | undefined | null;
|
|
563
|
+
'data-sveltekit-preload-code'?: true | '' | 'eager' | 'viewport' | 'hover' | 'tap' | 'off' | undefined | null;
|
|
564
|
+
'data-sveltekit-preload-data'?: true | '' | 'hover' | 'tap' | 'off' | undefined | null;
|
|
565
|
+
'data-sveltekit-reload'?: true | '' | 'off' | undefined | null;
|
|
565
566
|
|
|
566
567
|
// Sapper
|
|
567
568
|
'sapper:noscroll'?: true | undefined | null;
|
package/svelte-jsx.d.ts
CHANGED
|
@@ -348,6 +348,7 @@ declare namespace svelte.JSX {
|
|
|
348
348
|
onsubmit?: EventHandler<SubmitEvent, T> | undefined | null;
|
|
349
349
|
oninvalid?: EventHandler<Event, T> | undefined | null;
|
|
350
350
|
onbeforeinput?: EventHandler<InputEvent, T> | undefined | null;
|
|
351
|
+
'on:formdata'?: EventHandler<FormDataEvent, T> | undefined | null;
|
|
351
352
|
|
|
352
353
|
// Image Events
|
|
353
354
|
onload?: EventHandler | undefined | null;
|
|
@@ -1176,10 +1177,10 @@ declare namespace svelte.JSX {
|
|
|
1176
1177
|
}
|
|
1177
1178
|
|
|
1178
1179
|
interface SvelteKitAnchorProps {
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1180
|
+
'data-sveltekit-noscroll'?: true | '' | 'off' | undefined | null;
|
|
1181
|
+
'data-sveltekit-preload-code'?: true | '' | 'eager' | 'viewport' | 'hover' | 'tap' | 'off' | undefined | null;
|
|
1182
|
+
'data-sveltekit-preload-data'?: true | '' | 'hover' | 'tap' | 'off' | undefined | null;
|
|
1183
|
+
'data-sveltekit-reload'?: true | '' | 'off' | undefined | null;
|
|
1183
1184
|
}
|
|
1184
1185
|
|
|
1185
1186
|
interface SvelteMediaTimeRange {
|
package/svelte-shims.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ type SvelteAnimationReturnType = {
|
|
|
102
102
|
|
|
103
103
|
type SvelteWithOptionalProps<Props, Keys extends keyof Props> = Omit<Props, Keys> & Partial<Pick<Props, Keys>>;
|
|
104
104
|
type SvelteAllProps = { [index: string]: any }
|
|
105
|
-
type SveltePropsAnyFallback<Props> = {[K in keyof Props]: Props[K] extends undefined ? any : Props[K]}
|
|
105
|
+
type SveltePropsAnyFallback<Props> = {[K in keyof Props]: Props[K] extends never ? never : Props[K] extends undefined ? any : Props[K]}
|
|
106
106
|
type SvelteSlotsAnyFallback<Slots> = {[K in keyof Slots]: {[S in keyof Slots[K]]: Slots[K][S] extends undefined ? any : Slots[K][S]}}
|
|
107
107
|
type SvelteRestProps = { [index: string]: any }
|
|
108
108
|
type SvelteSlots = { [index: string]: any }
|
|
@@ -231,6 +231,7 @@ declare function __sveltets_2_createComponentAny(props: Record<string, any>): _S
|
|
|
231
231
|
declare function __sveltets_2_any(...dummy: any[]): any;
|
|
232
232
|
declare function __sveltets_2_empty(...dummy: any[]): {};
|
|
233
233
|
declare function __sveltets_2_union<T1,T2,T3,T4,T5>(t1:T1,t2?:T2,t3?:T3,t4?:T4,t5?:T5): T1 & T2 & T3 & T4 & T5;
|
|
234
|
+
declare function __sveltets_2_nonNullable<T>(type: T): NonNullable<T>;
|
|
234
235
|
|
|
235
236
|
declare function __sveltets_2_cssProp(prop: Record<string, any>): {};
|
|
236
237
|
|
|
@@ -295,9 +296,16 @@ declare type ATypedSvelteComponent = {
|
|
|
295
296
|
$on(event: string, handler: ((e: any) => any) | null | undefined): () => void;
|
|
296
297
|
}
|
|
297
298
|
/**
|
|
298
|
-
* Ambient type only used for intellisense, DO NOT USE IN YOUR PROJECT
|
|
299
|
+
* Ambient type only used for intellisense, DO NOT USE IN YOUR PROJECT.
|
|
300
|
+
*
|
|
301
|
+
* If you're looking for the type of a Svelte Component, use `SvelteComponentTyped` and `ComponentType` instead:
|
|
302
|
+
*
|
|
303
|
+
* ```ts
|
|
304
|
+
* import type { ComponentType, SvelteComponentTyped } from "svelte";
|
|
305
|
+
* let myComponentConstructor: ComponentType<SvelteComponentTyped> = ..;
|
|
306
|
+
* ```
|
|
299
307
|
*/
|
|
300
308
|
declare type ConstructorOfATypedSvelteComponent = new (args: {target: any, props?: any}) => ATypedSvelteComponent
|
|
301
|
-
declare function __sveltets_2_ensureComponent<T extends ConstructorOfATypedSvelteComponent>(type: T): T
|
|
309
|
+
declare function __sveltets_2_ensureComponent<T extends ConstructorOfATypedSvelteComponent | null | undefined>(type: T): NonNullable<T>;
|
|
302
310
|
|
|
303
311
|
declare function __sveltets_2_ensureArray<T extends ArrayLike<unknown>>(array: T): T extends ArrayLike<infer U> ? U[] : any[];
|