@doubao-apps/taro-runtime 0.0.18 → 0.0.19

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.
Files changed (63) hide show
  1. package/dist/api/base/index.d.ts +12 -0
  2. package/dist/api/base/index.js +13 -1
  3. package/dist/api/create-selector-query/index.d.ts +3 -0
  4. package/dist/api/create-selector-query/index.js +577 -0
  5. package/dist/api/index.d.ts +7 -3
  6. package/dist/api/index.js +7 -3
  7. package/dist/api/location/index.d.ts +10 -0
  8. package/dist/api/location/index.js +77 -0
  9. package/dist/api/map/index.js +28 -30
  10. package/dist/api/request/index.js +8 -18
  11. package/dist/api/router/index.d.ts +4 -0
  12. package/dist/api/router/index.js +4 -0
  13. package/dist/api/router/navigate-back.d.ts +5 -0
  14. package/dist/api/router/navigate-back.js +20 -0
  15. package/dist/api/{navigate/index.d.ts → router/navigate-to.d.ts} +2 -2
  16. package/dist/api/{navigate/index.js → router/navigate-to.js} +7 -7
  17. package/dist/api/router/redirect-to.d.ts +5 -0
  18. package/dist/api/router/redirect-to.js +22 -0
  19. package/dist/api/show-toast/index.d.ts +6 -0
  20. package/dist/api/show-toast/index.js +39 -0
  21. package/dist/api/storage/index.d.ts +16 -0
  22. package/dist/api/storage/index.js +55 -0
  23. package/dist/api/system/index.d.ts +12 -0
  24. package/dist/api/system/index.js +40 -10
  25. package/dist/api/utils.d.ts +21 -0
  26. package/dist/api/utils.js +65 -0
  27. package/dist/components/Image/index.d.ts +2 -1
  28. package/dist/components/Image/index.jsx +3 -2
  29. package/dist/components/Input/index.d.ts +3 -5
  30. package/dist/components/Input/index.jsx +50 -3
  31. package/dist/components/Input/map.d.ts +50 -0
  32. package/dist/components/Input/map.js +226 -0
  33. package/dist/components/Map/bridge.d.ts +32 -4
  34. package/dist/components/Map/bridge.js +224 -13
  35. package/dist/components/Map/index.jsx +78 -58
  36. package/dist/components/Map/mapping.d.ts +71 -3
  37. package/dist/components/Map/mapping.js +0 -15
  38. package/dist/components/PickerView/index.d.ts +8 -0
  39. package/dist/components/PickerView/index.jsx +47 -0
  40. package/dist/components/PickerView/map.d.ts +36 -0
  41. package/dist/components/PickerView/map.js +29 -0
  42. package/dist/components/Radio/index.d.ts +5 -0
  43. package/dist/components/Radio/index.jsx +82 -0
  44. package/dist/components/Radio/map.d.ts +38 -0
  45. package/dist/components/Radio/map.js +109 -0
  46. package/dist/components/Radio/shared.d.ts +7 -0
  47. package/dist/components/Radio/shared.js +9 -0
  48. package/dist/components/RadioGroup/context.d.ts +11 -0
  49. package/dist/components/RadioGroup/context.js +3 -0
  50. package/dist/components/RadioGroup/index.d.ts +3 -0
  51. package/dist/components/RadioGroup/index.jsx +80 -0
  52. package/dist/components/RadioGroup/map.d.ts +44 -0
  53. package/dist/components/RadioGroup/map.js +109 -0
  54. package/dist/components/WebView/index.d.ts +3 -0
  55. package/dist/components/WebView/index.jsx +24 -0
  56. package/dist/components/index.d.ts +4 -0
  57. package/dist/components/index.js +4 -0
  58. package/dist/exports/app-core.d.ts +1 -1
  59. package/dist/exports/app-core.js +1 -1
  60. package/dist/exports/view-core.d.ts +1 -1
  61. package/dist/exports/view-core.js +1 -1
  62. package/dist/internal/map-context/index.d.ts +7 -1
  63. package/package.json +1 -1
