jass 0.9.1 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/jass.rb +5 -0
- data/lib/jass/compiler.rb +5 -0
- data/lib/jass/plugin.rb +2 -1
- data/lib/jass/version.rb +1 -1
- data/vendor/node_modules/@types/estree/index.d.ts +4 -2
- data/vendor/node_modules/@types/estree/package.json +2 -2
- data/vendor/node_modules/acorn/bin/_acorn.js +12 -12
- data/vendor/node_modules/acorn/bin/run_test262.js +2 -3
- data/vendor/node_modules/acorn/bin/test262.whitelist +0 -5
- data/vendor/node_modules/acorn/dist/acorn.es.js +76 -68
- data/vendor/node_modules/acorn/dist/acorn.js +76 -68
- data/vendor/node_modules/acorn/dist/acorn_loose.es.js +42 -30
- data/vendor/node_modules/acorn/dist/acorn_loose.js +42 -30
- data/vendor/node_modules/acorn/dist/walk.es.js +47 -43
- data/vendor/node_modules/acorn/dist/walk.js +47 -43
- data/vendor/node_modules/acorn/package.json +9 -5
- data/vendor/node_modules/chalk/index.js.flow +93 -0
- data/vendor/node_modules/chalk/package.json +8 -3
- data/vendor/node_modules/color-convert/conversions.js +36 -29
- data/vendor/node_modules/color-convert/package.json +4 -4
- data/vendor/node_modules/estree-walker/index.d.ts +17 -0
- data/vendor/node_modules/estree-walker/package.json +2 -1
- data/vendor/node_modules/fill-range/index.js +2 -2
- data/vendor/node_modules/fill-range/package.json +24 -7
- data/vendor/node_modules/is-reference/node_modules/@types/estree/index.d.ts +546 -0
- data/vendor/node_modules/is-reference/node_modules/@types/estree/package.json +22 -0
- data/vendor/node_modules/math-random/browser.js +17 -0
- data/vendor/node_modules/math-random/node.js +13 -0
- data/vendor/node_modules/math-random/package.json +31 -0
- data/vendor/node_modules/math-random/test.js +26 -0
- data/vendor/node_modules/nodent-compiler/compiler.js +115 -11
- data/vendor/node_modules/nodent-compiler/{lib/output.js → output.js} +0 -0
- data/vendor/node_modules/nodent-compiler/package.json +8 -4
- data/vendor/node_modules/{nodent-compiler/lib → nodent-transform}/arboriculture.js +1340 -1107
- data/vendor/node_modules/nodent-transform/package.json +19 -0
- data/vendor/node_modules/path-parse/package.json +1 -1
- data/vendor/node_modules/pretty-ms/index.js +2 -1
- data/vendor/node_modules/pretty-ms/package.json +2 -3
- data/vendor/node_modules/randomatic/index.js +12 -2
- data/vendor/node_modules/randomatic/node_modules/is-number/index.js +6 -7
- data/vendor/node_modules/randomatic/node_modules/is-number/package.json +9 -16
- data/vendor/node_modules/randomatic/node_modules/kind-of/index.js +112 -102
- data/vendor/node_modules/randomatic/node_modules/kind-of/package.json +18 -20
- data/vendor/node_modules/randomatic/package.json +15 -13
- data/vendor/node_modules/repeat-element/index.js +1 -1
- data/vendor/node_modules/repeat-element/package.json +27 -22
- data/vendor/node_modules/resolve/lib/async.js +20 -17
- data/vendor/node_modules/resolve/lib/core.js +2 -2
- data/vendor/node_modules/resolve/lib/core.json +4 -1
- data/vendor/node_modules/resolve/lib/sync.js +52 -13
- data/vendor/node_modules/resolve/package.json +3 -3
- data/vendor/node_modules/rollup-plugin-commonjs/dist/rollup-plugin-commonjs.cjs.js +50 -12
- data/vendor/node_modules/rollup-plugin-commonjs/dist/rollup-plugin-commonjs.es.js +50 -12
- data/vendor/node_modules/rollup-plugin-commonjs/package.json +2 -2
- data/vendor/node_modules/rollup-plugin-commonjs/src/index.js +49 -11
- data/vendor/node_modules/rollup-plugin-commonjs/src/transform.js +1 -1
- data/vendor/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js +82 -85
- data/vendor/node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.es.js +82 -85
- data/vendor/node_modules/rollup-plugin-node-resolve/package.json +1 -1
- data/vendor/node_modules/rollup-plugin-node-resolve/src/index.js +81 -84
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.cjs.js +81 -2
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es.js +81 -3
- data/vendor/node_modules/rollup-pluginutils/package.json +12 -6
- data/vendor/node_modules/rollup-pluginutils/src/attachScopes.js +10 -2
- data/vendor/node_modules/rollup-pluginutils/src/dataToEsm.js +69 -0
- data/vendor/node_modules/rollup-pluginutils/src/index.js +1 -0
- data/vendor/node_modules/supports-color/index.js +1 -5
- data/vendor/node_modules/supports-color/package.json +51 -51
- data/vendor/yarn.lock +65 -70
- metadata +16 -21
- data/vendor/node_modules/irregular-plurals/irregular-plurals.json +0 -146
- data/vendor/node_modules/irregular-plurals/package.json +0 -39
- data/vendor/node_modules/nodent-compiler/lib/parser.js +0 -291
- data/vendor/node_modules/path-parse/index.min.js +0 -1
- data/vendor/node_modules/path-parse/test.min.js +0 -1
- data/vendor/node_modules/plur/index.js +0 -20
- data/vendor/node_modules/plur/package.json +0 -42
- data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/index.js +0 -116
- data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/package.json +0 -90
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es6.js +0 -217
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/dist/estree-walker.es.js +0 -55
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/dist/estree-walker.es6.js +0 -59
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/dist/estree-walker.umd.js +0 -65
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/package.json +0 -33
- data/vendor/node_modules/rollup-pluginutils/node_modules/estree-walker/src/estree-walker.js +0 -49
@@ -11,7 +11,9 @@ var CONSOLE_WARN = function () {
|
|
11
11
|
|
12
12
|
return console.warn.apply( console, args );
|
13
13
|
}; // eslint-disable-line no-console
|
14
|
-
|
14
|
+
// It is important that .mjs occur before .js so that Rollup will interpret npm modules
|
15
|
+
// which deploy both ESM .mjs and CommonJS .js files as ESM.
|
16
|
+
var DEFAULT_EXTS = [ '.mjs', '.js', '.json', '.node' ];
|
15
17
|
|
16
18
|
var readFileCache = {};
|
17
19
|
var readFileAsync = function (file) { return new Promise(function (fulfil, reject) { return fs.readFile(file, function (err, contents) { return err ? reject(err) : fulfil(contents); }); }); };
|
@@ -41,6 +43,8 @@ function cachedIsFile (file, cb) {
|
|
41
43
|
isFileCache[file].then(function (contents) { return cb(null, contents); }, cb);
|
42
44
|
}
|
43
45
|
|
46
|
+
var resolveIdAsync = function (file, opts) { return new Promise(function (fulfil, reject) { return resolveId(file, opts, function (err, contents) { return err ? reject(err) : fulfil(contents); }); }); };
|
47
|
+
|
44
48
|
function nodeResolve ( options ) {
|
45
49
|
if ( options === void 0 ) options = {};
|
46
50
|
|
@@ -83,7 +87,7 @@ function nodeResolve ( options ) {
|
|
83
87
|
readFileCache = {};
|
84
88
|
},
|
85
89
|
|
86
|
-
resolveId: function resolveId
|
90
|
+
resolveId: function resolveId$$1 ( importee, importer ) {
|
87
91
|
if ( /\0/.test( importee ) ) { return null; } // ignore IDs with null character, these belong to other plugins
|
88
92
|
|
89
93
|
// disregard entry module
|
@@ -114,99 +118,92 @@ function nodeResolve ( options ) {
|
|
114
118
|
|
115
119
|
if (only && !only.some(function (pattern) { return pattern.test(id); })) { return null; }
|
116
120
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
}
|
121
|
+
var disregardResult = false;
|
122
|
+
var packageBrowserField = false;
|
123
|
+
var extensions = options.extensions || DEFAULT_EXTS;
|
124
|
+
|
125
|
+
var resolveOptions = {
|
126
|
+
basedir: dirname( importer ),
|
127
|
+
packageFilter: function packageFilter ( pkg, pkgPath ) {
|
128
|
+
var pkgRoot = dirname( pkgPath );
|
129
|
+
if (options.browser && typeof pkg[ 'browser' ] === 'object') {
|
130
|
+
packageBrowserField = Object.keys(pkg[ 'browser' ]).reduce(function (browser, key) {
|
131
|
+
var resolved = pkg[ 'browser' ][ key ] === false ? false : resolve( pkgRoot, pkg[ 'browser' ][ key ] );
|
132
|
+
browser[ key ] = resolved;
|
133
|
+
if ( key[0] === '.' ) {
|
134
|
+
var absoluteKey = resolve( pkgRoot, key );
|
135
|
+
browser[ absoluteKey ] = resolved;
|
136
|
+
if ( !extname(key) ) {
|
137
|
+
extensions.reduce( function ( browser, ext ) {
|
138
|
+
browser[ absoluteKey + ext ] = browser[ key ];
|
139
|
+
return browser;
|
140
|
+
}, browser );
|
138
141
|
}
|
139
|
-
|
140
|
-
|
141
|
-
}
|
142
|
+
}
|
143
|
+
return browser;
|
144
|
+
}, {});
|
145
|
+
}
|
142
146
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
147
|
+
if (options.browser && typeof pkg[ 'browser' ] === 'string') {
|
148
|
+
pkg[ 'main' ] = pkg[ 'browser' ];
|
149
|
+
} else if ( useModule && pkg[ 'module' ] ) {
|
150
|
+
pkg[ 'main' ] = pkg[ 'module' ];
|
151
|
+
} else if ( useJsnext && pkg[ 'jsnext:main' ] ) {
|
152
|
+
pkg[ 'main' ] = pkg[ 'jsnext:main' ];
|
153
|
+
} else if ( ( useJsnext || useModule ) && !useMain ) {
|
154
|
+
disregardResult = true;
|
155
|
+
}
|
156
|
+
return pkg;
|
157
|
+
},
|
158
|
+
readFile: cachedReadFile,
|
159
|
+
isFile: cachedIsFile,
|
160
|
+
extensions: extensions
|
161
|
+
};
|
162
|
+
|
163
|
+
if (preserveSymlinks !== undefined) {
|
164
|
+
resolveOptions.preserveSymlinks = preserveSymlinks;
|
165
|
+
}
|
162
166
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
167
|
+
return resolveIdAsync(
|
168
|
+
importee,
|
169
|
+
Object.assign( resolveOptions, customResolveOptions )
|
170
|
+
)
|
171
|
+
.catch(function () { return false; })
|
172
|
+
.then(function (resolved) {
|
173
|
+
if (options.browser && packageBrowserField) {
|
174
|
+
if (packageBrowserField[ resolved ]) {
|
175
|
+
resolved = packageBrowserField[ resolved ];
|
172
176
|
}
|
177
|
+
browserMapCache[resolved] = packageBrowserField;
|
178
|
+
}
|
173
179
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
180
|
+
if ( !disregardResult && resolved !== false ) {
|
181
|
+
if ( !preserveSymlinks && resolved && fs.existsSync( resolved ) ) {
|
182
|
+
resolved = fs.realpathSync( resolved );
|
183
|
+
}
|
178
184
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
}
|
189
|
-
fulfil( null );
|
190
|
-
} else if ( jail && resolved.indexOf( normalize( jail.trim( sep ) ) ) !== 0 ) {
|
191
|
-
fulfil( null );
|
185
|
+
if ( ~builtins.indexOf( resolved ) ) {
|
186
|
+
return null;
|
187
|
+
} else if ( ~builtins.indexOf( importee ) && preferBuiltins ) {
|
188
|
+
if ( !isPreferBuiltinsSet ) {
|
189
|
+
onwarn(
|
190
|
+
"preferring built-in module '" + importee + "' over local alternative " +
|
191
|
+
"at '" + resolved + "', pass 'preferBuiltins: false' to disable this " +
|
192
|
+
"behavior or 'preferBuiltins: true' to disable this warning"
|
193
|
+
);
|
192
194
|
}
|
195
|
+
return null;
|
196
|
+
} else if ( jail && resolved.indexOf( normalize( jail.trim( sep ) ) ) !== 0 ) {
|
197
|
+
return null;
|
193
198
|
}
|
199
|
+
}
|
194
200
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
} else {
|
200
|
-
var valid = isModule( code );
|
201
|
-
fulfil( valid ? resolved : null );
|
202
|
-
}
|
203
|
-
});
|
204
|
-
} else {
|
205
|
-
fulfil( resolved );
|
206
|
-
}
|
201
|
+
if ( resolved && options.modulesOnly ) {
|
202
|
+
return readFileAsync( resolved, 'utf-8').then(function (code) { return isModule( code ) ? resolved : null; });
|
203
|
+
} else {
|
204
|
+
return resolved === false ? null : resolved;
|
207
205
|
}
|
208
|
-
);
|
209
|
-
});
|
206
|
+
});
|
210
207
|
}
|
211
208
|
};
|
212
209
|
}
|
@@ -6,7 +6,9 @@ import fs from 'fs';
|
|
6
6
|
|
7
7
|
const ES6_BROWSER_EMPTY = resolve( __dirname, '../src/empty.js' );
|
8
8
|
const CONSOLE_WARN = ( ...args ) => console.warn( ...args ); // eslint-disable-line no-console
|
9
|
-
|
9
|
+
// It is important that .mjs occur before .js so that Rollup will interpret npm modules
|
10
|
+
// which deploy both ESM .mjs and CommonJS .js files as ESM.
|
11
|
+
const DEFAULT_EXTS = [ '.mjs', '.js', '.json', '.node' ];
|
10
12
|
|
11
13
|
let readFileCache = {};
|
12
14
|
const readFileAsync = file => new Promise((fulfil, reject) => fs.readFile(file, (err, contents) => err ? reject(err) : fulfil(contents)));
|
@@ -36,6 +38,8 @@ function cachedIsFile (file, cb) {
|
|
36
38
|
isFileCache[file].then(contents => cb(null, contents), cb);
|
37
39
|
}
|
38
40
|
|
41
|
+
const resolveIdAsync = (file, opts) => new Promise((fulfil, reject) => resolveId(file, opts, (err, contents) => err ? reject(err) : fulfil(contents)));
|
42
|
+
|
39
43
|
export default function nodeResolve ( options = {} ) {
|
40
44
|
const useModule = options.module !== false;
|
41
45
|
const useMain = options.main !== false;
|
@@ -107,99 +111,92 @@ export default function nodeResolve ( options = {} ) {
|
|
107
111
|
|
108
112
|
if (only && !only.some(pattern => pattern.test(id))) return null;
|
109
113
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
}
|
114
|
+
let disregardResult = false;
|
115
|
+
let packageBrowserField = false;
|
116
|
+
const extensions = options.extensions || DEFAULT_EXTS;
|
117
|
+
|
118
|
+
const resolveOptions = {
|
119
|
+
basedir: dirname( importer ),
|
120
|
+
packageFilter ( pkg, pkgPath ) {
|
121
|
+
const pkgRoot = dirname( pkgPath );
|
122
|
+
if (options.browser && typeof pkg[ 'browser' ] === 'object') {
|
123
|
+
packageBrowserField = Object.keys(pkg[ 'browser' ]).reduce((browser, key) => {
|
124
|
+
const resolved = pkg[ 'browser' ][ key ] === false ? false : resolve( pkgRoot, pkg[ 'browser' ][ key ] );
|
125
|
+
browser[ key ] = resolved;
|
126
|
+
if ( key[0] === '.' ) {
|
127
|
+
const absoluteKey = resolve( pkgRoot, key );
|
128
|
+
browser[ absoluteKey ] = resolved;
|
129
|
+
if ( !extname(key) ) {
|
130
|
+
extensions.reduce( ( browser, ext ) => {
|
131
|
+
browser[ absoluteKey + ext ] = browser[ key ];
|
132
|
+
return browser;
|
133
|
+
}, browser );
|
131
134
|
}
|
132
|
-
|
133
|
-
|
134
|
-
}
|
135
|
+
}
|
136
|
+
return browser;
|
137
|
+
}, {});
|
138
|
+
}
|
135
139
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
140
|
+
if (options.browser && typeof pkg[ 'browser' ] === 'string') {
|
141
|
+
pkg[ 'main' ] = pkg[ 'browser' ];
|
142
|
+
} else if ( useModule && pkg[ 'module' ] ) {
|
143
|
+
pkg[ 'main' ] = pkg[ 'module' ];
|
144
|
+
} else if ( useJsnext && pkg[ 'jsnext:main' ] ) {
|
145
|
+
pkg[ 'main' ] = pkg[ 'jsnext:main' ];
|
146
|
+
} else if ( ( useJsnext || useModule ) && !useMain ) {
|
147
|
+
disregardResult = true;
|
148
|
+
}
|
149
|
+
return pkg;
|
150
|
+
},
|
151
|
+
readFile: cachedReadFile,
|
152
|
+
isFile: cachedIsFile,
|
153
|
+
extensions: extensions
|
154
|
+
};
|
155
|
+
|
156
|
+
if (preserveSymlinks !== undefined) {
|
157
|
+
resolveOptions.preserveSymlinks = preserveSymlinks;
|
158
|
+
}
|
155
159
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
160
|
+
return resolveIdAsync(
|
161
|
+
importee,
|
162
|
+
Object.assign( resolveOptions, customResolveOptions )
|
163
|
+
)
|
164
|
+
.catch(() => false)
|
165
|
+
.then(resolved => {
|
166
|
+
if (options.browser && packageBrowserField) {
|
167
|
+
if (packageBrowserField[ resolved ]) {
|
168
|
+
resolved = packageBrowserField[ resolved ];
|
165
169
|
}
|
170
|
+
browserMapCache[resolved] = packageBrowserField;
|
171
|
+
}
|
166
172
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
173
|
+
if ( !disregardResult && resolved !== false ) {
|
174
|
+
if ( !preserveSymlinks && resolved && fs.existsSync( resolved ) ) {
|
175
|
+
resolved = fs.realpathSync( resolved );
|
176
|
+
}
|
171
177
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
}
|
182
|
-
fulfil( null );
|
183
|
-
} else if ( jail && resolved.indexOf( normalize( jail.trim( sep ) ) ) !== 0 ) {
|
184
|
-
fulfil( null );
|
178
|
+
if ( ~builtins.indexOf( resolved ) ) {
|
179
|
+
return null;
|
180
|
+
} else if ( ~builtins.indexOf( importee ) && preferBuiltins ) {
|
181
|
+
if ( !isPreferBuiltinsSet ) {
|
182
|
+
onwarn(
|
183
|
+
`preferring built-in module '${importee}' over local alternative ` +
|
184
|
+
`at '${resolved}', pass 'preferBuiltins: false' to disable this ` +
|
185
|
+
`behavior or 'preferBuiltins: true' to disable this warning`
|
186
|
+
);
|
185
187
|
}
|
188
|
+
return null;
|
189
|
+
} else if ( jail && resolved.indexOf( normalize( jail.trim( sep ) ) ) !== 0 ) {
|
190
|
+
return null;
|
186
191
|
}
|
192
|
+
}
|
187
193
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
} else {
|
193
|
-
const valid = isModule( code );
|
194
|
-
fulfil( valid ? resolved : null );
|
195
|
-
}
|
196
|
-
});
|
197
|
-
} else {
|
198
|
-
fulfil( resolved );
|
199
|
-
}
|
194
|
+
if ( resolved && options.modulesOnly ) {
|
195
|
+
return readFileAsync( resolved, 'utf-8').then(code => isModule( code ) ? resolved : null);
|
196
|
+
} else {
|
197
|
+
return resolved === false ? null : resolved;
|
200
198
|
}
|
201
|
-
);
|
202
|
-
});
|
199
|
+
});
|
203
200
|
}
|
204
201
|
};
|
205
202
|
}
|
@@ -21,13 +21,21 @@ var blockDeclarations = {
|
|
21
21
|
};
|
22
22
|
|
23
23
|
var extractors = {
|
24
|
+
Literal: function Literal ( names, param ) {
|
25
|
+
names.push( param.value );
|
26
|
+
},
|
27
|
+
|
24
28
|
Identifier: function Identifier ( names, param ) {
|
25
29
|
names.push( param.name );
|
26
30
|
},
|
27
31
|
|
28
32
|
ObjectPattern: function ObjectPattern ( names, param ) {
|
29
33
|
param.properties.forEach( function (prop) {
|
30
|
-
|
34
|
+
if ( prop.type === 'RestElement' ) {
|
35
|
+
extractors.RestElement( names, prop );
|
36
|
+
} else {
|
37
|
+
extractors[ (prop.value || prop.key).type ]( names, prop.value || prop.key );
|
38
|
+
}
|
31
39
|
});
|
32
40
|
},
|
33
41
|
|
@@ -79,7 +87,7 @@ Scope.prototype.addDeclaration = function addDeclaration ( node, isBlockDeclarat
|
|
79
87
|
// it's a `var` or function node, and this
|
80
88
|
// is a block scope, so we need to go up
|
81
89
|
this.parent.addDeclaration( node, isBlockDeclaration, isVar );
|
82
|
-
} else {
|
90
|
+
} else if ( node.id ) {
|
83
91
|
extractNames( node.id ).forEach( function (name) {
|
84
92
|
this$1.declarations[ name ] = true;
|
85
93
|
});
|
@@ -217,7 +225,78 @@ function makeLegalIdentifier ( str ) {
|
|
217
225
|
return str;
|
218
226
|
}
|
219
227
|
|
228
|
+
function serializeArray (arr, indent, baseIndent) {
|
229
|
+
var output = '[';
|
230
|
+
var separator = indent ? '\n' + baseIndent + indent : '';
|
231
|
+
for (var i = 0; i < arr.length; i++) {
|
232
|
+
var key = arr[i];
|
233
|
+
output += "" + (i > 0 ? ',' : '') + separator + (serialize(key, indent, baseIndent + indent));
|
234
|
+
}
|
235
|
+
return output + (indent ? '\n' + baseIndent : '') + "]";
|
236
|
+
}
|
237
|
+
|
238
|
+
function serializeObject (obj, indent, baseIndent) {
|
239
|
+
var output = '{';
|
240
|
+
var separator = indent ? '\n' + baseIndent + indent : '';
|
241
|
+
var keys = Object.keys(obj);
|
242
|
+
for (var i = 0; i < keys.length; i++) {
|
243
|
+
var key = keys[i];
|
244
|
+
var stringKey = makeLegalIdentifier(key) === key ? key : JSON.stringify(key);
|
245
|
+
output += "" + (i > 0 ? ',' : '') + separator + stringKey + ":" + (indent ? ' ' : '') + (serialize(obj[key], indent, baseIndent + indent));
|
246
|
+
}
|
247
|
+
return output + (indent ? '\n' + baseIndent : '') + "}";
|
248
|
+
}
|
249
|
+
|
250
|
+
function serialize (obj, indent, baseIndent) {
|
251
|
+
if (obj === Infinity)
|
252
|
+
{ return 'Infinity'; }
|
253
|
+
if (obj instanceof Date)
|
254
|
+
{ return 'new Date(' + obj.getTime() + ')'; }
|
255
|
+
if (obj instanceof RegExp)
|
256
|
+
{ return obj.toString(); }
|
257
|
+
if (typeof obj === 'number' && isNaN(obj))
|
258
|
+
{ return 'NaN'; }
|
259
|
+
if (Array.isArray(obj))
|
260
|
+
{ return serializeArray(obj, indent, baseIndent); }
|
261
|
+
if (obj === null)
|
262
|
+
{ return 'null'; }
|
263
|
+
if (typeof obj === 'object')
|
264
|
+
{ return serializeObject(obj, indent, baseIndent); }
|
265
|
+
return JSON.stringify(obj);
|
266
|
+
}
|
267
|
+
|
268
|
+
// convert data object into separate named exports (and default)
|
269
|
+
function dataToNamedExports (data, options) {
|
270
|
+
if ( options === void 0 ) options = {};
|
271
|
+
|
272
|
+
var t = options.compact ? '' : 'indent' in options ? options.indent : '\t';
|
273
|
+
var _ = options.compact ? '' : ' ';
|
274
|
+
var n = options.compact ? '' : '\n';
|
275
|
+
var declarationType = options.preferConst ? 'const' : 'var';
|
276
|
+
|
277
|
+
if (options.namedExports === false || typeof data !== 'object' || Array.isArray(data) || data === null)
|
278
|
+
{ return ("export default" + _ + (serialize( data, options.compact ? null : t, '' )) + ";"); }
|
279
|
+
|
280
|
+
var namedExportCode = '';
|
281
|
+
var defaultExportRows = [];
|
282
|
+
var dataKeys = Object.keys(data);
|
283
|
+
for (var i = 0; i < dataKeys.length; i++) {
|
284
|
+
var key = dataKeys[i];
|
285
|
+
if (key === makeLegalIdentifier(key)) {
|
286
|
+
if (options.objectShorthand)
|
287
|
+
{ defaultExportRows.push(key); }
|
288
|
+
else
|
289
|
+
{ defaultExportRows.push((key + ":" + _ + key)); }
|
290
|
+
namedExportCode += "export " + declarationType + " " + key + _ + "=" + _ + (serialize(data[key], options.compact ? null : t, '')) + ";" + n;
|
291
|
+
} else {
|
292
|
+
defaultExportRows.push(((JSON.stringify(key)) + ": " + (serialize(data[key], options.compact ? null : t, ''))));
|
293
|
+
}
|
294
|
+
}
|
295
|
+
return namedExportCode + "export default" + _ + "{" + n + t + (defaultExportRows.join(("," + n + t))) + n + "};" + n;
|
296
|
+
}
|
297
|
+
|
220
298
|
exports.addExtension = addExtension;
|
221
299
|
exports.attachScopes = attachScopes;
|
222
300
|
exports.createFilter = createFilter;
|
223
301
|
exports.makeLegalIdentifier = makeLegalIdentifier;
|
302
|
+
exports.dataToEsm = dataToNamedExports;
|