homura-runtime 0.2.9 → 0.2.11
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 +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +3 -3
- data/docs/ARCHITECTURE.md +2 -1
- data/exe/homura-build +17 -10
- data/lib/cloudflare_workers/version.rb +1 -1
- data/lib/cloudflare_workers.rb +6 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7426d1447a4eca3f4ae0b8826e8dfaee809c9868d99314e381ae5b0e338defc3
|
|
4
|
+
data.tar.gz: d42df70713ac5bf410d91ccd77ade2c3500464a2280c769ee5475449ce427231
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f92aca6718eeb4440a60a45611378e0fa4669116fbe56f56f4663705f6440e9010e92d9d30f09c5faac5b2d7de47798a2c26dba69f9995012ce655b861831c9e
|
|
7
|
+
data.tar.gz: 9686bae18cd4c9f858f8056c807d47e068130710b44d73b796b21119b102a176f9c5154f9f5e40b95f0e4b5c6a846e6b37a16a00677c208820cef5263c7b4e27
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.11 (2026-04-25)
|
|
4
|
+
|
|
5
|
+
- Normalize bare JS `undefined` / `null` values to Ruby `nil` while converting
|
|
6
|
+
D1 rows into Ruby Hashes, preventing first-row crashes when a nullable column
|
|
7
|
+
is present in the result shape.
|
|
8
|
+
|
|
9
|
+
## 0.2.10 (2026-04-24)
|
|
10
|
+
|
|
11
|
+
- Derive `worker.entrypoint.mjs` import paths relative to the actual
|
|
12
|
+
`--entrypoint-out` location, so standalone builds keep working when apps move
|
|
13
|
+
the bundle and entrypoint under custom output directories.
|
|
14
|
+
|
|
3
15
|
## 0.2.9 (2026-04-24)
|
|
4
16
|
|
|
5
17
|
- Skip auto-await rewrites when the source expression is already followed by
|
data/README.md
CHANGED
|
@@ -9,14 +9,14 @@ Core Ruby + Module Worker glue for [Opal](https://opalrb.com/) on [Cloudflare Wo
|
|
|
9
9
|
- `runtime/worker_module.mjs` — fetch / scheduled / queue / DO adapters (**no Opal bundle import**).
|
|
10
10
|
- `runtime/worker.mjs` — thin bootstrap (crypto shim → bundle → `worker_module`) for legacy layouts.
|
|
11
11
|
- `runtime/setup-node-crypto.mjs` — `node:crypto` on `globalThis` before the Opal bundle loads.
|
|
12
|
-
- `homura build` — single build pipeline (ERB → assets → Opal → patch → `worker.entrypoint.mjs`). Use `--standalone` in generated apps; it
|
|
12
|
+
- `homura build` — single build pipeline (ERB → assets → Opal → patch → `worker.entrypoint.mjs`). Use `--standalone` in generated apps; it restores `cf-runtime/` automatically, derives standalone template/asset namespaces from the project name, and computes entrypoint import paths relative to the actual `--entrypoint-out` location.
|
|
13
13
|
- `docs/ARCHITECTURE.md` — wrangler `main`, codegen entrypoint, and fixed-import policy.
|
|
14
14
|
|
|
15
15
|
## Quick start (homura monorepo)
|
|
16
16
|
|
|
17
17
|
1. `Gemfile`: `gem 'homura-runtime', path: 'gems/homura-runtime'` and `gem 'opal-homura', '= 1.8.3.rc1.3', require: 'opal'` (path or exact pin).
|
|
18
|
-
2. `bundle exec homura build` — writes `build/hello.no-exit.mjs`
|
|
19
|
-
3. `wrangler.toml`: `main = "
|
|
18
|
+
2. `bundle exec homura build` — in generated standalone apps, writes `build/hello.no-exit.mjs` plus root-level `worker.entrypoint.mjs`; in the monorepo it writes `build/worker.entrypoint.mjs`.
|
|
19
|
+
3. `wrangler.toml`: generated apps use `main = "worker.entrypoint.mjs"` and `compatibility_flags = ["nodejs_compat"]`.
|
|
20
20
|
|
|
21
21
|
## Support matrix (indicative)
|
|
22
22
|
|
data/docs/ARCHITECTURE.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
| レイヤ | 役割 |
|
|
6
6
|
|--------|------|
|
|
7
7
|
| `wrangler.toml` の `main` | **Workers Module のエントリ**(`fetch` / `scheduled` / `queue` / DO クラスを export) |
|
|
8
|
-
| `worker.entrypoint.mjs`(生成物) | `setup-node-crypto` → **Opal bundle(副作用)** → `worker_module.mjs` の順で import
|
|
8
|
+
| `worker.entrypoint.mjs`(生成物) | `setup-node-crypto` → **Opal bundle(副作用)** → `worker_module.mjs` の順で import。import path は entrypoint 出力位置からの **相対パス** に自動調整される |
|
|
9
9
|
| Opal bundle(例: `build/hello.no-exit.mjs`) | **ビルド成果物**。Rack ディスパッチャ等を `globalThis` に登録 |
|
|
10
10
|
| `worker_module.mjs`(gem 同梱) | Rack / Cron / Queue / DO への **純粋な JS アダプタ**(Opal bundle を import しない) |
|
|
11
11
|
|
|
@@ -37,6 +37,7 @@ flowchart LR
|
|
|
37
37
|
- プロジェクト直下に `worker.entrypoint.mjs`(`main` と一致)。
|
|
38
38
|
- `cf-runtime/` に `setup-node-crypto.mjs` と `worker_module.mjs` をコピー(gem から)。
|
|
39
39
|
- `bundle exec homura build --standalone` が consumer 向けパイプラインを実行し、`Gemfile` の `path:` から homura の `vendor/` を追加ロードパスへ取り込み(digest / zlib 等の Workers 向け補助ファイル)。
|
|
40
|
+
- low-level `--output` / `--entrypoint-out` を変えても、entrypoint 内 import は出力先からの相対パスに自動調整される。
|
|
40
41
|
|
|
41
42
|
## Phase 17 — Email Service(`SEND_EMAIL`)
|
|
42
43
|
|
data/exe/homura-build
CHANGED
|
@@ -77,14 +77,14 @@ options[:assets_namespace] ||= CloudflareWorkers::BuildSupport.standalone_namesp
|
|
|
77
77
|
|
|
78
78
|
if options[:standalone]
|
|
79
79
|
Dir.chdir(root) { require 'bundler/setup' }
|
|
80
|
-
options[:setup_import] ||= '
|
|
81
|
-
options[:bundle_import] ||=
|
|
82
|
-
options[:worker_module_import] ||= '
|
|
80
|
+
options[:setup_import] ||= 'cf-runtime/setup-node-crypto.mjs'
|
|
81
|
+
options[:bundle_import] ||= options[:opal_output]
|
|
82
|
+
options[:worker_module_import] ||= 'cf-runtime/worker_module.mjs'
|
|
83
83
|
options[:entrypoint_out] ||= 'worker.entrypoint.mjs'
|
|
84
84
|
else
|
|
85
|
-
options[:setup_import] ||= '
|
|
86
|
-
options[:bundle_import] ||=
|
|
87
|
-
options[:worker_module_import] ||= '
|
|
85
|
+
options[:setup_import] ||= 'gems/homura-runtime/runtime/setup-node-crypto.mjs'
|
|
86
|
+
options[:bundle_import] ||= options[:opal_output]
|
|
87
|
+
options[:worker_module_import] ||= 'gems/homura-runtime/runtime/worker_module.mjs'
|
|
88
88
|
options[:entrypoint_out] ||= 'build/worker.entrypoint.mjs'
|
|
89
89
|
end
|
|
90
90
|
|
|
@@ -139,13 +139,20 @@ def run_opal_standalone!(root, opal_input, opal_output, with_db:)
|
|
|
139
139
|
end
|
|
140
140
|
|
|
141
141
|
def write_entrypoint!(root, out_path, setup:, bundle:, worker_mod:)
|
|
142
|
+
out_file = root.join(out_path)
|
|
143
|
+
out_dir = out_file.dirname
|
|
142
144
|
body = <<~JS
|
|
143
145
|
// GENERATED by homura build — do not edit by hand.
|
|
144
|
-
import "#{setup}";
|
|
145
|
-
import "#{bundle}";
|
|
146
|
-
export { default, HomuraCounterDO } from "#{worker_mod}";
|
|
146
|
+
import "#{relative_import_spec(out_dir, root.join(setup))}";
|
|
147
|
+
import "#{relative_import_spec(out_dir, root.join(bundle))}";
|
|
148
|
+
export { default, HomuraCounterDO } from "#{relative_import_spec(out_dir, root.join(worker_mod))}";
|
|
147
149
|
JS
|
|
148
|
-
File.write(
|
|
150
|
+
File.write(out_file, body)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def relative_import_spec(from_dir, target_path)
|
|
154
|
+
rel = Pathname(target_path).relative_path_from(Pathname(from_dir)).to_s
|
|
155
|
+
rel.start_with?('.', '/') ? rel : "./#{rel}"
|
|
149
156
|
end
|
|
150
157
|
|
|
151
158
|
def resolve_opal_input(root, explicit_input)
|
data/lib/cloudflare_workers.rb
CHANGED
|
@@ -504,8 +504,13 @@ module Cloudflare
|
|
|
504
504
|
while i < len
|
|
505
505
|
k = `#{keys}[#{i}]`
|
|
506
506
|
v = `#{js_obj}[#{k}]`
|
|
507
|
+
# Normalize bare JS null/undefined to Ruby nil before storing them.
|
|
508
|
+
if `#{v} == null`
|
|
509
|
+
v = nil
|
|
507
510
|
# Recurse for nested plain objects (but not Arrays, Dates, etc.)
|
|
508
|
-
|
|
511
|
+
elsif `typeof #{v} === 'object' && !Array.isArray(#{v}) && !(#{v} instanceof Date)`
|
|
512
|
+
v = js_object_to_hash(v)
|
|
513
|
+
end
|
|
509
514
|
h[k] = v
|
|
510
515
|
i += 1
|
|
511
516
|
end
|