@@ -1,6 +1,4 @@
1
- type InputProps = {
2
- value?: string;
3
- } & Record<string, unknown>;
4
- export declare function Input({ ...rest }: InputProps): any;
5
- export {};
1
+ import type { InputRef as LynxInputRef } from '@byted-doubao-apps/components';
2
+ import type { InputProps as TaroInputProps } from '@tarojs/components';
3
+ export declare const Input: import("react").ForwardRefExoticComponent<Omit<TaroInputProps, "ref"> & import("react").RefAttributes<LynxInputRef>>;
6
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,52 @@
1
- export function Input({ ...rest }) {
2
- // @ts-expect-error
3
- return <x-input-ng {...rest}/>;
1
+ import { forwardRef, useCallback, useEffect, useRef } from '@byted-doubao-apps/framework';
2
+ import { warnUnsupported } from '../base/warn-unsupported.js';
3
+ import { mapInputProps, resolveFocusBehavior, toFocusEventDetail, toInputCommonEvent, toInputEventDetail, toSelectionChangeEventDetail, toValueEventDetail } from './map.js';
4
+ export const Input = forwardRef(InputImpl);
5
+ function InputImpl(props, ref) {
6
+ const { onInput, onFocus, onBlur, onConfirm, onSelectionChange, ...nonEventProps } = props;
7
+ const { mapped, unsupported, inputId, resolvedFocus, resolvedAutoFocus } = mapInputProps(nonEventProps);
8
+ const inputRef = useRef(null);
9
+ const hasAutoFocusedRef = useRef(false);
10
+ warnUnsupported('Input', unsupported);
11
+ const assignRef = useCallback((instance) => {
12
+ inputRef.current = instance;
13
+ assignForwardedRef(ref, instance);
14
+ }, [ref]);
15
+ useEffect(() => {
16
+ const { action, hasAutoFocused } = resolveFocusBehavior(resolvedFocus, resolvedAutoFocus, hasAutoFocusedRef.current);
17
+ hasAutoFocusedRef.current = hasAutoFocused;
18
+ if (action === 'focus') {
19
+ void inputRef.current?.focus();
20
+ return;
21
+ }
22
+ if (action === 'blur') {
23
+ void inputRef.current?.blur();
24
+ }
25
+ }, [resolvedAutoFocus, resolvedFocus]);
26
+ const handleInput = useCallback((event) => {
27
+ onInput?.(toInputCommonEvent(toInputEventDetail(event), 'input', inputId));
28
+ }, [inputId, onInput]);
29
+ const handleFocus = useCallback((event) => {
30
+ onFocus?.(toInputCommonEvent(toFocusEventDetail(event), 'focus', inputId));
31
+ }, [inputId, onFocus]);
32
+ const handleBlur = useCallback((event) => {
33
+ onBlur?.(toInputCommonEvent(toValueEventDetail(event), 'blur', inputId));
34
+ }, [inputId, onBlur]);
35
+ const handleConfirm = useCallback((event) => {
36
+ onConfirm?.(toInputCommonEvent(toValueEventDetail(event), 'confirm', inputId));
37
+ }, [inputId, onConfirm]);
38
+ const handleSelectionChange = useCallback((event) => {
39
+ onSelectionChange?.(toInputCommonEvent(toSelectionChangeEventDetail(event), 'selectionchange', inputId));
40
+ }, [inputId, onSelectionChange]);
41
+ return (<input {...mapped} ref={assignRef} {...(onInput ? { onInput: handleInput } : {})} {...(onFocus ? { onFocus: handleFocus } : {})} {...(onBlur ? { onBlur: handleBlur } : {})} {...(onConfirm ? { onConfirm: handleConfirm } : {})} {...(onSelectionChange ? { onSelectionChange: handleSelectionChange } : {})}/>);
42
+ }
43
+ function assignForwardedRef(ref, value) {
44
+ if (typeof ref === 'function') {
45
+ ref(value);
46
+ return;
47
+ }
48
+ if (ref) {
49
+ ref.current = value;
50
+ }
4
51
  }
5
52
  //# sourceMappingURL=index.jsx.map
@@ -0,0 +1,50 @@
1
+ import type { InputProps as LynxInputProps } from '@byted-doubao-apps/components';
2
+ import type { InputProps as TaroInputProps } from '@tarojs/components';
3
+ import type { PropMap } from '../types/prop-map.js';
4
+ type LynxInputEvent = Parameters<NonNullable<LynxInputProps['onInput']>>[0];
5
+ type LynxFocusEvent = Parameters<NonNullable<LynxInputProps['onFocus']>>[0];
6
+ type LynxBlurEvent = Parameters<NonNullable<LynxInputProps['onBlur']>>[0];
7
+ type LynxConfirmEvent = Parameters<NonNullable<LynxInputProps['onConfirm']>>[0];
8
+ type LynxSelectionEvent = Parameters<NonNullable<LynxInputProps['onSelectionChange']>>[0];
9
+ export type MappableTaroInputProps = Omit<TaroInputProps, 'onInput' | 'onFocus' | 'onBlur' | 'onConfirm' | 'onSelectionChange'>;
10
+ export type InputCommonEvent<T = unknown> = {
11
+ type: string;
12
+ timeStamp: number;
13
+ target: {
14
+ id: string;
15
+ tagName: string;
16
+ dataset: Record<string, unknown>;
17
+ };
18
+ currentTarget: {
19
+ id: string;
20
+ tagName: string;
21
+ dataset: Record<string, unknown>;
22
+ };
23
+ detail: T;
24
+ preventDefault: () => void;
25
+ stopPropagation: () => void;
26
+ };
27
+ type FocusBehavior = {
28
+ action: 'focus' | 'blur' | null;
29
+ hasAutoFocused: boolean;
30
+ };
31
+ type MapInputPropsResult = {
32
+ mapped: Record<string, unknown>;
33
+ unsupported: string[];
34
+ inputId: string;
35
+ resolvedFocus: boolean | undefined;
36
+ resolvedAutoFocus: boolean | undefined;
37
+ };
38
+ export declare const INPUT_PROP_MAP: PropMap;
39
+ export declare function mapInputProps(props: MappableTaroInputProps): MapInputPropsResult;
40
+ export declare function resolveFocusBehavior(focus: boolean | undefined, autoFocus: boolean | undefined, hasAutoFocused: boolean): FocusBehavior;
41
+ export declare function toInputCommonEvent<T>(detail: T, type: string, inputId: string): InputCommonEvent<T>;
42
+ export declare function toInputEventDetail(event: LynxInputEvent): TaroInputProps.inputEventDetail;
43
+ export declare function toFocusEventDetail(event: LynxFocusEvent): TaroInputProps.inputForceEventDetail;
44
+ export declare function toValueEventDetail(event: LynxBlurEvent | LynxConfirmEvent): TaroInputProps.inputValueEventDetail;
45
+ export declare function toSelectionChangeEventDetail(event: LynxSelectionEvent): {
46
+ selectionStart: number;
47
+ selectionEnd: number;
48
+ };
49
+ export {};
50
+ //# sourceMappingURL=map.d.ts.map
@@ -0,0 +1,226 @@
1
+ import { BASE_PROP_MAP } from '../base/prop-map.js';
2
+ const SUPPORTED_INPUT_TYPES = new Set([
3
+ 'text',
4
+ 'number',
5
+ 'digit',
6
+ 'password',
7
+ 'tel',
8
+ 'email'
9
+ ]);
10
+ export const INPUT_PROP_MAP = {
11
+ value: 'value',
12
+ defaultValue: 'defaultValue',
13
+ placeholder: 'placeholder',
14
+ disabled: 'disabled',
15
+ maxlength: 'maxlength',
16
+ confirmType: 'confirmType',
17
+ placeholderStyle: null,
18
+ placeholderClass: null,
19
+ placeholderTextColor: 'placeholderColor',
20
+ cursorSpacing: null,
21
+ confirmHold: null,
22
+ cursor: null,
23
+ cursorColor: null,
24
+ selectionStart: null,
25
+ selectionEnd: null,
26
+ adjustPosition: null,
27
+ holdKeyboard: null,
28
+ alwaysEmbed: null,
29
+ safePasswordCertPath: null,
30
+ safePasswordLength: null,
31
+ safePasswordTimeStamp: null,
32
+ safePasswordNonce: null,
33
+ safePasswordSalt: null,
34
+ safePasswordCustomHash: null,
35
+ randomNumber: null,
36
+ controlled: null,
37
+ nativeProps: null,
38
+ name: null,
39
+ alwaysSystem: null,
40
+ ariaLabel: null,
41
+ clueType: null,
42
+ onKeyboardHeightChange: null,
43
+ onNickNameReview: null,
44
+ onKeyboardCompositionStart: null,
45
+ onKeyboardCompositionUpdate: null,
46
+ onKeyboardCompositionEnd: null,
47
+ onKeyoardHeightChangeWorklet: null
48
+ };
49
+ export function mapInputProps(props) {
50
+ const { type, password, focus, autoFocus, ...rest } = props;
51
+ const mapped = {};
52
+ const unsupported = [];
53
+ Object.entries(rest).forEach(([key, value]) => {
54
+ if (key === 'placeholderStyle') {
55
+ mapPlaceholderStyle(value, mapped, unsupported);
56
+ return;
57
+ }
58
+ const target = INPUT_PROP_MAP[key] ?? BASE_PROP_MAP[key];
59
+ if (target) {
60
+ mapped[target] = value;
61
+ return;
62
+ }
63
+ unsupported.push(key);
64
+ });
65
+ const resolvedType = resolveInputType(type, password, unsupported);
66
+ if (resolvedType !== undefined) {
67
+ mapped.type = resolvedType;
68
+ }
69
+ const resolvedFocus = resolveBooleanProp(focus, 'focus', unsupported);
70
+ const resolvedAutoFocus = resolveBooleanProp(autoFocus, 'autoFocus', unsupported);
71
+ return {
72
+ mapped,
73
+ unsupported: dedupe(unsupported),
74
+ inputId: resolveInputId(mapped.id),
75
+ resolvedFocus,
76
+ resolvedAutoFocus
77
+ };
78
+ }
79
+ export function resolveFocusBehavior(focus, autoFocus, hasAutoFocused) {
80
+ if (typeof focus === 'boolean') {
81
+ return {
82
+ action: focus ? 'focus' : 'blur',
83
+ hasAutoFocused
84
+ };
85
+ }
86
+ if (!autoFocus || hasAutoFocused) {
87
+ return {
88
+ action: null,
89
+ hasAutoFocused
90
+ };
91
+ }
92
+ return {
93
+ action: 'focus',
94
+ hasAutoFocused: true
95
+ };
96
+ }
97
+ export function toInputCommonEvent(detail, type, inputId) {
98
+ return {
99
+ type,
100
+ timeStamp: Date.now(),
101
+ target: {
102
+ id: inputId,
103
+ tagName: 'input',
104
+ dataset: {}
105
+ },
106
+ currentTarget: {
107
+ id: inputId,
108
+ tagName: 'input',
109
+ dataset: {}
110
+ },
111
+ detail,
112
+ preventDefault: () => { },
113
+ stopPropagation: () => { }
114
+ };
115
+ }
116
+ export function toInputEventDetail(event) {
117
+ return {
118
+ value: event.detail.value,
119
+ cursor: event.detail.selectionEnd,
120
+ keyCode: 0
121
+ };
122
+ }
123
+ export function toFocusEventDetail(event) {
124
+ return {
125
+ value: event.detail.value,
126
+ height: 0
127
+ };
128
+ }
129
+ export function toValueEventDetail(event) {
130
+ return {
131
+ value: event.detail.value
132
+ };
133
+ }
134
+ export function toSelectionChangeEventDetail(event) {
135
+ return {
136
+ selectionStart: event.detail.selectionStart,
137
+ selectionEnd: event.detail.selectionEnd
138
+ };
139
+ }
140
+ function resolveInputType(type, password, unsupported) {
141
+ if (password !== undefined && typeof password !== 'boolean') {
142
+ unsupported.push('password');
143
+ }
144
+ if (password === true) {
145
+ return 'password';
146
+ }
147
+ if (type === undefined) {
148
+ return undefined;
149
+ }
150
+ if (typeof type === 'string' && SUPPORTED_INPUT_TYPES.has(type)) {
151
+ return type;
152
+ }
153
+ unsupported.push('type');
154
+ return 'text';
155
+ }
156
+ function resolveBooleanProp(value, key, unsupported) {
157
+ if (value === undefined) {
158
+ return undefined;
159
+ }
160
+ if (typeof value === 'boolean') {
161
+ return value;
162
+ }
163
+ unsupported.push(key);
164
+ return undefined;
165
+ }
166
+ function resolveInputId(id) {
167
+ if (typeof id === 'string') {
168
+ return id;
169
+ }
170
+ if (typeof id === 'number') {
171
+ return String(id);
172
+ }
173
+ return '';
174
+ }
175
+ function dedupe(values) {
176
+ return [...new Set(values)];
177
+ }
178
+ function mapPlaceholderStyle(placeholderStyle, mapped, unsupported) {
179
+ if (placeholderStyle === undefined) {
180
+ return;
181
+ }
182
+ if (typeof placeholderStyle !== 'string') {
183
+ unsupported.push('placeholderStyle');
184
+ return;
185
+ }
186
+ const declarationMap = parsePlaceholderStyle(placeholderStyle);
187
+ const placeholderFontSize = declarationMap['font-size'];
188
+ const placeholderFontWeight = declarationMap['font-weight'];
189
+ if (placeholderFontSize !== undefined) {
190
+ mapped.placeholderFontSize = placeholderFontSize;
191
+ }
192
+ if (placeholderFontWeight !== undefined) {
193
+ mapped.placeholderFontWeight = placeholderFontWeight;
194
+ }
195
+ if (placeholderFontSize === undefined && placeholderFontWeight === undefined) {
196
+ unsupported.push('placeholderStyle');
197
+ }
198
+ }
199
+ function parsePlaceholderStyle(style) {
200
+ const declarationMap = {};
201
+ style.split(';').forEach((declaration) => {
202
+ const declarationText = declaration.trim();
203
+ if (!declarationText) {
204
+ return;
205
+ }
206
+ const separatorIndex = declarationText.indexOf(':');
207
+ if (separatorIndex <= 0) {
208
+ return;
209
+ }
210
+ const property = normalizeStyleProperty(declarationText.slice(0, separatorIndex));
211
+ const value = declarationText.slice(separatorIndex + 1).trim();
212
+ if ((property === 'font-size' || property === 'font-weight') && value) {
213
+ declarationMap[property] = value;
214
+ }
215
+ });
216
+ return declarationMap;
217
+ }
218
+ function normalizeStyleProperty(property) {
219
+ return property
220
+ .trim()
221
+ .replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)
222
+ .replace(/\s+/g, '')
223
+ .replace(/^-/, '')
224
+ .toLowerCase();
225
+ }
226
+ //# sourceMappingURL=map.js.map
@@ -1,3 +1,4 @@
1
+ import type { MapMarkerProps } from '@byted-doubao-apps/components';
1
2
  import type { MapProps } from '@tarojs/components';
