line-flex-message-preview 0.0.0-stage → 0.1.0
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 +254 -2
- package/dist/define.d.ts +1 -0
- package/dist/define.js +4 -0
- package/dist/dom.d.ts +15 -0
- package/dist/dom.js +38 -0
- package/dist/element.d.ts +44 -0
- package/dist/element.js +174 -0
- package/dist/flex-message.bundle.js +132 -0
- package/dist/html.d.ts +30 -0
- package/dist/html.js +86 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +7 -0
- package/dist/profile.d.ts +75 -0
- package/dist/profile.js +86 -0
- package/dist/styles.d.ts +4 -0
- package/dist/styles.js +152 -0
- package/dist/tree.d.ts +29 -0
- package/dist/tree.js +503 -0
- package/dist/types.d.ts +174 -0
- package/dist/types.js +9 -0
- package/dist/validate.d.ts +46 -0
- package/dist/validate.js +473 -0
- package/dist/values.d.ts +24 -0
- package/dist/values.js +78 -0
- package/docs/measurements.md +119 -0
- package/package.json +62 -4
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Measurements
|
|
2
|
+
|
|
3
|
+
LINE publishes the *structure* of Flex Messages (which components exist, which
|
|
4
|
+
properties they take) but not how they are drawn: no pixel value for `md`, no
|
|
5
|
+
bubble width for `kilo`, no line height. Every number in `src/profile.ts` is
|
|
6
|
+
therefore a measurement, and this file records where each one comes from, so
|
|
7
|
+
that a LINE update can be re-measured instead of guessed.
|
|
8
|
+
|
|
9
|
+
Change a value in `src/profile.ts` only together with its entry here.
|
|
10
|
+
|
|
11
|
+
## Sources
|
|
12
|
+
|
|
13
|
+
| id | what | date | status |
|
|
14
|
+
|---|---|---|---|
|
|
15
|
+
| **S1** | The stylesheet of LINE's Flex Message Simulator, read from LINE's public CDN: `https://static.line-scdn.net/line_flexible_msg/188b38e2f32/css/sp/main.css`, sha256 `00b1b8339093ff10be4e09d25d980f87e4e1efb9e3ccdcd8eb2eaaee9d46ccab`, 17 569 bytes | read 2026-12-02 | first-hand |
|
|
16
|
+
| **S2** | Layout comparison in Chrome 158 (macOS) between this package's `simulator` profile and a reconstruction of the Simulator: the HTML produced by [lis186/line-flex-message-skill](https://github.com/lis186/line-flex-message-skill) at `db1df486` (MIT; its authors verified it against the Simulator's output for 292 single-property probes on 2026-10-24) styled by S1. `pnpm test:parity`: 311 cases, 3 488 boxes and as many computed styles, all within 0.02 px | 2026-12-02 | first-hand comparison, third-party reconstruction |
|
|
17
|
+
| **S3** | iPhone measurements published by lis186/line-flex-message-skill (`references/device-ios.md`, `tests/device/ios-expected.json` at `db1df486`): a calibration carousel pushed to LINE for iOS on an iPhone with a 1290×2796 screen (430 pt wide, 3x), dark mode, default iOS and LINE text sizes, measured from screenshots against a 200 px ruler. iOS and LINE app versions are not stated | 2026-10-24 | **third-party, not yet repeated by this project** |
|
|
18
|
+
| **S5** | LINE's own verdict on 172 single-rule messages, through its `validate/push` endpoint, which delivers nothing. Cases in `tests/line-cases.ts`, answers in `spec/line-verdicts.json`: 76 accepted, 96 rejected, each with LINE's reason | 2026-12-02 | first-hand |
|
|
19
|
+
| **S4** | LINE's answers recorded by the same project for its 292 probes (`tests/data/probe-results.json`): 289 accepted, 3 rejected with `unknown field` | 2026-10-24 | third-party |
|
|
20
|
+
|
|
21
|
+
Nothing from S1 is copied into this repository: the numbers were read from it,
|
|
22
|
+
and the stylesheet in `src/styles.ts` is written independently, with its own
|
|
23
|
+
element structure and class names. The parity test downloads S1 and the S2
|
|
24
|
+
reference into `.cache/` at run time and checks the stylesheet's sha256, so a
|
|
25
|
+
change on LINE's side stops the test instead of passing unnoticed.
|
|
26
|
+
|
|
27
|
+
## Values shared by both profiles (source S1, confirmed by S2)
|
|
28
|
+
|
|
29
|
+
| metric | value |
|
|
30
|
+
|---|---|
|
|
31
|
+
| spacing / margin / padding / offset keywords | none 0, xs 2, sm 4, md 8, lg 12, xl 16, xxl 20 px |
|
|
32
|
+
| text, span and icon size keywords | xxs 11, xs 13, sm 14, md 16, lg 19, xl 22, xxl 29, 3xl 35, 4xl 48, 5xl 74 px |
|
|
33
|
+
| image size keywords | xxs 40, xs 60, sm 80, md 100, lg 120, xl 140, xxl 160, 3xl 180, 4xl 200, 5xl 220 px; `full` 100% |
|
|
34
|
+
| corner radius keywords | none 0, xs 2, sm 4, md 8, lg 12, xl 16, xxl 20 px |
|
|
35
|
+
| border width keywords | none 0, light 0.5, normal 1, medium 2, semi-bold 3, bold 4 px |
|
|
36
|
+
| bubble max width | nano 120, micro 160, deca 220, hecto 241, kilo 260, mega 300, giga 500 px |
|
|
37
|
+
| bubble corner radius | giga 5, mega 17, all others 10 px |
|
|
38
|
+
| header padding | mega, giga 20; kilo 13; deca, hecto 11 14 13; micro, nano 10 px |
|
|
39
|
+
| body padding | mega, giga 19 20 20; kilo 13; deca, hecto 11 14 13; micro, nano 10 px |
|
|
40
|
+
| body bottom padding when a footer follows | mega, giga 10; kilo, hecto, deca 17; micro, nano 10 px |
|
|
41
|
+
| footer padding | 10 px |
|
|
42
|
+
| button | height 52 px (`sm` 40), side padding 16, radius 8, font 16 px |
|
|
43
|
+
| button colours | primary `#17c950` on white text; secondary `#dcdfe5` with `#111111`; link `#42659a` |
|
|
44
|
+
| default text colour | `#444444` |
|
|
45
|
+
| separator | `#d4d6da`, half a px thick, takes no space |
|
|
46
|
+
| carousel | each bubble 80% of the width up to its max; 7 px before the first, 9 px between, 7 px after |
|
|
47
|
+
| default image aspect ratio | 1:1 |
|
|
48
|
+
|
|
49
|
+
Structural rules confirmed by S2 rather than by a number: a component's `flex`
|
|
50
|
+
maps to `flex: N 0 auto` in a vertical box and `flex: N 0 0` in a horizontal
|
|
51
|
+
one (also stated in LINE's layout documentation); a box with a fixed size along
|
|
52
|
+
its parent's main axis stops flexing; `margin` on a child replaces the parent's
|
|
53
|
+
`spacing`; a `px` spacing also applies before fillers while a keyword spacing
|
|
54
|
+
does not; `position: absolute` drops margins.
|
|
55
|
+
|
|
56
|
+
## `simulator` profile
|
|
57
|
+
|
|
58
|
+
| metric | value | source |
|
|
59
|
+
|---|---|---|
|
|
60
|
+
| line height | 1.4 × font size | S1, S2 |
|
|
61
|
+
| `maxLines`, `lineSpacing` | ignored | S2 (the reconstruction's probes show no change in the Simulator's output) |
|
|
62
|
+
| giga side inset | 7 px | S1 |
|
|
63
|
+
|
|
64
|
+
## `ios` profile
|
|
65
|
+
|
|
66
|
+
Everything above, except:
|
|
67
|
+
|
|
68
|
+
| metric | value | source | this project's check |
|
|
69
|
+
|---|---|---|---|
|
|
70
|
+
| line height | `max(1.2 × font size, 16px)` | S3: single lines of xs…xxl measured 16.0, 17.0, 19.7, 23.0, 26.3, 35.0 px | `pnpm test:device`: 6/6 within 1 px |
|
|
71
|
+
| `maxLines` | clamps wrapped text, ellipsis on the last line | S3 | 4/4 boxes, same line counts |
|
|
72
|
+
| `lineSpacing` | added between lines only | S3 (also LINE's documentation) | 4/4 boxes |
|
|
73
|
+
| trailing `\n` in wrapped text | adds an empty line | S3 | 1/1 |
|
|
74
|
+
| giga side inset | 8 px | S3 | not checked |
|
|
75
|
+
|
|
76
|
+
`pnpm test:device` passes 18 of 18 boxes (Chrome 158 on macOS, 2026-12-02). It
|
|
77
|
+
depends on Apple's system font for line breaks, so it is only meaningful on
|
|
78
|
+
macOS.
|
|
79
|
+
|
|
80
|
+
## What LINE accepts (source S5)
|
|
81
|
+
|
|
82
|
+
`validate()` is held to all 172 recorded verdicts by
|
|
83
|
+
`tests/line-verdicts.test.ts`. Rules found this way that neither LINE's
|
|
84
|
+
documentation pages nor its OpenAPI document state:
|
|
85
|
+
|
|
86
|
+
- A bubble needs at least one block. A carousel holds 1 to 12 bubbles, all of
|
|
87
|
+
the same size (an absent size counts as mega).
|
|
88
|
+
- A baseline box may hold only icon, text, filler and spacer.
|
|
89
|
+
- A video may only be the hero of a kilo, mega or giga bubble that is not in a
|
|
90
|
+
carousel; its `altContent` must be a box or an image.
|
|
91
|
+
- The action of a button needs a non-empty `label`; actions elsewhere do not.
|
|
92
|
+
- A span needs non-empty `text`.
|
|
93
|
+
- A gradient angle must be at least `0deg` and less than `360deg`.
|
|
94
|
+
- Margins, spacing, paddings and `lineSpacing` may not be negative; offsets may.
|
|
95
|
+
- Unknown properties are rejected (`unknown field`).
|
|
96
|
+
- The `spacer` component, gone from the documentation and the OpenAPI
|
|
97
|
+
document, is still accepted, with `size` xs…xxl and nothing else.
|
|
98
|
+
|
|
99
|
+
## Not measured yet
|
|
100
|
+
|
|
101
|
+
- **`spacer` on screen.** It is drawn from the rules for it in S1 (a fixed gap
|
|
102
|
+
of the spacing keyword's size, `md` by default, which also suppresses keyword
|
|
103
|
+
spacing after it). The reconstruction in S2 does not cover it, so this has
|
|
104
|
+
not been compared with anything.
|
|
105
|
+
|
|
106
|
+
- **Our own iPhone calibration.** S3 is one device, one day, by someone else,
|
|
107
|
+
and it does not state the iOS or LINE version. It has to be repeated, and the
|
|
108
|
+
result stored here with device, OS, LINE version and date.
|
|
109
|
+
- **Android.** Nothing is known; there is no `android` profile.
|
|
110
|
+
- **On a phone:** default block paddings, button height and label weight,
|
|
111
|
+
separator thickness, bubble width on screens other than 430 pt, sizes `xxs`
|
|
112
|
+
and `3xl`–`5xl`, span line heights, icon line height. The `ios` profile
|
|
113
|
+
assumes the Simulator's value for all of these.
|
|
114
|
+
- **`adjustMode: shrink-to-fit` and `scaling`.** S3 has measurements for both;
|
|
115
|
+
the renderer does not implement them yet, so `validate()` reports them as
|
|
116
|
+
`not-rendered`.
|
|
117
|
+
- **Video.** The Simulator shows `altContent`, and so does this renderer. What
|
|
118
|
+
a phone shows before playback has not been measured.
|
|
119
|
+
- **Text without `wrap` that contains `\n`,** and `\n` inside a span.
|
package/package.json
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "line-flex-message-preview",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Framework-free preview of LINE Flex Message JSON: a <flex-message> custom element with shadow DOM isolation, an HTML string renderer, and a structural validator.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"line",
|
|
7
|
+
"flex-message",
|
|
8
|
+
"line-messaging-api",
|
|
9
|
+
"preview",
|
|
10
|
+
"renderer",
|
|
11
|
+
"web-component",
|
|
12
|
+
"custom-element",
|
|
13
|
+
"shadow-dom",
|
|
14
|
+
"validator"
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"sideEffects": [
|
|
19
|
+
"./dist/define.js",
|
|
20
|
+
"./dist/flex-message.bundle.js"
|
|
21
|
+
],
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./element": {
|
|
30
|
+
"types": "./dist/element.d.ts",
|
|
31
|
+
"import": "./dist/element.js"
|
|
32
|
+
},
|
|
33
|
+
"./define": {
|
|
34
|
+
"types": "./dist/define.d.ts",
|
|
35
|
+
"import": "./dist/define.js"
|
|
36
|
+
},
|
|
37
|
+
"./bundle": "./dist/flex-message.bundle.js"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"docs/measurements.md"
|
|
42
|
+
],
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && node scripts/fix-dts.ts && esbuild src/define.ts --bundle --format=esm --target=es2022 --minify --outfile=dist/flex-message.bundle.js",
|
|
45
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
46
|
+
"test": "node --test 'tests/*.test.ts'",
|
|
47
|
+
"test:browser": "node tests/browser/run.ts",
|
|
48
|
+
"test:parity": "node tests/browser/parity.ts",
|
|
49
|
+
"test:device": "node tests/browser/device.ts",
|
|
50
|
+
"test:all": "pnpm typecheck && pnpm test && pnpm build && pnpm test:browser && pnpm test:parity && pnpm test:device",
|
|
51
|
+
"screenshot": "node scripts/screenshot.ts",
|
|
52
|
+
"test:line": "node scripts/validate-with-line.ts tests/fixtures/*.json",
|
|
53
|
+
"spec:check": "node scripts/spec-snapshot.ts --check",
|
|
54
|
+
"spec:update": "node scripts/spec-snapshot.ts --update",
|
|
55
|
+
"demo": "node scripts/serve.ts",
|
|
56
|
+
"line:record": "node scripts/line-verdicts.ts",
|
|
57
|
+
"test:package": "node tests/package.ts"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/node": "22.20.7",
|
|
61
|
+
"esbuild": "0.28.2",
|
|
62
|
+
"typescript": "7.0.2"
|
|
63
|
+
}
|
|
64
|
+
}
|