hyperstack-config 1.0.alpha1.4 → 1.0.alpha1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60c21092fde747464cfb3942b3871d93d186577009ae7eb0435621ddf3cbd357
4
- data.tar.gz: 4946f4a97f818dae12f89ed66c90bee89e36be1329afc9059a5ad8eae1b6d8bc
3
+ metadata.gz: d14021b6ecdd6098649de52f6da0252c1293adf0c78e5d3def26df3a15a3564c
4
+ data.tar.gz: c9da07047b3a4b765986c70ea1461e41458d6bf638b3c00530bd2e252a97d3f4
5
5
  SHA512:
6
- metadata.gz: aaaa02d68b6390e11ab5cd8de537235c7ebf43c083bdb2185ade0785186350df5eb5056be9778e34367d4bd0c040c83e8f425bd0c45bbc416ac12f56e14e34c4
7
- data.tar.gz: c6a73f7a61b5fc4641d91e55746fc4b1b07d8f5f1b78ee59132ccc30fafb7463f82bcb0dd3be9f70e53a93afa3a72dbd742017802eb7438c25c26e07980a7236
6
+ metadata.gz: 4d4375dc40618772fbde219f71217038b06baa335a1e4b772e2ce598e7a988f7e582c35c947584907d635eaaed8703f1ec9df7a5d1a8fa1c553febc081797fad
7
+ data.tar.gz: c00034e43ae80a7bfd39534a8f3e497c84f20968f5182b1e7450035035772fe500a896467c52155e5dac16ce1f71482ad2eed8d7568800c3bea2c75bbeea2675
@@ -38,6 +38,7 @@ else
38
38
  require 'hyperstack/on_error'
39
39
  Hyperstack.define_setting :hotloader_port, 25222
40
40
  Hyperstack.define_setting :hotloader_ping, nil
41
+ Hyperstack.define_setting :hotloader_ignore_callback_mapping, false
41
42
  Hyperstack.import 'opal', gem: true
42
43
  Hyperstack.import 'browser', client_only: true
43
44
  Hyperstack.import 'hyperstack-config', gem: true
@@ -1,7 +1,7 @@
1
- console.log('hotloader config doing its thing')
2
1
  if ((typeof(window) !== 'undefined') && (window.Hyperstack==undefined || window.Hyperstack.hotloader==undefined)) {
3
2
  window.Hyperstack = { hotloader: function(port, ping) { }}
4
3
  }
5
4
  //if (typeof(Hyperstack) === 'undefined') { Hyperstack = {} }
6
5
  Hyperstack.hotloader.port = <%= Hyperstack.hotloader_port %>
7
- Hyperstack.hotloader.ping = <%= !!Hyperstack.hotloader_ping %>
6
+ Hyperstack.hotloader.ping = <%= Hyperstack.hotloader_ping ? Hyperstack.hotloader_ping : false %>
7
+ Hyperstack.hotloader.ignore_callback_mapping = <%= !(!Hyperstack.hotloader_ignore_callback_mapping && Rails.configuration.assets.debug) %>
@@ -1,5 +1,5 @@
1
1
  module Hyperstack
2
2
  module Config
3
- VERSION = '1.0.alpha1.4'
3
+ VERSION = '1.0.alpha1.5'
4
4
  end
5
5
  end
@@ -25,7 +25,8 @@ module Hyperstack
25
25
  # @context.
26
26
  if @context
27
27
  @context.each do |ctx, vars|
28
- vars.each { |var, init| ctx.instance_variable_set(var, init.dup) }
28
+ # be careful: You can't dup nil, hence `init && init.dup`
29
+ vars.each { |var, init| ctx.instance_variable_set(var, init && init.dup) }
29
30
  end
30
31
  Hyperstack::Application::Boot.run if reboot
31
32
  else
@@ -19,19 +19,29 @@ module Hyperstack
19
19
  @@callbacks ||= Hash.new { |h, k| h[k] = Array.new }
20
20
  end
21
21
 
22
- STACKDIRS = ['hyperstack/', 'corelib/']
22
+ STACKDIRS = ['hyperstack', 'corelib']
23
23
 
24
24
  def self.file_name(frame)
25
+ return unless frame
25
26
  file_name = `#{frame}.fileName`
