klenod-runtime 0.0.6 → 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: c27ef979d9823153396b640d84a1d4e892f4e66c5c88f8afad0f6fc02a8ae17e
4
- data.tar.gz: 6b4be228b1052f59104eff4ac30750661c689422978b5e0484ec95c95da9febc
3
+ metadata.gz: b7d30cadc8f70335c697f2974ee29843b6cf5baea08820c41779df984f3da013
4
+ data.tar.gz: 5d3d22a5164b695fc990df065b9ba7eacd56e2dfc555514b9882d4d3eeb2012e
5
5
  SHA512:
6
- metadata.gz: daab02d1ecd9845a8e6faba1bddca6db086226ba200e4420349a9fd35ca65283b0c7408ec32b8b66ef016901dd45679a14c4f9aece51dff406b573d0275113ca
7
- data.tar.gz: 92f1cf562e098530ec0a7689b32e86ab70f4c0d58af380a97d6fa2a1e965b3ac7851e23b0fdebe29de6a25224b586d711d7cccd0cbbbe8d70e857ce15c5900d8
6
+ metadata.gz: 42933525078e0f9e8b574050bf42fa97bde62f61fff6c41cd7c6e8eb639465edecc3fd801c2dc5d7d25dea6289779e13a2856cded9e5c18bd5a6aa73de3f3f38
7
+ data.tar.gz: 4d96112ca70266198b4eb991acff14449ae3744d32a9e448a8f202f732fe2fbf05f085d34f13385edd41381f1ba4ccb7ec674c20d4ccc78760cf774bc9abe0a7
@@ -45,6 +45,11 @@ module Klenod
45
45
  normalized = normalize(base)
46
46
  normalized if normalized.start_with?("/")
47
47
  end
48
+
49
+ def origin(base)
50
+ uri = URI.parse(normalize(base))
51
+ uri.origin if uri.is_a?(URI::HTTP)
52
+ end
48
53
  end
49
54
  end
50
55
  end
@@ -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
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,12 +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
+ @asset_origin = AssetUrl.origin(@base)
44
45
  @assets = bind_asset_urls(assets)
46
+ @namespace = namespace
45
47
  @mods = {}
46
48
  end
47
49
 
@@ -152,7 +154,9 @@ module Klenod
152
154
  def marshal_load(data)
153
155
  @entrypoints, @modules, assets, @source_root, base = data
154
156
  @base = AssetUrl.normalize(base)
157
+ @asset_origin = AssetUrl.origin(@base)
155
158
  @assets = bind_asset_urls(assets)
159
+ @namespace = Module.new
156
160
  @mods = {}
157
161
  end
158
162
 
@@ -313,7 +317,8 @@ module Klenod
313
317
  source_map: spec.source_map,
314
318
  version: spec.version,
315
319
  constant_name: spec.constant_name,
316
- eval_path: eval_path_for(spec)
320
+ eval_path: eval_path_for(spec),
321
+ namespace: namespace
317
322
  )
318
323
  end
319
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.6"
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.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrés Alin