@sigx/lynx-markdown 0.4.1

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/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @sigx/lynx-markdown
2
+
3
+ Typed SignalX wrapper around Lynx's `<x-markdown>` XElement.
4
+
5
+ ## Status
6
+
7
+ **Pre-release** — the wrapper compiles and types cleanly today, but the
8
+ underlying native element ships per-platform on different schedules:
9
+
10
+ | Platform | First version | Notes |
11
+ | -------- | -------------- | ---------------------------------------------- |
12
+ | Harmony | Lynx 3.7.0 | Stable. |
13
+ | Android | Lynx 3.8.0-rc.0 | Ships as `org.lynxsdk.lynx:lynx_xelement_markdown`. |
14
+ | iOS | (post-3.8.0) | Currently only on the upstream `main` branch. |
15
+
16
+ On platforms where `<x-markdown>` is not yet registered, the component
17
+ renders nothing at runtime. This package exists so that app code can
18
+ already adopt the typed API surface — once you bump SignalX's Lynx pins
19
+ to a release that includes the native element on your target platforms,
20
+ it starts rendering without code changes.
21
+
22
+ When the iOS/Android pods land in stable, this README will be updated
23
+ with the matching native dependency wiring (Podfile + gradle).
24
+
25
+ ## Install
26
+
27
+ ```
28
+ pnpm add @sigx/lynx-markdown
29
+ ```
30
+
31
+ ## Use
32
+
33
+ ```tsx
34
+ import { Markdown } from '@sigx/lynx-markdown';
35
+
36
+ export default function ArticleScreen() {
37
+ return (
38
+ <Markdown
39
+ value={"# Hello\n\nThis is **markdown**."}
40
+ effect="typewriter"
41
+ onLink={(e) => console.log('tapped', e.detail.url)}
42
+ onParseEnd={() => console.log('parsed')}
43
+ />
44
+ );
45
+ }
46
+ ```
47
+
48
+ ## Props
49
+
50
+ | Prop | Type | Notes |
51
+ | ------------- | --------------------------------------- | --------------------------------------------------- |
52
+ | `value` | `string` | Markdown source passed as a raw-text child. |
53
+ | `effect` | `'typewriter' \| 'none' \| string` | Maps to the `markdown-effect` attribute. |
54
+ | `attachments` | `ReadonlyArray<unknown>` | Maps to `text-mark-attachments`. Engine-defined. |
55
+ | `class` | `string` | |
56
+ | `style` | `string \| Record<string, ...>` | |
57
+ | `onLink` | `(e: MarkdownLinkEvent) => void` | Underlying `bindlink`. |
58
+ | `onImageTap` | `(e: MarkdownImageTapEvent) => void` | Underlying `bindimageTap`. |
59
+ | `onParseEnd` | `(e: MarkdownParseEndEvent) => void` | Underlying `bindparseEnd`. |
60
+
61
+ ## Native element methods
62
+
63
+ The underlying `<x-markdown>` exposes UI methods you can invoke via a
64
+ `main-thread:ref`:
65
+
66
+ - `getContent`, `getParseResult`, `getImages`
67
+ - `pauseAnimation`, `resumeAnimation`, `clearStatus`
68
+ - `getTextBoundingRect`, `setTextSelection`, `getSelectedText`
69
+
70
+ These are not yet wrapped by the component; drop down to the intrinsic
71
+ `<x-markdown>` element with a ref to call them directly.
@@ -0,0 +1,30 @@
1
+ import { type Define } from '@sigx/lynx';
2
+ import './jsx-augment.js';
3
+ import type { MarkdownLinkEvent, MarkdownImageTapEvent, MarkdownParseEndEvent } from './jsx-augment.js';
4
+ export type MarkdownEffect = 'typewriter' | 'none' | (string & {});
5
+ export type MarkdownProps = Define.Prop<'value', string, false> & Define.Prop<'effect', MarkdownEffect, false> & Define.Prop<'attachments', ReadonlyArray<unknown>, false> & Define.Prop<'class', string, false> & Define.Prop<'style', string | Record<string, string | number>, false> & Define.Prop<'onLink', (e: MarkdownLinkEvent) => void, false> & Define.Prop<'onImageTap', (e: MarkdownImageTapEvent) => void, false> & Define.Prop<'onParseEnd', (e: MarkdownParseEndEvent) => void, false>;
6
+ /**
7
+ * Render a markdown document using Lynx's `<x-markdown>` XElement.
8
+ *
9
+ * The markdown source is passed via the `value` prop; it is delivered to the
10
+ * native element as a raw-text child (per the 3.7.0 "raw-text node
11
+ * optimization" path). Event props use signalx's automatic
12
+ * `onLink`→`bindlink` mapping in `nodeOps.parseEventProp`, so handlers wire
13
+ * up without any per-event glue.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <Markdown
18
+ * value={"# Hello\n\nThis is **markdown**."}
19
+ * effect="typewriter"
20
+ * onLink={(e) => console.log('tapped', e.detail.url)}
21
+ * />
22
+ * ```
23
+ *
24
+ * @remarks
25
+ * Availability of the `<x-markdown>` element is platform-dependent — see
26
+ * `jsx-augment.ts` for the per-platform schedule. On platforms where the
27
+ * native element is not registered, the engine logs a warning and renders
28
+ * no view; there is no JS-side feature gate.
29
+ */
30
+ export declare const Markdown: import("@sigx/runtime-core").ComponentFactory<MarkdownProps, void, {}>;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx } from "@sigx/lynx/jsx-runtime";
2
+ import { component } from '@sigx/lynx';
3
+ import './jsx-augment.js';
4
+ /**
5
+ * Render a markdown document using Lynx's `<x-markdown>` XElement.
6
+ *
7
+ * The markdown source is passed via the `value` prop; it is delivered to the
8
+ * native element as a raw-text child (per the 3.7.0 "raw-text node
9
+ * optimization" path). Event props use signalx's automatic
10
+ * `onLink`→`bindlink` mapping in `nodeOps.parseEventProp`, so handlers wire
11
+ * up without any per-event glue.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * <Markdown
16
+ * value={"# Hello\n\nThis is **markdown**."}
17
+ * effect="typewriter"
18
+ * onLink={(e) => console.log('tapped', e.detail.url)}
19
+ * />
20
+ * ```
21
+ *
22
+ * @remarks
23
+ * Availability of the `<x-markdown>` element is platform-dependent — see
24
+ * `jsx-augment.ts` for the per-platform schedule. On platforms where the
25
+ * native element is not registered, the engine logs a warning and renders
26
+ * no view; there is no JS-side feature gate.
27
+ */
28
+ export const Markdown = component(({ props }) => {
29
+ return () => (_jsx("x-markdown", { "markdown-effect": props.effect, "text-mark-attachments": props.attachments, class: props.class, style: props.style, bindlink: props.onLink, bindimageTap: props.onImageTap, bindparseEnd: props.onParseEnd, children: props.value ?? '' }));
30
+ });
@@ -0,0 +1,4 @@
1
+ import './jsx-augment.js';
2
+ export { Markdown } from './Markdown.js';
3
+ export type { MarkdownProps, MarkdownEffect } from './Markdown.js';
4
+ export type { XMarkdownAttributes, MarkdownLinkEvent, MarkdownLinkEventDetail, MarkdownImageTapEvent, MarkdownImageTapEventDetail, MarkdownParseEndEvent, MarkdownParseEndEventDetail, } from './jsx-augment.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import './jsx-augment.js';
2
+ export { Markdown } from './Markdown.js';
@@ -0,0 +1,83 @@
1
+ /**
2
+ * JSX intrinsic type augmentation for Lynx's `<x-markdown>` XElement.
3
+ *
4
+ * Importing this module registers `'x-markdown'` as a valid JSX intrinsic
5
+ * with its 3.7.0+ attributes and events. Pulled in automatically by
6
+ * `@sigx/lynx-markdown`'s entry point so consumers do not need to import
7
+ * it directly.
8
+ *
9
+ * The native element ships per-platform on different schedules:
10
+ * - Harmony: available since 3.7.0
11
+ * - Android: available since 3.8.0-rc.0 (artifact `lynx_xelement_markdown`)
12
+ * - iOS: not yet in any tagged release; lands on the main branch
13
+ * post-3.8.0
14
+ *
15
+ * `<x-markdown>` props in JSX still type-check on every platform. At
16
+ * runtime the SignalX renderer issues a `__CreateElement('x-markdown')`
17
+ * op unconditionally; on platforms where the native element is not
18
+ * registered, the underlying engine handles the unknown tag (today it
19
+ * logs a warning and emits no view). There is no JS-side feature gate
20
+ * in this package — once you upgrade to a Lynx release that ships the
21
+ * element on your target platforms, rendering activates automatically.
22
+ */
23
+ import type { LynxCommonAttributes, LynxEventHandler } from '@sigx/lynx-runtime';
24
+ /** Detail payload of `bindlink` — the engine ships `url` plus optional fields. */
25
+ export interface MarkdownLinkEventDetail {
26
+ url: string;
27
+ [k: string]: unknown;
28
+ }
29
+ export interface MarkdownLinkEvent {
30
+ type: 'link';
31
+ detail: MarkdownLinkEventDetail;
32
+ }
33
+ /** Detail payload of `bindimageTap`. */
34
+ export interface MarkdownImageTapEventDetail {
35
+ src: string;
36
+ [k: string]: unknown;
37
+ }
38
+ export interface MarkdownImageTapEvent {
39
+ type: 'imageTap';
40
+ detail: MarkdownImageTapEventDetail;
41
+ }
42
+ /** Detail payload of `bindparseEnd`. */
43
+ export interface MarkdownParseEndEventDetail {
44
+ [k: string]: unknown;
45
+ }
46
+ export interface MarkdownParseEndEvent {
47
+ type: 'parseEnd';
48
+ detail: MarkdownParseEndEventDetail;
49
+ }
50
+ export interface XMarkdownAttributes extends LynxCommonAttributes {
51
+ /**
52
+ * Raw markdown source. Lynx parses the first text child of
53
+ * `<x-markdown>` per the 3.7.0 raw-text-node optimization. Passing a
54
+ * single string here is the common path; JSX expressions resolving to
55
+ * a string also work.
56
+ */
57
+ children?: any;
58
+ /**
59
+ * Render-time effect applied to the parsed markdown output.
60
+ * Known values: `'typewriter'`, `'none'`. The engine treats unknown
61
+ * strings as `'none'`.
62
+ */
63
+ 'markdown-effect'?: string;
64
+ /**
65
+ * Inline view attachments referenced by markdown text marks. Shape is
66
+ * engine-defined; passed through as-is.
67
+ */
68
+ 'text-mark-attachments'?: ReadonlyArray<unknown>;
69
+ /** Fires when the user taps an `[anchor](url)` link. */
70
+ bindlink?: LynxEventHandler<MarkdownLinkEvent>;
71
+ /** Fires when the user taps an inline image. */
72
+ bindimageTap?: LynxEventHandler<MarkdownImageTapEvent>;
73
+ /** Fires once the engine finishes parsing the source. */
74
+ bindparseEnd?: LynxEventHandler<MarkdownParseEndEvent>;
75
+ }
76
+ declare global {
77
+ namespace JSX {
78
+ interface IntrinsicElements {
79
+ 'x-markdown': XMarkdownAttributes;
80
+ }
81
+ }
82
+ }
83
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@sigx/lynx-markdown",
3
+ "version": "0.4.1",
4
+ "description": "Typed signalx wrapper around Lynx's <x-markdown> element. Renders markdown source via XElement/Markdown.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "scripts": {
22
+ "build": "node ../../scripts/clean.mjs dist && tsgo",
23
+ "dev": "tsgo --watch",
24
+ "clean": "node ../../scripts/clean.mjs dist .turbo"
25
+ },
26
+ "peerDependencies": {
27
+ "@sigx/lynx": "workspace:^"
28
+ },
29
+ "devDependencies": {
30
+ "@sigx/lynx": "workspace:^",
31
+ "@typescript/native-preview": "7.0.0-dev.20260511.1",
32
+ "typescript": "^6.0.3"
33
+ },
34
+ "author": "Andreas Ekdahl",
35
+ "license": "MIT",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/signalxjs/lynx.git",
39
+ "directory": "packages/lynx-markdown"
40
+ },
41
+ "homepage": "https://github.com/signalxjs/lynx/tree/main/packages/lynx-markdown",
42
+ "bugs": {
43
+ "url": "https://github.com/signalxjs/lynx/issues"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "keywords": [
49
+ "signalx",
50
+ "sigx",
51
+ "lynx",
52
+ "markdown",
53
+ "x-markdown"
54
+ ]
55
+ }