@sekiso/markdown 0.0.1 → 0.0.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sekiso/markdown",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "description": "Sekiso renderer adapter for Markdown: the same views as text, with no framework and no DOM",
6
6
  "repository": {
7
7
  "type": "git",
@@ -13,7 +13,7 @@
13
13
  ".": "./src/index.ts"
14
14
  },
15
15
  "dependencies": {
16
- "@sekiso/core": "0.0.1",
16
+ "@sekiso/core": "0.0.2",
17
17
  "@ui-sdk/core": "0.1.0-beta.17"
18
18
  }
19
19
  }
package/src/index.test.ts CHANGED
@@ -15,7 +15,7 @@ describe('markdown adapter', () => {
15
15
  },
16
16
  children: View({ of: meterView }),
17
17
  }))
18
- expect(text).toBe('[add] value 0')
18
+ expect(text).toBe('[add] [send] [done] value 0')
19
19
  })
20
20
 
21
21
  it('keeps state between renders, and hears every change', () => {
@@ -23,7 +23,7 @@ describe('markdown adapter', () => {
23
23
  let heard = 0
24
24
  let api: { add: () => void } | undefined
25
25
  const view = defineView(meter, {
26
- tags: { root: 'p', add: 'button' },
26
+ parts: { root: 'p', add: 'button' },
27
27
  }, (context, s) => {
28
28
  api = context.api
29
29
  return s.Root({
@@ -46,7 +46,7 @@ describe('markdown adapter', () => {
46
46
  const app = createMeterApp({ step: 5 })
47
47
  let bump: (() => void) | undefined
48
48
  const view = defineView(readout, {
49
- tags: { root: 'p' },
49
+ parts: { root: 'p' },
50
50
  uses: { meter },
51
51
  }, (context, s) => {
52
52
  bump = context.api.bump
@@ -92,7 +92,7 @@ describe('markdown adapter', () => {
92
92
  }),
93
93
  })
94
94
  const view = defineView(place, {
95
- tags: { root: 'p' },
95
+ parts: { root: 'p' },
96
96
  }, ({ state }, s) => s.Root({ children: state.current?.path }))
97
97
  let path = '/'
98
98
  const markdown = createMarkdown(() => Sekiso({
@@ -148,13 +148,11 @@ describe('markdown adapter', () => {
148
148
  }),
149
149
  })
150
150
  const view = defineView(page, {
151
- tags: {
151
+ parts: {
152
152
  root: 'article',
153
153
  link: 'a',
154
154
  toggle: 'button',
155
155
  field: 'input',
156
- },
157
- layout: {
158
156
  title: 'h1',
159
157
  items: 'ul',
160
158
  item: 'li',
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@ import type { App, AppState } from '@sekiso/core/app'
2
2
  import type { AnyView, KElement, KNode, Used, Uses, ViewContext, ViewDefinition } from '@sekiso/core/view'
3
3
  import type { OptionsOf, Primitive } from '@ui-sdk/core'
4
4
  import type { Flow } from './text'
5
- import { isElement, needsOf, viewKey } from '@sekiso/core/renderer'
5
+ import { isElement, needsOf, sharedOptions, viewKey } from '@sekiso/core/renderer'
6
6
  // What a part renders, read with no DOM. UI SDK marks these stable, and ships them for tests.
7
7
  import { partAttrs, partPresent } from '@ui-sdk/core/testing'
8
8
  import { escape, flowOfTag, serialize } from './text'
@@ -186,7 +186,7 @@ export function createMarkdown(tree: () => Child): Markdown {
186
186
  ]),
187
187
  )
188
188
  return {
189
- ...pass.app.theme.hints[of.name],
189
+ ...sharedOptions(pass.app, of),
190
190
  ...needed,
191
191
  ...options,
192
192
  }
@@ -239,6 +239,13 @@ export function createMarkdown(tree: () => Child): Markdown {
239
239
  read: Read
240
240
  }
241
241
 
242
+ /** The name a view gives a part, where it gives one. */
243
+ function named(element: KElement): Record<string, string> {
244
+ return element.label === undefined
245
+ ? {}
246
+ : { 'aria-label': element.label }
247
+ }
248
+
242
249
  function elementFlow(element: KElement, index: number, place: Place): Flow {
243
250
  const { view, instance, path, pass, read } = place
244
251
  const at = `${path}/${element.name}:${element.key ?? index}`
@@ -247,14 +254,14 @@ export function createMarkdown(tree: () => Child): Markdown {
247
254
  const part = instance.part(element.name, element.props)
248
255
  if (!partPresent(part, element.props))
249
256
  return []
250
- const attributes = partAttrs(part, element.props) as Record<string, unknown>
257
+ const attributes = {
258
+ ...partAttrs(part, element.props) as Record<string, unknown>,
259
+ ...named(element),
260
+ }
251
261
  return flowOfTag(view.tags[element.name]!, attributes, nodeFlow(element.children, { ...place, path: at }))
252
262
  }
253
263
  case 'layout': {
254
- const attributes = element.label === undefined
255
- ? {}
256
- : { 'aria-label': element.label }
257
- return flowOfTag(view.tags[element.name]!, attributes, nodeFlow(element.children, { ...place, path: at }))
264
+ return flowOfTag(view.tags[element.name]!, named(element), nodeFlow(element.children, { ...place, path: at }))
258
265
  }
259
266
  // An icon's artwork is the theme's, which text has no use for. The words beside it say the same.
260
267
  case 'icon':