From f73a87230a891d3377e12d630b88cc445b18abdb Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Thu, 15 Dec 2016 23:56:08 -0500 Subject: [PATCH] move some files around --- .../createGenerator.js | 5 ++--- src/{generate => generators/dom}/index.js | 21 ++++++++++--------- .../dom}/visitors/Comment.js | 0 .../dom}/visitors/Component.js | 4 ++-- .../dom}/visitors/EachBlock.js | 2 +- .../dom}/visitors/Element.js | 4 ++-- .../dom}/visitors/IfBlock.js | 2 +- .../dom}/visitors/MustacheTag.js | 2 +- .../dom}/visitors/RawMustacheTag.js | 2 +- .../dom}/visitors/Text.js | 0 .../dom}/visitors/YieldTag.js | 0 .../attributes/addComponentAttributes.js | 2 +- .../attributes/addElementAttributes.js | 4 ++-- .../dom}/visitors/attributes/binding/index.js | 6 +++--- .../dom}/visitors/attributes/lookup.js | 0 .../dom}/visitors/index.js | 0 .../server-side-rendering/index.js} | 12 +++++------ .../shared}/css/process.js | 2 +- .../shared}/css/transform.js | 0 .../shared}/utils/counter.js | 0 .../shared}/utils/getGlobals.js | 0 .../shared}/utils/getIntro.js | 2 +- .../shared}/utils/getOutro.js | 0 .../shared}/utils/walkHtml.js | 0 src/index.js | 4 ++-- 25 files changed, 37 insertions(+), 37 deletions(-) rename src/{generate => generators}/createGenerator.js (97%) rename src/{generate => generators/dom}/index.js (95%) rename src/{generate => generators/dom}/visitors/Comment.js (100%) rename src/{generate => generators/dom}/visitors/Component.js (97%) rename src/{generate => generators/dom}/visitors/EachBlock.js (98%) rename src/{generate => generators/dom}/visitors/Element.js (96%) rename src/{generate => generators/dom}/visitors/IfBlock.js (98%) rename src/{generate => generators/dom}/visitors/MustacheTag.js (88%) rename src/{generate => generators/dom}/visitors/RawMustacheTag.js (96%) rename src/{generate => generators/dom}/visitors/Text.js (100%) rename src/{generate => generators/dom}/visitors/YieldTag.js (100%) rename src/{generate => generators/dom}/visitors/attributes/addComponentAttributes.js (98%) rename src/{generate => generators/dom}/visitors/attributes/addElementAttributes.js (98%) rename src/{generate => generators/dom}/visitors/attributes/binding/index.js (95%) rename src/{generate => generators/dom}/visitors/attributes/lookup.js (100%) rename src/{generate => generators/dom}/visitors/index.js (100%) rename src/{server-side-rendering/compile.js => generators/server-side-rendering/index.js} (97%) rename src/{generate => generators/shared}/css/process.js (79%) rename src/{generate => generators/shared}/css/transform.js (100%) rename src/{generate => generators/shared}/utils/counter.js (100%) rename src/{generate => generators/shared}/utils/getGlobals.js (100%) rename src/{generate => generators/shared}/utils/getIntro.js (97%) rename src/{generate => generators/shared}/utils/getOutro.js (100%) rename src/{generate => generators/shared}/utils/walkHtml.js (100%) diff --git a/src/generate/createGenerator.js b/src/generators/createGenerator.js similarity index 97% rename from src/generate/createGenerator.js rename to src/generators/createGenerator.js index 4a6608d967..bde0120561 100644 --- a/src/generate/createGenerator.js +++ b/src/generators/createGenerator.js @@ -3,12 +3,11 @@ import CodeBuilder from '../utils/CodeBuilder.js'; import { walk } from 'estree-walker'; import deindent from '../utils/deindent.js'; import isReference from '../utils/isReference.js'; -import counter from './utils/counter.js'; +import counter from './shared/utils/counter.js'; import flattenReference from '../utils/flattenReference.js'; -import visitors from './visitors/index.js'; import globalWhitelist from '../utils/globalWhitelist.js'; -export default function createGenerator ( parsed, source, names ) { +export default function createGenerator ( parsed, source, names, visitors ) { const generator = { addElement ( name, renderStatement, needsIdentifier = false ) { const isToplevel = generator.current.localElementDepth === 0; diff --git a/src/generate/index.js b/src/generators/dom/index.js similarity index 95% rename from src/generate/index.js rename to src/generators/dom/index.js index 7a7226be29..af98031e75 100644 --- a/src/generate/index.js +++ b/src/generators/dom/index.js @@ -1,16 +1,17 @@ import MagicString, { Bundle } from 'magic-string'; -import CodeBuilder from '../utils/CodeBuilder.js'; -import deindent from '../utils/deindent.js'; -import namespaces from '../utils/namespaces.js'; -import getIntro from './utils/getIntro.js'; -import getOutro from './utils/getOutro.js'; -import processCss from './css/process.js'; -import createGenerator from './createGenerator.js'; - -export default function generate ( parsed, source, options, names ) { +import deindent from '../../utils/deindent.js'; +import CodeBuilder from '../../utils/CodeBuilder.js'; +import namespaces from '../../utils/namespaces.js'; +import getIntro from '../shared/utils/getIntro.js'; +import getOutro from '../shared/utils/getOutro.js'; +import processCss from '../shared/css/process.js'; +import visitors from './visitors/index.js'; +import createGenerator from '../createGenerator.js'; + +export default function dom ( parsed, source, options, names ) { const format = options.format || 'es'; - const generator = createGenerator( parsed, source, names ); + const generator = createGenerator( parsed, source, names, visitors ); const templateProperties = {}; const imports = []; diff --git a/src/generate/visitors/Comment.js b/src/generators/dom/visitors/Comment.js similarity index 100% rename from src/generate/visitors/Comment.js rename to src/generators/dom/visitors/Comment.js diff --git a/src/generate/visitors/Component.js b/src/generators/dom/visitors/Component.js similarity index 97% rename from src/generate/visitors/Component.js rename to src/generators/dom/visitors/Component.js index c48bf29a42..31d52c777e 100644 --- a/src/generate/visitors/Component.js +++ b/src/generators/dom/visitors/Component.js @@ -1,5 +1,5 @@ -import deindent from '../../utils/deindent.js'; -import CodeBuilder from '../../utils/CodeBuilder.js'; +import deindent from '../../../utils/deindent.js'; +import CodeBuilder from '../../../utils/CodeBuilder.js'; import addComponentAttributes from './attributes/addComponentAttributes.js'; export default { diff --git a/src/generate/visitors/EachBlock.js b/src/generators/dom/visitors/EachBlock.js similarity index 98% rename from src/generate/visitors/EachBlock.js rename to src/generators/dom/visitors/EachBlock.js index 0c6a976728..e7c39e93f2 100644 --- a/src/generate/visitors/EachBlock.js +++ b/src/generators/dom/visitors/EachBlock.js @@ -1,4 +1,4 @@ -import deindent from '../../utils/deindent.js'; +import deindent from '../../../utils/deindent.js'; export default { enter ( generator, node ) { diff --git a/src/generate/visitors/Element.js b/src/generators/dom/visitors/Element.js similarity index 96% rename from src/generate/visitors/Element.js rename to src/generators/dom/visitors/Element.js index 163378640e..39ca4b297e 100644 --- a/src/generate/visitors/Element.js +++ b/src/generators/dom/visitors/Element.js @@ -1,5 +1,5 @@ -import CodeBuilder from '../../utils/CodeBuilder.js'; -import deindent from '../../utils/deindent.js'; +import CodeBuilder from '../../../utils/CodeBuilder.js'; +import deindent from '../../../utils/deindent.js'; import addElementAttributes from './attributes/addElementAttributes.js'; import Component from './Component.js'; diff --git a/src/generate/visitors/IfBlock.js b/src/generators/dom/visitors/IfBlock.js similarity index 98% rename from src/generate/visitors/IfBlock.js rename to src/generators/dom/visitors/IfBlock.js index bf4cd96953..e95fefc7f1 100644 --- a/src/generate/visitors/IfBlock.js +++ b/src/generators/dom/visitors/IfBlock.js @@ -1,4 +1,4 @@ -import deindent from '../../utils/deindent.js'; +import deindent from '../../../utils/deindent.js'; function getConditionsAndBlocks ( generator, node, _name, i = 0 ) { generator.addSourcemapLocations( node.expression ); diff --git a/src/generate/visitors/MustacheTag.js b/src/generators/dom/visitors/MustacheTag.js similarity index 88% rename from src/generate/visitors/MustacheTag.js rename to src/generators/dom/visitors/MustacheTag.js index 0222d714b6..f956a7be08 100644 --- a/src/generate/visitors/MustacheTag.js +++ b/src/generators/dom/visitors/MustacheTag.js @@ -1,4 +1,4 @@ -import deindent from '../../utils/deindent.js'; +import deindent from '../../../utils/deindent.js'; export default { enter ( generator, node ) { diff --git a/src/generate/visitors/RawMustacheTag.js b/src/generators/dom/visitors/RawMustacheTag.js similarity index 96% rename from src/generate/visitors/RawMustacheTag.js rename to src/generators/dom/visitors/RawMustacheTag.js index d90e1d7d01..455833497c 100644 --- a/src/generate/visitors/RawMustacheTag.js +++ b/src/generators/dom/visitors/RawMustacheTag.js @@ -1,4 +1,4 @@ -import deindent from '../../utils/deindent.js'; +import deindent from '../../../utils/deindent.js'; export default { enter ( generator, node ) { diff --git a/src/generate/visitors/Text.js b/src/generators/dom/visitors/Text.js similarity index 100% rename from src/generate/visitors/Text.js rename to src/generators/dom/visitors/Text.js diff --git a/src/generate/visitors/YieldTag.js b/src/generators/dom/visitors/YieldTag.js similarity index 100% rename from src/generate/visitors/YieldTag.js rename to src/generators/dom/visitors/YieldTag.js diff --git a/src/generate/visitors/attributes/addComponentAttributes.js b/src/generators/dom/visitors/attributes/addComponentAttributes.js similarity index 98% rename from src/generate/visitors/attributes/addComponentAttributes.js rename to src/generators/dom/visitors/attributes/addComponentAttributes.js index e5c9fec984..d1c70a574a 100644 --- a/src/generate/visitors/attributes/addComponentAttributes.js +++ b/src/generators/dom/visitors/attributes/addComponentAttributes.js @@ -1,5 +1,5 @@ import createBinding from './binding/index.js'; -import deindent from '../../../utils/deindent.js'; +import deindent from '../../../../utils/deindent.js'; export default function addComponentAttributes ( generator, node, local ) { local.staticAttributes = []; diff --git a/src/generate/visitors/attributes/addElementAttributes.js b/src/generators/dom/visitors/attributes/addElementAttributes.js similarity index 98% rename from src/generate/visitors/attributes/addElementAttributes.js rename to src/generators/dom/visitors/attributes/addElementAttributes.js index ec5a67eb7b..71adfa3c08 100644 --- a/src/generate/visitors/attributes/addElementAttributes.js +++ b/src/generators/dom/visitors/attributes/addElementAttributes.js @@ -1,7 +1,7 @@ import attributeLookup from './lookup.js'; import createBinding from './binding/index.js'; -import deindent from '../../../utils/deindent.js'; -import flattenReference from '../../../utils/flattenReference.js'; +import deindent from '../../../../utils/deindent.js'; +import flattenReference from '../../../../utils/flattenReference.js'; export default function addElementAttributes ( generator, node, local ) { node.attributes.forEach( attribute => { diff --git a/src/generate/visitors/attributes/binding/index.js b/src/generators/dom/visitors/attributes/binding/index.js similarity index 95% rename from src/generate/visitors/attributes/binding/index.js rename to src/generators/dom/visitors/attributes/binding/index.js index 585beda5e4..0411357664 100644 --- a/src/generate/visitors/attributes/binding/index.js +++ b/src/generators/dom/visitors/attributes/binding/index.js @@ -1,6 +1,6 @@ -import deindent from '../../../../utils/deindent.js'; -import isReference from '../../../../utils/isReference.js'; -import flattenReference from '../../../../utils/flattenReference.js'; +import deindent from '../../../../../utils/deindent.js'; +import isReference from '../../../../../utils/isReference.js'; +import flattenReference from '../../../../../utils/flattenReference.js'; export default function createBinding ( generator, node, attribute, current, local ) { const parts = attribute.value.split( '.' ); diff --git a/src/generate/visitors/attributes/lookup.js b/src/generators/dom/visitors/attributes/lookup.js similarity index 100% rename from src/generate/visitors/attributes/lookup.js rename to src/generators/dom/visitors/attributes/lookup.js diff --git a/src/generate/visitors/index.js b/src/generators/dom/visitors/index.js similarity index 100% rename from src/generate/visitors/index.js rename to src/generators/dom/visitors/index.js diff --git a/src/server-side-rendering/compile.js b/src/generators/server-side-rendering/index.js similarity index 97% rename from src/server-side-rendering/compile.js rename to src/generators/server-side-rendering/index.js index 0e45a0f2ef..28b7873a92 100644 --- a/src/server-side-rendering/compile.js +++ b/src/generators/server-side-rendering/index.js @@ -1,10 +1,10 @@ -import { walk } from 'estree-walker'; -import deindent from '../utils/deindent.js'; -import isReference from '../utils/isReference.js'; -import flattenReference from '../utils/flattenReference.js'; import MagicString, { Bundle } from 'magic-string'; -import processCss from '../generate/css/process.js'; -import voidElementNames from '../utils/voidElementNames.js'; +import { walk } from 'estree-walker'; +import deindent from '../../utils/deindent.js'; +import isReference from '../../utils/isReference.js'; +import flattenReference from '../../utils/flattenReference.js'; +import voidElementNames from '../../utils/voidElementNames.js'; +import processCss from '../shared/css/process.js'; export default function compile ( parsed, source, { filename }) { const code = new MagicString( source ); diff --git a/src/generate/css/process.js b/src/generators/shared/css/process.js similarity index 79% rename from src/generate/css/process.js rename to src/generators/shared/css/process.js index a75d1cf46e..41b6e01452 100644 --- a/src/generate/css/process.js +++ b/src/generators/shared/css/process.js @@ -1,4 +1,4 @@ -import spaces from '../../utils/spaces.js'; +import spaces from '../../../utils/spaces.js'; import transform from './transform.js'; export default function process ( parsed ) { diff --git a/src/generate/css/transform.js b/src/generators/shared/css/transform.js similarity index 100% rename from src/generate/css/transform.js rename to src/generators/shared/css/transform.js diff --git a/src/generate/utils/counter.js b/src/generators/shared/utils/counter.js similarity index 100% rename from src/generate/utils/counter.js rename to src/generators/shared/utils/counter.js diff --git a/src/generate/utils/getGlobals.js b/src/generators/shared/utils/getGlobals.js similarity index 100% rename from src/generate/utils/getGlobals.js rename to src/generators/shared/utils/getGlobals.js diff --git a/src/generate/utils/getIntro.js b/src/generators/shared/utils/getIntro.js similarity index 97% rename from src/generate/utils/getIntro.js rename to src/generators/shared/utils/getIntro.js index 3d1e3b9e5d..ce0f5525b8 100644 --- a/src/generate/utils/getIntro.js +++ b/src/generators/shared/utils/getIntro.js @@ -1,4 +1,4 @@ -import deindent from '../../utils/deindent.js'; +import deindent from '../../../utils/deindent.js'; import getGlobals from './getGlobals.js'; export default function getIntro ( format, options, imports ) { diff --git a/src/generate/utils/getOutro.js b/src/generators/shared/utils/getOutro.js similarity index 100% rename from src/generate/utils/getOutro.js rename to src/generators/shared/utils/getOutro.js diff --git a/src/generate/utils/walkHtml.js b/src/generators/shared/utils/walkHtml.js similarity index 100% rename from src/generate/utils/walkHtml.js rename to src/generators/shared/utils/walkHtml.js diff --git a/src/index.js b/src/index.js index 79a5665dce..dc2bcefe6a 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ import parse from './parse/index.js'; import validate from './validate/index.js'; -import generate from './generate/index.js'; -import generateSSR from './server-side-rendering/compile.js'; +import generate from './generators/dom/index.js'; +import generateSSR from './generators/server-side-rendering/index.js'; function normalizeOptions ( options ) { return Object.assign( {