@foldkit/markdown 0.14.3-canary.bfd880b1e6ca → 0.14.3-canary.c55d84c8199b

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 CHANGED
@@ -111,48 +111,21 @@ import { islandAttributes } from './src/islands'
111
111
  markdown({ islands: islandAttributes })
112
112
  ```
113
113
 
114
- `islandsFor` pairs the same definitions with typed views: attributes arrive decoded through each island's schema, and the record must cover every declared name. State stays in your Model; the markdown only decides placement. The third argument is the zero-based occurrence of that island name in the document, for identifiers that must be unique per instance, like an `h.block` slotId:
114
+ `islandsFor` pairs the same definitions with typed views: attributes arrive decoded through each island's schema, and the record must cover every declared name. State stays in your Model; the markdown only decides placement. The third argument is the zero-based occurrence of that island name in the document, for identifiers that must be unique per instance, like an `h.submodel` slotId:
115
115
 
116
116
  ```typescript
117
- import { Schema } from 'effect'
118
- import { Block } from 'foldkit'
119
- import { makeApplicationDefinition } from 'foldkit'
120
- import type { Html } from 'foldkit/html'
121
- import { defineMessageUnion } from 'foldkit/message'
117
+ import { Html, type HtmlBuilder } from 'foldkit/html'
122
118
 
123
119
  import * as Markdown from '@foldkit/markdown'
124
120
 
125
- import * as Counter from './counter'
121
+ import { Counter } from './counter'
126
122
  import { islandAttributes } from './islands'
127
-
128
- const Model = Schema.Struct({ counter: Counter.Model })
129
- type Model = typeof Model.Type
130
-
131
- const Message = defineMessageUnion({
132
- GotCounterMessage: { message: Counter.Message },
133
- })
134
-
135
- export const ApplicationDefinition = makeApplicationDefinition({
136
- Model,
137
- Message,
138
- })
139
-
140
- const CounterBinding = ApplicationDefinition.bindChild(Counter.block, {
141
- field: 'counter',
142
- parentMessage: Message.GotCounterMessage,
143
- })
144
-
145
- export const ApplicationComposition = ApplicationDefinition.makeComposition({
146
- bindings: [CounterBinding],
147
- })
148
- type ApplicationViewBuilder = Block.ViewBuilderFor<
149
- typeof ApplicationComposition
150
- >
123
+ import { GotCounterMessage, type Message, type Model } from './message'
151
124
 
152
125
  const postView = (
153
126
  model: Model,
154
127
  post: Markdown.MarkdownDocument,
155
- h: ApplicationViewBuilder,
128
+ h: HtmlBuilder<Message>,
156
129
  ): Html =>
157
130
  Markdown.view(post, {
158
131
  islands: Markdown.islandsFor(islandAttributes, {
@@ -161,12 +134,12 @@ const postView = (
161
134
  [],
162
135
  [
163
136
  h.span([], [label ?? 'Counter']),
164
- h.block(
165
- counter.embedView({
166
- slotId: `counter-${occurrenceIndex}`,
167
- model: model.counter,
168
- }),
169
- ),
137
+ h.submodel({
138
+ slotId: `counter-${occurrenceIndex}`,
139
+ model: model.counter,
140
+ view: Counter.view,
141
+ toParentMessage: message => GotCounterMessage({ message }),
142
+ }),
170
143
  ],
171
144
  ),
172
145
  Note: (_attributes, content) =>
@@ -8,7 +8,7 @@ export type InlineContent = ReadonlyArray<Html | string>;
8
8
  * rendered nested blocks (empty for leaf directives), and the zero-based
9
9
  * occurrence of this island name in the document, in document order. Use the
10
10
  * occurrence index to derive identifiers that must be unique per instance,
11
- * such as an `h.block` slotId.
11
+ * such as an `h.submodel` slotId.
12
12
  */
13
13
  export type IslandView = (attributes: Readonly<globalThis.Record<string, string>>, content: ReadonlyArray<Html>, occurrenceIndex: number) => Html;
14
14
  /** Island views by directive name. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldkit/markdown",
3
- "version": "0.14.3-canary.bfd880b1e6ca",
3
+ "version": "0.14.3-canary.c55d84c8199b",
4
4
  "description": "Write markdown files, get Foldkit views with live islands.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "peerDependencies": {
28
28
  "effect": "4.0.0",
29
- "foldkit": "0.168.0-canary.bfd880b1e6ca",
29
+ "foldkit": "0.168.0-canary.c55d84c8199b",
30
30
  "vite": "^8.0.0"
31
31
  },
32
32
  "dependencies": {
@@ -40,7 +40,7 @@
40
40
  "@types/mdast": "^4.0.4",
41
41
  "@types/unist": "^3.0.3",
42
42
  "effect": "4.0.0",
43
- "foldkit": "0.168.0-canary.bfd880b1e6ca",
43
+ "foldkit": "0.168.0-canary.c55d84c8199b",
44
44
  "happy-dom": "^20.14.5",
45
45
  "mdast-util-directive": "^3.1.0",
46
46
  "rimraf": "^6.1.3",