Files
openclaw/extensions/line/runtime-api.ts
Drickon 715b13547f fix(line): pre-export clashing symbols to prevent jiti TypeError on startup (#53221)
* fix(line): pre-export clashing symbols to prevent jiti TypeError on startup

When jiti CJS-transforms extensions/line/runtime-api.ts, both
export * from "openclaw/plugin-sdk/line-runtime" and the subsequent
export * from individual source files attempt to define the same 13
symbols via Object.defineProperty with configurable:false. The second
call throws TypeError: Cannot redefine property.

The root cause is that src/plugin-sdk/line-runtime.ts re-exports
these symbols directly from the extension source files, creating a
circular path back to the same files that runtime-api.ts star-exports.

Fix: add named pre-exports for all symbols that plugin-sdk/line-runtime
re-exports from this extension. Named exports register in jiti's
_exportNames map at transform time; the star re-export's hasOwnProperty
guard then skips them, preventing the duplicate Object.defineProperty.

export * reordering cannot fix this: _exportNames is only populated
by named exports, not by export *, so the guard never fires regardless
of order.

This is the same class of bug as the Matrix plugin crash described in
issues #50868, #52780, and #52891, and uses the same fix pattern as
PR #50919.

* test: add LINE runtime-api Jiti regression (#53221) (thanks @Drickon)

* test: stabilize LINE Jiti regression (#53221) (thanks @Drickon)

* test: harden LINE Jiti regression (#53221) (thanks @Drickon)

* chore: retrigger PR checks (#53221)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-03-23 19:13:25 -07:00

132 lines
4.0 KiB
TypeScript

// Private runtime barrel for the bundled LINE extension.
// Keep this barrel thin and aligned with the local extension surface.
export type {
ChannelPlugin,
OpenClawConfig,
OpenClawPluginApi,
PluginRuntime,
} from "openclaw/plugin-sdk/core";
export { clearAccountEntryFields } from "openclaw/plugin-sdk/core";
export { buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-schema";
export type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime";
export type { ChannelAccountSnapshot, ChannelGatewayContext } from "openclaw/plugin-sdk/testing";
export type { ChannelStatusIssue } from "openclaw/plugin-sdk/channel-contract";
export type { ChannelSetupDmPolicy, ChannelSetupWizard } from "openclaw/plugin-sdk/setup";
export {
buildComputedAccountStatusSnapshot,
buildTokenChannelStatusSummary,
} from "openclaw/plugin-sdk/status-helpers";
export {
DEFAULT_ACCOUNT_ID,
formatDocsLink,
setSetupChannelEnabled,
splitSetupEntries,
} from "openclaw/plugin-sdk/setup";
// Pre-export all symbols that src/plugin-sdk/line-runtime.ts re-exports from this
// extension's source files. These named exports register the symbols in jiti's
// _exportNames map at transform time. The star re-export below then skips them
// via the hasOwnProperty guard, preventing a second Object.defineProperty call
// with configurable:false that would throw TypeError: Cannot redefine property.
//
// If src/plugin-sdk/line-runtime.ts gains new re-exports from extension source
// files, add matching named exports here to keep the two files in sync.
// See: src/plugin-sdk/line-runtime.ts for the authoritative list.
export {
firstDefined,
isSenderAllowed,
normalizeAllowFrom,
normalizeDmAllowFromWithStore,
} from "./src/bot-access.js";
export { downloadLineMedia } from "./src/download.js";
export { probeLineBot } from "./src/probe.js";
export { buildTemplateMessageFromPayload } from "./src/template-messages.js";
export {
createQuickReplyItems,
pushFlexMessage,
pushLocationMessage,
pushMessageLine,
pushMessagesLine,
pushTemplateMessage,
pushTextMessageWithQuickReplies,
sendMessageLine,
} from "./src/send.js";
export * from "openclaw/plugin-sdk/line-runtime";
export * from "./src/accounts.js";
export * from "./src/bot-access.js";
export * from "./src/channel-access-token.js";
export * from "./src/config-schema.js";
export * from "./src/download.js";
export * from "./src/group-keys.js";
export * from "./src/markdown-to-line.js";
export * from "./src/probe.js";
export * from "./src/send.js";
export * from "./src/signature.js";
export * from "./src/template-messages.js";
export type {
LineChannelData,
LineConfig,
LineProbeResult,
ResolvedLineAccount,
} from "./src/types.js";
export * from "./src/webhook-node.js";
export * from "./src/webhook.js";
export * from "./src/webhook-utils.js";
export { datetimePickerAction, messageAction, postbackAction, uriAction } from "./src/actions.js";
export type { Action } from "./src/actions.js";
export {
createActionCard,
createAgendaCard,
createAppleTvRemoteCard,
createCarousel,
createDeviceControlCard,
createEventCard,
createImageCard,
createInfoCard,
createListCard,
createMediaPlayerCard,
createNotificationBubble,
createReceiptCard,
toFlexMessage,
} from "./src/flex-templates.js";
export type {
CardAction,
FlexBox,
FlexBubble,
FlexButton,
FlexCarousel,
FlexComponent,
FlexContainer,
FlexImage,
FlexText,
ListItem,
} from "./src/flex-templates.js";
export {
cancelDefaultRichMenu,
createDefaultMenuConfig,
createGridLayout,
createRichMenu,
createRichMenuAlias,
deleteRichMenu,
deleteRichMenuAlias,
getDefaultRichMenuId,
getRichMenu,
getRichMenuIdOfUser,
getRichMenuList,
linkRichMenuToUser,
linkRichMenuToUsers,
setDefaultRichMenu,
unlinkRichMenuFromUser,
unlinkRichMenuFromUsers,
uploadRichMenuImage,
} from "./src/rich-menu.js";
export type {
CreateRichMenuParams,
RichMenuArea,
RichMenuAreaRequest,
RichMenuRequest,
RichMenuResponse,
RichMenuSize,
} from "./src/rich-menu.js";