mirror of https://github.com/sveltejs/svelte
parent
366c490bcc
commit
1c5e6e7430
@ -0,0 +1,9 @@
|
|||||||
|
const glob = require( 'glob' );
|
||||||
|
const fs = require( 'fs' );
|
||||||
|
|
||||||
|
glob.sync( 'src/**/*.js' ).forEach( file => {
|
||||||
|
console.log( file );
|
||||||
|
const js = fs.readFileSync( file, 'utf-8' );
|
||||||
|
fs.writeFileSync( file.replace( /\.js$/, '.ts' ), js );
|
||||||
|
fs.unlinkSync( file );
|
||||||
|
});
|
@ -1,4 +1,4 @@
|
|||||||
import CodeBuilder from '../../utils/CodeBuilder.js';
|
import CodeBuilder from '../../utils/CodeBuilder.ts';
|
||||||
import deindent from '../../utils/deindent.js';
|
import deindent from '../../utils/deindent.js';
|
||||||
|
|
||||||
export default class Block {
|
export default class Block {
|
@ -1,14 +1,14 @@
|
|||||||
import MagicString from 'magic-string';
|
import MagicString from 'magic-string';
|
||||||
import { parseExpressionAt } from 'acorn';
|
import { parseExpressionAt } from 'acorn';
|
||||||
import annotateWithScopes from '../../utils/annotateWithScopes.js';
|
import annotateWithScopes from '../../utils/annotateWithScopes.ts';
|
||||||
import isReference from '../../utils/isReference.js';
|
import isReference from '../../utils/isReference.ts';
|
||||||
import { walk } from 'estree-walker';
|
import { walk } from 'estree-walker';
|
||||||
import deindent from '../../utils/deindent.js';
|
import deindent from '../../utils/deindent.js';
|
||||||
import CodeBuilder from '../../utils/CodeBuilder.js';
|
import CodeBuilder from '../../utils/CodeBuilder.ts';
|
||||||
import visit from './visit.js';
|
import visit from './visit.ts';
|
||||||
import shared from './shared.js';
|
import shared from './shared.ts';
|
||||||
import Generator from '../Generator.js';
|
import Generator from '../Generator.ts';
|
||||||
import preprocess from './preprocess.js';
|
import preprocess from './preprocess.ts';
|
||||||
|
|
||||||
class DomGenerator extends Generator {
|
class DomGenerator extends Generator {
|
||||||
constructor ( parsed, source, name, options ) {
|
constructor ( parsed, source, name, options ) {
|
@ -1,5 +1,5 @@
|
|||||||
import Block from './Block.js';
|
import Block from './Block.ts';
|
||||||
import { trimStart, trimEnd } from '../../utils/trim.js';
|
import { trimStart, trimEnd } from '../../utils/trim.ts';
|
||||||
import { assign } from '../../shared/index.js';
|
import { assign } from '../../shared/index.js';
|
||||||
|
|
||||||
function isElseIf ( node ) {
|
function isElseIf ( node ) {
|
@ -0,0 +1,35 @@
|
|||||||
|
// this file is auto-generated, do not edit it
|
||||||
|
export default {
|
||||||
|
"appendNode": "function appendNode ( node, target ) {\n\ttarget.appendChild( node );\n}",
|
||||||
|
"insertNode": "function insertNode ( node, target, anchor ) {\n\ttarget.insertBefore( node, anchor );\n}",
|
||||||
|
"detachNode": "function detachNode ( node ) {\n\tnode.parentNode.removeChild( node );\n}",
|
||||||
|
"detachBetween": "function detachBetween ( before, after ) {\n\twhile ( before.nextSibling && before.nextSibling !== after ) {\n\t\tbefore.parentNode.removeChild( before.nextSibling );\n\t}\n}",
|
||||||
|
"destroyEach": "function destroyEach ( iterations, detach, start ) {\n\tfor ( var i = start; i < iterations.length; i += 1 ) {\n\t\tif ( iterations[i] ) iterations[i].destroy( detach );\n\t}\n}",
|
||||||
|
"createElement": "function createElement ( name ) {\n\treturn document.createElement( name );\n}",
|
||||||
|
"createSvgElement": "function createSvgElement ( name ) {\n\treturn document.createElementNS( 'http://www.w3.org/2000/svg', name );\n}",
|
||||||
|
"createText": "function createText ( data ) {\n\treturn document.createTextNode( data );\n}",
|
||||||
|
"createComment": "function createComment () {\n\treturn document.createComment( '' );\n}",
|
||||||
|
"addEventListener": "function addEventListener ( node, event, handler ) {\n\tnode.addEventListener( event, handler, false );\n}",
|
||||||
|
"removeEventListener": "function removeEventListener ( node, event, handler ) {\n\tnode.removeEventListener( event, handler, false );\n}",
|
||||||
|
"setAttribute": "function setAttribute ( node, attribute, value ) {\n\tnode.setAttribute( attribute, value );\n}",
|
||||||
|
"setXlinkAttribute": "function setXlinkAttribute ( node, attribute, value ) {\n\tnode.setAttributeNS( 'http://www.w3.org/1999/xlink', attribute, value );\n}",
|
||||||
|
"getBindingGroupValue": "function getBindingGroupValue ( group ) {\n\tvar value = [];\n\tfor ( var i = 0; i < group.length; i += 1 ) {\n\t\tif ( group[i].checked ) value.push( group[i].__value );\n\t}\n\treturn value;\n}",
|
||||||
|
"differs": "function differs ( a, b ) {\n\treturn ( a !== b ) || ( a && ( typeof a === 'object' ) || ( typeof a === 'function' ) );\n}",
|
||||||
|
"dispatchObservers": "function dispatchObservers ( component, group, newState, oldState ) {\n\tfor ( var key in group ) {\n\t\tif ( !( key in newState ) ) continue;\n\n\t\tvar newValue = newState[ key ];\n\t\tvar oldValue = oldState[ key ];\n\n\t\tif ( differs( newValue, oldValue ) ) {\n\t\t\tvar callbacks = group[ key ];\n\t\t\tif ( !callbacks ) continue;\n\n\t\t\tfor ( var i = 0; i < callbacks.length; i += 1 ) {\n\t\t\t\tvar callback = callbacks[i];\n\t\t\t\tif ( callback.__calling ) continue;\n\n\t\t\t\tcallback.__calling = true;\n\t\t\t\tcallback.call( component, newValue, oldValue );\n\t\t\t\tcallback.__calling = false;\n\t\t\t}\n\t\t}\n\t}\n}",
|
||||||
|
"get": "function get ( key ) {\n\treturn key ? this._state[ key ] : this._state;\n}",
|
||||||
|
"fire": "function fire ( eventName, data ) {\n\tvar handlers = eventName in this._handlers && this._handlers[ eventName ].slice();\n\tif ( !handlers ) return;\n\n\tfor ( var i = 0; i < handlers.length; i += 1 ) {\n\t\thandlers[i].call( this, data );\n\t}\n}",
|
||||||
|
"observe": "function observe ( key, callback, options ) {\n\tvar group = ( options && options.defer ) ? this._observers.post : this._observers.pre;\n\n\t( group[ key ] || ( group[ key ] = [] ) ).push( callback );\n\n\tif ( !options || options.init !== false ) {\n\t\tcallback.__calling = true;\n\t\tcallback.call( this, this._state[ key ] );\n\t\tcallback.__calling = false;\n\t}\n\n\treturn {\n\t\tcancel: function () {\n\t\t\tvar index = group[ key ].indexOf( callback );\n\t\t\tif ( ~index ) group[ key ].splice( index, 1 );\n\t\t}\n\t};\n}",
|
||||||
|
"observeDev": "function observeDev ( key, callback, options ) {\n\tvar c = ( key = '' + key ).search( /[^\\w]/ );\n\tif ( c > -1 ) {\n\t\tvar message = \"The first argument to component.observe(...) must be the name of a top-level property\";\n\t\tif ( c > 0 ) message += \", i.e. '\" + key.slice( 0, c ) + \"' rather than '\" + key + \"'\";\n\n\t\tthrow new Error( message );\n\t}\n\n\treturn observe.call( this, key, callback, options );\n}",
|
||||||
|
"on": "function on ( eventName, handler ) {\n\tif ( eventName === 'teardown' ) return this.on( 'destroy', handler );\n\n\tvar handlers = this._handlers[ eventName ] || ( this._handlers[ eventName ] = [] );\n\thandlers.push( handler );\n\n\treturn {\n\t\tcancel: function () {\n\t\t\tvar index = handlers.indexOf( handler );\n\t\t\tif ( ~index ) handlers.splice( index, 1 );\n\t\t}\n\t};\n}",
|
||||||
|
"onDev": "function onDev ( eventName, handler ) {\n\tif ( eventName === 'teardown' ) {\n\t\tconsole.warn( \"Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2\" );\n\t\treturn this.on( 'destroy', handler );\n\t}\n\n\treturn on.call( this, eventName, handler );\n}",
|
||||||
|
"set": "function set ( newState ) {\n\tthis._set( assign( {}, newState ) );\n\tthis._root._flush();\n}",
|
||||||
|
"_flush": "function _flush () {\n\tif ( !this._renderHooks ) return;\n\n\twhile ( this._renderHooks.length ) {\n\t\tthis._renderHooks.pop()();\n\t}\n}",
|
||||||
|
"proto": "{\n\tget: get,\n\tfire: fire,\n\tobserve: observe,\n\ton: on,\n\tset: set,\n\t_flush: _flush\n}",
|
||||||
|
"protoDev": "{\n\tget: get,\n\tfire: fire,\n\tobserve: observeDev,\n\ton: onDev,\n\tset: set,\n\t_flush: _flush\n}",
|
||||||
|
"linear": "function linear ( t ) {\n\treturn t;\n}",
|
||||||
|
"generateKeyframes": "function generateKeyframes ( a, b, delta, duration, ease, fn, node, style ) {\n\tvar id = '__svelte' + ~~( Math.random() * 1e9 ); // TODO make this more robust\n\tvar keyframes = '@keyframes ' + id + '{\\n';\n\n\tfor ( var p = 0; p <= 1; p += 16.666 / duration ) {\n\t\tvar t = a + delta * ease( p );\n\t\tkeyframes += ( p * 100 ) + '%{' + fn( t ) + '}\\n';\n\t}\n\n\tkeyframes += '100% {' + fn( b ) + '}\\n}';\n\tstyle.textContent += keyframes;\n\n\tdocument.head.appendChild( style );\n\n\tnode.style.animation = node.style.animation.split( ',' )\n\t\t.filter( function ( anim ) {\n\t\t\t// when introing, discard old animations if there are any\n\t\t\treturn anim && ( delta < 0 || !/__svelte/.test( anim ) );\n\t\t})\n\t\t.concat( id + ' ' + duration + 'ms linear 1 forwards' )\n\t\t.join( ', ' );\n}",
|
||||||
|
"wrapTransition": "function wrapTransition ( node, fn, params, intro, outgroup ) {\n\tvar obj = fn( node, params );\n\tvar duration = obj.duration || 300;\n\tvar ease = obj.easing || linear;\n\n\t// TODO share <style> tag between all transitions?\n\tif ( obj.css ) {\n\t\tvar style = document.createElement( 'style' );\n\t}\n\n\tif ( intro && obj.tick ) obj.tick( 0 );\n\n\treturn {\n\t\tt: intro ? 0 : 1,\n\t\trunning: false,\n\t\tprogram: null,\n\t\tpending: null,\n\t\trun: function ( intro, callback ) {\n\t\t\tvar program = {\n\t\t\t\tstart: window.performance.now() + ( obj.delay || 0 ),\n\t\t\t\tintro: intro,\n\t\t\t\tcallback: callback\n\t\t\t};\n\n\t\t\tif ( obj.delay ) {\n\t\t\t\tthis.pending = program;\n\t\t\t} else {\n\t\t\t\tthis.start( program );\n\t\t\t}\n\n\t\t\tif ( !this.running ) {\n\t\t\t\tthis.running = true;\n\t\t\t\ttransitionManager.add( this );\n\t\t\t}\n\t\t},\n\t\tstart: function ( program ) {\n\t\t\tprogram.a = this.t;\n\t\t\tprogram.b = program.intro ? 1 : 0;\n\t\t\tprogram.delta = program.b - program.a;\n\t\t\tprogram.duration = duration * Math.abs( program.b - program.a );\n\t\t\tprogram.end = program.start + program.duration;\n\n\t\t\tif ( obj.css ) {\n\t\t\t\tgenerateKeyframes( program.a, program.b, program.delta, program.duration, ease, obj.css, node, style );\n\t\t\t}\n\n\t\t\tthis.program = program;\n\t\t\tthis.pending = null;\n\t\t},\n\t\tupdate: function ( now ) {\n\t\t\tvar program = this.program;\n\t\t\tif ( !program ) return;\n\n\t\t\tvar p = now - program.start;\n\t\t\tthis.t = program.a + program.delta * ease( p / program.duration );\n\t\t\tif ( obj.tick ) obj.tick( this.t );\n\t\t},\n\t\tdone: function () {\n\t\t\tthis.t = this.program.b;\n\t\t\tif ( obj.tick ) obj.tick( this.t );\n\t\t\tif ( obj.css ) document.head.removeChild( style );\n\t\t\tthis.program.callback();\n\t\t\tthis.program = null;\n\t\t\tthis.running = !!this.pending;\n\t\t},\n\t\tabort: function () {\n\t\t\tif ( obj.tick ) obj.tick( 1 );\n\t\t\tif ( obj.css ) document.head.removeChild( style );\n\t\t\tthis.program = this.pending = null;\n\t\t\tthis.running = false;\n\t\t}\n\t};\n}",
|
||||||
|
"transitionManager": "{\n\trunning: false,\n\ttransitions: [],\n\n\tadd: function ( transition ) {\n\t\ttransitionManager.transitions.push( transition );\n\n\t\tif ( !this.running ) {\n\t\t\tthis.running = true;\n\t\t\tthis.next();\n\t\t}\n\t},\n\n\tnext: function () {\n\t\ttransitionManager.running = false;\n\n\t\tvar now = window.performance.now();\n\t\tvar i = transitionManager.transitions.length;\n\n\t\twhile ( i-- ) {\n\t\t\tvar transition = transitionManager.transitions[i];\n\n\t\t\tif ( transition.program && now >= transition.program.end ) {\n\t\t\t\ttransition.done();\n\t\t\t}\n\n\t\t\tif ( transition.pending && now >= transition.pending.start ) {\n\t\t\t\ttransition.start( transition.pending );\n\t\t\t}\n\n\t\t\tif ( transition.running ) {\n\t\t\t\ttransition.update( now );\n\t\t\t\ttransitionManager.running = true;\n\t\t\t} else if ( !transition.pending ) {\n\t\t\t\ttransitionManager.transitions.splice( i, 1 );\n\t\t\t}\n\t\t}\n\n\t\tif ( transitionManager.running ) {\n\t\t\trequestAnimationFrame( transitionManager.next );\n\t\t}\n\t}\n}",
|
||||||
|
"noop": "function noop () {}",
|
||||||
|
"assign": "function assign ( target ) {\n\tfor ( var i = 1; i < arguments.length; i += 1 ) {\n\t\tvar source = arguments[i];\n\t\tfor ( var k in source ) target[k] = source[k];\n\t}\n\n\treturn target;\n}"
|
||||||
|
};
|
@ -1,4 +1,4 @@
|
|||||||
import visitors from './visitors/index.js';
|
import visitors from './visitors/index.ts';
|
||||||
|
|
||||||
export default function visit ( generator, block, state, node ) {
|
export default function visit ( generator, block, state, node ) {
|
||||||
const visitor = visitors[ node.type ];
|
const visitor = visitors[ node.type ];
|
@ -1,6 +1,6 @@
|
|||||||
import deindent from '../../../../utils/deindent.js';
|
import deindent from '../../../../utils/deindent.js';
|
||||||
import flattenReference from '../../../../utils/flattenReference.js';
|
import flattenReference from '../../../../utils/flattenReference.ts';
|
||||||
import getSetter from '../shared/binding/getSetter.js';
|
import getSetter from '../shared/binding/getSetter.ts';
|
||||||
|
|
||||||
export default function visitBinding ( generator, block, state, node, attribute, local ) {
|
export default function visitBinding ( generator, block, state, node, attribute, local ) {
|
||||||
const { name } = flattenReference( attribute.value );
|
const { name } = flattenReference( attribute.value );
|
@ -1,10 +1,10 @@
|
|||||||
import deindent from '../../../../utils/deindent.js';
|
import deindent from '../../../../utils/deindent.js';
|
||||||
import CodeBuilder from '../../../../utils/CodeBuilder.js';
|
import CodeBuilder from '../../../../utils/CodeBuilder.ts';
|
||||||
import visit from '../../visit.js';
|
import visit from '../../visit.ts';
|
||||||
import visitAttribute from './Attribute.js';
|
import visitAttribute from './Attribute.ts';
|
||||||
import visitEventHandler from './EventHandler.js';
|
import visitEventHandler from './EventHandler.ts';
|
||||||
import visitBinding from './Binding.js';
|
import visitBinding from './Binding.ts';
|
||||||
import visitRef from './Ref.js';
|
import visitRef from './Ref.ts';
|
||||||
|
|
||||||
function stringifyProps ( props ) {
|
function stringifyProps ( props ) {
|
||||||
if ( !props.length ) return '{}';
|
if ( !props.length ) return '{}';
|
@ -1,5 +1,5 @@
|
|||||||
import deindent from '../../../utils/deindent.js';
|
import deindent from '../../../utils/deindent.js';
|
||||||
import visit from '../visit.js';
|
import visit from '../visit.ts';
|
||||||
|
|
||||||
export default function visitEachBlock ( generator, block, state, node ) {
|
export default function visitEachBlock ( generator, block, state, node ) {
|
||||||
const each_block = generator.getUniqueName( `each_block` );
|
const each_block = generator.getUniqueName( `each_block` );
|
@ -1,6 +1,6 @@
|
|||||||
import attributeLookup from './lookup.js';
|
import attributeLookup from './lookup.ts';
|
||||||
import deindent from '../../../../utils/deindent.js';
|
import deindent from '../../../../utils/deindent.js';
|
||||||
import getStaticAttributeValue from './getStaticAttributeValue.js';
|
import getStaticAttributeValue from './getStaticAttributeValue.ts';
|
||||||
|
|
||||||
export default function visitAttribute ( generator, block, state, node, attribute ) {
|
export default function visitAttribute ( generator, block, state, node, attribute ) {
|
||||||
const name = attribute.name;
|
const name = attribute.name;
|
@ -1,7 +1,7 @@
|
|||||||
import deindent from '../../../../utils/deindent.js';
|
import deindent from '../../../../utils/deindent.js';
|
||||||
import flattenReference from '../../../../utils/flattenReference.js';
|
import flattenReference from '../../../../utils/flattenReference.ts';
|
||||||
import getSetter from '../shared/binding/getSetter.js';
|
import getSetter from '../shared/binding/getSetter.ts';
|
||||||
import getStaticAttributeValue from './getStaticAttributeValue.js';
|
import getStaticAttributeValue from './getStaticAttributeValue.ts';
|
||||||
|
|
||||||
export default function visitBinding ( generator, block, state, node, attribute ) {
|
export default function visitBinding ( generator, block, state, node, attribute ) {
|
||||||
const { name, parts } = flattenReference( attribute.value );
|
const { name, parts } = flattenReference( attribute.value );
|
@ -1,12 +1,12 @@
|
|||||||
import deindent from '../../../../utils/deindent.js';
|
import deindent from '../../../../utils/deindent.js';
|
||||||
import visit from '../../visit.js';
|
import visit from '../../visit.ts';
|
||||||
import visitComponent from '../Component/Component.js';
|
import visitComponent from '../Component/Component.ts';
|
||||||
import visitWindow from './meta/Window.js';
|
import visitWindow from './meta/Window.ts';
|
||||||
import visitAttribute from './Attribute.js';
|
import visitAttribute from './Attribute.ts';
|
||||||
import visitEventHandler from './EventHandler.js';
|
import visitEventHandler from './EventHandler.ts';
|
||||||
import visitBinding from './Binding.js';
|
import visitBinding from './Binding.ts';
|
||||||
import visitRef from './Ref.js';
|
import visitRef from './Ref.ts';
|
||||||
import addTransitions from './addTransitions.js';
|
import addTransitions from './addTransitions.ts';
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
':Window': visitWindow
|
':Window': visitWindow
|
@ -1,5 +1,5 @@
|
|||||||
import deindent from '../../../../utils/deindent.js';
|
import deindent from '../../../../utils/deindent.js';
|
||||||
import flattenReference from '../../../../utils/flattenReference.js';
|
import flattenReference from '../../../../utils/flattenReference.ts';
|
||||||
|
|
||||||
export default function visitEventHandler ( generator, block, state, node, attribute ) {
|
export default function visitEventHandler ( generator, block, state, node, attribute ) {
|
||||||
const name = attribute.name;
|
const name = attribute.name;
|
@ -1,4 +1,4 @@
|
|||||||
import flattenReference from '../../../../../utils/flattenReference.js';
|
import flattenReference from '../../../../../utils/flattenReference.ts';
|
||||||
import deindent from '../../../../../utils/deindent.js';
|
import deindent from '../../../../../utils/deindent.js';
|
||||||
|
|
||||||
const associatedEvents = {
|
const associatedEvents = {
|
@ -1,5 +1,5 @@
|
|||||||
import deindent from '../../../utils/deindent.js';
|
import deindent from '../../../utils/deindent.js';
|
||||||
import visit from '../visit.js';
|
import visit from '../visit.ts';
|
||||||
|
|
||||||
function isElseIf ( node ) {
|
function isElseIf ( node ) {
|
||||||
return node && node.children.length === 1 && node.children[0].type === 'IfBlock';
|
return node && node.children.length === 1 && node.children[0].type === 'IfBlock';
|
@ -1,17 +0,0 @@
|
|||||||
import EachBlock from './EachBlock.js';
|
|
||||||
import Element from './Element/Element.js';
|
|
||||||
import IfBlock from './IfBlock.js';
|
|
||||||
import MustacheTag from './MustacheTag.js';
|
|
||||||
import RawMustacheTag from './RawMustacheTag.js';
|
|
||||||
import Text from './Text.js';
|
|
||||||
import YieldTag from './YieldTag.js';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
EachBlock,
|
|
||||||
Element,
|
|
||||||
IfBlock,
|
|
||||||
MustacheTag,
|
|
||||||
RawMustacheTag,
|
|
||||||
Text,
|
|
||||||
YieldTag
|
|
||||||
};
|
|
@ -0,0 +1,17 @@
|
|||||||
|
import EachBlock from './EachBlock.ts';
|
||||||
|
import Element from './Element/Element.ts';
|
||||||
|
import IfBlock from './IfBlock.ts';
|
||||||
|
import MustacheTag from './MustacheTag.ts';
|
||||||
|
import RawMustacheTag from './RawMustacheTag.ts';
|
||||||
|
import Text from './Text.ts';
|
||||||
|
import YieldTag from './YieldTag.ts';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
EachBlock,
|
||||||
|
Element,
|
||||||
|
IfBlock,
|
||||||
|
MustacheTag,
|
||||||
|
RawMustacheTag,
|
||||||
|
Text,
|
||||||
|
YieldTag
|
||||||
|
};
|
@ -1,5 +1,5 @@
|
|||||||
import deindent from '../../utils/deindent.js';
|
import deindent from '../../utils/deindent.js';
|
||||||
import flattenReference from '../../utils/flattenReference.js';
|
import flattenReference from '../../utils/flattenReference.ts';
|
||||||
|
|
||||||
export default class Block {
|
export default class Block {
|
||||||
constructor ( options ) {
|
constructor ( options ) {
|
@ -1,7 +1,7 @@
|
|||||||
import deindent from '../../utils/deindent.js';
|
import deindent from '../../utils/deindent.js';
|
||||||
import Generator from '../Generator.js';
|
import Generator from '../Generator.ts';
|
||||||
import Block from './Block.js';
|
import Block from './Block.ts';
|
||||||
import visit from './visit.js';
|
import visit from './visit.ts';
|
||||||
|
|
||||||
class SsrGenerator extends Generator {
|
class SsrGenerator extends Generator {
|
||||||
constructor ( parsed, source, name, options ) {
|
constructor ( parsed, source, name, options ) {
|
@ -1,4 +1,4 @@
|
|||||||
import visitors from './visitors/index.js';
|
import visitors from './visitors/index.ts';
|
||||||
|
|
||||||
export default function visit ( generator, fragment, node ) {
|
export default function visit ( generator, fragment, node ) {
|
||||||
const visitor = visitors[ node.type ];
|
const visitor = visitors[ node.type ];
|
@ -1,5 +1,5 @@
|
|||||||
import flattenReference from '../../../utils/flattenReference.js';
|
import flattenReference from '../../../utils/flattenReference.ts';
|
||||||
import visit from '../visit.js';
|
import visit from '../visit.ts';
|
||||||
|
|
||||||
export default function visitComponent ( generator, block, node ) {
|
export default function visitComponent ( generator, block, node ) {
|
||||||
function stringify ( chunk ) {
|
function stringify ( chunk ) {
|
@ -1,4 +1,4 @@
|
|||||||
import visit from '../visit.js';
|
import visit from '../visit.ts';
|
||||||
|
|
||||||
export default function visitEachBlock ( generator, block, node ) {
|
export default function visitEachBlock ( generator, block, node ) {
|
||||||
const { dependencies, snippet } = block.contextualise( node.expression );
|
const { dependencies, snippet } = block.contextualise( node.expression );
|
@ -1,7 +1,7 @@
|
|||||||
import visitComponent from './Component.js';
|
import visitComponent from './Component.ts';
|
||||||
import isVoidElementName from '../../../utils/isVoidElementName.js';
|
import isVoidElementName from '../../../utils/isVoidElementName.ts';
|
||||||
import visit from '../visit.js';
|
import visit from '../visit.ts';
|
||||||
import visitWindow from './meta/Window.js';
|
import visitWindow from './meta/Window.ts';
|
||||||
|
|
||||||
const meta = {
|
const meta = {
|
||||||
':Window': visitWindow
|
':Window': visitWindow
|
@ -1,4 +1,4 @@
|
|||||||
import visit from '../visit.js';
|
import visit from '../visit.ts';
|
||||||
|
|
||||||
export default function visitIfBlock ( generator, block, node ) {
|
export default function visitIfBlock ( generator, block, node ) {
|
||||||
const { snippet } = block.contextualise( node.expression );
|
const { snippet } = block.contextualise( node.expression );
|
@ -1,19 +0,0 @@
|
|||||||
import Comment from './Comment.js';
|
|
||||||
import EachBlock from './EachBlock.js';
|
|
||||||
import Element from './Element.js';
|
|
||||||
import IfBlock from './IfBlock.js';
|
|
||||||
import MustacheTag from './MustacheTag.js';
|
|
||||||
import RawMustacheTag from './RawMustacheTag.js';
|
|
||||||
import Text from './Text.js';
|
|
||||||
import YieldTag from './YieldTag.js';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
Comment,
|
|
||||||
EachBlock,
|
|
||||||
Element,
|
|
||||||
IfBlock,
|
|
||||||
MustacheTag,
|
|
||||||
RawMustacheTag,
|
|
||||||
Text,
|
|
||||||
YieldTag
|
|
||||||
};
|
|
@ -0,0 +1,19 @@
|
|||||||
|
import Comment from './Comment.ts';
|
||||||
|
import EachBlock from './EachBlock.ts';
|
||||||
|
import Element from './Element.ts';
|
||||||
|
import IfBlock from './IfBlock.ts';
|
||||||
|
import MustacheTag from './MustacheTag.ts';
|
||||||
|
import RawMustacheTag from './RawMustacheTag.ts';
|
||||||
|
import Text from './Text.ts';
|
||||||
|
import YieldTag from './YieldTag.ts';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
Comment,
|
||||||
|
EachBlock,
|
||||||
|
Element,
|
||||||
|
IfBlock,
|
||||||
|
MustacheTag,
|
||||||
|
RawMustacheTag,
|
||||||
|
Text,
|
||||||
|
YieldTag
|
||||||
|
};
|
@ -1,5 +1,5 @@
|
|||||||
import deindent from '../../../utils/deindent.js';
|
import deindent from '../../../utils/deindent.js';
|
||||||
import getGlobals from './getGlobals.js';
|
import getGlobals from './getGlobals.ts';
|
||||||
|
|
||||||
export default function getIntro ( format, options, imports ) {
|
export default function getIntro ( format, options, imports ) {
|
||||||
if ( format === 'es' ) return '';
|
if ( format === 'es' ) return '';
|
@ -1,4 +1,4 @@
|
|||||||
import getGlobals from './getGlobals.js';
|
import getGlobals from './getGlobals.ts';
|
||||||
|
|
||||||
export default function getOutro ( format, name, options, imports ) {
|
export default function getOutro ( format, name, options, imports ) {
|
||||||
if ( format === 'es' ) {
|
if ( format === 'es' ) {
|
@ -1,6 +1,6 @@
|
|||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import deindent from './deindent.js';
|
import deindent from './deindent.js';
|
||||||
import CodeBuilder from './CodeBuilder.js';
|
import CodeBuilder from './CodeBuilder.ts';
|
||||||
|
|
||||||
describe( 'deindent', () => {
|
describe( 'deindent', () => {
|
||||||
it( 'deindents a simple string', () => {
|
it( 'deindents a simple string', () => {
|
@ -1,4 +1,4 @@
|
|||||||
import { whitespace } from './patterns.js';
|
import { whitespace } from './patterns.ts';
|
||||||
|
|
||||||
export function trimStart ( str ) {
|
export function trimStart ( str ) {
|
||||||
let i = 0;
|
let i = 0;
|
@ -1,6 +1,6 @@
|
|||||||
import * as namespaces from '../../utils/namespaces.js';
|
import * as namespaces from '../../utils/namespaces.ts';
|
||||||
import validateElement from './validateElement.js';
|
import validateElement from './validateElement.ts';
|
||||||
import validateWindow from './validateWindow.js';
|
import validateWindow from './validateWindow.ts';
|
||||||
|
|
||||||
const svg = /^(?:altGlyph|altGlyphDef|altGlyphItem|animate|animateColor|animateMotion|animateTransform|circle|clipPath|color-profile|cursor|defs|desc|discard|ellipse|feBlend|feColorMatrix|feComponentTransfer|feComposite|feConvolveMatrix|feDiffuseLighting|feDisplacementMap|feDistantLight|feDropShadow|feFlood|feFuncA|feFuncB|feFuncG|feFuncR|feGaussianBlur|feImage|feMerge|feMergeNode|feMorphology|feOffset|fePointLight|feSpecularLighting|feSpotLight|feTile|feTurbulence|filter|font|font-face|font-face-format|font-face-name|font-face-src|font-face-uri|foreignObject|g|glyph|glyphRef|hatch|hatchpath|hkern|image|line|linearGradient|marker|mask|mesh|meshgradient|meshpatch|meshrow|metadata|missing-glyph|mpath|path|pattern|polygon|polyline|radialGradient|rect|set|solidcolor|stop|switch|symbol|text|textPath|title|tref|tspan|unknown|use|view|vkern)$/;
|
const svg = /^(?:altGlyph|altGlyphDef|altGlyphItem|animate|animateColor|animateMotion|animateTransform|circle|clipPath|color-profile|cursor|defs|desc|discard|ellipse|feBlend|feColorMatrix|feComponentTransfer|feComposite|feConvolveMatrix|feDiffuseLighting|feDisplacementMap|feDistantLight|feDropShadow|feFlood|feFuncA|feFuncB|feFuncG|feFuncR|feGaussianBlur|feImage|feMerge|feMergeNode|feMorphology|feOffset|fePointLight|feSpecularLighting|feSpotLight|feTile|feTurbulence|filter|font|font-face|font-face-format|font-face-name|font-face-src|font-face-uri|foreignObject|g|glyph|glyphRef|hatch|hatchpath|hkern|image|line|linearGradient|marker|mask|mesh|meshgradient|meshpatch|meshrow|metadata|missing-glyph|mpath|path|pattern|polygon|polyline|radialGradient|rect|set|solidcolor|stop|switch|symbol|text|textPath|title|tref|tspan|unknown|use|view|vkern)$/;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import validateEventHandler from './validateEventHandler.js';
|
import validateEventHandler from './validateEventHandler.ts';
|
||||||
|
|
||||||
export default function validateElement ( validator, node ) {
|
export default function validateElement ( validator, node ) {
|
||||||
const isComponent = node.name === ':Self' || validator.components.has( node.name );
|
const isComponent = node.name === ':Self' || validator.components.has( node.name );
|
@ -1,5 +1,5 @@
|
|||||||
import flattenReference from '../../utils/flattenReference.js';
|
import flattenReference from '../../utils/flattenReference.ts';
|
||||||
import list from '../utils/list.js';
|
import list from '../utils/list.ts';
|
||||||
|
|
||||||
const validBuiltins = new Set([
|
const validBuiltins = new Set([
|
||||||
'set',
|
'set',
|
@ -1,7 +1,7 @@
|
|||||||
import flattenReference from '../../utils/flattenReference.js';
|
import flattenReference from '../../utils/flattenReference.ts';
|
||||||
import fuzzymatch from '../utils/fuzzymatch.js';
|
import fuzzymatch from '../utils/fuzzymatch.ts';
|
||||||
import list from '../utils/list.js';
|
import list from '../utils/list.ts';
|
||||||
import validateEventHandler from './validateEventHandler.js';
|
import validateEventHandler from './validateEventHandler.ts';
|
||||||
|
|
||||||
const validBindings = [
|
const validBindings = [
|
||||||
'innerWidth',
|
'innerWidth',
|
@ -1,7 +1,7 @@
|
|||||||
import validateJs from './js/index.js';
|
import validateJs from './js/index.ts';
|
||||||
import validateHtml from './html/index.js';
|
import validateHtml from './html/index.ts';
|
||||||
import { getLocator } from 'locate-character';
|
import { getLocator } from 'locate-character';
|
||||||
import getCodeFrame from '../utils/getCodeFrame.js';
|
import getCodeFrame from '../utils/getCodeFrame.ts';
|
||||||
|
|
||||||
export default function validate ( parsed, source, { onerror, onwarn, name, filename } ) {
|
export default function validate ( parsed, source, { onerror, onwarn, name, filename } ) {
|
||||||
const locator = getLocator( source );
|
const locator = getLocator( source );
|
@ -1,8 +1,8 @@
|
|||||||
import propValidators from './propValidators/index.js';
|
import propValidators from './propValidators/index.ts';
|
||||||
import fuzzymatch from '../utils/fuzzymatch.js';
|
import fuzzymatch from '../utils/fuzzymatch.ts';
|
||||||
import checkForDupes from './utils/checkForDupes.js';
|
import checkForDupes from './utils/checkForDupes.ts';
|
||||||
import checkForComputedKeys from './utils/checkForComputedKeys.js';
|
import checkForComputedKeys from './utils/checkForComputedKeys.ts';
|
||||||
import namespaces from '../../utils/namespaces.js';
|
import namespaces from '../../utils/namespaces.ts';
|
||||||
|
|
||||||
const validPropList = Object.keys( propValidators );
|
const validPropList = Object.keys( propValidators );
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
import checkForDupes from '../utils/checkForDupes.js';
|
import checkForDupes from '../utils/checkForDupes.ts';
|
||||||
import checkForComputedKeys from '../utils/checkForComputedKeys.js';
|
import checkForComputedKeys from '../utils/checkForComputedKeys.ts';
|
||||||
|
|
||||||
export default function components ( validator, prop ) {
|
export default function components ( validator, prop ) {
|
||||||
if ( prop.value.type !== 'ObjectExpression' ) {
|
if ( prop.value.type !== 'ObjectExpression' ) {
|
@ -1,5 +1,5 @@
|
|||||||
import checkForDupes from '../utils/checkForDupes.js';
|
import checkForDupes from '../utils/checkForDupes.ts';
|
||||||
import checkForComputedKeys from '../utils/checkForComputedKeys.js';
|
import checkForComputedKeys from '../utils/checkForComputedKeys.ts';
|
||||||
|
|
||||||
const isFunctionExpression = new Set( [ 'FunctionExpression', 'ArrowFunctionExpression' ] );
|
const isFunctionExpression = new Set( [ 'FunctionExpression', 'ArrowFunctionExpression' ] );
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
import checkForDupes from '../utils/checkForDupes.js';
|
import checkForDupes from '../utils/checkForDupes.ts';
|
||||||
import checkForComputedKeys from '../utils/checkForComputedKeys.js';
|
import checkForComputedKeys from '../utils/checkForComputedKeys.ts';
|
||||||
|
|
||||||
export default function events ( validator, prop ) {
|
export default function events ( validator, prop ) {
|
||||||
if ( prop.value.type !== 'ObjectExpression' ) {
|
if ( prop.value.type !== 'ObjectExpression' ) {
|
@ -1,5 +1,5 @@
|
|||||||
import checkForDupes from '../utils/checkForDupes.js';
|
import checkForDupes from '../utils/checkForDupes.ts';
|
||||||
import checkForComputedKeys from '../utils/checkForComputedKeys.js';
|
import checkForComputedKeys from '../utils/checkForComputedKeys.ts';
|
||||||
import { walk } from 'estree-walker';
|
import { walk } from 'estree-walker';
|
||||||
|
|
||||||
export default function helpers ( validator, prop ) {
|
export default function helpers ( validator, prop ) {
|
@ -1,27 +0,0 @@
|
|||||||
import data from './data.js';
|
|
||||||
import computed from './computed.js';
|
|
||||||
import oncreate from './oncreate.js';
|
|
||||||
import ondestroy from './ondestroy.js';
|
|
||||||
import onrender from './onrender.js';
|
|
||||||
import onteardown from './onteardown.js';
|
|
||||||
import helpers from './helpers.js';
|
|
||||||
import methods from './methods.js';
|
|
||||||
import components from './components.js';
|
|
||||||
import events from './events.js';
|
|
||||||
import namespace from './namespace.js';
|
|
||||||
import transitions from './transitions.js';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
data,
|
|
||||||
computed,
|
|
||||||
oncreate,
|
|
||||||
ondestroy,
|
|
||||||
onrender,
|
|
||||||
onteardown,
|
|
||||||
helpers,
|
|
||||||
methods,
|
|
||||||
components,
|
|
||||||
events,
|
|
||||||
namespace,
|
|
||||||
transitions
|
|
||||||
};
|
|
@ -0,0 +1,27 @@
|
|||||||
|
import data from './data.ts';
|
||||||
|
import computed from './computed.ts';
|
||||||
|
import oncreate from './oncreate.ts';
|
||||||
|
import ondestroy from './ondestroy.ts';
|
||||||
|
import onrender from './onrender.ts';
|
||||||
|
import onteardown from './onteardown.ts';
|
||||||
|
import helpers from './helpers.ts';
|
||||||
|
import methods from './methods.ts';
|
||||||
|
import components from './components.ts';
|
||||||
|
import events from './events.ts';
|
||||||
|
import namespace from './namespace.ts';
|
||||||
|
import transitions from './transitions.ts';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data,
|
||||||
|
computed,
|
||||||
|
oncreate,
|
||||||
|
ondestroy,
|
||||||
|
onrender,
|
||||||
|
onteardown,
|
||||||
|
helpers,
|
||||||
|
methods,
|
||||||
|
components,
|
||||||
|
events,
|
||||||
|
namespace,
|
||||||
|
transitions
|
||||||
|
};
|
@ -1,7 +1,7 @@
|
|||||||
import checkForAccessors from '../utils/checkForAccessors.js';
|
import checkForAccessors from '../utils/checkForAccessors.ts';
|
||||||
import checkForDupes from '../utils/checkForDupes.js';
|
import checkForDupes from '../utils/checkForDupes.ts';
|
||||||
import checkForComputedKeys from '../utils/checkForComputedKeys.js';
|
import checkForComputedKeys from '../utils/checkForComputedKeys.ts';
|
||||||
import usesThisOrArguments from '../utils/usesThisOrArguments.js';
|
import usesThisOrArguments from '../utils/usesThisOrArguments.ts';
|
||||||
|
|
||||||
const builtin = new Set( [ 'set', 'get', 'on', 'fire', 'observe', 'destroy' ] );
|
const builtin = new Set( [ 'set', 'get', 'on', 'fire', 'observe', 'destroy' ] );
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
import * as namespaces from '../../../utils/namespaces.js';
|
import * as namespaces from '../../../utils/namespaces.ts';
|
||||||
import fuzzymatch from '../../utils/fuzzymatch.js';
|
import fuzzymatch from '../../utils/fuzzymatch.ts';
|
||||||
|
|
||||||
const valid = new Set( namespaces.validNamespaces );
|
const valid = new Set( namespaces.validNamespaces );
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
import usesThisOrArguments from '../utils/usesThisOrArguments.js';
|
import usesThisOrArguments from '../utils/usesThisOrArguments.ts';
|
||||||
|
|
||||||
export default function oncreate ( validator, prop ) {
|
export default function oncreate ( validator, prop ) {
|
||||||
if ( prop.value.type === 'ArrowFunctionExpression' ) {
|
if ( prop.value.type === 'ArrowFunctionExpression' ) {
|
@ -1,4 +1,4 @@
|
|||||||
import usesThisOrArguments from '../utils/usesThisOrArguments.js';
|
import usesThisOrArguments from '../utils/usesThisOrArguments.ts';
|
||||||
|
|
||||||
export default function ondestroy ( validator, prop ) {
|
export default function ondestroy ( validator, prop ) {
|
||||||
if ( prop.value.type === 'ArrowFunctionExpression' ) {
|
if ( prop.value.type === 'ArrowFunctionExpression' ) {
|
@ -1,4 +1,4 @@
|
|||||||
import oncreate from './oncreate.js';
|
import oncreate from './oncreate.ts';
|
||||||
|
|
||||||
export default function onrender ( validator, prop ) {
|
export default function onrender ( validator, prop ) {
|
||||||
validator.warn( `'onrender' has been deprecated in favour of 'oncreate', and will cause an error in Svelte 2.x`, prop.start );
|
validator.warn( `'onrender' has been deprecated in favour of 'oncreate', and will cause an error in Svelte 2.x`, prop.start );
|
@ -1,4 +1,4 @@
|
|||||||
import ondestroy from './ondestroy.js';
|
import ondestroy from './ondestroy.ts';
|
||||||
|
|
||||||
export default function onteardown ( validator, prop ) {
|
export default function onteardown ( validator, prop ) {
|
||||||
validator.warn( `'onteardown' has been deprecated in favour of 'ondestroy', and will cause an error in Svelte 2.x`, prop.start );
|
validator.warn( `'onteardown' has been deprecated in favour of 'ondestroy', and will cause an error in Svelte 2.x`, prop.start );
|
@ -1,5 +1,5 @@
|
|||||||
import checkForDupes from '../utils/checkForDupes.js';
|
import checkForDupes from '../utils/checkForDupes.ts';
|
||||||
import checkForComputedKeys from '../utils/checkForComputedKeys.js';
|
import checkForComputedKeys from '../utils/checkForComputedKeys.ts';
|
||||||
|
|
||||||
export default function transitions ( validator, prop ) {
|
export default function transitions ( validator, prop ) {
|
||||||
if ( prop.value.type !== 'ObjectExpression' ) {
|
if ( prop.value.type !== 'ObjectExpression' ) {
|
@ -1,5 +1,5 @@
|
|||||||
import { walk } from 'estree-walker';
|
import { walk } from 'estree-walker';
|
||||||
import isReference from '../../../utils/isReference.js';
|
import isReference from '../../../utils/isReference.ts';
|
||||||
|
|
||||||
export default function usesThisOrArguments ( node ) {
|
export default function usesThisOrArguments ( node ) {
|
||||||
let result = false;
|
let result = false;
|
@ -1,4 +1,4 @@
|
|||||||
import FuzzySet from './FuzzySet.js';
|
import FuzzySet from './FuzzySet.ts';
|
||||||
|
|
||||||
export default function fuzzymatch ( name, names ) {
|
export default function fuzzymatch ( name, names ) {
|
||||||
const set = new FuzzySet( names );
|
const set = new FuzzySet( names );
|
Loading…
Reference in new issue