@sigx/lynx-runtime-internal 0.2.4
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/LICENSE +21 -0
- package/README.md +14 -0
- package/dist/animated-style-types.d.ts +93 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/ops.d.ts +50 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Andreas Ekdahl
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @sigx/lynx-runtime-internal
|
|
2
|
+
|
|
3
|
+
Shared types for the BG ↔ MT wire protocol used by [`@sigx/lynx-runtime`](../lynx-runtime) and [`@sigx/lynx-runtime-main`](../lynx-runtime-main). Re-exports nothing user-facing; ship-time decoupling only.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- **`OP`** — the numeric op codes that travel from the background thread to the main thread (`CREATE`, `SET_STYLE`, `SET_WORKLET_EVENT`, `INIT_MT_REF`, `REGISTER_AV_BRIDGE`, etc.). Both runtime packages import these so they stay aligned.
|
|
8
|
+
- **`MapperParams`, `BuiltinMapperName`, `AnimatedStyleMapper`** — the type signatures consumed by `useAnimatedStyle` (`@sigx/gestures`) and the MT-side mapper registry (`@sigx/lynx-runtime-main`).
|
|
9
|
+
|
|
10
|
+
> If you're writing application code, you don't need to depend on this package — the public surface is re-exported through [`@sigx/lynx`](../lynx).
|
|
11
|
+
|
|
12
|
+
## License
|
|
13
|
+
|
|
14
|
+
MIT
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for the `useAnimatedStyle` linkage.
|
|
3
|
+
*
|
|
4
|
+
* The MT-side mapper registry (in lynx-runtime-main) and the BG-side
|
|
5
|
+
* `useAnimatedStyle` factory (in @sigx/lynx) both need agreement on the
|
|
6
|
+
* param shape per built-in mapper name. This module is the single source of
|
|
7
|
+
* truth — adding a new built-in mapper means an entry here AND a matching
|
|
8
|
+
* implementation in lynx-runtime-main's `mtMappers` table.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Range-mapping params: linear interpolation from input domain to output range.
|
|
12
|
+
* Available on `translateX`, `translateY`, `scale`, `opacity` as an alternative
|
|
13
|
+
* to the linear `factor`/`offset` shape. Multi-stop ranges (length ≥ 2) work —
|
|
14
|
+
* each segment is interpolated independently.
|
|
15
|
+
*
|
|
16
|
+
* `extrapolate`:
|
|
17
|
+
* - `'clamp'` (default): cap at endpoints when input is outside the range.
|
|
18
|
+
* - `'identity'`: extend linearly beyond the endpoints using the slope of
|
|
19
|
+
* the nearest segment.
|
|
20
|
+
*/
|
|
21
|
+
export interface RangeParams {
|
|
22
|
+
inputRange: number[];
|
|
23
|
+
outputRange: number[];
|
|
24
|
+
extrapolate?: 'clamp' | 'identity';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Param shapes per built-in mapper. Add an entry here AND a matching
|
|
28
|
+
* implementation in lynx-runtime-main's `mtMappers` table to ship a new
|
|
29
|
+
* built-in mapper.
|
|
30
|
+
*/
|
|
31
|
+
export interface MapperParams {
|
|
32
|
+
/** translateX(value * factor)px — defaults: { factor: 1 }. Or range-map. */
|
|
33
|
+
translateX: {
|
|
34
|
+
factor?: number;
|
|
35
|
+
} | RangeParams;
|
|
36
|
+
/** translateY(value * factor)px — defaults: { factor: 1 }. Or range-map. */
|
|
37
|
+
translateY: {
|
|
38
|
+
factor?: number;
|
|
39
|
+
} | RangeParams;
|
|
40
|
+
/** translate(value.x * factorX, value.y * factorY)px — for 2D AVs. */
|
|
41
|
+
translate: {
|
|
42
|
+
factorX?: number;
|
|
43
|
+
factorY?: number;
|
|
44
|
+
};
|
|
45
|
+
/** scale(value + offset) — defaults: { offset: 0 }. Or range-map. */
|
|
46
|
+
scale: {
|
|
47
|
+
offset?: number;
|
|
48
|
+
} | RangeParams;
|
|
49
|
+
/**
|
|
50
|
+
* opacity = clamp01(value * factor + offset). Or range-map (output is
|
|
51
|
+
* clamped to [0,1] after interpolation either way).
|
|
52
|
+
*/
|
|
53
|
+
opacity: {
|
|
54
|
+
factor?: number;
|
|
55
|
+
offset?: number;
|
|
56
|
+
} | RangeParams;
|
|
57
|
+
/** rotate(value)deg. */
|
|
58
|
+
rotate: Record<string, never>;
|
|
59
|
+
/** padding-top: (value * factor)px — defaults: { factor: 1 }. Or range-map. */
|
|
60
|
+
paddingTop: {
|
|
61
|
+
factor?: number;
|
|
62
|
+
} | RangeParams;
|
|
63
|
+
/** padding-right: (value * factor)px — defaults: { factor: 1 }. Or range-map. */
|
|
64
|
+
paddingRight: {
|
|
65
|
+
factor?: number;
|
|
66
|
+
} | RangeParams;
|
|
67
|
+
/** padding-bottom: (value * factor)px — defaults: { factor: 1 }. Or range-map. */
|
|
68
|
+
paddingBottom: {
|
|
69
|
+
factor?: number;
|
|
70
|
+
} | RangeParams;
|
|
71
|
+
/** padding-left: (value * factor)px — defaults: { factor: 1 }. Or range-map. */
|
|
72
|
+
paddingLeft: {
|
|
73
|
+
factor?: number;
|
|
74
|
+
} | RangeParams;
|
|
75
|
+
/** margin-top: (value * factor)px — defaults: { factor: 1 }. Or range-map. */
|
|
76
|
+
marginTop: {
|
|
77
|
+
factor?: number;
|
|
78
|
+
} | RangeParams;
|
|
79
|
+
/** margin-right: (value * factor)px — defaults: { factor: 1 }. Or range-map. */
|
|
80
|
+
marginRight: {
|
|
81
|
+
factor?: number;
|
|
82
|
+
} | RangeParams;
|
|
83
|
+
/** margin-bottom: (value * factor)px — defaults: { factor: 1 }. Or range-map. */
|
|
84
|
+
marginBottom: {
|
|
85
|
+
factor?: number;
|
|
86
|
+
} | RangeParams;
|
|
87
|
+
/** margin-left: (value * factor)px — defaults: { factor: 1 }. Or range-map. */
|
|
88
|
+
marginLeft: {
|
|
89
|
+
factor?: number;
|
|
90
|
+
} | RangeParams;
|
|
91
|
+
}
|
|
92
|
+
export type BuiltinMapperName = keyof MapperParams;
|
|
93
|
+
export type AnimatedStyleMapper<P = unknown> = (value: unknown, params?: P) => Record<string, string | number>;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/ops.ts
|
|
2
|
+
var e = {
|
|
3
|
+
CREATE: 0,
|
|
4
|
+
CREATE_TEXT: 1,
|
|
5
|
+
INSERT: 2,
|
|
6
|
+
REMOVE: 3,
|
|
7
|
+
SET_PROP: 4,
|
|
8
|
+
SET_TEXT: 5,
|
|
9
|
+
SET_EVENT: 6,
|
|
10
|
+
REMOVE_EVENT: 7,
|
|
11
|
+
SET_STYLE: 8,
|
|
12
|
+
SET_CLASS: 9,
|
|
13
|
+
SET_ID: 10,
|
|
14
|
+
SET_WORKLET_EVENT: 11,
|
|
15
|
+
SET_MT_REF: 12,
|
|
16
|
+
INIT_MT_REF: 13,
|
|
17
|
+
RELEASE_MT_REF: 14,
|
|
18
|
+
REGISTER_AV_BRIDGE: 15,
|
|
19
|
+
UNREGISTER_AV_BRIDGE: 16,
|
|
20
|
+
REGISTER_AV_STYLE_BINDING: 17,
|
|
21
|
+
UNREGISTER_AV_STYLE_BINDING: 18,
|
|
22
|
+
SET_GESTURE_DETECTOR: 19,
|
|
23
|
+
REMOVE_GESTURE_DETECTOR: 20
|
|
24
|
+
};
|
|
25
|
+
//#endregion
|
|
26
|
+
export { e as OP };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/ops.ts"],"sourcesContent":["/**\n * Flat-array operation codes — the wire protocol between BG Thread and Main Thread.\n *\n * Format (all numbers/strings, JSON-serializable):\n * CREATE: [0, id, type]\n * CREATE_TEXT: [1, id]\n * INSERT: [2, parentId, childId, anchorId] anchorId=-1 means append\n * REMOVE: [3, parentId, childId]\n * SET_PROP: [4, id, key, value]\n * SET_TEXT: [5, id, text]\n * SET_EVENT: [6, id, eventType, eventName, sign]\n * REMOVE_EVENT: [7, id, eventType, eventName]\n * SET_STYLE: [8, id, styleObject]\n * SET_CLASS: [9, id, classString]\n * SET_ID: [10, id, idString]\n * SET_WORKLET_EVENT: [11, id, eventType, eventName, workletCtx]\n * SET_MT_REF: [12, id, refImpl]\n * INIT_MT_REF: [13, wvid, initValue]\n * RELEASE_MT_REF: [14, wvid]\n * REGISTER_AV_BRIDGE: [15, wvid, initValue]\n * UNREGISTER_AV_BRIDGE: [16, wvid]\n * REGISTER_AV_STYLE_BINDING: [17, bindingId, elementWvid, avWvid, mapperName, params]\n * UNREGISTER_AV_STYLE_BINDING: [18, bindingId]\n * SET_GESTURE_DETECTOR: [19, elementId, gestureId, type, config, relationMap]\n * REMOVE_GESTURE_DETECTOR: [20, elementId, gestureId]\n */\nexport const OP = {\n CREATE: 0,\n CREATE_TEXT: 1,\n INSERT: 2,\n REMOVE: 3,\n SET_PROP: 4,\n SET_TEXT: 5,\n SET_EVENT: 6,\n REMOVE_EVENT: 7,\n SET_STYLE: 8,\n SET_CLASS: 9,\n SET_ID: 10,\n SET_WORKLET_EVENT: 11,\n SET_MT_REF: 12,\n INIT_MT_REF: 13,\n RELEASE_MT_REF: 14,\n REGISTER_AV_BRIDGE: 15,\n UNREGISTER_AV_BRIDGE: 16,\n REGISTER_AV_STYLE_BINDING: 17,\n UNREGISTER_AV_STYLE_BINDING: 18,\n SET_GESTURE_DETECTOR: 19,\n REMOVE_GESTURE_DETECTOR: 20,\n} as const;\n\nexport type OpCode = (typeof OP)[keyof typeof OP];\n"],"mappings":";AA0BA,IAAa,IAAK;CAChB,QAAQ;CACR,aAAa;CACb,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,UAAU;CACV,WAAW;CACX,cAAc;CACd,WAAW;CACX,WAAW;CACX,QAAQ;CACR,mBAAmB;CACnB,YAAY;CACZ,aAAa;CACb,gBAAgB;CAChB,oBAAoB;CACpB,sBAAsB;CACtB,2BAA2B;CAC3B,6BAA6B;CAC7B,sBAAsB;CACtB,yBAAyB;CAC1B"}
|
package/dist/ops.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flat-array operation codes — the wire protocol between BG Thread and Main Thread.
|
|
3
|
+
*
|
|
4
|
+
* Format (all numbers/strings, JSON-serializable):
|
|
5
|
+
* CREATE: [0, id, type]
|
|
6
|
+
* CREATE_TEXT: [1, id]
|
|
7
|
+
* INSERT: [2, parentId, childId, anchorId] anchorId=-1 means append
|
|
8
|
+
* REMOVE: [3, parentId, childId]
|
|
9
|
+
* SET_PROP: [4, id, key, value]
|
|
10
|
+
* SET_TEXT: [5, id, text]
|
|
11
|
+
* SET_EVENT: [6, id, eventType, eventName, sign]
|
|
12
|
+
* REMOVE_EVENT: [7, id, eventType, eventName]
|
|
13
|
+
* SET_STYLE: [8, id, styleObject]
|
|
14
|
+
* SET_CLASS: [9, id, classString]
|
|
15
|
+
* SET_ID: [10, id, idString]
|
|
16
|
+
* SET_WORKLET_EVENT: [11, id, eventType, eventName, workletCtx]
|
|
17
|
+
* SET_MT_REF: [12, id, refImpl]
|
|
18
|
+
* INIT_MT_REF: [13, wvid, initValue]
|
|
19
|
+
* RELEASE_MT_REF: [14, wvid]
|
|
20
|
+
* REGISTER_AV_BRIDGE: [15, wvid, initValue]
|
|
21
|
+
* UNREGISTER_AV_BRIDGE: [16, wvid]
|
|
22
|
+
* REGISTER_AV_STYLE_BINDING: [17, bindingId, elementWvid, avWvid, mapperName, params]
|
|
23
|
+
* UNREGISTER_AV_STYLE_BINDING: [18, bindingId]
|
|
24
|
+
* SET_GESTURE_DETECTOR: [19, elementId, gestureId, type, config, relationMap]
|
|
25
|
+
* REMOVE_GESTURE_DETECTOR: [20, elementId, gestureId]
|
|
26
|
+
*/
|
|
27
|
+
export declare const OP: {
|
|
28
|
+
readonly CREATE: 0;
|
|
29
|
+
readonly CREATE_TEXT: 1;
|
|
30
|
+
readonly INSERT: 2;
|
|
31
|
+
readonly REMOVE: 3;
|
|
32
|
+
readonly SET_PROP: 4;
|
|
33
|
+
readonly SET_TEXT: 5;
|
|
34
|
+
readonly SET_EVENT: 6;
|
|
35
|
+
readonly REMOVE_EVENT: 7;
|
|
36
|
+
readonly SET_STYLE: 8;
|
|
37
|
+
readonly SET_CLASS: 9;
|
|
38
|
+
readonly SET_ID: 10;
|
|
39
|
+
readonly SET_WORKLET_EVENT: 11;
|
|
40
|
+
readonly SET_MT_REF: 12;
|
|
41
|
+
readonly INIT_MT_REF: 13;
|
|
42
|
+
readonly RELEASE_MT_REF: 14;
|
|
43
|
+
readonly REGISTER_AV_BRIDGE: 15;
|
|
44
|
+
readonly UNREGISTER_AV_BRIDGE: 16;
|
|
45
|
+
readonly REGISTER_AV_STYLE_BINDING: 17;
|
|
46
|
+
readonly UNREGISTER_AV_STYLE_BINDING: 18;
|
|
47
|
+
readonly SET_GESTURE_DETECTOR: 19;
|
|
48
|
+
readonly REMOVE_GESTURE_DETECTOR: 20;
|
|
49
|
+
};
|
|
50
|
+
export type OpCode = (typeof OP)[keyof typeof OP];
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sigx/lynx-runtime-internal",
|
|
3
|
+
"version": "0.2.4",
|
|
4
|
+
"description": "Shared op types for SignalX Lynx renderer (BG ↔ MTS wire protocol)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"sigx",
|
|
19
|
+
"lynx",
|
|
20
|
+
"internal",
|
|
21
|
+
"ops"
|
|
22
|
+
],
|
|
23
|
+
"author": "Andreas Ekdahl",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/signalxjs/lynx.git",
|
|
28
|
+
"directory": "packages/lynx-runtime-internal"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/signalxjs/lynx/tree/main/packages/lynx-runtime-internal",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/signalxjs/lynx/issues"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@sigx/vite": "^0.4.3",
|
|
36
|
+
"typescript": "^6.0.3",
|
|
37
|
+
"vite": "^8.0.12"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "vite build && tsgo --emitDeclarationOnly",
|
|
44
|
+
"dev": "vite build --watch"
|
|
45
|
+
}
|
|
46
|
+
}
|