@doubao-apps/taro-runtime 0.0.19 → 0.0.20

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.
@@ -1,8 +1,8 @@
1
1
  export { getEnv, ENV_TYPE } from './base/index.js';
2
2
  export { request } from './request/index.js';
3
- export { navigateBack, navigateTo, redirectTo } from './router/index.js';
3
+ export { exitMiniProgram, navigateBack, navigateTo, reLaunch, redirectTo } from './router/index.js';
4
4
  export { setStorage, setStorageSync, getStorage, getStorageSync, removeStorage, removeStorageSync, clearStorage, clearStorageSync, getStorageInfo, getStorageInfoSync } from './storage/index.js';
5
- export { getSystemSetting, getAppAuthorizeSetting, getDeviceInfo, getAppBaseInfo, getWindowInfo, makePhoneCall, getNetworkType } from './system/index.js';
5
+ export { getSystemSetting, getAppAuthorizeSetting, getDeviceInfo, getAppBaseInfo, getWindowInfo, makePhoneCall, getNetworkType, onKeyboardHeightChange } from './system/index.js';
6
6
  export { getLocation } from './location/index.js';
7
7
  export { showToast } from './show-toast/index.js';
8
8
  export { createMapContext } from './map/index.js';
package/dist/api/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  export { getEnv, ENV_TYPE } from './base/index.js';
2
2
  export { request } from './request/index.js';
3
- export { navigateBack, navigateTo, redirectTo } from './router/index.js';
3
+ export { exitMiniProgram, navigateBack, navigateTo, reLaunch, redirectTo } from './router/index.js';
4
4
  export { setStorage, setStorageSync, getStorage, getStorageSync, removeStorage, removeStorageSync, clearStorage, clearStorageSync, getStorageInfo, getStorageInfoSync } from './storage/index.js';
5
- export { getSystemSetting, getAppAuthorizeSetting, getDeviceInfo, getAppBaseInfo, getWindowInfo, makePhoneCall, getNetworkType } from './system/index.js';
5
+ export { getSystemSetting, getAppAuthorizeSetting, getDeviceInfo, getAppBaseInfo, getWindowInfo, makePhoneCall, getNetworkType, onKeyboardHeightChange } from './system/index.js';
6
6
  export { getLocation } from './location/index.js';
7
7
  export { showToast } from './show-toast/index.js';
8
8
  export { createMapContext } from './map/index.js';
@@ -0,0 +1,3 @@
1
+ import type { exitMiniProgram as taroExitMiniProgram } from '@tarojs/taro';
2
+ export declare function exitMiniProgram(option?: Parameters<typeof taroExitMiniProgram>[0]): Promise<TaroGeneral.CallbackResult>;
3
+ //# sourceMappingURL=exit-mini-program.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { exitApp } from '@byted-doubao-apps/framework/api';
2
+ import { runCallbackApi } from '../utils.js';
3
+ export async function exitMiniProgram(option) {
4
+ return runCallbackApi('exitMiniProgram', option, () => exitApp());
5
+ }
6
+ //# sourceMappingURL=exit-mini-program.js.map
@@ -1,4 +1,6 @@
1
+ export { exitMiniProgram } from './exit-mini-program.js';
1
2
  export { navigateBack } from './navigate-back.js';
2
3
  export { navigateTo } from './navigate-to.js';
4
+ export { reLaunch } from './re-launch.js';
3
5
  export { redirectTo } from './redirect-to.js';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,6 @@
1
+ export { exitMiniProgram } from './exit-mini-program.js';
1
2
  export { navigateBack } from './navigate-back.js';
2
3
  export { navigateTo } from './navigate-to.js';
4
+ export { reLaunch } from './re-launch.js';
3
5
  export { redirectTo } from './redirect-to.js';
4
6
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ import type { reLaunch as taroReLaunch } from '@tarojs/taro';
2
+ export declare function reLaunch(params: Parameters<typeof taroReLaunch>[0]): Promise<TaroGeneral.CallbackResult>;
3
+ //# sourceMappingURL=re-launch.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { reLaunch as appReLaunch } from '@byted-doubao-apps/framework/api';
2
+ import { runCallbackApi } from '../utils.js';
3
+ export async function reLaunch(params) {
4
+ return runCallbackApi('reLaunch', params, () => appReLaunch({
5
+ url: params.url
6
+ }));
7
+ }
8
+ //# sourceMappingURL=re-launch.js.map
@@ -7,6 +7,9 @@ type TaroGetNetworkTypeOption = Parameters<typeof taroGetNetworkType>[0];
7
7
  type TaroGetNetworkTypeResult = Awaited<ReturnType<typeof taroGetNetworkType>>;
