@_linked/react 1.4.2-next.20260713192413 → 1.5.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#37](https://github.com/linked-cm/react/pull/37) [`03c1d42`](https://github.com/linked-cm/react/commit/03c1d42112b3ad229f4f4814b3d17987ab1fa78e) Thanks [@flyon](https://github.com/flyon)! - Support React 19 and React Native.
8
+
9
+ - The `react` peer range is now `^18.2.0 || ^19.0.0`. On React 19 apps (such as any current Expo SDK), `npm install` no longer fails with `ERESOLVE`, so you can remove the `overrides` workaround.
10
+ - New `@_linked/react/native` entry point. It exports the same API as `@_linked/react`. Importing it sets `LinkedComponentDefaults.loader` to an `ActivityIndicator` (`testID="linked-loader"`) and `LinkedComponentDefaults.errorElement` to an alert `Text` reading "Failed to load" (`testID="linked-error"`), unless your app has already set them. It also replaces `LinkedInfinityLoader` with an `ActivityIndicator`. The built-in `<svg>` loader and error elements crash on React Native, so React Native apps should import from `@_linked/react/native`. If your app set these defaults itself as a workaround, you can remove that code.
11
+ - `react-native` (`>=0.76`) is an optional peer dependency. The root entry doesn't import it, so web behaviour is unchanged.
12
+
3
13
  ## 1.4.2
4
14
 
5
15
  ### Patch Changes
package/README.md CHANGED
@@ -18,6 +18,26 @@ This package provides:
18
18
  npm install @_linked/react @_linked/core react react-dom
