@foldkit/markdown 0.14.3-canary.76fa0d1ee2a5 → 0.14.3-canary.c701daa80af1

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,21 +111,48 @@ 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.submodel` 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.block` slotId:
115
115
 
116
116
  ```typescript
117
- import { Html, type HtmlBuilder } from 'foldkit/html'
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'
118
122
 
119
123
  import * as Markdown from '@foldkit/markdown'
120
124
 
121
- import { Counter } from './counter'
125
+ import * as Counter from './counter'
122
126
  import { islandAttributes } from './islands'
123
- import { GotCounterMessage, type Message, type Model } from './message'
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
+ >
124
151
 
125
152
  const postView = (
126
153
  model: Model,
127
154
  post: Markdown.MarkdownDocument,
128
- h: HtmlBuilder<Message>,
155
+ h: ApplicationViewBuilder,
129
156
  ): Html =>
130
157
  Markdown.view(post, {
131
158
  islands: Markdown.islandsFor(islandAttributes, {
@@ -134,12 +161,12 @@ const postView = (
134
161
  [],
135
162
  [
136
163
  h.span([], [label ?? 'Counter']),
137
- h.submodel({
138
- slotId: `counter-${occurrenceIndex}`,
139
- model: model.counter,
140
- view: Counter.view,
141
- toParentMessage: message => GotCounterMessage({ message }),
142
- }),
164
+ h.block(
165
+ counter.embedView({
166
+ slotId: `counter-${occurrenceIndex}`,
167
+ model: model.counter,
168
+ }),
169
+ ),
143
170
  ],
144
171
  ),
145
172
  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.submodel` slotId.
11
+ * such as an `h.block` 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.76fa0d1ee2a5",
3
+ "version": "0.14.3-canary.c701daa80af1",
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.76fa0d1ee2a5",
29
+ "foldkit": "0.168.0-canary.c701daa80af1",
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.76fa0d1ee2a5",
43
+ "foldkit": "0.168.0-canary.c701daa80af1",
44
44
  "happy-dom": "^20.14.5",
45
45
  "mdast-util-directive": "^3.1.0",
46
46
  "rimraf": "^6.1.3",