@wuchale/jsx 0.9.2 → 0.9.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/dist/index.js CHANGED
@@ -65,6 +65,9 @@ const defaultArgs = {
65
65
  };
66
66
  const resolveLoaderPath = loaderPathResolver(import.meta.url, '../src/loaders', 'js');
67
67
  export function getDefaultLoaderPath(loader, bundle) {
68
+ if (loader === 'custom') {
69
+ return null;
70
+ }
68
71
  if (loader === 'default') {
69
72
  return getDefaultLoaderPathVanilla('bundle', bundle);
70
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wuchale/jsx",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "Protobuf-like i18n from plain code: JSX adapter",
5
5
  "scripts": {
6
6
  "dev": "tsc --watch",
@@ -71,7 +71,7 @@
71
71
  "dependencies": {
72
72
  "@sveltejs/acorn-typescript": "^1.0.6",
73
73
  "acorn": "^8.15.0",
74
- "wuchale": "^0.18.1"
74
+ "wuchale": "^0.18.2"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@types/estree-jsx": "^1.0.5",
@@ -1,10 +1,8 @@
1
- // This is just the default loader.
2
- // You can customize it however you want, it will not be overwritten once it exists and is not empty.
3
-
4
1
  import { useState, useEffect, useMemo } from 'react'
5
2
  import toRuntime from 'wuchale/runtime'
3
+ import { locales } from '${DATA}'
6
4
 
7
- let locale = 'en'
5
+ let locale = locales[0]
8
6
 
9
7
  const callbacks = new Set([(/** @type {string} */ loc) => {locale = loc}])
10
8
 
@@ -18,7 +16,7 @@ export function setLocale(locale) {
18
16
  }
19
17
 
20
18
  export const getRuntimeRx = (/** @type {{[locale: string]: import('wuchale/runtime').CatalogModule }} */ catalogs) => {
21
- const [locale, setLocale] = useState('en')
19
+ const [locale, setLocale] = useState(locales[0])
22
20
  useEffect(() => {
23
21
  const cb = (/** @type {string} */ locale) => setLocale(locale)
24
22
  callbacks.add(cb)
@@ -1,11 +1,9 @@
1
- // This is just the default loader.
2
- // You can customize it however you want, it will not be overwritten once it exists and is not empty.
3
-
4
1
  import { loadCatalog, loadIDs } from '${PROXY}'
5
2
  import { registerLoaders } from 'wuchale/load-utils'
6
3
  import { useState, useEffect } from 'react'
7
4
 
8
5
  export const key = '${KEY}'
6
+ /** @type {{[loadID: string]: Set<Function>}} */
9
7
  const callbacks = {}
10
8
  const store = {}
11
9
 
@@ -16,17 +14,19 @@ const collection = {
16
14
  get: getRuntime,
17
15
  set: (/** @type {string} */ loadID, /** @type {import('wuchale/runtime').Runtime} */ runtime) => {
18
16
  store[loadID] = runtime // for when useEffect hasn't run yet
19
- callbacks[loadID]?.(runtime)
17
+ callbacks[loadID]?.forEach(cb => cb(runtime))
20
18
  }
21
19
  }
22
20
 
23
21
  registerLoaders(key, loadCatalog, loadIDs, collection)
24
22
 
25
23
  export const getRuntimeRx = (/** @type {string} */ loadID) => {
26
- const [runtime, setRuntime] = useState(collection.get(loadID))
24
+ const [runtime, setRuntime] = useState(getRuntime(loadID))
27
25
  useEffect(() => {
28
- callbacks[loadID] = (/** @type {import('wuchale/runtime').Runtime} */ runtime) => setRuntime(runtime)
29
- return () => delete callbacks[loadID]
26
+ const cb = (/** @type {import('wuchale/runtime').Runtime} */ runtime) => setRuntime(runtime)
27
+ callbacks[loadID] ??= new Set()
28
+ callbacks[loadID].add(cb)
29
+ return () => callbacks[loadID].delete(cb)
30
30
  }, [loadID])
31
31
  return runtime
32
32
  }
@@ -1,7 +1,3 @@
1
- // This is just the default loader.
2
- // You can customize it however you want, it will not be overwritten once it exists and is not empty.
3
- // The content is this way because you have enabled bundleLoad in the config.
4
-
5
1
  import { createSignal } from "solid-js"
6
2
  import toRuntime from "wuchale/runtime"
7
3
 
@@ -1,6 +1,3 @@
1
- // This is just the default loader.
2
- // You can customize it however you want, it will not be overwritten once it exists and is not empty.
3
-
4
1
  import { loadCatalog, loadIDs } from '${PROXY}'
5
2
  import { registerLoaders } from 'wuchale/load-utils'
6
3
  import { createStore } from 'solid-js/store'