19
19
  ```
20
20
 
21
+ Supports React 18 (`^18.2.0`) and React 19 (`^19.0.0`).
22
+
23
+ ## React Native
24
+
25
+ Import from the `@_linked/react/native` subpath instead of the root:
26
+
27
+ ```tsx
28
+ import {linkedComponent, linkedSetComponent, linkedShape} from '@_linked/react/native';
29
+ ```
30
+
31
+ It exports the same API as `@_linked/react` (the same objects, not copies). Importing it also sets React Native render defaults, because the built-in loader and error elements are `<svg>` elements, and those crash on React Native:
32
+
33
+ - `LinkedComponentDefaults.loader`: `<ActivityIndicator testID="linked-loader" />`
34
+ - `LinkedComponentDefaults.errorElement`: `<Text testID="linked-error" accessibilityRole="alert">Failed to load</Text>`
35
+ - `LinkedInfinityLoader` renders the same `ActivityIndicator`
36
+
37
+ It sets a default only when your app hasn't already set it. Instance props and definition options still take precedence as usual. Use the subpath for at least the first `@_linked/react` import your app evaluates, for example in `App.tsx`.
38
+
39
+ `react-native` (`>=0.76`) is an optional peer dependency. The root entry never imports it, so web apps don't install it and get no peer warning.
40
+
21
41
  ## Usage
22
42
 
23
43
  ### Setup package exports
@@ -0,0 +1,26 @@
1
+ /**
2
+ * React Native entry point: `import {...} from '@_linked/react/native'`.
3
+ *
4
+ * Re-exports the full root API and, on import, installs React Native render
5
+ * defaults. The built-in loader and error elements (and `LinkedInfinityLoader`)
6
+ * render `<svg>` host elements, which crash on React Native
7
+ * (`View config getter callback for component 'svg'`).
8
+ *
9
+ * The defaults are written to `LinkedComponentDefaults` only where the app has
10
+ * not already set them, so the normal resolution order still applies:
11
+ * instance prop > definition options > LinkedComponentDefaults > built-in
12
+ *
13
+ * The root barrel (`@_linked/react`) never imports `react-native`; web
14
+ * behaviour is unchanged.
15
+ */
16
+ import React from 'react';
17
+ export * from './index.js';
18
+ /** React Native loading element: an `ActivityIndicator` (`testID="linked-loader"`). */
19
+ export declare function createNativeLoader(): React.ReactElement;
20
+ /** React Native error element: an alert `Text` (`testID="linked-error"`). */
21
+ export declare function createNativeErrorElement(): React.ReactElement;
22
+ /**
23
+ * React Native stand-in for the web `LinkedInfinityLoader` (an SVG), so code
24
+ * that opts into it keeps working on native. Shadows the root re-export.
25
+ */
26
+ export declare function LinkedInfinityLoader(): React.ReactElement;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * React Native entry point: `import {...} from '@_linked/react/native'`.
3
+ *
4
+ * Re-exports the full root API and, on import, installs React Native render
5
+ * defaults. The built-in loader and error elements (and `LinkedInfinityLoader`)
6
+ * render `<svg>` host elements, which crash on React Native
7
+ * (`View config getter callback for component 'svg'`).
8
+ *
9
+ * The defaults are written to `LinkedComponentDefaults` only where the app has
10
+ * not already set them, so the normal resolution order still applies:
11
+ * instance prop > definition options > LinkedComponentDefaults > built-in
12
+ *
13
+ * The root barrel (`@_linked/react`) never imports `react-native`; web
14
+ * behaviour is unchanged.
15
+ */
16
+ import React from 'react';
17
+ import { ActivityIndicator, Text } from 'react-native';
18
+ import { LinkedComponentDefaults } from './utils/LinkedComponent.js';
19
+ export * from './index.js';
20
+ /** React Native loading element: an `ActivityIndicator` (`testID="linked-loader"`). */
21
+ export function createNativeLoader() {
22
+ return React.createElement(ActivityIndicator, {
23
+ testID: 'linked-loader',
24
+ accessibilityLabel: 'Loading',
25
+ });
26
+ }
27
+ /** React Native error element: an alert `Text` (`testID="linked-error"`). */
28
+ export function createNativeErrorElement() {
29
+ return React.createElement(Text, { testID: 'linked-error', accessibilityRole: 'alert' }, 'Failed to load');
30
+ }
31
+ /**
32
+ * React Native stand-in for the web `LinkedInfinityLoader` (an SVG), so code
33
+ * that opts into it keeps working on native. Shadows the root re-export.
34
+ */
35
+ export function LinkedInfinityLoader() {
36
+ return createNativeLoader();
37
+ }
38
+ if (LinkedComponentDefaults.loader === undefined) {
39
+ LinkedComponentDefaults.loader = createNativeLoader();
40
+ }
41
+ if (LinkedComponentDefaults.errorElement === undefined) {
42
+ LinkedComponentDefaults.errorElement = createNativeErrorElement();
43
+ }
44
+ //# sourceMappingURL=native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/native.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,iBAAiB,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AACrD,OAAO,EAAC,uBAAuB,EAAC,MAAM,4BAA4B,CAAC;AAEnE,cAAc,YAAY,CAAC;AAE3B,uFAAuF;AACvF,MAAM,UAAU,kBAAkB;IAChC,OAAO,KAAK,CAAC,aAAa,CAAC,iBAAiB,EAAE;QAC5C,MAAM,EAAE,eAAe;QACvB,kBAAkB,EAAE,SAAS;KAC9B,CAAC,CAAC;AACL,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,wBAAwB;IACtC,OAAO,KAAK,CAAC,aAAa,CACxB,IAAI,EACJ,EAAC,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,OAAO,EAAC,EACpD,gBAAgB,CACjB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,kBAAkB,EAAE,CAAC;AAC9B,CAAC;AAED,IAAI,uBAAuB,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;IACjD,uBAAuB,CAAC,MAAM,GAAG,kBAAkB,EAAE,CAAC;AACxD,CAAC;AACD,IAAI,uBAAuB,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;IACvD,uBAAuB,CAAC,YAAY,GAAG,wBAAwB,EAAE,CAAC;AACpE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@_linked/react",
3
- "version": "1.4.2-next.20260713192413",
3
+ "version": "1.5.0",
4
4
  "license": "MIT",
5
5
  "linkedPackage": true,
6
6
  "type": "module",
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "git+https://github.com/Semantu/linked-react.git"
13
+ "url": "git+https://github.com/linked-cm/react.git"
14
14
  },
15
15
  "main": "lib/esm/index.js",
16
16
  "module": "lib/esm/index.js",
@@ -49,7 +49,13 @@
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@_linked/core": "^2.10",
52
- "react": "^18.2.0"
52
+ "react": "^18.2.0 || ^19.0.0",
53
+ "react-native": ">=0.76"
54
+ },
55
+ "peerDependenciesMeta": {
56
+ "react-native": {
57
+ "optional": true
58
+ }
53
59
  },
54
60
  "dependencies": {
55
61
  "react-usestateref": "^1.0.8"
@@ -60,15 +66,17 @@
60
66
  "@changesets/changelog-github": "^0.5.2",
61
67
  "@changesets/cli": "^2.29.8",
62
68
  "@jest/globals": "^29.7.0",
63
- "@testing-library/react": "^14.2.1",
69
+ "@testing-library/dom": "^10.4.2",
70
+ "@testing-library/react": "^16.3.3",
64
71
  "@types/jest": "^29.5.12",
65
72
  "@types/node": "^20.12.7",
66
- "@types/react": "^18.2.61",
67
- "@types/react-dom": "^18.2.19",
73
+ "@types/react": "^19.3.0",
74
+ "@types/react-dom": "^19.3.0",
68
75
  "jest": "^29.7.0",
69
76
  "jest-environment-jsdom": "^29.7.0",
70
- "react": "^18.2.0",
71
- "react-dom": "^18.2.0",
77
+ "react": "^19.3.0",
78
+ "react-dom": "^19.3.0",
79
+ "react-native": "0.86.3",
72
80
  "rimraf": "^5.0.7",
73
81
  "ts-jest": "^29.1.2",
74
82
  "typescript": "^5.7.3"