Jean-Yves Didier

finalized migration of the core library from bower + grunt to webpack

1 -module.exports = function (grunt) {
2 - "use strict";
3 -
4 - let shim = function(obj) { return `\nexport default ${obj};\n`; };
5 -
6 -// Project configuration.
7 - grunt.initConfig({
8 - terser: {
9 - build: {
10 - files: {
11 - 'build/arcs.min.js': [
12 - 'build/arcs.js'
13 - ],
14 - 'build/arcs_browser.min.js': [
15 - 'src/arcs_browser.js'
16 - ],
17 - 'build/arcseditor.min.js': [
18 - 'build/arcseditor.js'
19 - ]
20 - }
21 - }
22 - },
23 - bower: {
24 - options : {
25 - verbose: true,
26 - targetDir: './deps',
27 - copy: true,
28 - cleanBowerDir: true,
29 - layout: 'byComponent'
30 - },
31 - install : {
32 -
33 - }
34 -
35 - },
36 - file_append: {
37 - default_options: {
38 - files: [
39 - {
40 - append: shim('AR'),
41 - prepend: `import CV from '../cv/index.js';\n`,
42 - input: './deps/aruco/index.js'
43 - },
44 - {
45 - append: shim('CV'),
46 - input: './deps/cv/index.js'
47 - }
48 - ]
49 - }
50 - },
51 - 'string-replace': {
52 - dist: {
53 - files: {
54 - 'deps/objloader/objloader.js': 'deps/objloader/index.js',
55 - 'deps/mtlloader/mtlloader.js': 'deps/mtlloader/index.js',
56 - 'deps/ddsloader/ddsloader.js': 'deps/ddsloader/index.js'
57 - },
58 - options: {
59 - replacements:[{
60 - pattern: '../../../build/three.module.js',
61 - replacement: '../three.js/index.js'
62 - }]
63 - }
64 -
65 - }
66 - },
67 - concat: {
68 - editor : {
69 - src: [
70 - 'utils/editor/arcseditor.js',
71 - 'utils/editor/dragdrop.js',
72 - 'utils/editor/template.js',
73 - 'utils/editor/dialog.js',
74 - 'utils/editor/componentdialog.js',
75 - 'utils/editor/invocationdialog.js',
76 - 'utils/editor/connectiondialog.js'
77 - ],
78 - dest: 'build/arcseditor.js'
79 - }
80 -
81 - }
82 -
83 - });
84 -
85 - // Load the plugin that provides the "uglify" task.
86 - grunt.loadNpmTasks('grunt-contrib-concat');
87 - grunt.loadNpmTasks('grunt-contrib-copy');
88 - grunt.loadNpmTasks('grunt-jsdoc');
89 - grunt.loadNpmTasks('grunt-jslint');
90 - grunt.loadNpmTasks('grunt-terser');
91 - grunt.loadNpmTasks('grunt-bower-task');
92 - grunt.loadNpmTasks('grunt-file-append');
93 - grunt.loadNpmTasks('grunt-string-replace');
94 -
95 - // Default task(s).
96 - grunt.registerTask('default', ['concat','copy','terser']);
97 - grunt.registerTask('lint', ['jslint']);
98 - grunt.registerTask('doc', ['jsdoc']);
99 - grunt.registerTask('install-deps', ['bower', 'file_append', 'string-replace']);
100 -
101 -};
1 -{
2 - "name": "ARCS",
3 - "version": "0.2.0",
4 - "description": "Augmented Reality Component System in web browser and node environment",
5 - "main": "build/arcs.js",
6 - "keywords": [
7 - "Augmented",
8 - "Reality"
9 - ],
10 - "author": "Jean-Yves Didier",
11 - "license": "GPL",
12 - "dependencies": {
13 - "tracking.js": "*",
14 - "three.js": "https://raw.githubusercontent.com/mrdoob/three.js/r116/build/three.module.js",
15 - "objloader" : "https://raw.githubusercontent.com/mrdoob/three.js/r116/examples/jsm/loaders/OBJLoader.js",
16 - "mtlloader" : "https://raw.githubusercontent.com/mrdoob/three.js/r116/examples/jsm/loaders/MTLLoader.js",
17 - "ddsloader" : "https://raw.githubusercontent.com/mrdoob/three.js/r116/examples/jsm/loaders/DDSLoader.js",
18 - "aruco": "https://raw.githubusercontent.com/jcmellado/js-aruco/master/src/aruco.js",
19 - "cv": "https://raw.githubusercontent.com/jcmellado/js-aruco/master/src/cv.js",
20 - "codemirror" : "*",
21 - "CodeMirror-htmlmixed": "https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/htmlmixed/htmlmixed.js",
22 - "CodeMirror-javascript": "https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/javascript/javascript.js",
23 - "md5" :"*"
24 -
25 -
26 -
27 - }
28 -}
...@@ -40,8 +40,70 @@ module.exports = { ...@@ -40,8 +40,70 @@ module.exports = {
40 }), 40 }),
41 new copy({ 41 new copy({
42 patterns: [ 42 patterns: [
43 - { from : 'src/arcs_browser.js', to: 'arcs_browser.js'}, 43 + { from :'src/arcs_browser.js', to: 'arcs_browser.js'},
44 - { from: 'src/arcs_node.mjs', to: 'arcs_node.mjs'} 44 + { from: 'src/arcs_node.mjs', to: 'arcs_node.mjs'},
45 + { from: 'node_modules/tracking/build/tracking.js', to: '../deps/tracking/tracking.js'},
46 + { from: 'node_modules/three/build/three.module.js', to: '../deps/three.js/index.js'},
47 + {
48 + from: 'node_modules/three/examples/jsm/loaders/OBJLoader.js',
49 + to: '../deps/objloader/index.js',
50 + transform: function(content, path) {
51 + return Buffer.from(content.toString().replace(
52 + '../../../build/three.module.js',
53 + '../three.js/index.js'
54 + ));
55 + }
56 + },
57 + {
58 + from: 'node_modules/three/examples/jsm/loaders/MTLLoader.js',
59 + to: '../deps/mtlloader/index.js',
60 + transform: function(content, path) {
61 + return Buffer.from(content.toString().replace(
62 + '../../../build/three.module.js',
63 + '../three.js/index.js'
64 + ));
65 + }
66 + },
67 + {
68 + from: 'node_modules/three/examples/jsm/loaders/DDSLoader.js',
69 + to: '../deps/ddsloader/index.js',
70 + transform: function(content, path) {
71 + return Buffer.from(content.toString().replace(
72 + '../../../build/three.module.js',
73 + '../three.js/index.js'
74 + ));
75 + }
76 + },
77 + {
78 + from: 'node_modules/js-aruco/src/aruco.js',
79 + to: '../deps/aruco/index.js',
80 + transform: function(content, path) {
81 + return Buffer.from(content.toString()
82 + .replace(
83 + "var CV = require('./cv');",
84 + "import CV from '../cv/index.js';"
85 + )
86 + .replace(
87 + "module.exports = AR;",
88 + "export default AR;"
89 + )
90 + );
91 + }
92 + },
93 + {
94 + from: 'node_modules/js-aruco/src/cv.js',
95 + to: '../deps/cv/index.js',
96 + transform: function(content, path) {
97 + return Buffer.from(content.toString()
98 + .replace(
99 + "module.exports = CV;",
100 + "export default CV;"
101 + )
102 + );
103 + }
104 + },
105 +
106 +
45 // TODO put here also files for dep directory. 107 // TODO put here also files for dep directory.
46 // can also prepend content and replace strings using the transform property! 108 // can also prepend content and replace strings using the transform property!
47 ] 109 ]
...@@ -49,3 +111,48 @@ module.exports = { ...@@ -49,3 +111,48 @@ module.exports = {
49 new eslint({}) 111 new eslint({})
50 ] 112 ]
51 }; 113 };
114 +
115 +
116 +
117 +/*** parts of gruntfile not processed yet
118 +
119 + - minification with probably some custom targets
120 +
121 + files: {
122 + 'build/arcs.min.js': [
123 + 'build/arcs.js'
124 + ],
125 + 'build/arcs_browser.min.js': [
126 + 'src/arcs_browser.js'
127 + ],
128 + 'build/arcseditor.min.js': [
129 + 'build/arcseditor.js'
130 + ]
131 + }
132 +
133 + - editor (to rebuild from scratch)
134 +
135 + editor : {
136 + src: [
137 + 'utils/editor/arcseditor.js',
138 + 'utils/editor/dragdrop.js',
139 + 'utils/editor/template.js',
140 + 'utils/editor/dialog.js',
141 + 'utils/editor/componentdialog.js',
142 + 'utils/editor/invocationdialog.js',
143 + 'utils/editor/connectiondialog.js'
144 + ],
145 + dest: 'build/arcseditor.js'
146 + }
147 +
148 +***/
149 +
150 +/*** parts of bower not processed yet
151 + not sure if it is of any use
152 +
153 + "codemirror" : "*",
154 + "CodeMirror-htmlmixed": "https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/htmlmixed/htmlmixed.js",
155 + "CodeMirror-javascript": "https://raw.githubusercontent.com/codemirror/CodeMirror/master/mode/javascript/javascript.js",
156 + "md5" :"*"
157 +
158 +***/
......