foldkit-mixins 0.2.0 → 0.3.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/README.md +236 -121
- package/dist/index.d.mts +33 -11
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +50 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { Stream } from "effect";
|
|
3
2
|
import { inertHtml } from "foldkit/html";
|
|
3
|
+
import { Stream } from "effect";
|
|
4
4
|
//#region src/metadataToken.ts
|
|
5
5
|
var metadataToken_exports = /* @__PURE__ */ __exportAll({
|
|
6
6
|
MetadataTokenTypeId: () => MetadataTokenTypeId,
|
|
@@ -223,6 +223,38 @@ const AriaDisabled = make$4("aria-disabled");
|
|
|
223
223
|
const Disabled = make$4("disabled");
|
|
224
224
|
const Value = make$4("value");
|
|
225
225
|
//#endregion
|
|
226
|
+
//#region src/attribute.ts
|
|
227
|
+
/** The brand `childAttribute.d.ts` stamps; Foldkit's guard is not exported. */
|
|
228
|
+
const CHILD_ATTRIBUTE_BRAND = "__childAttribute";
|
|
229
|
+
const isChildAttribute = (value) => typeof value === "object" && value !== null && Object.hasOwn(value, CHILD_ATTRIBUTE_BRAND);
|
|
230
|
+
const isTagged = (value) => typeof value === "object" && value !== null && Object.hasOwn(value, "_tag") && typeof value._tag === "string";
|
|
231
|
+
/** `Class` carries no Message, so the inert builder is the honest constructor. */
|
|
232
|
+
const classAttribute = (value) => inertHtml.Class(value);
|
|
233
|
+
const styleAttribute = (value) => inertHtml.Style(value);
|
|
234
|
+
/**
|
|
235
|
+
* `inertHtml.OnMount` only accepts `MountAction<never>`, so a Message-bearing
|
|
236
|
+
* mount is built directly. The shape is the same tagged value `h.OnMount`
|
|
237
|
+
* produces (`{ _tag: 'OnMount', action }`).
|
|
238
|
+
*/
|
|
239
|
+
const mountAttribute = (action) => ({
|
|
240
|
+
_tag: "OnMount",
|
|
241
|
+
action
|
|
242
|
+
});
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/attributes.ts
|
|
245
|
+
var attributes_exports = /* @__PURE__ */ __exportAll({
|
|
246
|
+
filter: () => filter,
|
|
247
|
+
find: () => find,
|
|
248
|
+
tagOf: () => tagOf
|
|
249
|
+
});
|
|
250
|
+
/** The tag of one bundle entry; `undefined` for an opaque `ChildAttribute`. */
|
|
251
|
+
const tagOf = (attribute) => isTagged(attribute) ? attribute._tag : void 0;
|
|
252
|
+
const hasTag = (tag) => (attribute) => tagOf(attribute) === tag;
|
|
253
|
+
/** The first attribute with `tag`, typed as that variant. */
|
|
254
|
+
const find = (attributes, tag) => attributes.find(hasTag(tag));
|
|
255
|
+
/** Every attribute with `tag`, in bundle order. */
|
|
256
|
+
const filter = (attributes, tag) => attributes.filter(hasTag(tag));
|
|
257
|
+
//#endregion
|
|
226
258
|
//#region src/diagnostics.ts
|
|
227
259
|
var diagnostics_exports = /* @__PURE__ */ __exportAll({ DiagnosticError: () => DiagnosticError });
|
|
228
260
|
var DiagnosticError = class extends Error {
|
|
@@ -290,24 +322,6 @@ const contributionsFor = (mixin, slot) => mixin.contributions[slot];
|
|
|
290
322
|
/** Ported from `effect-atom-jsx/src/View.ts` `pipeSelf`. */
|
|
291
323
|
const pipeSelf = (self, fns) => fns.reduce((acc, fn) => fn(acc), self);
|
|
292
324
|
//#endregion
|
|
293
|
-
//#region src/attribute.ts
|
|
294
|
-
/** The brand `childAttribute.d.ts` stamps; Foldkit's guard is not exported. */
|
|
295
|
-
const CHILD_ATTRIBUTE_BRAND = "__childAttribute";
|
|
296
|
-
const isChildAttribute = (value) => typeof value === "object" && value !== null && Object.hasOwn(value, CHILD_ATTRIBUTE_BRAND);
|
|
297
|
-
const isTagged = (value) => typeof value === "object" && value !== null && Object.hasOwn(value, "_tag") && typeof value._tag === "string";
|
|
298
|
-
/** `Class` carries no Message, so the inert builder is the honest constructor. */
|
|
299
|
-
const classAttribute = (value) => inertHtml.Class(value);
|
|
300
|
-
const styleAttribute = (value) => inertHtml.Style(value);
|
|
301
|
-
/**
|
|
302
|
-
* `inertHtml.OnMount` only accepts `MountAction<never>`, so a Message-bearing
|
|
303
|
-
* mount is built directly. The shape is the same tagged value `h.OnMount`
|
|
304
|
-
* produces (`{ _tag: 'OnMount', action }`).
|
|
305
|
-
*/
|
|
306
|
-
const mountAttribute = (action) => ({
|
|
307
|
-
_tag: "OnMount",
|
|
308
|
-
action
|
|
309
|
-
});
|
|
310
|
-
//#endregion
|
|
311
325
|
//#region src/resolver.ts
|
|
312
326
|
/**
|
|
313
327
|
* The deterministic resolver. `resolve` is pure: it decomposes the base
|
|
@@ -490,11 +504,19 @@ const composeMounts = (mounts, slot) => {
|
|
|
490
504
|
};
|
|
491
505
|
//#endregion
|
|
492
506
|
//#region src/slotView.ts
|
|
507
|
+
/**
|
|
508
|
+
* `SlotView` is the structural equivalent of a Surface: a pure Foldkit view
|
|
509
|
+
* that publishes typed Slots and lets Mixins attach without forking it. It
|
|
510
|
+
* owns no state and runs no Effects. Attached Mixins are resolved into
|
|
511
|
+
* ordinary Foldkit attributes per slot, using the view's own `h` so Message
|
|
512
|
+
* capability masking is preserved.
|
|
513
|
+
*/
|
|
493
514
|
var slotView_exports = /* @__PURE__ */ __exportAll({
|
|
494
515
|
attach: () => attach$2,
|
|
495
516
|
buildersFor: () => buildersFor,
|
|
496
517
|
define: () => define$2,
|
|
497
|
-
forMessages: () => forMessages
|
|
518
|
+
forMessages: () => forMessages,
|
|
519
|
+
inertBuilder: () => inertBuilder
|
|
498
520
|
});
|
|
499
521
|
/** Build one `attrs` resolver per published slot, evaluating Mixins lazily. */
|
|
500
522
|
const buildersFor = (slots, mixins, context) => {
|
|
@@ -549,6 +571,13 @@ const makeView = (name, slots, mixins, render) => {
|
|
|
549
571
|
*/
|
|
550
572
|
const define$2 = (slots, render, options) => makeView(options?.name, slots, [], render);
|
|
551
573
|
/**
|
|
574
|
+
* Foldkit's `inertHtml` typed for a Message universe, for rendering a view
|
|
575
|
+
* outside a runtime (tests, demos, static description). `inertHtml` is
|
|
576
|
+
* `HtmlBuilder<never>`, and the builder is invariant in `Message`, so this is
|
|
577
|
+
* the one cast: sound because inert handlers are never dispatched.
|
|
578
|
+
*/
|
|
579
|
+
const inertBuilder = () => inertHtml;
|
|
580
|
+
/**
|
|
552
581
|
* Binds the view constructors to one Message universe, so the render callback
|
|
553
582
|
* no longer has to annotate `h` to pin it. `Input` is still inferred from the
|
|
554
583
|
* callback's own `input` annotation.
|
|
@@ -1199,6 +1228,6 @@ const Theme = {
|
|
|
1199
1228
|
variables
|
|
1200
1229
|
};
|
|
1201
1230
|
//#endregion
|
|
1202
|
-
export { a11y_exports as A11y, attr_exports as Attr, behavior_exports as Behavior, capability_exports as Capability, diagnostics_exports as Diagnostics, event_exports as Event, metadataToken_exports as MetadataToken, mixin_exports as Mixin, requirement_exports as Requirement, resolver_exports as Resolver, slot_exports as Slot, slotView_exports as SlotView, slots_exports as Slots, Style, Theme };
|
|
1231
|
+
export { a11y_exports as A11y, attr_exports as Attr, attributes_exports as Attributes, behavior_exports as Behavior, capability_exports as Capability, diagnostics_exports as Diagnostics, event_exports as Event, metadataToken_exports as MetadataToken, mixin_exports as Mixin, requirement_exports as Requirement, resolver_exports as Resolver, slot_exports as Slot, slotView_exports as SlotView, slots_exports as Slots, Style, Theme };
|
|
1203
1232
|
|
|
1204
1233
|
//# sourceMappingURL=index.mjs.map
|