8
8
  type TaroGetScreenBrightnessOption = Parameters<typeof taroGetScreenBrightness>[0];
9
9
  type TaroGetScreenBrightnessResult = Awaited<ReturnType<typeof taroGetScreenBrightness>>;
10
+ type TaroSetClipboardDataOption = Parameters<typeof Taro.setClipboardData>[0];
11
+ type TaroSetClipboardDataResult = Awaited<ReturnType<typeof Taro.setClipboardData>>;
12
+ type KeyboardHeightChangeCallback = Parameters<typeof Taro.onKeyboardHeightChange>[0];
10
13
  export declare function getSystemSetting(): Taro.getSystemSetting.Result;
11
14
  export declare function getAppAuthorizeSetting(): Taro.getAppAuthorizeSetting.Result;
12
15
  export declare function getDeviceInfo(): Taro.getDeviceInfo.Result;
@@ -15,5 +18,7 @@ export declare function getWindowInfo(): Taro.getWindowInfo.Result;
15
18
  export declare function makePhoneCall(option: TaroMakePhoneCallOption): Promise<TaroMakePhoneCallResult>;
16
19
  export declare function getNetworkType(option?: TaroGetNetworkTypeOption): Promise<TaroGetNetworkTypeResult>;
17
20
  export declare function getScreenBrightness(option?: TaroGetScreenBrightnessOption): Promise<TaroGetScreenBrightnessResult>;
21
+ export declare function setClipboardData(option: TaroSetClipboardDataOption): Promise<TaroSetClipboardDataResult>;
22
+ export declare function onKeyboardHeightChange(callback: KeyboardHeightChangeCallback): void;
18
23
  export {};
19
24
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- import { getAppBaseInfoSync, getWindowInfoSync, makePhoneCall as appMakePhoneCall, getNetworkType as appGetNetworkType, getScreenBrightness as appGetScreenBrightness } from '@byted-doubao-apps/framework/api';
1
+ import { getAppBaseInfoSync, getWindowInfoSync, makePhoneCall as appMakePhoneCall, getNetworkType as appGetNetworkType, getScreenBrightness as appGetScreenBrightness, setClipboardData as appSetClipboardData, onKeyboardHeightChange as appOnKeyboardHeightChange } from '@byted-doubao-apps/framework/api';
2
2
  import { buildFailCallbackResult, emitFailure, runCallbackApi, runTaroApi } from '../utils.js';
3
3
  export function getSystemSetting() {
4
4
  return {};
@@ -71,4 +71,29 @@ export async function getScreenBrightness(option = {}) {
71
71
  };
72
72
  });
73
73
  }
74
+ export async function setClipboardData(option) {
75
+ const { data } = option;
76
+ if (typeof data !== 'string') {
77
+ const result = buildFailCallbackResult('setClipboardData', 'parameter error: parameter.data should be String');
78
+ emitFailure(option, result);
79
+ return Promise.reject(result);
80
+ }
81
+ if (data.length === 0) {
82
+ const result = buildFailCallbackResult('setClipboardData', 'parameter error: data is empty');
83
+ emitFailure(option, result);
84
+ return Promise.reject(result);
85
+ }
86
+ const params = { data };
87
+ return runCallbackApi('setClipboardData', option, () => appSetClipboardData(params));
88
+ }
89
+ export function onKeyboardHeightChange(callback) {
90
+ if (typeof callback !== 'function') {
91
+ return;
92
+ }
93
+ appOnKeyboardHeightChange(({ height }) => {
94
+ callback({
95
+ height
96
+ });
97
+ });
98
+ }
74
99
  //# sourceMappingURL=index.js.map
@@ -135,13 +135,18 @@ export function mapPolylineTapDetail(id) {
135
135
  };
136
136
  }
