"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/discourse_js_processor.rb" between
discourse-2.7.3.tar.gz and discourse-2.7.4.tar.gz

About: Discourse is a "next-generation" forum platform for community discussions.

discourse_js_processor.rb  (discourse-2.7.3):discourse_js_processor.rb  (discourse-2.7.4)
skipping to change at line 99 skipping to change at line 99
ctx.eval <<JS ctx.eval <<JS
console = { console = {
prefix: "", prefix: "",
log: function(msg){ rails.logger.info(console.prefix + msg); }, log: function(msg){ rails.logger.info(console.prefix + msg); },
error: function(msg){ rails.logger.error(console.prefix + msg); } error: function(msg){ rails.logger.error(console.prefix + msg); }
} }
JS JS
source = File.read("#{Rails.root}/lib/javascripts/widget-hbs-compiler.js") source = File.read("#{Rails.root}/lib/javascripts/widget-hbs-compiler.js")
js_source = ::JSON.generate(source, quirks_mode: true) js_source = ::JSON.generate(source, quirks_mode: true)
js = ctx.eval("Babel.transform(#{js_source}, { ast: false, plugins: ['tran sform-arrow-functions', 'transform-block-scoped-functions', 'transform-block-sco ping', 'transform-computed-properties', 'transform-destructuring', 'transform-du plicate-keys', 'transform-for-of', 'transform-function-name', 'transform-literal s', 'transform-object-super', 'transform-parameters', 'transform-shorthand-prope rties', 'transform-spread', 'transform-sticky-regex', 'transform-template-litera ls', 'transform-typeof-symbol', 'transform-unicode-regex', 'proposal-object-rest -spread'] }).code") js = ctx.eval("Babel.transform(#{js_source}, { ast: false, plugins: ['tran sform-arrow-functions', 'transform-block-scoped-functions', 'transform-block-sco ping', 'transform-computed-properties', 'transform-destructuring', 'transform-du plicate-keys', 'transform-for-of', 'transform-function-name', 'transform-literal s', 'transform-object-super', 'transform-parameters', 'transform-shorthand-prope rties', 'transform-spread', 'transform-sticky-regex', 'transform-template-litera ls', 'transform-typeof-symbol', 'transform-unicode-regex', 'proposal-object-rest -spread', 'proposal-optional-chaining'] }).code")
ctx.eval(js) ctx.eval(js)
ctx ctx
end end
def self.reset_context def self.reset_context
@ctx&.dispose @ctx&.dispose
@ctx = nil @ctx = nil
end end
skipping to change at line 146 skipping to change at line 146
end end
end end
def babel_source(source, opts = nil) def babel_source(source, opts = nil)
opts ||= {} opts ||= {}
js_source = ::JSON.generate(source, quirks_mode: true) js_source = ::JSON.generate(source, quirks_mode: true)
if opts[:module_name] && !@skip_module if opts[:module_name] && !@skip_module
filename = opts[:filename] || 'unknown' filename = opts[:filename] || 'unknown'
"Babel.transform(#{js_source}, { moduleId: '#{opts[:module_name]}', file name: '#{filename}', ast: false, presets: ['es2015'], plugins: [['transform-modu les-amd', {noInterop: true}], 'proposal-object-rest-spread', ['proposal-decorato rs', {legacy: true} ], exports.WidgetHbsCompiler] }).code" "Babel.transform(#{js_source}, { moduleId: '#{opts[:module_name]}', file name: '#{filename}', ast: false, presets: ['es2015'], plugins: [['transform-modu les-amd', {noInterop: true}], 'proposal-object-rest-spread', 'proposal-optional- chaining', ['proposal-decorators', {legacy: true} ], 'proposal-class-properties' , exports.WidgetHbsCompiler] }).code"
else else
"Babel.transform(#{js_source}, { ast: false, plugins: ['proposal-json-st rings', 'proposal-nullish-coalescing-operator', 'proposal-logical-assignment-ope rators', 'proposal-numeric-separator', 'proposal-optional-catch-binding', 'trans form-dotall-regex', 'proposal-unicode-property-regex', 'transform-named-capturin g-groups-regex', 'proposal-object-rest-spread', 'proposal-optional-chaining', 't ransform-arrow-functions', 'transform-block-scoped-functions', 'transform-block- scoping', 'transform-computed-properties', 'transform-destructuring', 'transform -duplicate-keys', 'transform-for-of', 'transform-function-name', 'transform-lite rals', 'transform-object-super', 'transform-parameters', 'transform-shorthand-pr operties', 'transform-spread', 'transform-sticky-regex', 'transform-template-lit erals', 'transform-typeof-symbol', 'transform-unicode-regex', ['proposal-decorat ors', {legacy: true}], exports.WidgetHbsCompiler] }).code" "Babel.transform(#{js_source}, { ast: false, plugins: ['proposal-json-st rings', 'proposal-nullish-coalescing-operator', 'proposal-logical-assignment-ope rators', 'proposal-numeric-separator', 'proposal-optional-catch-binding', 'trans form-dotall-regex', 'proposal-unicode-property-regex', 'transform-named-capturin g-groups-regex', 'proposal-object-rest-spread', 'proposal-optional-chaining', 't ransform-arrow-functions', 'transform-block-scoped-functions', 'transform-block- scoping', 'transform-computed-properties', 'transform-destructuring', 'transform -duplicate-keys', 'transform-for-of', 'transform-function-name', 'transform-lite rals', 'transform-object-super', 'transform-parameters', 'transform-shorthand-pr operties', 'transform-spread', 'transform-sticky-regex', 'transform-template-lit erals', 'transform-typeof-symbol', 'transform-unicode-regex', ['proposal-decorat ors', {legacy: true}], 'proposal-class-properties', exports.WidgetHbsCompiler] } ).code"
end end
end end
def module_name(root_path, logical_path) def module_name(root_path, logical_path)
path = nil path = nil
root_base = File.basename(Rails.root) root_base = File.basename(Rails.root)
# If the resource is a plugin, use the plugin name as a prefix # If the resource is a plugin, use the plugin name as a prefix
if root_path =~ /(.*\/#{root_base}\/plugins\/[^\/]+)\// if root_path =~ /(.*\/#{root_base}\/plugins\/[^\/]+)\//
plugin_path = "#{Regexp.last_match[1]}/plugin.rb" plugin_path = "#{Regexp.last_match[1]}/plugin.rb"
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)