2
3
  export interface NativeRegionChangeDetail {
3
4
  type: 'begin' | 'end';
@@ -31,17 +32,34 @@ export interface NativeMarkerBridgeProps {
31
32
  zIndex: number;
32
33
  };
33
34
  }
35
+ export interface MarkerElementPropsOptions {
36
+ nativeMarker: NativeMarkerBridgeProps;
37
+ onClick?: () => void;
38
+ }
39
+ export interface MarkerTextLayer {
40
+ key: 'callout' | 'label' | 'title';
41
+ content: string;
42
+ style: Record<string, unknown>;
43
+ }
44
+ export interface MarkerTextContent {
45
+ callout?: MarkerTextLayer;
46
+ label?: MarkerTextLayer;
47
+ title?: MarkerTextLayer;
48
+ }
34
49
  export declare function normalizeSetting(setting: MapProps['setting']): Record<string, unknown>;
35
50
  export declare function getNumberSetting(setting: Record<string, unknown>, key: string): number | undefined;
36
51
  export declare function getBooleanSetting(setting: Record<string, unknown>, key: string): boolean | undefined;
37
52
  export declare function resolvePolylines(polylines: MapProps['polyline']): {
38
53
  id: string;
39
54
  points: MapProps.point[];
40
- color: string | undefined;
55
+ edgeColor: string[] | undefined;
56
+ edgeTexture: string[] | undefined;
57
+ edgeTextureAssets: {
58
+ id: string;
59
+ url: string;
60
+ }[] | undefined;
41
61
  width: number | undefined;
42
62
  dottedLine: boolean | undefined;
43
- arrowLine: boolean | undefined;
44
- arrowLineIcon: string | undefined;
45
63
  }[];
