@wuchale/jsx 0.10.1 → 0.10.2

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.d.ts CHANGED
@@ -6,6 +6,7 @@ type LoadersAvailable = 'default' | 'react' | 'solidjs';
6
6
  export type JSXArgs = AdapterArgs<LoadersAvailable> & {
7
7
  variant: JSXLib;
8
8
  };
9
+ export declare const defaultArgs: JSXArgs;
9
10
  export declare function getDefaultLoaderPath(loader: LoaderChoice<LoadersAvailable>, bundle: boolean): string | {
10
11
  client: string;
11
12
  server: string;
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { getDefaultLoaderPath as getDefaultLoaderPathVanilla, pluralPattern } fr
4
4
  import { JSXTransformer } from './transformer.js';
5
5
  export function createJsxHeuristic(opts) {
6
6
  const defaultHeuristic = createHeuristic(opts);
7
- return (msg) => {
7
+ return msg => {
8
8
  const defRes = defaultHeuristic(msg);
9
9
  if (!defRes) {
10
10
  return false;
@@ -29,12 +29,12 @@ const defaultRuntime = {
29
29
  !nested &&
30
30
  ((funcName.startsWith('use') && funcName.length > 3) || /[A-Z]/.test(funcName[0])),
31
31
  reactive: {
32
- wrapInit: (expr) => expr,
33
- wrapUse: (expr) => expr,
32
+ wrapInit: expr => expr,
33
+ wrapUse: expr => expr,
34
34
  },
35
35
  plain: {
36
- wrapInit: (expr) => expr,
37
- wrapUse: (expr) => expr,
36
+ wrapInit: expr => expr,
37
+ wrapUse: expr => expr,
38
38
  },
39
39
  };
40
40
  const defaultRuntimeSolid = {
@@ -42,11 +42,11 @@ const defaultRuntimeSolid = {
42
42
  initReactive: ({ funcName }) => (funcName == null ? true : null), // init only in top level
43
43
  useReactive: true, // always reactive, because solidjs doesn't have a problem with it
44
44
  reactive: {
45
- wrapInit: (expr) => `() => ${expr}`,
46
- wrapUse: (expr) => `${expr}()`,
45
+ wrapInit: expr => `() => ${expr}`,
46
+ wrapUse: expr => `${expr}()`,
47
47
  },
48
48
  };
49
- const defaultArgs = {
49
+ export const defaultArgs = {
50
50
  files: { include: 'src/**/*.{js,ts,jsx,tsx}', ignore: '**/*.d.ts' },
51
51
  localesDir: './src/locales',
52
52
  patterns: [pluralPattern],
@@ -23,19 +23,19 @@ export class JSXTransformer extends Transformer {
23
23
  initMixedVisitor = () => new MixedVisitor({
24
24
  mstr: this.mstr,
25
25
  vars: this.vars,
26
- getRange: (node) => ({
26
+ getRange: node => ({
27
27
  start: node.start,
28
28
  end: node.end,
29
29
  }),
30
- isComment: (node) => node.type === 'JSXExpressionContainer' &&
30
+ isComment: node => node.type === 'JSXExpressionContainer' &&
31
31
  node.expression.type === 'JSXEmptyExpression' &&
32
32
  node.expression.end > node.expression.start,
33
- isText: (node) => node.type === 'JSXText',
33
+ isText: node => node.type === 'JSXText',
34
34
  leaveInPlace: () => false,
35
- isExpression: (node) => node.type === 'JSXExpressionContainer',
35
+ isExpression: node => node.type === 'JSXExpressionContainer',
36
36
  getTextContent: (node) => node.value,
37
37
  getCommentData: (node) => this.getMarkupCommentBody(node.expression),
38
- canHaveChildren: (node) => nodesWithChildren.includes(node.type),
38
+ canHaveChildren: node => nodesWithChildren.includes(node.type),
39
39
  visitFunc: (child, inCompoundText) => {
40
40
  const inCompoundTextPrev = this.inCompoundText;
41
41
  this.inCompoundText = inCompoundText;
@@ -110,7 +110,7 @@ export class JSXTransformer extends Transformer {
110
110
  msgs.push(...this.visitJx(attr));
111
111
  }
112
112
  if (this.inCompoundText && this.currentJsxKey != null) {
113
- const key = node.openingElement.attributes.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === 'key');
113
+ const key = node.openingElement.attributes.find(attr => attr.type === 'JSXAttribute' && attr.name.name === 'key');
114
114
  if (!key) {
115
115
  this.mstr.appendLeft(node.openingElement.name.end, ` key="_${this.currentJsxKey}"`);
116
116
  this.currentJsxKey++;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@wuchale/jsx",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "Protobuf-like i18n from plain code: JSX adapter",
5
5
  "scripts": {
6
6
  "dev": "tsc --watch",
7
7
  "build": "tsc",
8
- "test": "node tests/index.ts"
8
+ "test": "node --import ../wuchale/testing/resolve.ts --test"
9
9
  },
10
10
  "keywords": [
11
11
  "i18n",
@@ -58,10 +58,10 @@
58
58
  "author": "K1DV5",
59
59
  "license": "MIT",
60
60
  "dependencies": {
61
- "@sveltejs/acorn-typescript": "^1.0.8",
61
+ "@sveltejs/acorn-typescript": "^1.0.9",
62
62
  "acorn": "^8.15.0",
63
63
  "magic-string": "^0.30.21",
64
- "wuchale": "^0.19.1"
64
+ "wuchale": "^0.20.0"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/estree-jsx": "^1.0.5",
@@ -14,7 +14,7 @@ const collection = {
14
14
  get: getRuntime,
15
15
  set: (/** @type {string} */ loadID, /** @type {import('wuchale/runtime').Runtime} */ runtime) => {
16
16
  store[loadID] = runtime // for when useEffect hasn't run yet
17
- callbacks[loadID]?.forEach((cb) => {
17
+ callbacks[loadID]?.forEach(cb => {
18
18
  cb(runtime)
19
19
  })
20
20
  },
@@ -8,6 +8,6 @@ export { setLocale }
8
8
  /**
9
9
  * @param {{ [locale: string]: import('wuchale/runtime').CatalogModule }} catalogs
10
10
  */
11
- export const getRuntimeRx = (catalogs) => toRuntime(catalogs[locale()], locale())
11
+ export const getRuntimeRx = catalogs => toRuntime(catalogs[locale()], locale())
12
12
  // same function, because solid-js can use them anywhere
13
13
  export const getRuntime = getRuntimeRx
@@ -8,7 +8,7 @@ const [store, setStore] = createStore({})
8
8
 
9
9
  // two exports. can be the same because solid-js can use them anywhere unlike react
10
10
  export const getRuntimeRx = registerLoaders(key, loadCatalog, loadIDs, {
11
- get: (loadID) => store[loadID],
11
+ get: loadID => store[loadID],
12
12
  set: (loadID, runtime) => setStore(loadID, () => runtime),
13
13
  })
14
14
  export const getRuntime = getRuntimeRx