ruby_wasm_ui 0.8.1 → 0.8.3
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/README.md +1 -3
- data/examples/Gemfile.lock +1 -1
- data/examples/src/todos/index.html +23 -0
- data/examples/src/todos/index.rb +237 -0
- data/examples/src/todos/todos_repository.rb +23 -0
- data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/version.rb +1 -1
- data/lib/ruby_wasm_ui.rb +14 -0
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/packages/npm-packages/runtime/package-lock.json +2 -2
- data/packages/npm-packages/runtime/package.json +1 -1
- data/packages/npm-packages/runtime/rollup.config.mjs +67 -9
- data/packages/npm-packages/runtime/src/ruby_wasm_ui +1 -0
- data/packages/npm-packages/runtime/src/ruby_wasm_ui.rb +1 -0
- metadata +28 -25
- data/lib/ruby_wasm_ui +0 -1
- data/lib/ruby_wasm_ui.rb +0 -1
- data/packages/npm-packages/runtime/src/ruby_wasm_ui.rb +0 -14
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/app.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/component.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/dispatcher.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/dom/attributes.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/dom/destroy_dom.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/dom/events.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/dom/mount_dom.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/dom/patch_dom.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/dom/scheduler.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/dom.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/nodes_equal.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/template/build_conditional_group.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/template/build_for_group.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/template/build_vdom.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/template/parser.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/template.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/utils/arrays.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/utils/objects.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/utils/props.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/utils/strings.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/utils.rb +0 -0
- /data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/vdom.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b322433e65bc63155825e97695c798bce90602a54e52797cd040aea67b909751
|
|
4
|
+
data.tar.gz: 1655781e0e93952e5f2ecc2e450d5a9286718979f3201f0169ae35dc94979872
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97e3cf3322340377c5cb75d74796bd20096d604d9ef1efe87ed9598d8394ae76ad6d7b481c43c3e721b683208489083164b6c7730b09106f4dceefdb8647a52c
|
|
7
|
+
data.tar.gz: 7d04075d81325a78375ffbd9d711e82af3a48531acc9eec340f6d71df76501741d4573bae368eca7ae14c752c1f4fb8c894ee028007c028df39cab2595ef10a1
|
data/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Create an HTML file:
|
|
|
21
21
|
<!DOCTYPE html>
|
|
22
22
|
<html>
|
|
23
23
|
<head>
|
|
24
|
-
<script src="https://unpkg.com/ruby-wasm-ui@0.8.
|
|
24
|
+
<script src="https://unpkg.com/ruby-wasm-ui@0.8.3"></script>
|
|
25
25
|
<script defer type="text/ruby" src="app.rb"></script>
|
|
26
26
|
</head>
|
|
27
27
|
<body>
|
|
@@ -167,8 +167,6 @@ my-app/
|
|
|
167
167
|
Your `src/app.rb` file can use `ruby_wasm_ui` just like in the Quick Start example:
|
|
168
168
|
|
|
169
169
|
```ruby
|
|
170
|
-
require "js"
|
|
171
|
-
|
|
172
170
|
CounterComponent = RubyWasmUi.define_component(
|
|
173
171
|
state: ->(props) {
|
|
174
172
|
{ count: props[:count] || 0 }
|
data/examples/Gemfile.lock
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<title>Todos</title>
|
|
6
|
+
<script type="module">
|
|
7
|
+
import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.7.2/dist/browser/+esm";
|
|
8
|
+
const response = await fetch("../../src.wasm");
|
|
9
|
+
const module = await WebAssembly.compileStreaming(response);
|
|
10
|
+
const { vm } = await DefaultRubyVM(module);
|
|
11
|
+
vm.evalAsync(`
|
|
12
|
+
require "ruby_wasm_ui"
|
|
13
|
+
require_relative './src/todos/todos_repository.rb'
|
|
14
|
+
require_relative './src/todos/index.rb'
|
|
15
|
+
`);
|
|
16
|
+
</script>
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<h1>Todos</h1>
|
|
20
|
+
|
|
21
|
+
<div id="app"></div>
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# Main App component - coordinates all other components
|
|
2
|
+
AppComponent = RubyWasmUi.define_component(
|
|
3
|
+
# Initialize application state
|
|
4
|
+
state: ->(props) {
|
|
5
|
+
{
|
|
6
|
+
todos: [
|
|
7
|
+
{ id: rand(10000), text: "Walk the dog" },
|
|
8
|
+
{ id: rand(10000), text: "Water the plants" },
|
|
9
|
+
{ id: rand(10000), text: "Sand the chairs" }
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
on_mounted: -> {
|
|
15
|
+
update_state(todos: TodosRepository.read_todos)
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
# Render the complete application
|
|
19
|
+
template: ->() {
|
|
20
|
+
RubyWasmUi::Template::Parser.parse_and_eval(<<~HTML, binding)
|
|
21
|
+
<template>
|
|
22
|
+
<h1>My TODOs</h1>
|
|
23
|
+
<CreateTodoComponent
|
|
24
|
+
on="{ add: ->(text) { add_todo(text) } }"
|
|
25
|
+
/>
|
|
26
|
+
<TodoListComponent
|
|
27
|
+
todos="{state[:todos]}"
|
|
28
|
+
on="{
|
|
29
|
+
remove: ->(id) { remove_todo(id) },
|
|
30
|
+
edit: ->(payload) { edit_todo(payload) }
|
|
31
|
+
}"
|
|
32
|
+
/>
|
|
33
|
+
</template>
|
|
34
|
+
HTML
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
# Component methods
|
|
38
|
+
methods: {
|
|
39
|
+
# Add a new TODO to the list
|
|
40
|
+
# @param text [String] The TODO text
|
|
41
|
+
add_todo: ->(text) {
|
|
42
|
+
todo = { id: rand(10000), text: text }
|
|
43
|
+
new_todos = state[:todos] + [todo]
|
|
44
|
+
update_state(todos: new_todos)
|
|
45
|
+
TodosRepository.write_todos(new_todos)
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
# Remove a TODO from the list
|
|
49
|
+
# @param id [Integer] Id of TODO to remove
|
|
50
|
+
remove_todo: ->(id) {
|
|
51
|
+
new_todos = state[:todos].dup
|
|
52
|
+
new_todos.delete_at(new_todos.index { |todo| todo[:id] == id })
|
|
53
|
+
update_state(todos: new_todos)
|
|
54
|
+
TodosRepository.write_todos(new_todos)
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
# Edit an existing TODO
|
|
58
|
+
# @param payload [Hash] Contains edited text and index
|
|
59
|
+
edit_todo: ->(payload) {
|
|
60
|
+
edited = payload[:edited]
|
|
61
|
+
id = payload[:id]
|
|
62
|
+
new_todos = state[:todos].dup
|
|
63
|
+
new_todos[new_todos.index { |todo| todo[:id] == id }] = new_todos[new_todos.index { |todo| todo[:id] == id }].merge(text: edited)
|
|
64
|
+
update_state(todos: new_todos)
|
|
65
|
+
TodosRepository.write_todos(new_todos)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# CreateTodo component - handles new TODO input
|
|
71
|
+
CreateTodoComponent = RubyWasmUi.define_component(
|
|
72
|
+
# Initialize component state
|
|
73
|
+
state: ->(props) {
|
|
74
|
+
{ text: "" }
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
# Render the new TODO input form
|
|
78
|
+
template: ->() {
|
|
79
|
+
RubyWasmUi::Template::Parser.parse_and_eval(<<~HTML, binding)
|
|
80
|
+
<div>
|
|
81
|
+
<label for="todo-input" type="text">New TODO</label>
|
|
82
|
+
<input
|
|
83
|
+
type="text"
|
|
84
|
+
id="todo-input"
|
|
85
|
+
value="{state[:text]}"
|
|
86
|
+
on="{
|
|
87
|
+
input: ->(e) { update_state(text: e[:target][:value]) },
|
|
88
|
+
keydown: ->(e) {
|
|
89
|
+
if e[:key] == 'Enter' && state[:text].to_s.length >= 3
|
|
90
|
+
add_todo
|
|
91
|
+
end
|
|
92
|
+
}
|
|
93
|
+
}"
|
|
94
|
+
/>
|
|
95
|
+
<button disabled="{state[:text].to_s.length < 3}" on="{ click: ->() { add_todo } }">
|
|
96
|
+
Add
|
|
97
|
+
</button>
|
|
98
|
+
</div>
|
|
99
|
+
HTML
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
# Component methods
|
|
103
|
+
methods: {
|
|
104
|
+
# Add a new TODO and emit event to parent
|
|
105
|
+
add_todo: ->() {
|
|
106
|
+
emit("add", state[:text])
|
|
107
|
+
update_state(text: "")
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# TodoList component - manages the list of TODO items
|
|
113
|
+
TodoListComponent = RubyWasmUi.define_component(
|
|
114
|
+
# Render the TODO list
|
|
115
|
+
template: ->() {
|
|
116
|
+
todos = props[:todos]
|
|
117
|
+
|
|
118
|
+
RubyWasmUi::Template::Parser.parse_and_eval(<<~HTML, binding)
|
|
119
|
+
<ul>
|
|
120
|
+
<TodoItemComponent
|
|
121
|
+
r-for="{todo in todos}"
|
|
122
|
+
key="{todo[:id]}"
|
|
123
|
+
todo="{todo[:text]}"
|
|
124
|
+
id="{todo[:id]}"
|
|
125
|
+
on="{
|
|
126
|
+
remove: ->(id) { emit('remove', id) },
|
|
127
|
+
edit: ->(payload) { emit('edit', payload) }
|
|
128
|
+
}"
|
|
129
|
+
/>
|
|
130
|
+
</ul>
|
|
131
|
+
HTML
|
|
132
|
+
},
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# TodoItem component - handles individual TODO items
|
|
136
|
+
TodoItemComponent = RubyWasmUi.define_component(
|
|
137
|
+
# Initialize component state with editing capabilities
|
|
138
|
+
state: ->(props) {
|
|
139
|
+
{
|
|
140
|
+
original: props[:todo],
|
|
141
|
+
edited: props[:todo],
|
|
142
|
+
is_editing: false
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
# Render TODO item using r-if and r-else for conditional rendering
|
|
147
|
+
template: ->() {
|
|
148
|
+
RubyWasmUi::Template::Parser.parse_and_eval(<<~HTML, binding)
|
|
149
|
+
<template>
|
|
150
|
+
<TodoItemEditComponent
|
|
151
|
+
r-if="{state[:is_editing]}"
|
|
152
|
+
edited="{state[:edited]}"
|
|
153
|
+
on="{
|
|
154
|
+
input: ->(value) { input_value(value) },
|
|
155
|
+
save: ->() { save_edition },
|
|
156
|
+
cancel: ->() { cancel_edition }
|
|
157
|
+
}"
|
|
158
|
+
/>
|
|
159
|
+
<TodoItemViewComponent
|
|
160
|
+
r-else
|
|
161
|
+
original="{state[:original]}"
|
|
162
|
+
id="{props[:id]}"
|
|
163
|
+
on="{
|
|
164
|
+
editing: ->() { editing },
|
|
165
|
+
remove: ->(id) { emit('remove', id) }
|
|
166
|
+
}"
|
|
167
|
+
/>
|
|
168
|
+
</template>
|
|
169
|
+
HTML
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
# Component methods
|
|
173
|
+
methods: {
|
|
174
|
+
input_value: ->(value) {
|
|
175
|
+
update_state(edited: value)
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
editing: ->() {
|
|
179
|
+
update_state(is_editing: true)
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
# Save the edited TODO
|
|
183
|
+
save_edition: ->() {
|
|
184
|
+
update_state(is_editing: false, original: state[:edited])
|
|
185
|
+
emit("edit", { edited: state[:edited], id: props[:id] })
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
# Cancel editing and revert changes
|
|
189
|
+
cancel_edition: ->() {
|
|
190
|
+
update_state(edited: state[:original], is_editing: false)
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
# TodoItemEdit component - handles TODO editing mode
|
|
196
|
+
TodoItemEditComponent = RubyWasmUi.define_component(
|
|
197
|
+
# Render TODO item in edit mode
|
|
198
|
+
template: ->() {
|
|
199
|
+
RubyWasmUi::Template::Parser.parse_and_eval(<<~HTML, binding)
|
|
200
|
+
<li>
|
|
201
|
+
<input
|
|
202
|
+
value="{props[:edited]}"
|
|
203
|
+
type="text"
|
|
204
|
+
on="{ input: ->(e) { emit('input', e[:target][:value]) } }"
|
|
205
|
+
/>
|
|
206
|
+
<button on="{ click: ->() { emit('save') } }">
|
|
207
|
+
Save
|
|
208
|
+
</button>
|
|
209
|
+
<button on="{ click: ->() { emit('cancel') } }">
|
|
210
|
+
Cancel
|
|
211
|
+
</button>
|
|
212
|
+
</li>
|
|
213
|
+
HTML
|
|
214
|
+
},
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
# TodoItemView component - handles TODO display mode
|
|
218
|
+
TodoItemViewComponent = RubyWasmUi.define_component(
|
|
219
|
+
# Render TODO item in view mode
|
|
220
|
+
template: ->() {
|
|
221
|
+
RubyWasmUi::Template::Parser.parse_and_eval(<<~HTML, binding)
|
|
222
|
+
<li>
|
|
223
|
+
<span on="{ dblclick: ->() { emit('editing') } }">
|
|
224
|
+
{props[:original]}
|
|
225
|
+
</span>
|
|
226
|
+
<button on="{ click: ->() { emit('remove', props[:id]) } }">
|
|
227
|
+
Done
|
|
228
|
+
</button>
|
|
229
|
+
</li>
|
|
230
|
+
HTML
|
|
231
|
+
},
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
# Create and mount the application
|
|
235
|
+
app = RubyWasmUi::App.create(AppComponent)
|
|
236
|
+
app_element = JS.global[:document].getElementById("app")
|
|
237
|
+
app.mount(app_element)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
# Repository class for managing todos in local storage
|
|
4
|
+
class TodosRepository
|
|
5
|
+
class << self
|
|
6
|
+
# Read todos from local storage
|
|
7
|
+
# @return [Array] Array of todo items
|
|
8
|
+
def read_todos
|
|
9
|
+
todos_json = JS.global[:localStorage].getItem('todos') || '[]'
|
|
10
|
+
JSON.parse(todos_json.to_s).map do |todo|
|
|
11
|
+
{ id: todo["id"], text: todo["text"] }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Write todos to local storage
|
|
16
|
+
# @param todos [Array] Array of todo items to be stored
|
|
17
|
+
# @return [void]
|
|
18
|
+
def write_todos(todos)
|
|
19
|
+
todos_json = JSON.generate(todos)
|
|
20
|
+
JS.global[:localStorage].setItem('todos', todos_json)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/ruby_wasm_ui.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "ruby_wasm_ui/app"
|
|
4
|
+
require_relative "ruby_wasm_ui/component"
|
|
5
|
+
require_relative "ruby_wasm_ui/dispatcher"
|
|
6
|
+
require_relative "ruby_wasm_ui/dom"
|
|
7
|
+
require_relative "ruby_wasm_ui/nodes_equal"
|
|
8
|
+
require_relative "ruby_wasm_ui/template"
|
|
9
|
+
require_relative "ruby_wasm_ui/utils"
|
|
10
|
+
require_relative "ruby_wasm_ui/vdom"
|
|
11
|
+
require_relative "ruby_wasm_ui/version"
|
|
12
|
+
|
|
13
|
+
module RubyWasmUi
|
|
14
|
+
end
|
data/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ruby-wasm-ui-project",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "ruby-wasm-ui-project",
|
|
9
|
-
"version": "0.8.
|
|
9
|
+
"version": "0.8.2",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"workspaces": [
|
|
12
12
|
"packages/*"
|
data/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ruby-wasm-ui",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "ruby-wasm-ui",
|
|
9
|
-
"version": "0.8.
|
|
9
|
+
"version": "0.8.3",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@rollup/plugin-replace": "^6.0.2",
|
|
@@ -4,7 +4,13 @@ import filesize from "rollup-plugin-filesize";
|
|
|
4
4
|
import replace from "@rollup/plugin-replace";
|
|
5
5
|
import { glob } from "glob";
|
|
6
6
|
import process from "process";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
readFileSync,
|
|
9
|
+
writeFileSync,
|
|
10
|
+
lstatSync,
|
|
11
|
+
unlinkSync,
|
|
12
|
+
realpathSync,
|
|
13
|
+
} from "fs";
|
|
8
14
|
import { join, dirname } from "path";
|
|
9
15
|
import { fileURLToPath } from "url";
|
|
10
16
|
|
|
@@ -28,22 +34,68 @@ const rubyFiles = glob
|
|
|
28
34
|
// Determine environment based on NODE_ENV
|
|
29
35
|
const isDevelopment = process.env.NODE_ENV === "development";
|
|
30
36
|
|
|
37
|
+
// Plugin to clean up existing symlinks in dist directory before copy
|
|
38
|
+
const cleanupSymlinks = () => {
|
|
39
|
+
return {
|
|
40
|
+
name: "cleanup-symlinks",
|
|
41
|
+
buildStart() {
|
|
42
|
+
const distRubyFilePath = join(__dirname, "dist/ruby_wasm_ui.rb");
|
|
43
|
+
try {
|
|
44
|
+
const stats = lstatSync(distRubyFilePath);
|
|
45
|
+
if (stats.isSymbolicLink() || stats.isFile()) {
|
|
46
|
+
// Remove existing file/symlink before copy plugin runs
|
|
47
|
+
unlinkSync(distRubyFilePath);
|
|
48
|
+
}
|
|
49
|
+
} catch (e) {
|
|
50
|
+
// Ignore errors (file might not exist)
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
31
56
|
// Plugin to remove require_relative lines from Ruby files
|
|
32
57
|
const removeRequireRelative = () => {
|
|
33
58
|
return {
|
|
34
59
|
name: "remove-require-relative",
|
|
35
60
|
writeBundle() {
|
|
36
|
-
// Process all Ruby files in dist directory
|
|
37
|
-
|
|
61
|
+
// Process all Ruby files in dist directory (including dist/ruby_wasm_ui.rb)
|
|
62
|
+
// Ensure we only process files in dist/ directory, not lib/ or other source directories
|
|
63
|
+
const distDir = join(__dirname, "dist");
|
|
64
|
+
const distRubyFiles = glob.sync("dist/**/*.rb", {
|
|
65
|
+
cwd: __dirname,
|
|
66
|
+
absolute: false,
|
|
67
|
+
});
|
|
38
68
|
|
|
39
69
|
distRubyFiles.forEach((file) => {
|
|
40
70
|
const filePath = join(__dirname, file);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
71
|
+
try {
|
|
72
|
+
const stats = lstatSync(filePath);
|
|
73
|
+
let content;
|
|
74
|
+
// If it's a symlink to lib/, read from lib but write to dist
|
|
75
|
+
if (stats.isSymbolicLink()) {
|
|
76
|
+
const resolvedPath = realpathSync(filePath);
|
|
77
|
+
const distDirResolved = realpathSync(distDir);
|
|
78
|
+
if (!resolvedPath.startsWith(distDirResolved)) {
|
|
79
|
+
// Read from lib, but write to dist (replacing the symlink)
|
|
80
|
+
content = readFileSync(resolvedPath, "utf-8");
|
|
81
|
+
unlinkSync(filePath);
|
|
82
|
+
} else {
|
|
83
|
+
// Symlink resolves within dist, read resolved path
|
|
84
|
+
content = readFileSync(resolvedPath, "utf-8");
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
// Regular file, read directly
|
|
88
|
+
content = readFileSync(filePath, "utf-8");
|
|
89
|
+
}
|
|
90
|
+
// Remove lines that start with require_relative (with optional whitespace)
|
|
91
|
+
content = content.replace(/^\s*require_relative\s+.*$/gm, "");
|
|
92
|
+
// Remove multiple consecutive empty lines
|
|
93
|
+
content = content.replace(/\n{3,}/g, "\n\n");
|
|
94
|
+
writeFileSync(filePath, content, "utf-8");
|
|
95
|
+
} catch (e) {
|
|
96
|
+
// If read/write fails, skip this file
|
|
97
|
+
console.warn(`Could not process file ${filePath}: ${e.message}`);
|
|
98
|
+
}
|
|
47
99
|
});
|
|
48
100
|
},
|
|
49
101
|
};
|
|
@@ -66,6 +118,7 @@ export default {
|
|
|
66
118
|
"window.RUBY_WASM_UI_FILES": JSON.stringify(rubyFiles),
|
|
67
119
|
},
|
|
68
120
|
}),
|
|
121
|
+
cleanupSymlinks(),
|
|
69
122
|
copy({
|
|
70
123
|
targets: [
|
|
71
124
|
{
|
|
@@ -78,6 +131,11 @@ export default {
|
|
|
78
131
|
dest: "dist",
|
|
79
132
|
},
|
|
80
133
|
],
|
|
134
|
+
// Resolve symbolic links when copying to ensure dist files are regular files
|
|
135
|
+
// This allows us to process dist/ruby_wasm_ui.rb without affecting lib/ruby_wasm_ui.rb
|
|
136
|
+
copySyncOptions: {
|
|
137
|
+
dereference: true,
|
|
138
|
+
},
|
|
81
139
|
}),
|
|
82
140
|
cleanup({
|
|
83
141
|
comments: "none",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
../../../../lib/ruby_wasm_ui
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
../../../../lib/ruby_wasm_ui.rb
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_wasm_ui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- t0yohei
|
|
@@ -89,8 +89,33 @@ files:
|
|
|
89
89
|
- examples/package.json
|
|
90
90
|
- examples/src/counter/index.html
|
|
91
91
|
- examples/src/counter/index.rb
|
|
92
|
-
-
|
|
92
|
+
- examples/src/todos/index.html
|
|
93
|
+
- examples/src/todos/index.rb
|
|
94
|
+
- examples/src/todos/todos_repository.rb
|
|
93
95
|
- lib/ruby_wasm_ui.rb
|
|
96
|
+
- lib/ruby_wasm_ui/app.rb
|
|
97
|
+
- lib/ruby_wasm_ui/component.rb
|
|
98
|
+
- lib/ruby_wasm_ui/dispatcher.rb
|
|
99
|
+
- lib/ruby_wasm_ui/dom.rb
|
|
100
|
+
- lib/ruby_wasm_ui/dom/attributes.rb
|
|
101
|
+
- lib/ruby_wasm_ui/dom/destroy_dom.rb
|
|
102
|
+
- lib/ruby_wasm_ui/dom/events.rb
|
|
103
|
+
- lib/ruby_wasm_ui/dom/mount_dom.rb
|
|
104
|
+
- lib/ruby_wasm_ui/dom/patch_dom.rb
|
|
105
|
+
- lib/ruby_wasm_ui/dom/scheduler.rb
|
|
106
|
+
- lib/ruby_wasm_ui/nodes_equal.rb
|
|
107
|
+
- lib/ruby_wasm_ui/template.rb
|
|
108
|
+
- lib/ruby_wasm_ui/template/build_conditional_group.rb
|
|
109
|
+
- lib/ruby_wasm_ui/template/build_for_group.rb
|
|
110
|
+
- lib/ruby_wasm_ui/template/build_vdom.rb
|
|
111
|
+
- lib/ruby_wasm_ui/template/parser.rb
|
|
112
|
+
- lib/ruby_wasm_ui/utils.rb
|
|
113
|
+
- lib/ruby_wasm_ui/utils/arrays.rb
|
|
114
|
+
- lib/ruby_wasm_ui/utils/objects.rb
|
|
115
|
+
- lib/ruby_wasm_ui/utils/props.rb
|
|
116
|
+
- lib/ruby_wasm_ui/utils/strings.rb
|
|
117
|
+
- lib/ruby_wasm_ui/vdom.rb
|
|
118
|
+
- lib/ruby_wasm_ui/version.rb
|
|
94
119
|
- package-lock.json
|
|
95
120
|
- package.json
|
|
96
121
|
- packages/npm-packages/runtime/Gemfile
|
|
@@ -114,30 +139,8 @@ files:
|
|
|
114
139
|
- packages/npm-packages/runtime/spec/spec_helper.rb
|
|
115
140
|
- packages/npm-packages/runtime/src/__tests__/sample.test.js
|
|
116
141
|
- packages/npm-packages/runtime/src/index.js
|
|
142
|
+
- packages/npm-packages/runtime/src/ruby_wasm_ui
|
|
117
143
|
- packages/npm-packages/runtime/src/ruby_wasm_ui.rb
|
|
118
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/app.rb
|
|
119
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/component.rb
|
|
120
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/dispatcher.rb
|
|
121
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/dom.rb
|
|
122
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/dom/attributes.rb
|
|
123
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/dom/destroy_dom.rb
|
|
124
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/dom/events.rb
|
|
125
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/dom/mount_dom.rb
|
|
126
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/dom/patch_dom.rb
|
|
127
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/dom/scheduler.rb
|
|
128
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/nodes_equal.rb
|
|
129
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/template.rb
|
|
130
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/template/build_conditional_group.rb
|
|
131
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/template/build_for_group.rb
|
|
132
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/template/build_vdom.rb
|
|
133
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/template/parser.rb
|
|
134
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/utils.rb
|
|
135
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/utils/arrays.rb
|
|
136
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/utils/objects.rb
|
|
137
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/utils/props.rb
|
|
138
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/utils/strings.rb
|
|
139
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/vdom.rb
|
|
140
|
-
- packages/npm-packages/runtime/src/ruby_wasm_ui/version.rb
|
|
141
144
|
- packages/npm-packages/runtime/vitest.config.js
|
|
142
145
|
- playwright.config.js
|
|
143
146
|
- sig/ruby_wasm_ui.rbs
|
data/lib/ruby_wasm_ui
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
../packages/npm-packages/runtime/src/ruby_wasm_ui
|
data/lib/ruby_wasm_ui.rb
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
../packages/npm-packages/runtime/src/ruby_wasm_ui.rb
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "ruby_wasm_ui/app"
|
|
4
|
-
require_relative "ruby_wasm_ui/component"
|
|
5
|
-
require_relative "ruby_wasm_ui/dispatcher"
|
|
6
|
-
require_relative "ruby_wasm_ui/dom"
|
|
7
|
-
require_relative "ruby_wasm_ui/nodes_equal"
|
|
8
|
-
require_relative "ruby_wasm_ui/template"
|
|
9
|
-
require_relative "ruby_wasm_ui/utils"
|
|
10
|
-
require_relative "ruby_wasm_ui/vdom"
|
|
11
|
-
require_relative "ruby_wasm_ui/version"
|
|
12
|
-
|
|
13
|
-
module RubyWasmUi
|
|
14
|
-
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/data/{packages/npm-packages/runtime/src → lib}/ruby_wasm_ui/template/build_conditional_group.rb
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|