@swiftbrowser/react 0.14.1 → 0.14.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/components/images.d.ts +3 -1
- package/dist/components/images.d.ts.map +1 -1
- package/dist/index.js +17 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -21,7 +21,9 @@ export interface AsyncImageProps extends ViewModifiers {
|
|
|
21
21
|
/**
|
|
22
22
|
* `AsyncImage(url:)`: the page loads the image to learn its size (the
|
|
23
23
|
* engine lays a remote image out by its pixel size, as the Swift core does
|
|
24
|
-
* after its `image` request), then shows it.
|
|
24
|
+
* after its `image` request), then shows it. In a SwiftBrowser Native app,
|
|
25
|
+
* which has no page to load it with, the URL goes to the renderer at once
|
|
26
|
+
* and SwiftUI's own `AsyncImage` loads it.
|
|
25
27
|
*/
|
|
26
28
|
export declare function AsyncImage(props: AsyncImageProps): ReactNode;
|
|
27
29
|
//# sourceMappingURL=images.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../src/components/images.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAE9E,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,0CAA0C;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yDAAyD;IACzD,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,wEAAwE;IACxE,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oEAAoE;IACpE,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;
|
|
1
|
+
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../../src/components/images.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAE9E,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,0CAA0C;IAC1C,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yDAAyD;IACzD,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,wEAAwE;IACxE,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oEAAoE;IACpE,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzC;AAmBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,CAgC5D"}
|
package/dist/index.js
CHANGED
|
@@ -1237,7 +1237,7 @@ function segmentsOf(children, style, into) {
|
|
|
1237
1237
|
}
|
|
1238
1238
|
if (element.type === Image$1) {
|
|
1239
1239
|
const props = element.props;
|
|
1240
|
-
into.push({ image: imageProps(props), style });
|
|
1240
|
+
into.push({ image: imageProps$1(props), style });
|
|
1241
1241
|
return;
|
|
1242
1242
|
}
|
|
1243
1243
|
};
|
|
@@ -1279,7 +1279,7 @@ function placeholder(node, redacted) {
|
|
|
1279
1279
|
function openURL(url) {
|
|
1280
1280
|
if (typeof window !== "undefined") window.open(url, "_blank", "noopener");
|
|
1281
1281
|
}
|
|
1282
|
-
function imageProps(props) {
|
|
1282
|
+
function imageProps$1(props) {
|
|
1283
1283
|
if (props.systemName !== void 0) return { systemName: props.systemName };
|
|
1284
1284
|
if (props.url !== void 0) return { url: props.url, resizable: props.resizable ?? false, width: props.width ?? 0, height: props.height ?? 0 };
|
|
1285
1285
|
return { name: props.name ?? "", resizable: props.resizable ?? false };
|
|
@@ -1289,7 +1289,7 @@ function Image$1(props) {
|
|
|
1289
1289
|
const environment = useViewEnvironment();
|
|
1290
1290
|
const redacted = takeModifier(modifiers, "redacted") ?? environment.redacted;
|
|
1291
1291
|
const mode = takeModifier(modifiers, "symbolRenderingMode") ?? environment.symbolRenderingMode;
|
|
1292
|
-
const own = imageProps(props);
|
|
1292
|
+
const own = imageProps$1(props);
|
|
1293
1293
|
const element = props.systemName !== void 0 && mode === "palette" ? { ...own, renderingMode: "palette" } : own;
|
|
1294
1294
|
if (props.accessibilityLabel) element["accessibilityLabel"] = props.accessibilityLabel;
|
|
1295
1295
|
return applyModifiers(placeholder(sb("image", element), redacted), modifiers);
|
|
@@ -3399,6 +3399,9 @@ function EditButton(props) {
|
|
|
3399
3399
|
return applyModifiers(/* @__PURE__ */ jsx(Button, { title: editing ? "Done" : "Edit", editMode: editing ? "active" : "inactive", action: () => setEditing(!editing) }), modifiers);
|
|
3400
3400
|
}
|
|
3401
3401
|
const loaded = /* @__PURE__ */ new Map();
|
|
3402
|
+
function inNativeApp() {
|
|
3403
|
+
return typeof Image === "undefined" && globalThis.__sbNative !== void 0;
|
|
3404
|
+
}
|
|
3402
3405
|
function AsyncImage(props) {
|
|
3403
3406
|
const { own, modifiers } = splitProps(props);
|
|
3404
3407
|
const [state, setState] = useState(() => loaded.get(own.url) ?? null);
|
|
@@ -3425,19 +3428,19 @@ function AsyncImage(props) {
|
|
|
3425
3428
|
live = false;
|
|
3426
3429
|
};
|
|
3427
3430
|
}, [own.url]);
|
|
3431
|
+
if (inNativeApp()) {
|
|
3432
|
+
return applyModifiers(sb("image", { ...imageProps(own), url: own.url, width: 0, height: 0 }), modifiers);
|
|
3433
|
+
}
|
|
3428
3434
|
if (state === null) return own.placeholder ?? null;
|
|
3429
3435
|
if (state === "failed") return own.failure ?? own.placeholder ?? null;
|
|
3430
|
-
return applyModifiers(
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
}),
|
|
3439
|
-
modifiers
|
|
3440
|
-
);
|
|
3436
|
+
return applyModifiers(sb("image", { ...imageProps(own), url: state.url, width: state.width, height: state.height }), modifiers);
|
|
3437
|
+
}
|
|
3438
|
+
function imageProps(own) {
|
|
3439
|
+
return {
|
|
3440
|
+
resizable: own.resizable ?? false,
|
|
3441
|
+
...own.webInteractions ? { webInteractions: true } : {},
|
|
3442
|
+
...own.accessibilityLabel ? { accessibilityLabel: own.accessibilityLabel } : {}
|
|
3443
|
+
};
|
|
3441
3444
|
}
|
|
3442
3445
|
function BarMark(_props) {
|
|
3443
3446
|
return null;
|