137
137
  export function mapMarkerToNativeProps(marker, index) {
138
+ const resolvedAnchor = marker.anchor
139
+ ? [marker.anchor.x, marker.anchor.y]
140
+ : marker.label
141
+ ? [0, 0]
142
+ : [0.5, 1];
138
143
  return {
139
144
  markerId: getMarkerId(marker, index),
140
145
  position: {
141
146
  latitude: marker.latitude,
142
147
  longitude: marker.longitude
143
148
  },
144
- anchor: marker.anchor ? [marker.anchor.x, marker.anchor.y] : [0.5, 1],
149
+ anchor: resolvedAnchor,
145
150
  alpha: marker.alpha ?? 1,
146
151
  rotation: marker.rotate ?? 0,
147
152
  zIndexStyle: marker.zIndex === undefined ? undefined : { zIndex: marker.zIndex }
@@ -208,7 +213,7 @@ export function resolveMarkerTextContent(marker, markerId, activeCalloutMarkerId
208
213
  textContent.title = {
209
214
  key: 'title',
210
215
  content: marker.title,
211
- style: createTextStyle({ marginBottom: 4 })
216
+ style: createTextStyle({})
212
217
  };
213
218
  }
214
219
  return textContent;
@@ -298,7 +303,6 @@ function resolveCalloutLayer(marker, markerId, activeCalloutMarkerId) {
298
303
  key: 'callout',
299
304
  content: callout.content,
300
305
  style: createTextStyle({
301
- marginBottom: 4,
302
306
  padding: callout.padding ?? 6,
303
307
  color: callout.color ?? '#222222',
304
308
  backgroundColor: callout.bgColor ?? '#ffffff',
@@ -321,7 +325,6 @@ function resolveLabelLayer(marker) {
321
325
  key: 'label',
322
326
  content: label.content,
323
327
  style: createTextStyle({
324
- marginBottom: 4,
325
328
  padding: label.padding ?? 6,
326
329
  color: label.color ?? '#222222',
327
330
  backgroundColor: label.bgColor ?? '#ffffff',
@@ -337,25 +340,44 @@ function resolveLabelLayer(marker) {
337
340
  }
338
341
  function createTextStyle(options) {
339
342
  const style = {
340
- marginBottom: normalizeStyleSize(options.marginBottom ?? 0),
341
- padding: normalizeStyleSize(options.padding ?? 0),
342
343
  color: options.color ?? '#222222',
343
344
  backgroundColor: options.backgroundColor ?? 'transparent',
344
- borderRadius: normalizeStyleSize(options.borderRadius ?? 0),
345
- borderWidth: normalizeStyleSize(options.borderWidth ?? 0),
346
345
  borderColor: options.borderColor ?? 'transparent',
347
- fontSize: normalizeStyleSize(options.fontSize ?? 12),
348
346
  textAlign: options.textAlign ?? 'center',
349
347
  maxWidth: normalizeStyleSize(240)
350
348
  };
351
- if (typeof options.offsetX === 'number' || typeof options.offsetY === 'number') {
352
- style.position = 'relative';
349
+ if (options.padding != null) {
350
+ style.padding = normalizeStyleSize(options.padding);
353
351
  }
352
+ if (options.borderRadius != null) {
353
+ style.borderRadius = normalizeStyleSize(options.borderRadius);
354
+ }
355
+ if (options.borderWidth != null) {
356
+ style.borderWidth = normalizeStyleSize(options.borderWidth);
357
+ }
358
+ if (options.fontSize != null) {
359
+ style.fontSize = normalizeStyleSize(options.fontSize);
360
+ }
361
+ // Use margins for offsets to avoid breaking centering
354
362
  if (typeof options.offsetX === 'number') {
355
- style.left = normalizeStyleSize(options.offsetX);
363
+ const offsetX = options.offsetX > 0 ? options.offsetX : -options.offsetX;
364
+ const size = normalizeStyleSize(offsetX);
365
+ if (options.offsetX > 0) {
366
+ style.marginLeft = size;
367
+ }
368
+ else {
369
+ style.marginRight = size;
370
+ }
356
371
  }
357
372
  if (typeof options.offsetY === 'number') {
358
- style.top = normalizeStyleSize(options.offsetY);
373
+ const offsetY = options.offsetY > 0 ? options.offsetY : -options.offsetY;
374
+ const size = normalizeStyleSize(offsetY);
375
+ if (options.offsetY > 0) {
376
+ style.marginTop = size;
377
+ }
378
+ else {
379
+ style.marginBottom = size;
380
+ }
359
381
  }
360
382
  return style;
361
383
  }
@@ -1,3 +1,4 @@
1
1
  import type { MapProps } from '@tarojs/components';
2
- export declare function Map(props: MapProps): any;
2
+ declare function DoubaoAppsMap(props: MapProps): any;
3
+ export { DoubaoAppsMap as Map };
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -4,10 +4,11 @@ import { Image } from '../Image/index.jsx';
4
4
  import { warnUnsupported } from '../base/warn-unsupported.js';
5
5
  import { composeMarkers, createMarkerElementProps, dispatchMarkerTapEvent, getNumericMarkerId, hasByClickCallout, hasTapTitle, mapMarkerToNativeProps, mergeMarkersById, removeMarkersByIds, resolveMarkerIconStyle, resolveMarkerTextContent, shouldAutoSizeMarkerIcon, resolvePadding } from './bridge.js';
6
6
  import { collectMapUnsupportedWarnings, createMapElementProps, resolveMapValues, toCommonEvent } from './mapping.js';
7
- export function Map(props) {
7
+ function DoubaoAppsMap(props) {
8
8
  const { id, className, style, hidden, animation, children, onTouchStart, onTouchMove, onTouchCancel, onTouchEnd, onClick: onBaseClick, onLongPress, onLongClick, onTransitionEnd, onAnimationStart, onAnimationIteration, onAnimationEnd, longitude, latitude, scale, minScale, maxScale, markers, covers, polyline, circles, controls, includePoints, showLocation, polygons, subkey, layerStyle, rotate, skew, showCompass, showScale, enableOverlooking, enableZoom, enableScroll, enableRotate, enableSatellite, enableTraffic, setting, includePadding, groundOverlays, tileOverlay, enablePoi, enableBuilding, polygon, customMapStyle, panels, theme, optimize, enableAutoMaxOverlooking, enable3D, onTap, onMarkerTap, onLabelTap, onControlTap, onCalloutTap, onUpdated, onRegionChange, onPoiTap, onPolylineTap, onAbilitySuccess, onAbilityFailed, onAuthSuccess, onInterpolatePoint, onError, onCallOutTap, onAnchorPointTap, onPanelTap, onInitComplete, ...rest } = props;
9
9
  const mapRef = useRef(null);
10
10
  const mapControllerRef = useRef(null);
11
+ const markerRefsRef = useRef(new Map());
11
12
  const [activeCalloutMarkerId, setActiveCalloutMarkerId] = useState(undefined);
12
13
  const [imperativeAddedMarkers, setImperativeAddedMarkers] = useState([]);
13
14
  const [imperativeRemovedMarkerIds, setImperativeRemovedMarkerIds] = useState([]);
@@ -168,26 +169,69 @@ export function Map(props) {
168
169
  nativeMarker,
169
170
  onClick: handleMarkerClick
170
171
  });
171
- const markerContent = marker.children !== undefined
172
+ const handleMarkerLayout = () => {
173
+ const ref = markerRefsRef.current.get(markerId);
174
+ ref?.refreshMarker?.();
175
+ };
176
+ const markerContent = marker.children != null
172
177
  ? marker.children
173
- : renderDefaultMarkerContent(marker, markerId, activeCalloutMarkerId);
178
+ : renderDefaultMarkerContent(marker, markerId, activeCalloutMarkerId, handleMarkerLayout);
179
+ const markerElementPropsWithRef = {
180
+ ...markerElementProps,
181
+ ref: (node) => {
182
+ if (node) {
183
+ markerRefsRef.current.set(markerId, node);
184
+ }
185
+ else {
186
+ markerRefsRef.current.delete(markerId);
187
+ }
188
+ }
189
+ };
174
190
  return (
175
191
  // biome-ignore lint: key is not sure
176
- <map-marker {...markerElementProps}>{markerContent}</map-marker>);
192
+ <map-marker {...markerElementPropsWithRef}>{markerContent}</map-marker>);
177
193
  })}
178
194
  {children}
179
195
  </map>);
180
196
  }
181
- function renderDefaultMarkerContent(marker, markerId, activeCalloutMarkerId) {
197
+ function renderDefaultMarkerContent(marker, markerId, activeCalloutMarkerId, onLayout) {
182
198
  const textContent = resolveMarkerTextContent(marker, markerId, activeCalloutMarkerId);
183
199
  const iconStyle = resolveMarkerIconStyle(marker);
184
200
  const shouldAutoSizeIcon = shouldAutoSizeMarkerIcon(marker);
185
- return (<view style={{
201
+ return (<view flatten={false} bindlayoutchange={onLayout} style={{
186
202
  display: 'flex',
187
203
  flexDirection: 'column',
188
204
  alignItems: 'center'
189
205
  }}>
190
- {textContent.callout ? (<text style={textContent.callout.style}>{textContent.callout.content}</text>) : null}
206
+ {textContent.callout ? (<view flatten={false} style={{
207
+ ...(textContent.callout.style || {}),
208
+ position: textContent.callout.style?.position !== undefined
209
+ ? textContent.callout.style.position
210
+ : 'relative',
211
+ display: 'flex',
212
+ flexDirection: 'column',
213
+ alignItems: 'center',
214
+ overflow: 'visible',
215
+ paddingBottom: '4px'
216
+ }}>
217
+ <text style={{
218
+ color: textContent.callout.style?.color,
219
+ fontSize: textContent.callout.style?.fontSize,
220
+ textAlign: textContent.callout.style?.textAlign
221
+ }}>
222
+ {textContent.callout.content}
223
+ </text>
224
+ <view flatten={false} user-interaction-enabled={false} style={{
225
+ position: 'absolute',
226
+ left: '50%',
227
+ marginLeft: '-3px',
228
+ bottom: '-3px',
229
+ width: '6px',
230
+ height: '6px',
231
+ backgroundColor: textContent.callout.style?.backgroundColor ?? '#ffffff',
232
+ transform: 'rotate(45deg)'
233
+ }}/>
234
+ </view>) : null}
191
235
  {textContent.label ? <text style={textContent.label.style}>{textContent.label.content}</text> : null}
192
236
  {textContent.title ? <text style={textContent.title.style}>{textContent.title.content}</text> : null}
193
237
  <Image src={marker.iconPath} style={iconStyle} autoSize={shouldAutoSizeIcon}/>
@@ -238,4 +282,5 @@ function getMapInstance(mapRef) {
238
282
  }
239
283
  return mapRef.current;
240
284
  }
285
+ export { DoubaoAppsMap as Map };
241
286
  //# sourceMappingURL=index.jsx.map
@@ -56,7 +56,9 @@ export function resolveMapValues(values) {
56
56
  resolvedScale: values.scale ?? getNumberSetting(resolvedSetting, 'scale') ?? 16,
57
57
  resolvedMinScale: values.minScale ?? getNumberSetting(resolvedSetting, 'minScale') ?? 3,
58
58
  resolvedMaxScale: values.maxScale ?? getNumberSetting(resolvedSetting, 'maxScale') ?? 20,
59
- resolvedRotate: values.rotate ?? getNumberSetting(resolvedSetting, 'rotate') ?? 0,
59
+ // Taro(vx) rotate is clockwise; Doubao Map expects counterclockwise.
60
+ // Keep range in [0, 360): convert by (360 - angle) % 360 instead of negation.
61
+ resolvedRotate: (360 - (Number(values.rotate ?? getNumberSetting(resolvedSetting, 'rotate') ?? 0) % 360)) % 360,
60
62
  resolvedShowScale: values.showScale ?? getBooleanSetting(resolvedSetting, 'showScale') ?? false,
61
63
  resolvedEnableTilt: values.enableOverlooking ?? getBooleanSetting(resolvedSetting, 'enableOverlooking') ?? false,
62
64
  resolvedEnableScale: values.enableZoom ?? getBooleanSetting(resolvedSetting, 'enableZoom') ?? true,
package/package.json CHANGED
@@ -37,7 +37,7 @@
37
37
  "access": "public",
38
38
  "registry": "https://registry.npmjs.org/"
39
39
  },
40
- "version": "0.0.19",
40
+ "version": "0.0.20",
41
41
  "scripts": {
42
42
  "dev": "npm run build -- -w",
43
43
  "build": "rimraf dist bundle && tsc -p tsconfig.build.json",