@porotkin/vite-plugin-react-kotlinjs 0.0.2 → 0.0.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.
package/README.md CHANGED
@@ -10,7 +10,7 @@ This plugin is inspired by the original
10
10
  Add the following dependency to your `build.gradle.kts`:
11
11
  ```kotlin
12
12
  dependencies {
13
- jsMainImplementation(devNpm("@porotkin/vite-plugin-react-kotlinjs", "^0.0.1"))
13
+ jsMainImplementation(devNpm("@porotkin/vite-plugin-react-kotlinjs", "^0.0.3"))
14
14
  }
15
15
  ```
16
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@porotkin/vite-plugin-react-kotlinjs",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Support React fast refresh in Kotlin/JS",
5
5
  "license": "MIT",
6
6
  "author": "Mikhail Porotkin",
@@ -8,27 +8,15 @@ window.$RefreshSig$ = () => (type) => type;`
8
8
 
9
9
  export const getPreambleCode = () => preambleCode
10
10
 
11
- function capitalize(str) {
12
- if (!str) return '';
13
- return str.charAt(0).toUpperCase() + str.slice(1);
14
- }
15
-
16
11
  export function addRefreshWrapper(code, pluginName, id, getComponentName) {
17
12
  const componentName = getComponentName?.(code)
18
13
  if (!componentName) return code;
19
14
 
20
- const packageName = id.split('/kotlin/').pop()
21
- .replace(`${componentName}.mjs`, '')
22
- .split(/[\/\\-]/g)
23
- .map(part => capitalize(part))
24
- .join('')
25
-
26
15
  const registerHmr = `
27
16
  import * as RefreshRuntime from "${runtimePublicPath}";
28
17
  const inWebWorker = typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
29
18
  if (import.meta.hot && !inWebWorker) {
30
- const component = get_${componentName}?.()
31
- $RefreshReg$(component, "${componentName + packageName}")
19
+ $RefreshReg$(get_${componentName}?.(), "${componentName}")
32
20
  RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
33
21
  RefreshRuntime.registerExportsForReactRefresh(${JSON.stringify(id)}, currentExports);
34
22
  import.meta.hot.accept((nextExports) => {
@@ -46,7 +34,7 @@ function normalizeExports(value) {
46
34
  }
47
35
  }
48
36
  function $RefreshReg$(type, id) {
49
- return RefreshRuntime.register(type, "/Users/mikhail.porotkin_1/Projects/Open-source/use-action-state/src/App.tsx " + id);
37
+ return RefreshRuntime.register(type, ${JSON.stringify(id)} + " " + id);
50
38
  }
51
39
  function $RefreshSig$() {
52
40
  return RefreshRuntime.createSignatureFunctionForTransform();