proscenium 0.4.1-arm64-darwin → 0.5.0-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c49794ef4fa916c792416807d446491208f616aec182e09e85a894c4e42e9895
4
- data.tar.gz: 717c3a149ff1aef9d0c7460caf7c0dc749d0809cbe1b5098ed6998ed92277429
3
+ metadata.gz: e1e443cd0c368ca707e4e02040d7a24928a0bc304499d779a94d8ff90438dda3
4
+ data.tar.gz: ffea3a06fe5d3f6e7cf4fc9d68f1291e6d4eb7b1e707d8090938cac8d3870f33
5
5
  SHA512:
6
- metadata.gz: 281bc9f08e4c454a7bcef642f77dadf309a600685e014b0162b2d69710a78a4fdec6c4b9bbbaeea5d2af83f7a9a5f60670d57ade312733fe1e5dbfd5781a966e
7
- data.tar.gz: 576ed3414955a3d7a9036197e7a1bb3491aad35bfbdd1d4e4614216cf24022215a9a6da57e39d919159a18a7d1858a1ed0cdcee3b24491968b36290cb0b3954f
6
+ metadata.gz: e2f6ecf89ad6d3a4c95531211931812ae62351191f5010e5c9ad4d3a26500e1c20a80ddf497e3e570adf59816e46e568ebdff634489089e486cfd5e573782d6b
7
+ data.tar.gz: 9695a839740673b71a283c779f6f42f75a3a0c3b371f5ed1e15805d1bbfd3649eb6e2d880a58ad9125c4066bcb58910ad55b2c89e098bcada47bd62b53a05123
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Proscenium
2
4
  class Connection < ActionCable::Connection::Base
3
5
  identified_by :uid
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Proscenium
2
4
  class ReloadChannel < ActionCable::Channel::Base
3
5
  def subscribed
data/bin/esbuild CHANGED
Binary file
data/bin/lightningcss CHANGED
Binary file
data/config/routes.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Proscenium::Railtie.routes.draw do
2
4
  if Proscenium.config.auto_reload
3
5
  mount Proscenium::Railtie.websocket => Proscenium.config.cable_mount_path
