ruby_wasm_ui 0.8.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a999410f2d0e3c789843f58022405b1f9af0bd5640efb042ccc41464beb9e70d
4
- data.tar.gz: 92733ff997682478437f0df8f21fa3a4d0903ebf20fb1dd17c4923686b4e19df
3
+ metadata.gz: b322433e65bc63155825e97695c798bce90602a54e52797cd040aea67b909751
4
+ data.tar.gz: 1655781e0e93952e5f2ecc2e450d5a9286718979f3201f0169ae35dc94979872
5
5
  SHA512:
6
- metadata.gz: 35e4dcd436516375d2dc7e993580b1dd0cb73f3e8f6c55fbf4729ec6923f1b5655c724422e9356d65c6386c941838f6479281e002923f9f09071264e57681943
7
- data.tar.gz: 62b4a4bb92dc563ce77c6ad0ee761acffd7c39b32c438bc1ca2732b1e729bd25062c8681553768f1061963962337825bad2de8674d902363eff78f5e52456572
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.2"></script>
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>
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- ruby_wasm_ui (0.8.1)
4
+ ruby_wasm_ui (0.8.3)
5
5
  js (~> 2.7)
6
6
  ruby_wasm (~> 2.7)
7
7
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyWasmUi
4
- VERSION = "0.8.2"
4
+ VERSION = "0.8.3"
5
5
  end
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "ruby-wasm-ui",
3
- "version": "0.8.2",
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.2",
9
+ "version": "0.8.3",
10
10
  "license": "MIT",
11
11
  "devDependencies": {
12
12
  "@rollup/plugin-replace": "^6.0.2",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ruby-wasm-ui",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "",
5
5
  "main": "dist/ruby-wasm-ui.js",
6
6
  "files": [
@@ -10,8 +10,8 @@
10
10
  ],
11
11
  "scripts": {
12
12
  "prepack": "npm run build",
13
- "build": "rm -rf dist && NODE_ENV=production rollup -c",
14
- "build:dev": "rm -rf dist && NODE_ENV=development rollup -c",
13
+ "build": "NODE_ENV=production rollup -c",
14
+ "build:dev": "NODE_ENV=development rollup -c",
15
15
  "lint": "eslint src",
16
16
  "lint:fix": "eslint src --fix",
17
17
  "test": "vitest",
@@ -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 { readFileSync, writeFileSync } from "fs";
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 recursively
37
- const distRubyFiles = glob.sync("dist/**/*.rb");
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
- let content = readFileSync(filePath, "utf-8");
42
- // Remove lines that start with require_relative (with optional whitespace)
43
- content = content.replace(/^\s*require_relative\s+.*$/gm, "");
44
- // Remove multiple consecutive empty lines
45
- content = content.replace(/\n{3,}/g, "\n\n");
46
- writeFileSync(filePath, content, "utf-8");
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",
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.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - t0yohei