@octane-xplat/gif 0.1.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/dist/native/index.js +36 -0
- package/dist/native/octane-client-build.json +8 -0
- package/dist/web/index.js +38 -0
- package/dist/web/octane-client-build.json +8 -0
- package/package.json +49 -0
- package/src/AnimatedImage.native.tsrx +35 -0
- package/src/AnimatedImage.web.tsrx +25 -0
- package/src/index.native.ts +4 -0
- package/src/index.web.ts +4 -0
- package/src/props.ts +12 -0
- package/types/index.d.ts +8 -0
- package/types/props.d.ts +12 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { defineUniversalComponent, registerElement, universalPlan, universalValue } from "@nativescript-community/octane";
|
|
2
|
+
import { Img } from "@nativescript-community/ui-image";
|
|
3
|
+
//#region src/AnimatedImage.native.tsrx
|
|
4
|
+
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
5
|
+
"kind": "host",
|
|
6
|
+
"type": "animatedimage",
|
|
7
|
+
"props": {
|
|
8
|
+
"animatedImageView": true,
|
|
9
|
+
"autoPlayAnimations": true
|
|
10
|
+
},
|
|
11
|
+
"bindings": [
|
|
12
|
+
["id", 0],
|
|
13
|
+
["className", 1],
|
|
14
|
+
["style", 2],
|
|
15
|
+
["src", 3],
|
|
16
|
+
["stretch", 4],
|
|
17
|
+
["width", 5],
|
|
18
|
+
["height", 6],
|
|
19
|
+
["accessibilityLabel", 7]
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
registerElement("animatedimage", Img);
|
|
23
|
+
var AnimatedImage = defineUniversalComponent("nativescript", function AnimatedImage(props) {
|
|
24
|
+
return universalValue(__octaneUniversalPlan0, [
|
|
25
|
+
props.id,
|
|
26
|
+
props.className,
|
|
27
|
+
props.style,
|
|
28
|
+
props.src,
|
|
29
|
+
props.stretch ?? "aspectFit",
|
|
30
|
+
props.width,
|
|
31
|
+
props.height,
|
|
32
|
+
props.alt
|
|
33
|
+
]);
|
|
34
|
+
}, { "module": "@nativescript-community/octane" });
|
|
35
|
+
//#endregion
|
|
36
|
+
export { AnimatedImage };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { __s, bag6, clone, setStyle, template } from "octane";
|
|
2
|
+
import { bindSignalAttribute, enableSignalBindings, setPlainAttribute, setURLAttribute } from "octane/internal/client";
|
|
3
|
+
//#region src/AnimatedImage.web.tsrx
|
|
4
|
+
enableSignalBindings(1, true);
|
|
5
|
+
var _t$0 = /* @__PURE__ */ template("<img/>");
|
|
6
|
+
var OBJECT_FIT = {
|
|
7
|
+
none: "none",
|
|
8
|
+
fill: "fill",
|
|
9
|
+
aspectFit: "contain",
|
|
10
|
+
aspectFill: "cover"
|
|
11
|
+
};
|
|
12
|
+
var AnimatedImage = /* @__PURE__ */ __s(function AnimatedImage(props, __s, __extra) {
|
|
13
|
+
let _b = __s.slots[0];
|
|
14
|
+
if (_b === void 0) {
|
|
15
|
+
let _m1;
|
|
16
|
+
const _root = clone(_t$0);
|
|
17
|
+
_m1 = _root;
|
|
18
|
+
_b = bag6(__s, _root, void 0, _m1, void 0, void 0, void 0, void 0);
|
|
19
|
+
}
|
|
20
|
+
_b.a = bindSignalAttribute(__s, _b.a, _b.b, "id", props.id, "b:42ec7ee7", setPlainAttribute);
|
|
21
|
+
_b.c = bindSignalAttribute(__s, _b.c, _b.b, "class", props.className, "b:1b1f2715", "class");
|
|
22
|
+
{
|
|
23
|
+
const _v = {
|
|
24
|
+
objectFit: OBJECT_FIT[props.stretch ?? "aspectFit"],
|
|
25
|
+
width: props.width,
|
|
26
|
+
height: props.height,
|
|
27
|
+
...props.style
|
|
28
|
+
};
|
|
29
|
+
if (_b.d !== _v) {
|
|
30
|
+
setStyle(_b.b, _v, _b.d);
|
|
31
|
+
_b.d = _v;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
_b.e = bindSignalAttribute(__s, _b.e, _b.b, "src", props.src, "b:3d7475fa", setURLAttribute);
|
|
35
|
+
_b.f = bindSignalAttribute(__s, _b.f, _b.b, "alt", props.alt, "b:3f7e4d1f", setPlainAttribute);
|
|
36
|
+
});
|
|
37
|
+
//#endregion
|
|
38
|
+
export { AnimatedImage };
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@octane-xplat/gif",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Animated image (GIF/animated webp) leaf for Octane xplat — web <img> + @nativescript-community/ui-image",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"types",
|
|
8
|
+
"src"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./types/index.d.ts",
|
|
14
|
+
"web": "./dist/web/index.js",
|
|
15
|
+
"native": "./dist/native/index.js",
|
|
16
|
+
"default": "./dist/native/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@nativescript-community/ui-image": "4.6.20"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@nativescript-community/octane": "0.2.1",
|
|
27
|
+
"@nativescript/core": "9.1.2",
|
|
28
|
+
"@octanejs/vite-plugin": "0.1.60",
|
|
29
|
+
"octane": "0.5.0",
|
|
30
|
+
"typescript": "5.9.3",
|
|
31
|
+
"vite": "8.3.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@nativescript-community/octane": ">=0.2.1 <1",
|
|
35
|
+
"@nativescript/core": ">=9.1.0 <10",
|
|
36
|
+
"octane": ">=0.1.51 <1"
|
|
37
|
+
},
|
|
38
|
+
"peerDependenciesMeta": {
|
|
39
|
+
"@nativescript-community/octane": {
|
|
40
|
+
"optional": true
|
|
41
|
+
},
|
|
42
|
+
"@nativescript/core": {
|
|
43
|
+
"optional": true
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "vite build && vite build --mode native && tsc -p tsconfig.types.json"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** @jsxImportSource @nativescript-community/octane */
|
|
2
|
+
import { registerElement } from '@nativescript-community/octane';
|
|
3
|
+
import type { Attributes } from '@nativescript-community/octane/intrinsics';
|
|
4
|
+
import { Img } from '@nativescript-community/ui-image';
|
|
5
|
+
import type { AnimatedImageProps } from './props';
|
|
6
|
+
|
|
7
|
+
declare module '@nativescript-community/octane/intrinsics' {
|
|
8
|
+
interface NativeScriptElements {
|
|
9
|
+
animatedimage: Attributes<typeof Img>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// @nativescript-community/ui-image — Fresco DraweeView on Android,
|
|
14
|
+
// SDAnimatedImageView on iOS when `animatedImageView` is set (plain UIImageView
|
|
15
|
+
// otherwise, which would still decode but not animate).
|
|
16
|
+
registerElement('animatedimage', Img);
|
|
17
|
+
|
|
18
|
+
/** AnimatedImage — GIF/animated-webp decode + autoplay via ui-image. `src`
|
|
19
|
+
* takes the Img grammar: remote URL, res://name, ~/bundle path, file path.
|
|
20
|
+
* There is intentionally no play/pause prop — <img> can't pause on web, so
|
|
21
|
+
* the shared contract is always-playing. */
|
|
22
|
+
export function AnimatedImage(props: AnimatedImageProps) @{
|
|
23
|
+
<animatedimage
|
|
24
|
+
id={props.id}
|
|
25
|
+
className={props.className}
|
|
26
|
+
style={props.style}
|
|
27
|
+
src={props.src}
|
|
28
|
+
stretch={props.stretch ?? 'aspectFit'}
|
|
29
|
+
width={props.width}
|
|
30
|
+
height={props.height}
|
|
31
|
+
animatedImageView={true}
|
|
32
|
+
autoPlayAnimations={true}
|
|
33
|
+
accessibilityLabel={props.alt}
|
|
34
|
+
/>
|
|
35
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AnimatedImageProps } from './props';
|
|
2
|
+
|
|
3
|
+
const OBJECT_FIT = {
|
|
4
|
+
none: 'none',
|
|
5
|
+
fill: 'fill',
|
|
6
|
+
aspectFit: 'contain',
|
|
7
|
+
aspectFill: 'cover',
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
/** AnimatedImage — a plain <img>; browsers animate GIF/webp natively.
|
|
11
|
+
* `stretch` maps to object-fit. */
|
|
12
|
+
export function AnimatedImage(props: AnimatedImageProps) @{
|
|
13
|
+
<img
|
|
14
|
+
id={props.id}
|
|
15
|
+
className={props.className}
|
|
16
|
+
style={{
|
|
17
|
+
objectFit: OBJECT_FIT[props.stretch ?? 'aspectFit'],
|
|
18
|
+
width: props.width,
|
|
19
|
+
height: props.height,
|
|
20
|
+
...props.style,
|
|
21
|
+
}}
|
|
22
|
+
src={props.src}
|
|
23
|
+
alt={props.alt}
|
|
24
|
+
/>
|
|
25
|
+
}
|
package/src/index.web.ts
ADDED
package/src/props.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface AnimatedImageProps {
|
|
2
|
+
className?: any
|
|
3
|
+
style?: any
|
|
4
|
+
id?: string
|
|
5
|
+
src: string
|
|
6
|
+
alt?: string
|
|
7
|
+
/** Content fit — same grammar as core Image. Web maps to object-fit;
|
|
8
|
+
* ui-image (Fresco/SDWebImage) accepts the same values. */
|
|
9
|
+
stretch?: 'none' | 'fill' | 'aspectFit' | 'aspectFill'
|
|
10
|
+
width?: string | number
|
|
11
|
+
height?: string | number
|
|
12
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Boundary types for @octane-xplat/gif — the mechanical wrapper over
|
|
2
|
+
// props.ts (tsrx-tsc can't emit .tsrx declarations; see ui/types/index.d.ts
|
|
3
|
+
// for the same pattern).
|
|
4
|
+
import type { UniversalComponent } from 'octane/universal'
|
|
5
|
+
import type { AnimatedImageProps } from './props'
|
|
6
|
+
|
|
7
|
+
export declare const AnimatedImage: UniversalComponent<AnimatedImageProps>
|
|
8
|
+
export type { AnimatedImageProps }
|
package/types/props.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface AnimatedImageProps {
|
|
2
|
+
className?: any;
|
|
3
|
+
style?: any;
|
|
4
|
+
id?: string;
|
|
5
|
+
src: string;
|
|
6
|
+
alt?: string;
|
|
7
|
+
/** Content fit — same grammar as core Image. Web maps to object-fit;
|
|
8
|
+
* ui-image (Fresco/SDWebImage) accepts the same values. */
|
|
9
|
+
stretch?: 'none' | 'fill' | 'aspectFit' | 'aspectFill';
|
|
10
|
+
width?: string | number;
|
|
11
|
+
height?: string | number;
|
|
12
|
+
}
|