├── .gitignore
├── packages
├── synthesis-compiler
│ ├── .npm
│ │ └── package
│ │ │ ├── .gitignore
│ │ │ ├── README
│ │ │ └── npm-shrinkwrap.json
│ ├── synthesis-gen.js
│ ├── synthesis-compiler-tests.js
│ ├── package.js
│ ├── .versions
│ ├── LICENSE
│ ├── synthesis-compiler.js
│ └── README.md
├── synthesis-pug
│ ├── .npm
│ │ └── plugin
│ │ │ ├── synthesis-jade
│ │ │ ├── .gitignore
│ │ │ ├── README
│ │ │ └── npm-shrinkwrap.json
│ │ │ └── synthesis-pug
│ │ │ ├── .gitignore
│ │ │ ├── README
│ │ │ └── npm-shrinkwrap.json
│ ├── synthesis-pug-tests.js
│ ├── synthesis-client.js
│ ├── package.js
│ ├── LICENSE
│ ├── .versions
│ ├── plugin
│ │ └── synthesis.js
│ └── README.md
├── synthesis
│ ├── synthesis-tests.js
│ ├── synthesis-client.js
│ ├── package.js
│ ├── .versions
│ ├── LICENSE
│ ├── plugin
│ │ └── synthesis.js
│ └── README.md
└── synthesis-assets
│ ├── .versions
│ ├── package.js
│ ├── plugin
│ └── synthesis-assets.js
│ ├── LICENSE
│ └── README.md
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | npm-debug.log
3 |
--------------------------------------------------------------------------------
/packages/synthesis-compiler/.npm/package/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/packages/synthesis-pug/.npm/plugin/synthesis-jade/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/packages/synthesis-pug/.npm/plugin/synthesis-pug/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/packages/synthesis/synthesis-tests.js:
--------------------------------------------------------------------------------
1 | // Import Tinytest from the tinytest Meteor package.
2 | import { Tinytest } from "meteor/tinytest";
3 |
4 | // Write your tests here!
5 | // Here is an example.
6 | Tinytest.add('synthesis - example', function (test) {
7 | test.equal(true,true);
8 | });
9 |
--------------------------------------------------------------------------------
/packages/synthesis-compiler/synthesis-gen.js:
--------------------------------------------------------------------------------
1 | export class _synthesizer {
2 | constructor(settings) {
3 | this.settings = settings;
4 | }
5 | generateJS(html, toHead) {
6 | const htmlStr = JSON.stringify(html);
7 | return `
8 | Synthesis.render(${htmlStr},${!!toHead});
9 | `;
10 | }
11 |
12 | }
13 | export const Synthesizer = new _synthesizer();
14 |
--------------------------------------------------------------------------------
/packages/synthesis-pug/synthesis-pug-tests.js:
--------------------------------------------------------------------------------
1 | // Import Tinytest from the tinytest Meteor package.
2 | import { Tinytest } from "meteor/tinytest";
3 |
4 | // Import and rename a variable exported by synthesis-jade.js.
5 | import { name as packageName } from "meteor/synthesis-jade";
6 |
7 | // Write your tests here!
8 | // Here is an example.
9 | Tinytest.add('synthesis-jade - example', function (test) {
10 | test.equal(packageName, "synthesis-jade");
11 | });
12 |
--------------------------------------------------------------------------------
/packages/synthesis-compiler/.npm/package/README:
--------------------------------------------------------------------------------
1 | This directory and the files immediately inside it are automatically generated
2 | when you change this package's NPM dependencies. Commit the files in this
3 | directory (npm-shrinkwrap.json, .gitignore, and this README) to source control
4 | so that others run the same versions of sub-dependencies.
5 |
6 | You should NOT check in the node_modules directory that Meteor automatically
7 | creates; if you are using git, the .gitignore file tells git to ignore it.
8 |
--------------------------------------------------------------------------------
/packages/synthesis-compiler/synthesis-compiler-tests.js:
--------------------------------------------------------------------------------
1 | // Import Tinytest from the tinytest Meteor package.
2 | import { Tinytest } from 'meteor/tinytest';
3 |
4 | // Import and rename a variable exported by synthesis-compiler.js.
5 | import { name as packageName } from 'meteor/synthesis-compiler';
6 |
7 | // Write your tests here!
8 | // Here is an example.
9 | Tinytest.add('synthesis-compiler - example', (test) => {
10 | // Tests
11 | test.equal(packageName, 'synthesis-compiler');
12 | });
13 |
--------------------------------------------------------------------------------
/packages/synthesis-pug/.npm/plugin/synthesis-jade/README:
--------------------------------------------------------------------------------
1 | This directory and the files immediately inside it are automatically generated
2 | when you change this package's NPM dependencies. Commit the files in this
3 | directory (npm-shrinkwrap.json, .gitignore, and this README) to source control
4 | so that others run the same versions of sub-dependencies.
5 |
6 | You should NOT check in the node_modules directory that Meteor automatically
7 | creates; if you are using git, the .gitignore file tells git to ignore it.
8 |
--------------------------------------------------------------------------------
/packages/synthesis-pug/.npm/plugin/synthesis-pug/README:
--------------------------------------------------------------------------------
1 | This directory and the files immediately inside it are automatically generated
2 | when you change this package's NPM dependencies. Commit the files in this
3 | directory (npm-shrinkwrap.json, .gitignore, and this README) to source control
4 | so that others run the same versions of sub-dependencies.
5 |
6 | You should NOT check in the node_modules directory that Meteor automatically
7 | creates; if you are using git, the .gitignore file tells git to ignore it.
8 |
--------------------------------------------------------------------------------
/packages/synthesis-assets/.versions:
--------------------------------------------------------------------------------
1 | babel-compiler@6.13.0
2 | babel-runtime@0.1.12
3 | blaze-tools@1.0.10
4 | caching-compiler@1.1.9
5 | caching-html-compiler@1.0.7
6 | deps@1.0.12
7 | ecmascript@0.5.9
8 | ecmascript-runtime@0.3.15
9 | html-tools@1.0.11
10 | htmljs@1.0.11
11 | meteor@1.6.0
12 | minifier-js@1.2.14
13 | modules@0.7.7
14 | modules-runtime@0.7.7
15 | mwc:synthesis-assets@0.1.5
16 | promise@0.8.8
17 | random@1.0.10
18 | spacebars-compiler@1.0.13
19 | templating-tools@1.0.5
20 | tracker@1.0.14
21 | underscore@1.0.10
22 |
--------------------------------------------------------------------------------
/packages/synthesis/synthesis-client.js:
--------------------------------------------------------------------------------
1 | export class _synthesizer {
2 | constructor(settings) {
3 | this.settings = settings;
4 | }
5 | render(str, head) {
6 | if (document.body) {
7 | const el = head ? document.head : document.body;
8 | const div = document.createElement('div');
9 | const docFrag = document.createDocumentFragment();
10 | div.innerHTML = str;
11 | while (div.children.length > 0) {
12 | docFrag.appendChild(div.children[0]);
13 | }
14 | el.appendChild(docFrag);
15 | } else {
16 | document.write(str);
17 | }
18 | }
19 | }
20 |
21 | Synthesis = new _synthesizer();
22 |
--------------------------------------------------------------------------------
/packages/synthesis-assets/package.js:
--------------------------------------------------------------------------------
1 | Package.describe({
2 | name: 'mwc:synthesis-assets',
3 | version: '0.1.5',
4 | summary: 'assets handling for synthesis',
5 | git: 'https://github.com/meteorwebcomponents/synthesis',
6 | documentation: 'README.md',
7 | });
8 |
9 | Package.onUse((api) => {
10 | api.versionsFrom('1.3');
11 | api.use('ecmascript');
12 | api.use('isobuild:compiler-plugin@1.0.0');
13 | });
14 |
15 | Package.registerBuildPlugin({
16 | name: 'synthesis-assets',
17 | use: [
18 | 'caching-html-compiler@1.0.7',
19 | 'ecmascript@0.4.1',
20 | ],
21 | sources: [
22 | 'plugin/synthesis-assets.js',
23 | ],
24 | });
25 |
--------------------------------------------------------------------------------
/packages/synthesis-pug/synthesis-client.js:
--------------------------------------------------------------------------------
1 | export class _synthesizer {
2 | constructor(settings) {
3 | this.settings = settings;
4 | }
5 | render(str, head) {
6 | if (document.body) {
7 | const el = head ? document.head : document.body;
8 | const div = document.createElement('div');
9 | const docFrag = document.createDocumentFragment();
10 | div.innerHTML = str;
11 | while (div.children.length > 0) {
12 | docFrag.appendChild(div.children[0]);
13 | }
14 | el.appendChild(docFrag);
15 | } else {
16 | document.write(str);
17 | }
18 | }
19 | }
20 |
21 | Synthesis = new _synthesizer();
22 |
--------------------------------------------------------------------------------
/packages/synthesis-compiler/package.js:
--------------------------------------------------------------------------------
1 | Package.describe({
2 | name: 'mwc:synthesis-compiler',
3 | version: '1.3.11',
4 | summary: 'Synthesis is meteor + polymer',
5 | git: 'https://github.com/meteorwebcomponents/synthesis',
6 | documentation: 'README.md',
7 | });
8 |
9 | Package.onUse((api) => {
10 | api.versionsFrom('1.3');
11 | api.use('ecmascript');
12 | api.use('babel-compiler');
13 | api.use('caching-compiler@1.1.9');
14 | api.mainModule('synthesis-compiler.js', 'server');
15 | });
16 |
17 | Package.onTest((api) => {
18 | api.use('ecmascript');
19 | api.use('tinytest');
20 | api.use('mwc:synthesis-compiler');
21 | api.mainModule('synthesis-compiler-tests.js');
22 | });
23 |
24 | Npm.depends({
25 | lodash: '4.17.4',
26 | polyclean: '1.3.1',
27 | parse5: '3.0.3',
28 | });
29 |
--------------------------------------------------------------------------------
/packages/synthesis-assets/plugin/synthesis-assets.js:
--------------------------------------------------------------------------------
1 | function SynthesisFileCompiler() {}
2 | SynthesisFileCompiler.prototype.processFilesForTarget = function (files) {
3 | files.forEach(function (file) {
4 | let packagePrefix = '';
5 | if (file.getPackageName()) {
6 | packagePrefix += `/packages/${file.getPackageName()}/`;
7 | }
8 |
9 | const filePath = packagePrefix + file.getPathInPackage();
10 | const content = file.getContentsAsBuffer();
11 |
12 | file.addAsset({
13 | path: filePath,
14 | data: content
15 | });
16 | });
17 | };
18 |
19 | const img = ['png', 'jpg', 'jpeg', 'gif', 'tif', 'tiff', 'svg'];
20 | const font = ['ttf', 'woff', 'eot', 'otf', 'woff2'];
21 | const extensions = [...img, ...font];
22 |
23 | Plugin.registerCompiler({
24 | extensions,
25 | archMatching: 'web',
26 | }, function(){
27 | return new SynthesisFileCompiler();
28 | });
29 |
--------------------------------------------------------------------------------
/packages/synthesis/package.js:
--------------------------------------------------------------------------------
1 | Package.describe({
2 | name: 'mwc:synthesis',
3 | version: '1.3.12',
4 | summary: 'Synthesis is meteor + polymer',
5 | git: 'https://github.com/meteorwebcomponents/synthesis',
6 | documentation: 'README.md',
7 | });
8 |
9 | Package.onUse((api) => {
10 | api.versionsFrom('1.3');
11 | api.use('ecmascript');
12 | api.use('isobuild:compiler-plugin@1.0.0');
13 | api.addFiles('synthesis-client.js', 'client');
14 | api.export('Synthesis', ['client']);
15 | });
16 |
17 | Package.onTest((api) => {
18 | api.use('ecmascript');
19 | api.use('tinytest');
20 | api.use('mwc:synthesis');
21 | api.mainModule('synthesis-tests.js');
22 | });
23 |
24 |
25 | Package.registerBuildPlugin({
26 | name: 'synthesis',
27 | use: [
28 | 'mwc:synthesis-compiler@1.3.11',
29 | 'caching-html-compiler@1.0.7',
30 | 'ecmascript@0.4.1',
31 | ],
32 | sources: [
33 | 'plugin/synthesis.js',
34 | ],
35 | });
36 |
--------------------------------------------------------------------------------
/packages/synthesis-compiler/.versions:
--------------------------------------------------------------------------------
1 | allow-deny@1.1.0
2 | babel-compiler@6.24.7
3 | babel-runtime@1.1.1
4 | base64@1.0.10
5 | binary-heap@1.0.10
6 | boilerplate-generator@1.3.0
7 | caching-compiler@1.1.9
8 | callback-hook@1.0.10
9 | check@1.2.5
10 | ddp@1.4.0
11 | ddp-client@2.2.0
12 | ddp-common@1.3.0
13 | ddp-server@2.1.0
14 | diff-sequence@1.0.7
15 | ecmascript@0.9.0
16 | ecmascript-runtime@0.5.0
17 | ecmascript-runtime-client@0.5.0
18 | ecmascript-runtime-server@0.5.0
19 | ejson@1.1.0
20 | geojson-utils@1.0.10
21 | id-map@1.0.9
22 | local-test:mwc:synthesis-compiler@1.3.11
23 | logging@1.1.19
24 | meteor@1.8.0
25 | minimongo@1.4.0
26 | modules@0.11.0
27 | modules-runtime@0.9.0
28 | mongo@1.3.1
29 | mongo-dev-server@1.1.0
30 | mongo-id@1.0.6
31 | mwc:synthesis-compiler@1.3.11
32 | npm-mongo@2.2.33
33 | ordered-dict@1.0.9
34 | promise@0.10.0
35 | random@1.0.10
36 | retry@1.0.9
37 | routepolicy@1.0.12
38 | tinytest@1.0.12
39 | tracker@1.1.3
40 | underscore@1.0.10
41 | webapp@1.4.0
42 | webapp-hashing@1.0.9
43 |
--------------------------------------------------------------------------------
/packages/synthesis-pug/package.js:
--------------------------------------------------------------------------------
1 | Package.describe({
2 | name: 'mwc:synthesis-pug',
3 | version: '1.3.11',
4 | summary: 'Synthesis is meteor + polymer',
5 | git: 'https://github.com/meteorwebcomponents/synthesis',
6 | documentation: 'README.md',
7 | });
8 |
9 | Package.onUse((api) => {
10 | api.versionsFrom('1.3');
11 | api.use('ecmascript');
12 | api.use('isobuild:compiler-plugin@1.0.0');
13 | api.addFiles('synthesis-client.js', 'client');
14 | api.export('Synthesis', ['client']);
15 | });
16 |
17 | Package.onTest((api) => {
18 | api.use('ecmascript');
19 | api.use('tinytest');
20 | api.use('mwc:synthesis-pug');
21 | api.mainModule('synthesis-pug-tests.js');
22 | });
23 |
24 |
25 | Package.registerBuildPlugin({
26 | name: 'synthesis-pug',
27 | use: [
28 | 'mwc:synthesis-compiler@1.3.11',
29 | 'caching-html-compiler@1.0.7',
30 | 'ecmascript@0.4.1',
31 | ],
32 | sources: [
33 | 'plugin/synthesis.js',
34 | ],
35 | npmDependencies: {
36 | pug: '2.0.0-beta6',
37 | },
38 | });
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Meteor Webcomponents
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/synthesis-pug/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Meteor Webcomponents
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/synthesis/.versions:
--------------------------------------------------------------------------------
1 | allow-deny@1.1.0
2 | babel-compiler@6.24.7
3 | babel-runtime@1.1.1
4 | base64@1.0.10
5 | binary-heap@1.0.10
6 | blaze-tools@1.0.10
7 | boilerplate-generator@1.3.0
8 | caching-compiler@1.1.9
9 | caching-html-compiler@1.0.7
10 | callback-hook@1.0.10
11 | check@1.2.5
12 | ddp@1.4.0
13 | ddp-client@2.2.0
14 | ddp-common@1.3.0
15 | ddp-server@2.1.0
16 | deps@1.0.12
17 | diff-sequence@1.0.7
18 | ecmascript@0.9.0
19 | ecmascript-runtime@0.5.0
20 | ecmascript-runtime-client@0.5.0
21 | ecmascript-runtime-server@0.5.0
22 | ejson@1.1.0
23 | geojson-utils@1.0.10
24 | html-tools@1.0.11
25 | htmljs@1.0.11
26 | id-map@1.0.9
27 | local-test:mwc:synthesis@1.3.12
28 | logging@1.1.19
29 | meteor@1.8.0
30 | minimongo@1.4.0
31 | modules@0.11.0
32 | modules-runtime@0.9.0
33 | mongo@1.3.1
34 | mongo-dev-server@1.1.0
35 | mongo-id@1.0.6
36 | mwc:synthesis@1.3.12
37 | mwc:synthesis-compiler@1.3.11
38 | npm-mongo@2.2.33
39 | ordered-dict@1.0.9
40 | promise@0.10.0
41 | random@1.0.10
42 | retry@1.0.9
43 | routepolicy@1.0.12
44 | spacebars-compiler@1.1.0
45 | templating-tools@1.1.1
46 | tinytest@1.0.12
47 | tracker@1.1.3
48 | underscore@1.0.10
49 | webapp@1.4.0
50 | webapp-hashing@1.0.9
51 |
--------------------------------------------------------------------------------
/packages/synthesis/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Meteor Webcomponents
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/synthesis-assets/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Meteor Webcomponents
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/synthesis-compiler/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Meteor Webcomponents
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/packages/synthesis-pug/.versions:
--------------------------------------------------------------------------------
1 | allow-deny@1.1.0
2 | babel-compiler@6.24.7
3 | babel-runtime@1.1.1
4 | base64@1.0.10
5 | binary-heap@1.0.10
6 | blaze-tools@1.0.10
7 | boilerplate-generator@1.3.0
8 | caching-compiler@1.1.9
9 | caching-html-compiler@1.0.7
10 | callback-hook@1.0.10
11 | check@1.2.5
12 | ddp@1.4.0
13 | ddp-client@2.2.0
14 | ddp-common@1.3.0
15 | ddp-server@2.1.0
16 | deps@1.0.12
17 | diff-sequence@1.0.7
18 | ecmascript@0.9.0
19 | ecmascript-runtime@0.5.0
20 | ecmascript-runtime-client@0.5.0
21 | ecmascript-runtime-server@0.5.0
22 | ejson@1.1.0
23 | geojson-utils@1.0.10
24 | html-tools@1.0.11
25 | htmljs@1.0.11
26 | id-map@1.0.9
27 | local-test:mwc:synthesis-pug@1.3.11
28 | logging@1.1.19
29 | meteor@1.8.0
30 | minimongo@1.4.0
31 | modules@0.11.0
32 | modules-runtime@0.9.0
33 | mongo@1.3.1
34 | mongo-dev-server@1.1.0
35 | mongo-id@1.0.6
36 | mwc:synthesis-compiler@1.3.11
37 | mwc:synthesis-pug@1.3.11
38 | npm-mongo@2.2.33
39 | ordered-dict@1.0.9
40 | promise@0.10.0
41 | random@1.0.10
42 | retry@1.0.9
43 | routepolicy@1.0.12
44 | spacebars-compiler@1.1.0
45 | templating-tools@1.1.1
46 | tinytest@1.0.12
47 | tracker@1.1.3
48 | underscore@1.0.10
49 | webapp@1.4.0
50 | webapp-hashing@1.0.9
51 |
--------------------------------------------------------------------------------
/packages/synthesis/plugin/synthesis.js:
--------------------------------------------------------------------------------
1 | import { parseHtml, handleTags } from 'meteor/mwc:synthesis-compiler';
2 | import { CachingHtmlCompiler } from 'meteor/caching-html-compiler';
3 |
4 | class PolymerCachingHtmlCompiler extends CachingHtmlCompiler {
5 |
6 | getCacheKey(inputFile) {
7 | return inputFile.getSourceHash();
8 | }
9 |
10 | compileOneFile(inputFile) {
11 | const contents = inputFile.getContentsAsString();
12 | let packagePrefix = '';
13 | if (inputFile.getPackageName()) {
14 | packagePrefix += `/packages/${inputFile.getPackageName()}/`;
15 | }
16 | const inputPath = packagePrefix + inputFile.getPathInPackage();
17 | // files inside folders with names demo/test/docs are skipped.
18 | if (inputPath.match(/\/(demo|test|docs).*\//) && !process.env.FORCESYNTHESIS) {
19 | return null;
20 | }
21 | try {
22 | const tags = this.tagScannerFunc({
23 | sourceName: inputPath,
24 | contents,
25 | });
26 | const result = this.tagHandlerFunc(tags);
27 | return result;
28 | } catch (e) {
29 | throw e;
30 | }
31 | }
32 | }
33 |
34 | Plugin.registerCompiler({
35 | extensions: ['html', 'htm'],
36 | archMatching: 'web',
37 | isTemplate: true,
38 | }, () => new PolymerCachingHtmlCompiler('synthesis', parseHtml, handleTags));
39 |
--------------------------------------------------------------------------------
/packages/synthesis-pug/plugin/synthesis.js:
--------------------------------------------------------------------------------
1 | import { parseHtml, handleTags } from 'meteor/mwc:synthesis-compiler';
2 | import { CachingHtmlCompiler } from 'meteor/caching-html-compiler';
3 | import pug from 'pug';
4 |
5 | class PolymerCachingHtmlCompiler extends CachingHtmlCompiler {
6 |
7 | getCacheKey(inputFile) {
8 | return inputFile.getSourceHash();
9 | }
10 |
11 | compileOneFile(inputFile) {
12 | const contents = inputFile.getContentsAsString();
13 | let packagePrefix = '';
14 |
15 | if (inputFile.getPackageName()) {
16 | packagePrefix += `/packages/${inputFile.getPackageName()}/`;
17 | }
18 |
19 | const inputPath = packagePrefix + inputFile.getPathInPackage();
20 | // files inside folders with names demo/test/docs are skipped.
21 | if (inputPath.match(/\/(demo|test|docs).*\//) && !process.env.FORCESYNTHESIS) {
22 | return null;
23 | }
24 | try {
25 | const fn = pug.compile(contents, {
26 | filename: inputFile.getPathInPackage(),
27 | });
28 | const parsedJade = fn();
29 | const tags = this.tagScannerFunc({
30 | sourceName: inputPath,
31 | contents: parsedJade,
32 | });
33 | const result = this.tagHandlerFunc(tags);
34 | return result;
35 | } catch (e) {
36 | throw e;
37 | }
38 | }
39 | }
40 |
41 | Plugin.registerCompiler({
42 | extensions: ['pug'],
43 | archMatching: 'web',
44 | isTemplate: true,
45 | }, () => new PolymerCachingHtmlCompiler('synthesis-pug', parseHtml, handleTags));
46 |
47 |
--------------------------------------------------------------------------------
/packages/synthesis-pug/README.md:
--------------------------------------------------------------------------------
1 |
2 | # Synthesis is meteor + polymer
3 |
4 |
5 | ## Installation
6 |
7 | Remove `blaze-html-templates` (or remove the html compiler you are using).
8 |
9 | `meteor remove blaze-html-templates`
10 |
11 | Install synthesis
12 |
13 | `meteor add mwc:synthesis`
14 |
15 | synthesis is a meteor 1.3+ package. for 1.2 support use [mwc:compiler](https://github.com/meteorwebcomponents/compiler)
16 |
17 | You can optionally use these packages from meteorwebcomponents
18 |
19 | * [mwc:mixin](https://github.com/meteorwebcomponents/mixin) - Polymer data package.
20 | * [mwc:router](https://github.com/meteorwebcomponents/router) - Flowrouter with polymer.
21 | * [mwc:layout](https://github.com/meteorwebcomponents/layout) - Polymer layout renderer.
22 |
23 |
24 | ## Usage
25 |
26 | Refer http://guide.meteor.com
27 |
28 | Application Structure http://guide.meteor.com/structure.html.
29 |
30 | Keeps all your components in imports folder
31 |
32 | You can import html using
33 |
34 | 1. Meteor's `import './component.pug';`
35 |
36 | 2. ` `
37 |
38 | Script
39 | 1. ` `
40 |
41 | 2. ``
42 |
43 | Css (its important follow these two methods to confine style inside the component.)
44 | 1. ``
45 |
46 | 2. ``
47 |
48 | Add bower_components to any folder inside imports directory.
49 |
50 | Assume bower directory is imports/ui/bower_components
51 |
52 | ```pug
53 |
54 |
55 | link(rel='import', href='test-element2.html')
56 | // imports/ui/component/test-element.html Gets imported
57 | link(rel='import', href='../bower_components/paper-button/paper-button.html')
58 | script(src='test-element.js')
59 | dom-module#test-element
60 | template
61 | link(rel='stylesheet', href='test-element.css')
62 | // converted to style tag. this style is restricted to elements inside the element
63 | style.
64 | #nndiv{color:blue}
65 | paper-button(on-click='showNickName')
66 | | Show nickname
67 | p
68 | | Name : {{name}}
69 | #nnDiv(hidden='{{nndHidden}}')
70 | | Nickname: {{ nickname }}
71 | ```
72 | ```css
73 | /*imports/ui/component/test-element.css*/
74 | paper-button{
75 | color:red;
76 | }
77 | ```
78 | ```js
79 | // imports/ui/component/test-element.js
80 | import './test-element.pug';
81 |
82 | Polymer({
83 | is:"test-element",
84 | properties:{
85 | name:{
86 | type:String,
87 | value:"Arun Kumar"
88 | },
89 | nickname:{
90 | type:String,
91 | value:"tkay"
92 | },
93 | nndHidden:{
94 | type:Boolean,
95 | value:true
96 | }
97 | },
98 | showNickName: function () {
99 | this.nndHidden = false;
100 | }
101 | })
102 |
103 |
104 | ```
105 |
106 | ```html
107 |
108 | head
109 | title Synthesis
110 | body.fullbleed
111 | h1 Synthesis is Meteor + Polymer!
112 | test-element
113 | ```
114 | ```js
115 | // client/index.js
116 | import '../imports/ui/components/test-element.html';
117 | // include the webcomponents js file
118 | import "../imports/ui/bower_components/webcomponentsjs/webcomponents-lite.min.js";
119 |
120 | //Remember to include a polymer component or polymer.html itself in any file
121 |
122 | import "../imports/ui/bower_components/polymer/polymer.html";
123 |
124 | ```
125 | Best practice is to reduce the number of files in the imports directory. Avoid adding unecessary components, helps in lowering the build time
126 |
127 | A sample bower.json (imports/ui/bower.json)
128 |
129 | ```json
130 | {
131 | "dependencies": {
132 | "iron-pages": "PolymerElements/iron-pages#^1.0.0",
133 | "neon-animations": "PolymerElements/neon-animations#^1.0.0",
134 | "paper-button": "PolymerElements/paper-button#^1.0.5",
135 | "polymer": "Polymer/polymer#^1.0.0"
136 | },
137 | "name": "mwc-synthesis",
138 | "version": "0.0.1"
139 | }
140 | ```
141 |
142 | ### Demo
143 | Check out the [Synthesis Demo](https://github.com/meteorwebcomponents/synthesis-demo)
144 |
145 |
146 | ### Kickstart Your Meteor Polymer projects
147 | [Kickstart a Meteor/Polymer project](https://github.com/aruntk/kickstart-meteor-polymer) with Synthesis.
148 |
149 | 
150 |
151 |
152 |
153 | ### TODO
154 |
155 | - [ ] extend file1.pug
156 |
157 | ### Social
158 |
159 | Gitter - [meteorwebcomponents](https://gitter.im/aruntk/meteorwebcomponents?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
160 |
161 | Meteor forum - https://forums.meteor.com/t/polymer-meteor-support-with-meteor-webcomponents-packages/20536
162 |
163 | > NO NEED to use any VULCANIZING tools. Synthesis handles everything
164 |
165 |
166 |
--------------------------------------------------------------------------------
/packages/synthesis-pug/.npm/plugin/synthesis-pug/npm-shrinkwrap.json:
--------------------------------------------------------------------------------
1 | {
2 | "lockfileVersion": 1,
3 | "dependencies": {
4 | "acorn": {
5 | "version": "3.3.0",
6 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
7 | "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo="
8 | },
9 | "acorn-globals": {
10 | "version": "3.0.0",
11 | "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-3.0.0.tgz",
12 | "integrity": "sha1-GmTdj6dhKIWUYgZJUm4mJZF6VsY="
13 | },
14 | "align-text": {
15 | "version": "0.1.4",
16 | "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz",
17 | "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc="
18 | },
19 | "amdefine": {
20 | "version": "1.0.1",
21 | "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz",
22 | "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU="
23 | },
24 | "asap": {
25 | "version": "2.0.5",
26 | "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.5.tgz",
27 | "integrity": "sha1-UidltQw1EEkOUtfc/ghe+bqWlY8="
28 | },
29 | "async": {
30 | "version": "0.2.10",
31 | "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz",
32 | "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E="
33 | },
34 | "camelcase": {
35 | "version": "1.2.1",
36 | "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
37 | "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk="
38 | },
39 | "center-align": {
40 | "version": "0.1.3",
41 | "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz",
42 | "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60="
43 | },
44 | "character-parser": {
45 | "version": "2.2.0",
46 | "resolved": "https://registry.npmjs.org/character-parser/-/character-parser-2.2.0.tgz",
47 | "integrity": "sha1-x84o821LzZdE5f/CxfzeHHMmH8A="
48 | },
49 | "clean-css": {
50 | "version": "3.4.23",
51 | "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-3.4.23.tgz",
52 | "integrity": "sha1-YE+7yiTBL+tZsC8AuE8ft97W0AE="
53 | },
54 | "cliui": {
55 | "version": "2.1.0",
56 | "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
57 | "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE="
58 | },
59 | "commander": {
60 | "version": "2.8.1",
61 | "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz",
62 | "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ="
63 | },
64 | "constantinople": {
65 | "version": "3.1.0",
66 | "resolved": "https://registry.npmjs.org/constantinople/-/constantinople-3.1.0.tgz",
67 | "integrity": "sha1-dWnKqKo/jVk11i4fqW+fcCzYHHk="
68 | },
69 | "decamelize": {
70 | "version": "1.2.0",
71 | "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
72 | "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA="
73 | },
74 | "doctypes": {
75 | "version": "1.1.0",
76 | "resolved": "https://registry.npmjs.org/doctypes/-/doctypes-1.1.0.tgz",
77 | "integrity": "sha1-6oCxBqh1OHdOijpKWv4pPeSJ4Kk="
78 | },
79 | "graceful-readlink": {
80 | "version": "1.0.1",
81 | "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
82 | "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU="
83 | },
84 | "is-buffer": {
85 | "version": "1.1.4",
86 | "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.4.tgz",
87 | "integrity": "sha1-z8hszV3FpS+oBIkRHGkgxFfi2Ys="
88 | },
89 | "is-expression": {
90 | "version": "2.1.0",
91 | "resolved": "https://registry.npmjs.org/is-expression/-/is-expression-2.1.0.tgz",
92 | "integrity": "sha1-kb6dR968/vB3l36XIr5tz7RGXvA="
93 | },
94 | "is-promise": {
95 | "version": "2.1.0",
96 | "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz",
97 | "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o="
98 | },
99 | "is-regex": {
100 | "version": "1.0.3",
101 | "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.3.tgz",
102 | "integrity": "sha1-DVUYK9358v3ieCIK7Dp1ZCyQhjc="
103 | },
104 | "js-stringify": {
105 | "version": "1.0.2",
106 | "resolved": "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz",
107 | "integrity": "sha1-Fzb939lyTyijaCrcYjCufk6Weds="
108 | },
109 | "jstransformer": {
110 | "version": "1.0.0",
111 | "resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-1.0.0.tgz",
112 | "integrity": "sha1-7Yvwkh4vPx7U1cGkT2hwntJHIsM="
113 | },
114 | "kind-of": {
115 | "version": "3.1.0",
116 | "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.1.0.tgz",
117 | "integrity": "sha1-R11pil5J/15T0U4+cyQp3Iv0z0c="
118 | },
119 | "lazy-cache": {
120 | "version": "1.0.4",
121 | "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz",
122 | "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4="
123 | },
124 | "longest": {
125 | "version": "1.0.1",
126 | "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
127 | "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc="
128 | },
129 | "object-assign": {
130 | "version": "4.1.0",
131 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz",
132 | "integrity": "sha1-ejs9DpgGPUP0wD8uiubNUahog6A="
133 | },
134 | "promise": {
135 | "version": "7.1.1",
136 | "resolved": "https://registry.npmjs.org/promise/-/promise-7.1.1.tgz",
137 | "integrity": "sha1-SJZUxpJha4qlWwck+oCbt9tJxb8="
138 | },
139 | "pug": {
140 | "version": "2.0.0-beta6",
141 | "resolved": "https://registry.npmjs.org/pug/-/pug-2.0.0-beta6.tgz",
142 | "integrity": "sha1-nq0uWeVApGfvw3h8ywPkV0ul+uk="
143 | },
144 | "pug-attrs": {
145 | "version": "2.0.1",
146 | "resolved": "https://registry.npmjs.org/pug-attrs/-/pug-attrs-2.0.1.tgz",
147 | "integrity": "sha1-i13XwzBzDAn2Ipnga1j9DrxOv9U="
148 | },
149 | "pug-code-gen": {
150 | "version": "1.1.0",
151 | "resolved": "https://registry.npmjs.org/pug-code-gen/-/pug-code-gen-1.1.0.tgz",
152 | "integrity": "sha1-9jim1XkhhVNqSiuzy3O49Fi9wB8="
153 | },
154 | "pug-error": {
155 | "version": "1.3.1",
156 | "resolved": "https://registry.npmjs.org/pug-error/-/pug-error-1.3.1.tgz",
157 | "integrity": "sha1-YWJ0JcP4swexw4sQoLbVyOGjWB8="
158 | },
159 | "pug-filters": {
160 | "version": "1.2.4",
161 | "resolved": "https://registry.npmjs.org/pug-filters/-/pug-filters-1.2.4.tgz",
162 | "integrity": "sha1-kthSRyx0UIVyoNmwyR+dy5rgWDk="
163 | },
164 | "pug-lexer": {
165 | "version": "2.3.0",
166 | "resolved": "https://registry.npmjs.org/pug-lexer/-/pug-lexer-2.3.0.tgz",
167 | "integrity": "sha1-uEGsTNjSdQEoHg+ciPtCQyl6/zo=",
168 | "dependencies": {
169 | "acorn": {
170 | "version": "4.0.4",
171 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.4.tgz",
172 | "integrity": "sha1-F6jWp6bE71OLgU7Jq6wneSk78wo="
173 | },
174 | "is-expression": {
175 | "version": "3.0.0",
176 | "resolved": "https://registry.npmjs.org/is-expression/-/is-expression-3.0.0.tgz",
177 | "integrity": "sha1-Oayqa+f9HzRx3ELHQW5hwkMXrJ8="
178 | }
179 | }
180 | },
181 | "pug-linker": {
182 | "version": "1.0.1",
183 | "resolved": "https://registry.npmjs.org/pug-linker/-/pug-linker-1.0.1.tgz",
184 | "integrity": "sha1-1tp5uRDmg9MxNWcWgEfrr+2S0VM="
185 | },
186 | "pug-load": {
187 | "version": "2.0.3",
188 | "resolved": "https://registry.npmjs.org/pug-load/-/pug-load-2.0.3.tgz",
189 | "integrity": "sha1-/oz4OPecmhJJeFd01Suh1+pD3zc="
190 | },
191 | "pug-parser": {
192 | "version": "2.0.1",
193 | "resolved": "https://registry.npmjs.org/pug-parser/-/pug-parser-2.0.1.tgz",
194 | "integrity": "sha1-3Cxbu3dwR+mDWc1gaGD3X0v8FUE="
195 | },
196 | "pug-runtime": {
197 | "version": "2.0.2",
198 | "resolved": "https://registry.npmjs.org/pug-runtime/-/pug-runtime-2.0.2.tgz",
199 | "integrity": "sha1-lzMavOM5pUNiVKf5sL1lvhFmXCE="
200 | },
201 | "pug-strip-comments": {
202 | "version": "1.0.1",
203 | "resolved": "https://registry.npmjs.org/pug-strip-comments/-/pug-strip-comments-1.0.1.tgz",
204 | "integrity": "sha1-iWlZIaNPz1aFXUMCtCZoa0Jrr9E="
205 | },
206 | "pug-walk": {
207 | "version": "1.0.0",
208 | "resolved": "https://registry.npmjs.org/pug-walk/-/pug-walk-1.0.0.tgz",
209 | "integrity": "sha1-f0rhRWpPGP7uQKDXCLdcHFHS5OQ="
210 | },
211 | "repeat-string": {
212 | "version": "1.6.1",
213 | "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
214 | "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc="
215 | },
216 | "resolve": {
217 | "version": "1.2.0",
218 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.2.0.tgz",
219 | "integrity": "sha1-lYnD8vYUnRQXpAvswWY9tuxrwmw="
220 | },
221 | "right-align": {
222 | "version": "0.1.3",
223 | "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz",
224 | "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8="
225 | },
226 | "source-map": {
227 | "version": "0.4.4",
228 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz",
229 | "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s="
230 | },
231 | "token-stream": {
232 | "version": "0.0.1",
233 | "resolved": "https://registry.npmjs.org/token-stream/-/token-stream-0.0.1.tgz",
234 | "integrity": "sha1-zu78cXp2xDFvEm0LnbqlXX598Bo="
235 | },
236 | "uglify-js": {
237 | "version": "2.7.5",
238 | "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.7.5.tgz",
239 | "integrity": "sha1-RhLAx7qu4rp8SH3kkErhIgefLKg=",
240 | "dependencies": {
241 | "source-map": {
242 | "version": "0.5.6",
243 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz",
244 | "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI="
245 | }
246 | }
247 | },
248 | "uglify-to-browserify": {
249 | "version": "1.0.2",
250 | "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz",
251 | "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc="
252 | },
253 | "void-elements": {
254 | "version": "2.0.1",
255 | "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz",
256 | "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w="
257 | },
258 | "window-size": {
259 | "version": "0.1.0",
260 | "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz",
261 | "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0="
262 | },
263 | "with": {
264 | "version": "5.1.1",
265 | "resolved": "https://registry.npmjs.org/with/-/with-5.1.1.tgz",
266 | "integrity": "sha1-+k2qktrzLE6pTtRTyB8EaGtXXf4="
267 | },
268 | "wordwrap": {
269 | "version": "0.0.2",
270 | "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
271 | "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8="
272 | },
273 | "yargs": {
274 | "version": "3.10.0",
275 | "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
276 | "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E="
277 | }
278 | }
279 | }
280 |
--------------------------------------------------------------------------------
/packages/synthesis-compiler/synthesis-compiler.js:
--------------------------------------------------------------------------------
1 | import parse5 from 'parse5';
2 | import polyclean from 'polyclean';
3 | import fs from 'fs';
4 | import path from 'path';
5 | import _ from 'lodash';
6 | import { Babel } from 'meteor/babel-compiler';
7 | import { Synthesizer } from './synthesis-gen.js';
8 |
9 | export const parseHtml = (arg) => {
10 | const contents = arg.contents;
11 | const parsed = parse5.parse(contents);
12 | // parsed is a json object
13 | const tag = {
14 | tagName: 'template',
15 | attribs: {
16 | id: arg.sourceName,
17 | },
18 | contents: parsed,
19 | fileContents: arg.contents,
20 | sourceName: arg.sourceName,
21 | };
22 | return tag;
23 | };
24 | class DissectHtml {
25 | constructor() {
26 | this.dissected = {
27 | head: '',
28 | body: '',
29 | js: '//*synthesis*//\n',
30 | tailJs: '', // tailJs is appened last
31 | bodyAttrs: {},
32 | };
33 | }
34 | dissect(tag) {
35 | this.document = tag.contents;
36 | this.sourceName = tag.sourceName;
37 | const self = this;
38 | const children = this.document.childNodes || [];
39 | for (let i = 0; i < children.length; i += 1) {
40 | const child = children[i];
41 | switch (child.nodeName) {
42 | case '#documentType':
43 | break;
44 | case '#comment':
45 | break;
46 | case 'html': {
47 | const _children = child.childNodes || [];
48 | for (let _i = 0; _i < _children.length; _i += 1) {
49 | const _child = _children[_i];
50 | switch (_child.nodeName) {
51 | case 'head': {
52 | _child.childNodes = self.processChildNodes(_child.childNodes);
53 | const headContents = parse5.serialize(_child);
54 | // for files inside client folder html contents can be
55 | // directly added to dissected.html
56 | if (self.sourceName.match(/^client\//)) {
57 | self.dissected.head += headContents;
58 | } else {
59 | self.dissected.js += `\n${Synthesizer.generateJS(headContents, true)}\n`;
60 | }
61 | }
62 | break;
63 | case 'body': {
64 | const body = _child;
65 | body.attrs.forEach((attr) => {
66 | const bodyAttrs = self.dissected.bodyAttrs;
67 | const hasNameAttr = {}.hasOwnProperty.call(bodyAttrs, attr.name);
68 | if (!hasNameAttr) {
69 | self.dissected.bodyAttrs[attr.name] = attr.value;
70 | }
71 | });
72 | delete body.attrs;
73 | body.childNodes = self.processChildNodes(body.childNodes);
74 | const bodyContents = parse5.serialize(body);
75 | if (self.sourceName.match(/^client\//)) {
76 | self.dissected.body += bodyContents;
77 | } else {
78 | self.dissected.js += `\n${Synthesizer.generateJS(bodyContents)}\n`;
79 | }
80 | }
81 | break;
82 | default:
83 | break;
84 | }
85 | }
86 | }
87 | break;
88 | default:
89 | break;
90 | }
91 | }
92 | this.dissected.js += `\n${this.dissected.tailJs}\n`;
93 | }
94 | processChildNodes(childNodes) {
95 | const self = this;
96 | let pushNodes = [];
97 | const processedNodes = _.compact(_.map(childNodes, (child) => {
98 | switch (child.nodeName) {
99 | case 'template': {
100 | const template = child;
101 | const tmContent = template.content;
102 | const isWalkable = tmContent && tmContent.nodeName === '#document-fragment' && tmContent.childNodes;
103 | if (isWalkable) {
104 | tmContent.childNodes = self.processChildNodes(tmContent.childNodes);
105 | }
106 | template.content = tmContent;
107 | return template;
108 | }
109 | case 'link': {
110 | const processedLinkChild = self.processLinks(child);
111 | if (processedLinkChild) {
112 | return processedLinkChild;
113 | }
114 | }
115 | break;
116 | case 'script': {
117 | const result = self.processScripts(child);
118 | if (result) {
119 | return result;
120 | }
121 | }
122 | break;
123 | case 'style': {
124 | if (child.childNodes && child.childNodes.length) {
125 | const childNode = child.childNodes[0];
126 | const css = childNode.value;
127 | const result = self.processStyle(css);
128 | if (result) {
129 | childNode.value = result;
130 | }
131 | }
132 | return child;
133 | }
134 | case 'dom-module': {
135 | const domModule = child;
136 | if (domModule.childNodes) {
137 | domModule.childNodes = self.processChildNodes(domModule.childNodes);
138 | }
139 | return domModule;
140 | }
141 | case 'div': {
142 | const divChild = child;
143 | const attrs = _.filter(divChild.attrs, o => (o.name === 'hidden' || o.name === 'by-vulcanize'));
144 | if (attrs.length >= 2) {
145 | const _childNodes = self.processChildNodes(divChild.childNodes);
146 | pushNodes = pushNodes.concat(_childNodes);
147 | } else {
148 | if (divChild.childNodes) {
149 | divChild.childNodes = self.processChildNodes(divChild.childNodes);
150 | }
151 | return divChild;
152 | }
153 | }
154 | break;
155 | case '#comment':
156 | break;
157 |
158 | default: {
159 | const defChild = child;
160 | const attrs = _.map(defChild.attrs, (o) => {
161 | // all src values without [[*]] and {{*}}
162 | if (o.name === 'src' || o.name === 'src$') {
163 | o.value = self._changeRelUrl(o.value);
164 | }
165 | return o;
166 | });
167 | defChild.attrs = attrs;
168 | if (defChild.childNodes) {
169 | defChild.childNodes = self.processChildNodes(defChild.childNodes);
170 | }
171 | return defChild;
172 | }
173 | }
174 | return null;
175 | }));
176 | return processedNodes.concat(pushNodes);
177 | }
178 | processStyle(css, cssBasePath) {
179 | return this._changeCssUrls(polyclean.stripCss(css), cssBasePath);
180 | }
181 | processScripts(child) {
182 | const self = this;
183 | const importSource = _.find(child.attrs, v => (v.name === 'src'));
184 | if (importSource && importSource.value) {
185 | const importableUrl = self.importableUrl(importSource.value);
186 | if (!importableUrl) {
187 | return child;
188 | }
189 | self.dissected.tailJs += `\nrequire('${importableUrl}');\n`;
190 | } else {
191 | self.dissected.tailJs += `\n${self.babelJs(parse5.serialize(child))}\n`;
192 | }
193 | return null;
194 | }
195 | babelJs(js) {
196 | const babelOptions = Babel.getDefaultOptions();
197 | // const prod = process.env.NODE_ENV ==='production';
198 | const external = this.sourceName.match(/node_modules\//);
199 | // const buildFile = this.sourceName === 'imports/ui/build.html';
200 | // return (!external && !buildFile) ? Babel.compile(js, babelOptions).code : js;
201 | try {
202 | return !external ? Babel.compile(js, babelOptions).code: js;
203 | }
204 | catch (err) {
205 | console.error(`Error in ${this.sourceName}`);
206 | console.error(err);
207 | }
208 | }
209 |
210 | importableUrl(url) {
211 | if (url.match(/^(\/|https?:\/)/)) {
212 | return false;
213 | }
214 | return url.match(/^(\.\/|\.\.\/)/) ? url : `./${url}`;
215 | }
216 | processLinks(child) {
217 | const self = this;
218 | // and
219 | const supportedRels = ['import', 'stylesheet'];
220 | const ifImport = _.find(child.attrs, v => (v.name === 'rel' && supportedRels.indexOf(v.value) > -1));
221 | if (ifImport) {
222 | const hrefAttr = _.find(child.attrs, v => v.name === 'href');
223 | if (hrefAttr) {
224 | if (hrefAttr.value) {
225 | switch (ifImport.value) {
226 | case 'import': {
227 | // file is imported using require
228 | const url = self.importableUrl(hrefAttr.value);
229 | if (!url) {
230 | return child;
231 | }
232 | const typeAttr = _.find(child.attrs, v => (v.name === 'type'));
233 | if (typeAttr) {
234 | switch (typeAttr.value) {
235 | case 'css':
236 | const styleChild = self.processCssImport(hrefAttr, child);
237 | return styleChild;
238 | default:
239 | break;
240 | }
241 | }
242 | const link = `require('${url}');`;
243 | self.dissected.tailJs += `\n${link}\n`;
244 | }
245 | break;
246 | // Processing
247 | case 'stylesheet':
248 | // absolute file path
249 | return self.processCssImport(hrefAttr, child);
250 | default:
251 | break;
252 | }
253 | }
254 | } else {
255 | return child;
256 | }
257 | } else {
258 | return child;
259 | }
260 | return null;
261 | }
262 | _changeRelUrl(inpUrl, basePath) {
263 | // avoids var(--url-variable) and bound properties [[prop]] and {{prop}} and data urls
264 | const linkIsNotVar = !inpUrl.match(/^data:|var\(.*?\)|({{|\[\[).*(}}|\]\])/ig)
265 | if (inpUrl && linkIsNotVar) {
266 | // avoids absolute & remote urls
267 | const url = this.importableUrl(inpUrl);
268 | if (url) {
269 | return path.resolve(path.dirname((basePath || `/${this.sourceName}`)), inpUrl);
270 | }
271 | }
272 | return inpUrl;
273 |
274 | }
275 | _changeCssUrls(text, cssBasePath) {
276 | const self = this;
277 | // to get -> property: url(filepath)
278 |
279 | const processed = text.replace(/url\(['|"]?([^)]+?)['|"]?\)/ig, function(_u, url) {
280 | // to get -> filepath from url(filepath), url('filepath') and url("filepath")
281 | return `url(${self._changeRelUrl(url, cssBasePath)})`;
282 | });
283 | return processed;
284 | }
285 | processCssImport(hrefAttr, child) {
286 | const url = path.resolve(this.sourceName, '../', hrefAttr.value);
287 | // checks if file exists
288 | if (fs.existsSync(url)) {
289 | const contents = fs.readFileSync(url, 'utf8');
290 | const cssBasePath = path.resolve(path.dirname(`/${this.sourceName}`), hrefAttr.value);
291 | // css is inlined
292 | const minified = this.processStyle(contents, cssBasePath);
293 | if (minified) {
294 | // link tag is replaced with style tag
295 | return _.extend(child, {
296 | nodeName: 'style',
297 | tagName: 'style',
298 | attrs: [],
299 | childNodes: [
300 | {
301 | nodeName: '#text',
302 | value: minified,
303 | },
304 | ],
305 | });
306 | }
307 | }
308 | return child;
309 | }
310 | }
311 |
312 | export const handleTags = (tags) => {
313 | const handler = new DissectHtml();
314 | handler.dissect(tags);
315 | return handler.dissected;
316 | };
317 |
318 | export const name = 'synthesis-compiler';
319 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Synthesis is meteor + polymer
2 | [](https://gitter.im/aruntk/meteorwebcomponents?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
3 |
4 | ## About
5 |
6 | Synthesis helps you use polymer inside meteor.
7 |
8 | ### Under the hood
9 |
10 | Synthesis uses [parse5](https://github.com/inikulin/parse5) which parses HTML the way the latest version of your browser does.
11 | Does not use any regex to parse html. :)
12 |
13 | > A version that uses cheerio instead of parse ⇒ [synthesis-using-cheerio](https://github.com/meteorwebcomponents/synthesis/tree/cheerio).
14 |
15 | #####Main functions
16 |
17 | 1. Handles html link imports which polymer uses to add dependency files.
18 | 2. Handles external script files (script src)
19 | 3. Handles external css files (link rel stylesheet)
20 | 4. Handles template tags.
21 | 5. Removes comments and unecessary whitespaces.
22 | 5. Handles loading order of html and js inside the polymer files
23 | 4. Adds components to document during runtime.
24 |
25 | ## Installation
26 |
27 | Remove `blaze-html-templates` (or remove the html compiler you are using).
28 |
29 | `meteor remove blaze-html-templates`
30 |
31 | > If you want to use blaze along with synthesis use **[mwc:blaze-html-templating](https://github.com/meteorwebcomponents/blaze-html-templates)** . demo - [blaze+polymer](https://github.com/meteorwebcomponents/synthesis-demo/tree/blaze-polymer)
32 |
33 | Install synthesis
34 |
35 | ```sh
36 | meteor add mwc:synthesis #compiles html files
37 | # synthesis-assets is optional. If you want to handle relative asset paths.
38 | meteor add mwc:synthesis-assets #compiles assets for
115 | Name : {{name}}
116 |
to work.
39 | ```
40 |
41 | synthesis is a meteor 1.3+ package. for 1.2 support use [mwc:compiler](https://github.com/meteorwebcomponents/compiler)
42 |
43 | You can optionally use these packages from meteorwebcomponents
44 |
45 | * [mwc:mixin](https://github.com/meteorwebcomponents/mixin) - Polymer data package.
46 | * [mwc:router](https://github.com/meteorwebcomponents/router) - Flowrouter with polymer.
47 | * [mwc:layout](https://github.com/meteorwebcomponents/layout) - Polymer layout renderer.
48 |
49 |
50 | ## Usage
51 |
52 | ### Polymer Settings
53 |
54 | Create client/lib/settings.js
55 |
56 | Why lib directory ? Settings code should run before anything else.
57 |
58 | ```js
59 | /* client/lib/settings.js */
60 | window.Polymer = {
61 | //dom: 'shadow',
62 | lazyRegister: true
63 | };
64 | ```
65 | ### App Structure
66 |
67 | Refer http://guide.meteor.com
68 |
69 | Application Structure http://guide.meteor.com/structure.html.
70 |
71 | Keep all your components in imports folder
72 |
73 | You can import html using
74 |
75 | 1. `import './component.html';` from js files
76 |
77 | 2. ` `from html files
78 |
79 | > Please note that `import 'package/package.html;'` imports from node_modules directory while `` is the same as `import "./package/package.html";`. This is kept like this to go through polymer components in which dependency files inside the same folder are imported as ``.
80 |
81 | > If you want to import scripts/stylesheets/html from public use `src="/path/to/my/file"`. `src="path/to/my/file"` is interpreted as `import "./path/to/my/file"`.
82 |
83 | Script
84 |
85 | 1. ` `
86 |
87 | 2. ``
88 |
89 | Css (its important follow these two methods to confine style inside the component.)
90 |
91 | 1. ``
92 |
93 | 2. ``
94 |
95 | Add bower_components to any folder inside imports directory.
96 |
97 | Assume bower directory is imports/ui/bower_components
98 |
99 | ```html
100 |
101 |
102 |
103 |
104 |
105 |
226 |
to work.
41 | ```
42 |
43 | synthesis is a meteor 1.3+ package. for 1.2 support use [mwc:compiler](https://github.com/meteorwebcomponents/compiler)
44 |
45 | You can optionally use these packages from meteorwebcomponents
46 |
47 | * [mwc:mixin](https://github.com/meteorwebcomponents/mixin) - Polymer data package.
48 | * [mwc:router](https://github.com/meteorwebcomponents/router) - Flowrouter with polymer.
49 | * [mwc:layout](https://github.com/meteorwebcomponents/layout) - Polymer layout renderer.
50 |
51 |
52 | ## Usage
53 |
54 | ### Polymer Settings
55 |
56 | Create client/lib/settings.js
57 |
58 | Why lib directory ? Settings code should run before anything else.
59 |
60 | ```js
61 | /* client/lib/settings.js */
62 | window.Polymer = {
63 | //dom: 'shadow',
64 | lazyRegister: true
65 | };
66 | ```
67 | ### App Structure
68 |
69 | Refer http://guide.meteor.com
70 |
71 | Application Structure http://guide.meteor.com/structure.html.
72 |
73 | Keep all your components in imports folder
74 |
75 | You can import html using
76 |
77 | 1. `import './component.html';` from js files
78 |
79 | 2. ` `from html files
80 |
81 | > Please note that `import 'package/package.html;'` imports from node_modules directory while `` is the same as `import "./package/package.html";`. This is kept like this to go through polymer components in which dependency files inside the same folder are imported as ``.
82 |
83 | > If you want to import scripts/stylesheets/html from public use `src="/path/to/my/file"`. `src="path/to/my/file"` is interpreted as `import "./path/to/my/file"`.
84 |
85 | Script
86 |
87 | 1. ` `
88 |
89 | 2. ``
90 |
91 | Css (its important follow these two methods to confine style inside the component.)
92 |
93 | 1. ``
94 |
95 | 2. ``
96 |
97 | Add bower_components to any folder inside imports directory.
98 |
99 | Assume bower directory is imports/ui/bower_components
100 |
101 | ```html
102 |
103 |
104 |
105 |
106 |
107 | 117 | Name : {{name}} 118 |
119 |
228 |
to work.
41 | ```
42 |
43 | synthesis is a meteor 1.3+ package. for 1.2 support use [mwc:compiler](https://github.com/meteorwebcomponents/compiler)
44 |
45 | You can optionally use these packages from meteorwebcomponents
46 |
47 | * [mwc:mixin](https://github.com/meteorwebcomponents/mixin) - Polymer data package.
48 | * [mwc:router](https://github.com/meteorwebcomponents/router) - Flowrouter with polymer.
49 | * [mwc:layout](https://github.com/meteorwebcomponents/layout) - Polymer layout renderer.
50 |
51 |
52 | ## Usage
53 |
54 | ### Polymer Settings
55 |
56 | Create client/lib/settings.js
57 |
58 | Why lib directory ? Settings code should run before anything else.
59 |
60 | ```js
61 | /* client/lib/settings.js */
62 | window.Polymer = {
63 | //dom: 'shadow',
64 | lazyRegister: true
65 | };
66 | ```
67 | ### App Structure
68 |
69 | Refer http://guide.meteor.com
70 |
71 | Application Structure http://guide.meteor.com/structure.html.
72 |
73 | Keep all your components in imports folder
74 |
75 | You can import html using
76 |
77 | 1. `import './component.html';` from js files
78 |
79 | 2. ` `from html files
80 |
81 | > Please note that `import 'package/package.html;'` imports from node_modules directory while `` is the same as `import "./package/package.html";`. This is kept like this to go through polymer components in which dependency files inside the same folder are imported as ``.
82 |
83 | > If you want to import scripts/stylesheets/html from public use `src="/path/to/my/file"`. `src="path/to/my/file"` is interpreted as `import "./path/to/my/file"`.
84 |
85 | Script
86 |
87 | 1. ` `
88 |
89 | 2. ``
90 |
91 | Css (its important follow these two methods to confine style inside the component.)
92 |
93 | 1. ``
94 |
95 | 2. ``
96 |
97 | Add bower_components to any folder inside imports directory.
98 |
99 | Assume bower directory is imports/ui/bower_components
100 |
101 | ```html
102 |
103 |
104 |
105 |
106 |
107 | 117 | Name : {{name}} 118 |
119 |
228 |
to work.
41 | ```
42 |
43 | synthesis is a meteor 1.3+ package. for 1.2 support use [mwc:compiler](https://github.com/meteorwebcomponents/compiler)
44 |
45 | You can optionally use these packages from meteorwebcomponents
46 |
47 | * [mwc:mixin](https://github.com/meteorwebcomponents/mixin) - Polymer data package.
48 | * [mwc:router](https://github.com/meteorwebcomponents/router) - Flowrouter with polymer.
49 | * [mwc:layout](https://github.com/meteorwebcomponents/layout) - Polymer layout renderer.
50 |
51 |
52 | ## Usage
53 |
54 | ### Polymer Settings
55 |
56 | Create client/lib/settings.js
57 |
58 | Why lib directory ? Settings code should run before anything else.
59 |
60 | ```js
61 | /* client/lib/settings.js */
62 | window.Polymer = {
63 | //dom: 'shadow',
64 | lazyRegister: true
65 | };
66 | ```
67 | ### App Structure
68 |
69 | Refer http://guide.meteor.com
70 |
71 | Application Structure http://guide.meteor.com/structure.html.
72 |
73 | Keep all your components in imports folder
74 |
75 | You can import html using
76 |
77 | 1. `import './component.html';` from js files
78 |
79 | 2. ` `from html files
80 |
81 | > Please note that `import 'package/package.html;'` imports from node_modules directory while `` is the same as `import "./package/package.html";`. This is kept like this to go through polymer components in which dependency files inside the same folder are imported as ``.
82 |
83 | > If you want to import scripts/stylesheets/html from public use `src="/path/to/my/file"`. `src="path/to/my/file"` is interpreted as `import "./path/to/my/file"`.
84 |
85 | Script
86 |
87 | 1. ` `
88 |
89 | 2. ``
90 |
91 | Css (its important follow these two methods to confine style inside the component.)
92 |
93 | 1. ``
94 |
95 | 2. ``
96 |
97 | Add bower_components to any folder inside imports directory.
98 |
99 | Assume bower directory is imports/ui/bower_components
100 |
101 | ```html
102 |
103 |
104 |
105 |
106 |
107 | 117 | Name : {{name}} 118 |
119 |
228 |