klenod-runtime 0.0.7 → 0.0.8

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: 145f6247c62ae08faacd7baa15b37b0422a724ba09510994955514feeee51707
4
- data.tar.gz: 3c5c4fd66d2031904819cebcb44f86a1eef40decda92205e8e3db080f2e420e1
3
+ metadata.gz: b7d30cadc8f70335c697f2974ee29843b6cf5baea08820c41779df984f3da013
4
+ data.tar.gz: 5d3d22a5164b695fc990df065b9ba7eacd56e2dfc555514b9882d4d3eeb2012e
5
5
  SHA512:
6
- metadata.gz: 739c11f8fdf87d492cb728858cecb9ba845cc07efeb1cf9bc2b6b2940f3c65367f63a0d31e253f706113903133d495a358a1ca177dbfa9d4702cc1369919eced
7
- data.tar.gz: fadecdf29f49ce9482507b2a973508a6efd5c11bf8d43a192e264651791132f7962aa3854a916cc2864c95a4a253fa26e591ad6d50a1740c999d6d8bf509e58b
6
+ metadata.gz: 42933525078e0f9e8b574050bf42fa97bde62f61fff6c41cd7c6e8eb639465edecc3fd801c2dc5d7d25dea6289779e13a2856cded9e5c18bd5a6aa73de3f3f38
7
+ data.tar.gz: 4d96112ca70266198b4eb991acff14449ae3744d32a9e448a8f202f732fe2fbf05f085d34f13385edd41381f1ba4ccb7ec674c20d4ccc78760cf774bc9abe0a7
@@ -125,7 +125,9 @@ module Klenod
125
125
  next unless mod.respond_to?(:constant_name)
126
126
 
127
127
  display_path = mod.respond_to?(:path) ? mod.path : key
128
- index["Klenod::Runtime::Generated::#{mod.constant_name}"] = "Mod[#{display_path.inspect}]"
128
+ display_name = "Mod[#{display_path.inspect}]"
129
+ index["Klenod::Runtime::Generated::#{mod.constant_name}"] = display_name
130
+ index[mod.constant_name] = display_name
129
131
  end
130
132
  end
131
133
 
@@ -26,7 +26,7 @@ module Klenod
26
26
  AssetReference = Data.define(:index, :asset)
27
27
 
28
28
  class Bundle
29
- attr_reader :entrypoints, :modules, :assets, :source_root, :base, :asset_origin
29
+ attr_reader :entrypoints, :modules, :assets, :source_root, :base, :asset_origin, :namespace
30
30
 
31
31
  def self.load(source, source_root: nil)
32
32
  BundleFormat.load(source, source_root: source_root)
@@ -36,13 +36,14 @@ module Klenod
36
36
  load(path, source_root: source_root)
37
37
  end
38
38
 
39
- def initialize(entrypoints, modules, assets, source_root: nil, base: AssetUrl::DEFAULT_BASE)
39
+ def initialize(entrypoints, modules, assets, source_root: nil, base: AssetUrl::DEFAULT_BASE, namespace: Module.new)
40
40
  @entrypoints = entrypoints
41
41
  @modules = modules
42
42
  @source_root = source_root
43
43
  @base = AssetUrl.normalize(base)
44
44
  @asset_origin = AssetUrl.origin(@base)
45
45
  @assets = bind_asset_urls(assets)
46
+ @namespace = namespace
46
47
  @mods = {}
47
48
  end
48
49
 
@@ -155,6 +156,7 @@ module Klenod
155
156
  @base = AssetUrl.normalize(base)
156
157
  @asset_origin = AssetUrl.origin(@base)
157
158
  @assets = bind_asset_urls(assets)
159
+ @namespace = Module.new
158
160
  @mods = {}
159
161
  end
160
162
 
@@ -315,7 +317,8 @@ module Klenod
315
317
  source_map: spec.source_map,
316
318
  version: spec.version,
317
319
  constant_name: spec.constant_name,
318
- eval_path: eval_path_for(spec)
320
+ eval_path: eval_path_for(spec),
321
+ namespace: namespace
319
322
  )
320
323
  end
321
324
 
@@ -55,7 +55,7 @@ module Klenod
55
55
  end
56
56
  end
57
57
 
58
- attr_reader :path, :source, :source_map, :version, :constant_name, :eval_path
58
+ attr_reader :path, :source, :source_map, :version, :constant_name, :eval_path, :namespace
59
59
 
60
60
  def self.constant_name_for(path)
61
61
  "Mod_#{Digest::SHA256.hexdigest(path)[0, 24]}"
@@ -65,7 +65,7 @@ module Klenod
65
65
  "Mod(#{path.inspect})"
66
66
  end
67
67
 
68
- def initialize(path, source, imports: {}, source_map: nil, version: 0, constant_name: nil, eval_path: nil)
68
+ def initialize(path, source, imports: {}, source_map: nil, version: 0, constant_name: nil, eval_path: nil, namespace: Generated)
69
69
  @path = path
70
70
  @source = source
71
71
  @imports = imports
@@ -73,6 +73,7 @@ module Klenod
73
73
  @version = version
74
74
  @constant_name = constant_name || self.class.constant_name_for(path)
75
75
  @eval_path = eval_path || path
76
+ @namespace = namespace
76
77
  register_constant
77
78
  create_exports
78
79
  end
@@ -84,6 +85,7 @@ module Klenod
84
85
  def marshal_load(data)
85
86
  @path, @source, @source_map, @version, @constant_name, @eval_path = data
86
87
  @eval_path ||= @path
88
+ @namespace = Generated
87
89
  @imports = {}
88
90
  register_constant
89
91
  create_exports
@@ -96,8 +98,8 @@ module Klenod
96
98
  private
97
99
 
98
100
  def register_constant
99
- Generated.__send__(:remove_const, @constant_name) if Generated.const_defined?(@constant_name, false)
100
- Generated.const_set(@constant_name, self)
101
+ @namespace.__send__(:remove_const, @constant_name) if @namespace.const_defined?(@constant_name, false)
102
+ @namespace.const_set(@constant_name, self)
101
103
  end
102
104
 
103
105
  def create_exports
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Klenod
4
4
  module Runtime
5
- VERSION = "0.0.7"
5
+ VERSION = "0.0.8"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klenod-runtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrés Alin