@@ -28,6 +28,7 @@ export default function () {
28
28
  font-family: var(--monospace);
29
29
  line-height: 1.5;
30
30
  width: 800px;
31
+ height: 66vh;
31
32
  color: #d8d8d8;
32
33
  margin: 30px auto;
33
34
  padding: 25px 40px;
@@ -19,9 +19,11 @@ export default setup('env', () => {
19
19
  namespace: 'env',
20
20
  callback({ path }) {
21
21
  if (path.includes(':')) {
22
+ const name = Deno.env.get(path.split(':')[1])
23
+
22
24
  return {
23
25
  loader: 'js',
24
- contents: `export default '${Deno.env.get(path.split(':')[1])}'`
26
+ contents: name ? `export default '${name}'` : `export default ${name}`
25
27
  }
26
28
  }
27
29
 
@@ -1,5 +1,6 @@
1
1
  import { join, resolve } from 'std/path/mod.ts'
2
2
  import { resolve as resolveFromImportMap } from 'import-maps/resolve'
3
+ import { cache } from 'cache'
3
4
 
4
5
  import setup from './setup_plugin.js'
5
6
 
@@ -15,6 +16,45 @@ export default setup('resolve', (build, options) => {
15
16
  const isProd = env === 'production'
16
17
 
17
18
  return [
19
+ {
20
+ // Filters for imports starting with `url:http://` or `url:https://`; returning the path
21
+ // without the `url:` prefix, and a namespace of 'url`
22
+ type: 'onResolve',
23
+ filter: /^url:https?:\/\//,
24
+ callback(args) {
25
+ return {
26
+ path: args.path.slice(4),
27
+ namespace: 'url'
28
+ }
29
+ }
30
+ },
31
+
32
+ {
33
+ type: 'onResolve',
34
+ filter: /.*/,
35
+ namespace: 'url',
36
+ callback(args) {
37
+ if (!isBareModule(args.path)) {
38
+ return {
39
+ path: new URL(args.path, args.importer).toString(),
40
+ namespace: 'url'
41
+ }
42
+ }
43
+ }
44
+ },
45
+
46
+ {
47
+ type: 'onLoad',
48
+ filter: /.*/,
49
+ namespace: 'url',
50
+ async callback(args) {
51
+ const file = await cache(args.path)
52
+ const contents = await Deno.readTextFile(file.path)
53
+
54
+ return { contents }
55
+ }
56
+ },
57
+
18
58
  {
19
59
  type: 'onResolve',
20
60
  filter: /.*/,
@@ -28,9 +68,13 @@ export default setup('resolve', (build, options) => {
28
68
  args.suffix = `?${options.cacheQueryString}`
29
69
  }
30
70
 
31
- // Mark remote modules as external.
32
- if (args.path.startsWith('http://') || args.path.startsWith('https://')) {
33
- return { external: true }
71
+ // Mark remote modules as external. If not css, then the path is prefixed with "url:", which
72
+ // is then handled by the Url Middleware.
73
+ if (
74
+ !args.importer.endsWith('.css') &&
75
+ (args.path.startsWith('http://') || args.path.startsWith('https://'))
76
+ ) {
77
+ return { path: `/url:${encodeURIComponent(args.path)}`, external: true }
34
78
  }
35
79
 
36
80
  // Rewrite the path to the actual runtime directory.
@@ -56,14 +100,24 @@ export default setup('resolve', (build, options) => {
56
100
  const result = { path: params.path, suffix: params.suffix }
57
101
 
58
102
  if (importMap) {
59
- const baseURL = new URL(params.importer.slice(cwd.length), 'file://')
103
+ let baseURL
104
+ if (params.importer.startsWith('https://') || params.importer.startsWith('http://')) {
105
+ baseURL = new URL(params.importer)
106
+ } else {
107
+ baseURL = new URL(params.importer.slice(cwd.length), 'file://')
108
+ }
109
+
60
110
  const { matched, resolvedImport } = resolveFromImportMap(params.path, importMap, baseURL)
61
111
 
62
112
  if (matched) {
63
113
  if (resolvedImport.protocol === 'file:') {
64
114
  params.path = resolvedImport.pathname
65
115
  } else {
66
- return { path: resolvedImport.href, external: true }
116
+ if (params.importer.endsWith('.css')) {
117
+ return { path: resolvedImport.href, external: true }
118
+ }
119
+
120
+ return { path: `/url:${encodeURIComponent(resolvedImport.href)}`, external: true }
67
121
  }
68
122
  }
69
123
  }
@@ -73,9 +127,7 @@ export default setup('resolve', (build, options) => {
73
127
  result.path = resolve(cwd, params.path.slice(1))
74
128
  }
75
129
 
76
- // Resolve the path using esbuild's internal resolution. This allows us to import node packages
77
- // and extension-less paths without custom code, as esbuild with resolve them for us.
78
- const resolveResult = await build.resolve(result.path, {
130
+ const resOptions = {
79
131
  // If path is a bare module (node_modules), and resolveDir is the Proscenium runtime dir, or
80
132
  // is the current working dir, then use `cwd` as the `resolveDir`, otherwise pass it through
81
133
  // as is. This ensures that nested node_modules are resolved correctly.
@@ -84,11 +136,16 @@ export default setup('resolve', (build, options) => {
84
136
  (!params.resolveDir.startsWith(cwd) || params.resolveDir.startsWith(runtimeDir))
85
137
  ? cwd
86
138
  : params.resolveDir,
139
+ kind: params.kind,
87
140
  pluginData: {
88
141
  // We use this property later on, as we should ignore this resolution call.
89
142
  isResolvingPath: true
90
143
  }
91
- })
144
+ }
145
+
146
+ // Resolve the path using esbuild's internal resolution. This allows us to import node packages
147
+ // and extension-less paths without custom code, as esbuild with resolve them for us.
148
+ const resolveResult = await build.resolve(result.path, resOptions)
92
149
 
93
150
  // Simple return the resolved result if we have an error. Usually happens when module is not
94
151
  // found.
@@ -92,9 +92,10 @@ async function main(paths = [], options = {}) {
92
92
  for await (const file of expandGlob(path, { root })) {
93
93
  file.isFile && entryPoints.add(file.path)
94
94
  }
95
- } else if (path.startsWith('/')) {
96
- // Path is absolute, so it must be outsideRoot. Don't prefix the root.
97
- // See Proscenium::Middleware::OutsideRoot.
95
+ } else if (path.startsWith('/') || /^url:https?:\/\//.test(path)) {
96
+ // Path is absolute, or is prefixed with 'url:', so it must be outsideRoot, or Url. Don't
97
+ // prefix the root.
98
+ // See Proscenium::Middleware::[OutsideRoot|Url].
98
99
  entryPoints.add(path)
99
100
  } else {
100
101
  entryPoints.add(join(root, path))
@@ -128,6 +129,12 @@ async function main(paths = [], options = {}) {
128
129
  jsxDev: !isTest && !isProd,
129
130
  minify: isProd,
130
131
  bundle: true,
132
+
133
+ // The Esbuild default places browser before module, but we're building for modern browsers
134
+ // which support esm. So we prioritise that. Some libraries export a "browser" build that still
135
+ // uses CJS.
136
+ mainFields: ['module', 'browser', 'main'],
137
+
131
138
  plugins: [
132
139
  envPlugin(),
133
140
  resolvePlugin({ runtimeDir, importMap, debug, cacheQueryString: options.cacheQueryString }),
@@ -10,15 +10,6 @@ module Proscenium
10
10
  # link_to 'Go to', MyComponent
11
11
  #
12
12
  # TODO: ummm, todo it! ;)
13
- def link_to(*args, &block)
14
- # name_argument_index = block ? 0 : 1
15
- # if (args[name_argument_index]).respond_to?(:render_in)
16
- # return super(*LinkToComponentArguments.new(args, name_argument_index,
17
- # self).helper_options, &block)
18
- # end
19
-
20
- super
21
- end
22
13
  end
23
14
 
24
15
  # Component handling for the `link_to` helper.
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Proscenium
4
+ class Middleware
5
+ # Handles requests prefixed with "url:https://"; downloading, caching, and compiling them.
6
+ class Url < Esbuild
7
+ private
8
+
9
+ # @override [Esbuild] It's a URL, so always assume it is renderable (we won't actually know
10
+ # until it's downloaded).
11
+ def renderable?
12
+ true
13
+ end
14
+
15
+ # @override [Esbuild]
16
+ def path
17
+ CGI.unescape(@request.path)[1..]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -10,6 +10,7 @@ module Proscenium
10
10
  autoload :Base
11
11
  autoload :Esbuild
12
12
  autoload :Runtime
13
+ autoload :Url
13
14
  autoload :OutsideRoot
14
15
 
15
16
  def initialize(app)
@@ -45,6 +46,7 @@ module Proscenium
45
46
  return OutsideRoot if path.fnmatch?(glob_types[:outsideRoot], File::FNM_EXTGLOB)
46
47
  end
47
48
 
49
+ return Url if request.path.match?(glob_types[:url])
48
50
  return Runtime if path.fnmatch?(glob_types[:runtime], File::FNM_EXTGLOB)
49
51
  return Esbuild if path.fnmatch?(glob_types[:esbuild], File::FNM_EXTGLOB)
50
52
  end
@@ -11,9 +11,9 @@ module Proscenium
11
11
 
12
12
  module Helpers
13
13
  def side_load_javascripts(...)
14
- if (output = @_view_context.side_load_javascripts(...))
15
- @_target << output
16
- end
14
+ return unless (output = @_view_context.side_load_javascripts(...))
15
+
16
+ @_target << output
17
17
  end
18
18
 
19
19
  %i[side_load_stylesheets proscenium_dev].each do |name|
@@ -14,6 +14,7 @@ module Proscenium
14
14
  DEFAULT_GLOB_TYPES = {
15
15
  esbuild: '/{config,app,lib,node_modules}/**.{js,mjs,jsx,css}',
16
16
  runtime: '/proscenium-runtime/**.{js,jsx}',
17
+ url: %r{^/url:https?%3A%2F%2F},
17
18
  outsideRoot: '/**/*.{js,jsx,mjs,css}'
18
19
  }.freeze
19
20
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
3
4
  module Proscenium
4
5
  module SideLoad
5
6
  DEFAULT_EXTENSIONS = %i[js css].freeze
@@ -68,3 +69,4 @@ module Proscenium
68
69
  end
69
70
  end
70
71
  end
72
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Proscenium
4
- VERSION = '0.4.1'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proscenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-29 00:00:00.000000000 Z
11
+ date: 2022-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actioncable
@@ -132,14 +132,14 @@ dependencies:
132
132
  requirements:
133
133
  - - "~>"
134
134
  - !ruby/object:Gem::Version
135
- version: '2.0'
135
+ version: 2.74.1
136
136
  type: :runtime
137
137
  prerelease: false
138
138
  version_requirements: !ruby/object:Gem::Requirement
139
139
  requirements:
140
140
  - - "~>"
141
141
  - !ruby/object:Gem::Version
142
- version: '2.0'
142
+ version: 2.74.1
143
143
  description:
144
144
  email:
145
145
  - joel@developwithstyle.com
@@ -182,6 +182,7 @@ files:
182
182
  - lib/proscenium/middleware/outside_root.rb
183
183
  - lib/proscenium/middleware/runtime.rb
184
184
  - lib/proscenium/middleware/static.rb
185
+ - lib/proscenium/middleware/url.rb
185
186
  - lib/proscenium/phlex.rb
186
187
  - lib/proscenium/phlex/component.rb
187
188
  - lib/proscenium/phlex/react_component.rb