26
- match = %r{^(.+\/assets\/)(.+\/)(.+\/)}.match(file_name)
27
- return unless match && match[2] == match[3] && !STACKDIRS.include?(match[2])
28
- file_name.gsub(match[1] + match[2], '')
27
+ match = %r{^(.+\/assets)\/}.match(file_name)
28
+ return unless match
29
+ file_name = file_name.gsub(match[0], '').split('/')
30
+ n = (file_name.length - 1) / 2
31
+ return unless file_name[0..n - 1] == file_name[n..2 * n - 1]
32
+ return if STACKDIRS.include?(file_name[0])
33
+ "#{match[0]}#{file_name[0..n - 1].join('/')}/#{file_name[-1]}"
29
34
  end
30
35
 
31
36
  def self.when_file_updates(&block)
37
+ return if `Hyperstack.hotloader.ignore_callback_mapping`
32
38
  return callbacks[$_hyperstack_reloader_file_name] << block if $_hyperstack_reloader_file_name
33
39
  callback = lambda do |frames|
34
- frames.collect(&method(:file_name)).each { |name| callbacks[name] << block if name }
40
+ # StackTrace.get maps the stack frames back to the source maps
41
+ # we then associate any files in the call stack that match our application file pattern
42
+ # with the block, which will remove any callbacks defined when those files were executing.
43
+ # Note that StackTrace.getSync gives us the raw .js file names so it will not work
44
+ frames.collect(&method(:file_name)).compact.uniq.each { |name| callbacks[name] << block if name }
35
45
  end
36
46
  error = lambda do |e|
37
47
  `console.error(#{"hyperstack hot loader could not find source file for callback: #{e}"})`
@@ -4,6 +4,6 @@ if (typeof window !== 'undefined') {
4
4
  Opal.Hyperstack.$const_get('Hotloader').$listen(port || 25222, ping || Opal.nil)
5
5
  }
6
6
  }
7
- } else {
7
+ } /* else {
8
8
  throw 'Attempt to run hotloader during prerendering - make sure you import with the `client_only: true` option'
9
- }
9
+ } */
@@ -6,13 +6,17 @@ module Hyperstack
6
6
  end
7
7
 
8
8
  def import(value, gem: nil, cancelled: nil, client_only: nil, server_only: nil, tree: nil, js_import: nil, at_head: nil)
9
- return if import_list.detect { |current_value, *_rest| value == current_value }
9
+ return if imported? value
10
10
  new_element = [
11
11
  value, cancelled, !client_only, !server_only, (tree ? :tree : :gem), js_import
12
12
  ]
13
13
  import_list.send(at_head ? :unshift : :push, new_element)
14
14
  end
15
15
 
16
+ def imported?(value)
17
+ import_list.detect { |current_value, *| value == current_value }
18
+ end
19
+
16
20
  alias imports import
17
21
 
18
22
  def import_tree(value, cancelled: nil, client_only: nil, server_only: nil)
@@ -90,8 +94,8 @@ module Hyperstack
90
94
  Dir.glob(Rails.root.join('app', path, '**', '*')).sort.collect do |fname|
91
95
  fname = fname.gsub(/^#{base_name}/, '')
92
96
  fname = fname.gsub(/\.erb$/, '')
93
- if fname =~ /(\.js$)|(\.rb$)/
94
- fname = fname.gsub(/(\.js$)|(\.rb$)/, '')
97
+ if fname =~ /(\.js$)|(\.rb$)|(\.jsx$)/
98
+ fname = fname.gsub(/(\.js$)|(\.rb$)|(\.jsx$)/, '')
95
99
  r = "require '#{fname}' #{client_guard(render_on_server, render_on_client)}"
96
100
  puts " #{r}"
97
101
  "puts \"#{r}\"; #{r}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperstack-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.alpha1.4
4
+ version: 1.0.alpha1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitch VanDuyn
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-02-16 00:00:00.000000000 Z
12
+ date: 2019-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: listen
@@ -333,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
333
333
  - !ruby/object:Gem::Version
334
334
  version: 1.3.1
335
335
  requirements: []
336
- rubygems_version: 3.0.2
336
+ rubygems_version: 3.0.4
337
337
  signing_key:
338
338
  specification_version: 4
339
339
  summary: Provides a single point configuration module for hyperstack gems