46
64
  export declare function resolveCircles(circles: MapProps['circles']): {
47
65
  id: string;
@@ -63,12 +81,22 @@ export declare function resolveNativePolygons(polygons: MapProps.polygon[]): {
63
81
  fillColor: string | undefined;
64
82
  zIndex: number | undefined;
65
83
  }[];
66
- export declare function resolvePadding(padding: NonNullable<MapProps['includePadding']>): number | undefined;
84
+ export declare function resolvePadding(padding: NonNullable<MapProps['includePadding']>): number[] | undefined;
67
85
  export declare function resolveCustomMapStyle(customMapStyle: MapProps['customMapStyle']): "normal-light" | "simple-light" | undefined;
68
86
  export declare function mapRegionChangeDetail(detail: NativeRegionChangeDetail): MapProps.onRegionEventDetail<'begin'> | MapProps.onRegionEventDetail<'end'>;
69
87
  export declare function mapPolylineTapDetail(id: string): MapProps.onPolylineTapEventDetail;
70
88
  export declare function mapMarkerToNativeProps(marker: MapProps.marker, index: number): NativeMarkerBridgeProps;
71
89
  export declare function getMarkerId(marker: MapProps.marker, index: number): number;
90
+ export declare function createMarkerElementProps(options: MarkerElementPropsOptions): MapMarkerProps;
91
+ export declare function hasByClickCallout(marker: MapProps.marker): boolean;
92
+ export declare function hasTapTitle(marker: MapProps.marker): boolean;
93
+ export declare function resolveMarkerIconStyle(marker: MapProps.marker): Record<string, unknown> | undefined;
94
+ export declare function shouldAutoSizeMarkerIcon(marker: MapProps.marker): boolean;
95
+ export declare function resolveMarkerTextContent(marker: MapProps.marker, markerId: string | number, activeCalloutMarkerId?: string | number): MarkerTextContent;
96
+ export declare function composeMarkers(propMarkers: MapProps.marker[], addedMarkers: MapProps.marker[], removedMarkerIds: number[]): MapProps.marker[];
97
+ export declare function mergeMarkersById(base: MapProps.marker[], incoming: MapProps.marker[]): MapProps.marker[];
98
+ export declare function removeMarkersByIds(markers: MapProps.marker[], markerIds: number[]): MapProps.marker[];
99
+ export declare function getNumericMarkerId(marker: MapProps.marker): number | undefined;
72
100
  export declare function mapRegionCausedByEnd(causedBy: 'drag' | 'scale' | 'rotate'): "scale" | "drag" | "update";
73
101
  export declare function toNativeRegionChangeDetail(detail: NativeRegionChangeLike): NativeRegionChangeDetail;
74
102
  export declare function dispatchMarkerTapEvent<T>(handlers: {
@@ -11,15 +11,46 @@ export function getBooleanSetting(setting, key) {
11
11
  return typeof setting[key] === 'boolean' ? setting[key] : undefined;
12
12
  }
13
13
  export function resolvePolylines(polylines) {
14
- return (polylines ?? []).map((item, index) => ({
15
- id: String(getOptionalId(item, index)),
16
- points: item.points,
17
- color: item.color,
18
- width: item.width,
19
- dottedLine: item.dottedLine,
20
- arrowLine: item.arrowLine,
21
- arrowLineIcon: item.arrowIconPath
22
- }));
14
+ return (polylines ?? []).map((item, index) => {
15
+ // Map color list to Doubao edgeColor
16
+ const colorList = item.colorList ??
17
+ item.colors;
18
+ const edgeColor = Array.isArray(colorList)
19
+ ? colorList
20
+ : typeof item.color === 'string'
21
+ ? [item.color]
22
+ : undefined;
23
+ // Map arrow line/icon to Doubao edgeTexture + edgeTextureAssets
24
+ let edgeTexture;
25
+ let edgeTextureAssets;
26
+ const segmentCount = Array.isArray(item.points) ? Math.max(item.points.length - 1, 0) : 0;
27
+ const arrowIconPath = item.arrowIconPath;
28
+ const arrowLine = item.arrowLine;
29
+ if (arrowLine && typeof arrowIconPath === 'string' && segmentCount > 0) {
30
+ // Use a deterministic id per icon path
31
+ const textureId = `arrow_${hashString(arrowIconPath)}`;
32
+ edgeTextureAssets = [{ id: textureId, url: arrowIconPath }];
33
+ edgeTexture = new Array(segmentCount).fill(textureId);
34
+ }
35
+ return {
36
+ id: String(getOptionalId(item, index)),
37
+ points: item.points,
38
+ edgeColor,
39
+ edgeTexture,
40
+ edgeTextureAssets,
41
+ width: item.width,
42
+ dottedLine: item.dottedLine
43
+ };
44
+ });
45
+ }
46
+ function hashString(s) {
47
+ // Simple non-crypto hash for id stability
48
+ let h = 0;
49
+ for (let i = 0; i < s.length; i++) {
50
+ h = (h << 5) - h + s.charCodeAt(i);
51
+ h |= 0; // convert to 32-bit
52
+ }
53
+ return Math.abs(h).toString(36);
23
54
  }
24
55
  export function resolveCircles(circles) {
25
56
  return (circles ?? []).map((item, index) => ({
@@ -46,11 +77,11 @@ export function resolveNativePolygons(polygons) {
46
77
  }));
47
78
  }
48
79
  export function resolvePadding(padding) {
49
- const values = [padding.left, padding.right, padding.top, padding.bottom];
80
+ const values = [padding.top, padding.left, padding.bottom, padding.right];
50
81
  if (values.some((value) => typeof value !== 'number')) {
51
82
  return undefined;
52
83
  }
53
- return values.every((value) => value === values[0]) ? values[0] : undefined;
84
+ return values;
54
85
  }
55
86
  export function resolveCustomMapStyle(customMapStyle) {
56
87
  if (customMapStyle === 'default') {
@@ -111,14 +142,111 @@ export function mapMarkerToNativeProps(marker, index) {
111
142
  longitude: marker.longitude
112
143
  },
113
144
  anchor: marker.anchor ? [marker.anchor.x, marker.anchor.y] : [0.5, 1],
114
- alpha: marker.alpha,
115
- rotation: marker.rotate,
145
+ alpha: marker.alpha ?? 1,
146
+ rotation: marker.rotate ?? 0,
116
147
  zIndexStyle: marker.zIndex === undefined ? undefined : { zIndex: marker.zIndex }
117
148
  };
118
149
  }
119
150
  export function getMarkerId(marker, index) {
120
151
  return marker.id ?? index;
121
152
  }
153
+ export function createMarkerElementProps(options) {
154
+ const props = {
155
+ position: options.nativeMarker.position,
156
+ anchor: options.nativeMarker.anchor,
157
+ alpha: options.nativeMarker.alpha,
158
+ rotation: options.nativeMarker.rotation,
159
+ clickable: true,
160
+ children: null,
161
+ draggable: false
162
+ };
163
+ if (options.nativeMarker.zIndexStyle !== undefined) {
164
+ props.style = options.nativeMarker.zIndexStyle;
165
+ }
166
+ if (options.onClick !== undefined) {
167
+ props.onClick = options.onClick;
168
+ }
169
+ return props;
170
+ }
171
+ export function hasByClickCallout(marker) {
172
+ return (Boolean(marker.callout?.content) &&
173
+ marker.customCallout === undefined &&
174
+ marker.callout?.display !== 'ALWAYS');
175
+ }
176
+ export function hasTapTitle(marker) {
177
+ return marker.customCallout === undefined && !hasText(marker.callout?.content) && hasText(marker.title);
178
+ }
179
+ export function resolveMarkerIconStyle(marker) {
180
+ const style = {};
181
+ if (marker.width !== undefined) {
182
+ style.width = normalizeStyleSize(marker.width);
183
+ }
184
+ if (marker.height !== undefined) {
185
+ style.height = normalizeStyleSize(marker.height);
186
+ }
187
+ return Object.keys(style).length > 0 ? style : undefined;
188
+ }
189
+ export function shouldAutoSizeMarkerIcon(marker) {
190
+ return marker.width === undefined || marker.height === undefined;
191
+ }
192
+ export function resolveMarkerTextContent(marker, markerId, activeCalloutMarkerId) {
193
+ const hasCustomCallout = marker.customCallout !== undefined;
194
+ const calloutLayer = resolveCalloutLayer(marker, markerId, activeCalloutMarkerId);
195
+ const labelLayer = resolveLabelLayer(marker);
196
+ const hasCalloutContent = hasText(marker.callout?.content) && !hasCustomCallout;
197
+ const textContent = {};
198
+ if (calloutLayer) {
199
+ textContent.callout = calloutLayer;
200
+ }
201
+ if (labelLayer) {
202
+ textContent.label = labelLayer;
203
+ }
204
+ if (!hasCalloutContent &&
205
+ !hasCustomCallout &&
206
+ hasText(marker.title) &&
207
+ activeCalloutMarkerId === markerId) {
208
+ textContent.title = {
209
+ key: 'title',
210
+ content: marker.title,
211
+ style: createTextStyle({ marginBottom: 4 })
212
+ };
213
+ }
214
+ return textContent;
215
+ }
216
+ export function composeMarkers(propMarkers, addedMarkers, removedMarkerIds) {
217
+ const visiblePropMarkers = removeMarkersByIds(propMarkers, removedMarkerIds);
218
+ return mergeMarkersById(visiblePropMarkers, addedMarkers);
219
+ }
220
+ export function mergeMarkersById(base, incoming) {
221
+ const next = [...base];
222
+ incoming.forEach((marker) => {
223
+ const markerId = getNumericMarkerId(marker);
224
+ if (markerId === undefined) {
225
+ next.push(marker);
226
+ return;
227
+ }
228
+ const existingIndex = next.findIndex((item) => getNumericMarkerId(item) === markerId);
229
+ if (existingIndex === -1) {
230
+ next.push(marker);
231
+ return;
232
+ }
233
+ next[existingIndex] = marker;
234
+ });
235
+ return next;
236
+ }
237
+ export function removeMarkersByIds(markers, markerIds) {
238
+ if (markerIds.length === 0) {
239
+ return markers;
240
+ }
241
+ const markerIdSet = new Set(markerIds);
242
+ return markers.filter((marker) => {
243
+ const markerId = getNumericMarkerId(marker);
244
+ return markerId === undefined || !markerIdSet.has(markerId);
245
+ });
246
+ }
247
+ export function getNumericMarkerId(marker) {
248
+ return typeof marker.id === 'number' ? marker.id : undefined;
249
+ }
122
250
  export function mapRegionCausedByEnd(causedBy) {
123
251
  if (causedBy === 'drag' || causedBy === 'scale') {
124
252
  return causedBy;
@@ -154,4 +282,87 @@ export function getOptionalId(value, fallback) {
154
282
  const candidate = value.id;
155
283
  return candidate ?? fallback;
156
284
  }
285
+ function resolveCalloutLayer(marker, markerId, activeCalloutMarkerId) {
286
+ if (marker.customCallout !== undefined) {
287
+ return undefined;
288
+ }
289
+ const callout = marker.callout;
290
+ if (!hasText(callout?.content)) {
291
+ return undefined;
292
+ }
293
+ const calloutDisplay = callout.display ?? 'BYCLICK';
294
+ if (calloutDisplay !== 'ALWAYS' && activeCalloutMarkerId !== markerId) {
295
+ return undefined;
296
+ }
297
+ return {
298
+ key: 'callout',
299
+ content: callout.content,
300
+ style: createTextStyle({
301
+ marginBottom: 4,
302
+ padding: callout.padding ?? 6,
303
+ color: callout.color ?? '#222222',
304
+ backgroundColor: callout.bgColor ?? '#ffffff',
305
+ borderRadius: callout.borderRadius ?? 8,
306
+ borderWidth: callout.borderWidth ?? 0,
307
+ borderColor: callout.borderColor ?? 'transparent',
308
+ fontSize: callout.fontSize ?? 12,
309
+ textAlign: callout.textAlign ?? 'center',
310
+ offsetX: callout.anchorX,
311
+ offsetY: callout.anchorY
312
+ })
313
+ };
314
+ }
315
+ function resolveLabelLayer(marker) {
316
+ const label = marker.label;
317
+ if (!hasText(label?.content)) {
318
+ return undefined;
319
+ }
320
+ return {
321
+ key: 'label',
322
+ content: label.content,
323
+ style: createTextStyle({
324
+ marginBottom: 4,
325
+ padding: label.padding ?? 6,
326
+ color: label.color ?? '#222222',
327
+ backgroundColor: label.bgColor ?? '#ffffff',
328
+ borderRadius: label.borderRadius ?? 8,
329
+ borderWidth: label.borderWidth ?? 0,
330
+ borderColor: label.borderColor ?? 'transparent',
331
+ fontSize: label.fontSize ?? 12,
332
+ textAlign: label.textAlign ?? 'center',
333
+ offsetX: label.anchorX,
334
+ offsetY: label.anchorY
335
+ })
336
+ };
337
+ }
338
+ function createTextStyle(options) {
339
+ const style = {
340
+ marginBottom: normalizeStyleSize(options.marginBottom ?? 0),
341
+ padding: normalizeStyleSize(options.padding ?? 0),
342
+ color: options.color ?? '#222222',
343
+ backgroundColor: options.backgroundColor ?? 'transparent',
344
+ borderRadius: normalizeStyleSize(options.borderRadius ?? 0),
345
+ borderWidth: normalizeStyleSize(options.borderWidth ?? 0),
346
+ borderColor: options.borderColor ?? 'transparent',
347
+ fontSize: normalizeStyleSize(options.fontSize ?? 12),
348
+ textAlign: options.textAlign ?? 'center',
349
+ maxWidth: normalizeStyleSize(240)
350
+ };
351
+ if (typeof options.offsetX === 'number' || typeof options.offsetY === 'number') {
352
+ style.position = 'relative';
353
+ }
354
+ if (typeof options.offsetX === 'number') {
355
+ style.left = normalizeStyleSize(options.offsetX);
356
+ }
357
+ if (typeof options.offsetY === 'number') {
358
+ style.top = normalizeStyleSize(options.offsetY);
359
+ }
360
+ return style;
361
+ }
362
+ function hasText(value) {
363
+ return typeof value === 'string' && value.length > 0;
364
+ }
365
+ function normalizeStyleSize(value) {
366
+ return typeof value === 'number' ? `${value}px` : value;
367
+ }
157
368
  //# sourceMappingURL=bridge.js.map