@craft-ts/component 0.7.0-beta.13 → 0.7.0-beta.16

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.
Files changed (195) hide show
  1. package/package.json +7 -2
  2. package/src/index.d.ts +40 -40
  3. package/src/index.js +35 -35
  4. package/src/lib/a11y-control.d.ts +0 -1
  5. package/src/lib/a11y-control.js +0 -1
  6. package/src/lib/a11y.d.ts +4 -5
  7. package/src/lib/a11y.js +3 -4
  8. package/src/lib/ai/ai-context-menu.d.ts +24 -25
  9. package/src/lib/ai/ai-context-menu.js +2 -3
  10. package/src/lib/ai/ai-send-dialog.d.ts +277 -278
  11. package/src/lib/ai/ai-send-dialog.js +4 -5
  12. package/src/lib/ai/send-context-to-ai.d.ts +1 -2
  13. package/src/lib/ai/send-context-to-ai.js +4 -5
  14. package/src/lib/assert-defined-input.d.ts +1 -2
  15. package/src/lib/assert-defined-input.js +0 -1
  16. package/src/lib/bootstrap.d.ts +4 -3
  17. package/src/lib/bootstrap.js +6 -8
  18. package/src/lib/bridge.d.ts +9 -10
  19. package/src/lib/bridge.js +3 -4
  20. package/src/lib/catch-node.d.ts +35 -0
  21. package/src/lib/{block.js → catch-node.js} +9 -10
  22. package/src/lib/component.d.ts +23 -10
  23. package/src/lib/component.js +5 -6
  24. package/src/lib/composition.d.ts +1 -2
  25. package/src/lib/composition.js +2 -3
  26. package/src/lib/craft-defaults.d.ts +0 -1
  27. package/src/lib/craft-defaults.js +4 -5
  28. package/src/lib/craft-host-tokens.d.ts +0 -1
  29. package/src/lib/craft-host-tokens.js +0 -1
  30. package/src/lib/craft-router-outlet.d.ts +1 -2
  31. package/src/lib/craft-router-outlet.js +1 -2
  32. package/src/lib/css-vars.d.ts +0 -1
  33. package/src/lib/css-vars.js +0 -1
  34. package/src/lib/css-vars.type.d.ts +1 -2
  35. package/src/lib/css-vars.type.js +0 -1
  36. package/src/lib/{defer.d.ts → defer-node.d.ts} +4 -5
  37. package/src/lib/{defer.js → defer-node.js} +1 -2
  38. package/src/lib/directive.d.ts +1 -2
  39. package/src/lib/directive.js +1 -2
  40. package/src/lib/factory-runtime.d.ts +1 -2
  41. package/src/lib/factory-runtime.js +0 -1
  42. package/src/lib/{field-exception-block.d.ts → field-error-node.d.ts} +22 -23
  43. package/src/lib/{field-exception-block.js → field-error-node.js} +8 -9
  44. package/src/lib/for-node.d.ts +28 -0
  45. package/src/lib/{each.js → for-node.js} +4 -5
  46. package/src/lib/for-scheduling.d.ts +58 -0
  47. package/src/lib/{each-scheduling.js → for-scheduling.js} +14 -15
  48. package/src/lib/host-runtime.d.ts +0 -1
  49. package/src/lib/host-runtime.js +0 -1
  50. package/src/lib/hydrate.d.ts +2 -3
  51. package/src/lib/hydrate.js +57 -18
  52. package/src/lib/hyperscript.d.ts +1 -2
  53. package/src/lib/hyperscript.js +1 -2
  54. package/src/lib/if-node.d.ts +7 -0
  55. package/src/lib/{if-block.js → if-node.js} +2 -3
  56. package/src/lib/locator.d.ts +5 -6
  57. package/src/lib/locator.js +1 -2
  58. package/src/lib/{match-block.d.ts → match-node.d.ts} +8 -9
  59. package/src/lib/{match-block.js → match-node.js} +3 -4
  60. package/src/lib/{pending-block.d.ts → pending-node.d.ts} +28 -29
  61. package/src/lib/{pending-block.js → pending-node.js} +12 -13
  62. package/src/lib/project.d.ts +2 -3
  63. package/src/lib/project.js +2 -3
  64. package/src/lib/render/hydration-metadata.d.ts +0 -1
  65. package/src/lib/render/hydration-metadata.js +0 -1
  66. package/src/lib/render/hydration.d.ts +0 -1
  67. package/src/lib/render/hydration.js +0 -1
  68. package/src/lib/render/interpreter.d.ts +9 -8
  69. package/src/lib/render/interpreter.js +156 -81
  70. package/src/lib/render/server-style-collector.d.ts +0 -1
  71. package/src/lib/render/server-style-collector.js +0 -1
  72. package/src/lib/render/ssr-coordinator.d.ts +4 -2
  73. package/src/lib/render/ssr-coordinator.js +14 -3
  74. package/src/lib/render/string-dom.d.ts +0 -1
  75. package/src/lib/render/string-dom.js +48 -7
  76. package/src/lib/render/style-registry.d.ts +3 -2
  77. package/src/lib/render/style-registry.js +3 -2
  78. package/src/lib/render/style-scope.d.ts +0 -1
  79. package/src/lib/render/style-scope.js +0 -1
  80. package/src/lib/render/vnode.d.ts +117 -54
  81. package/src/lib/render/vnode.js +26 -27
  82. package/src/lib/security.d.ts +54 -0
  83. package/src/lib/security.js +502 -0
  84. package/src/lib/server-render.d.ts +12 -3
  85. package/src/lib/server-render.js +76 -17
  86. package/src/lib/start.d.ts +2 -3
  87. package/src/lib/start.js +3 -3
  88. package/src/lib/template-contract.d.ts +22 -23
  89. package/src/lib/template-contract.js +0 -1
  90. package/src/lib/template.d.ts +2 -3
  91. package/src/lib/template.js +2 -3
  92. package/src/lib/testing.d.ts +3 -4
  93. package/src/lib/testing.js +5 -6
  94. package/src/lib/types.d.ts +40 -28
  95. package/src/lib/types.js +3 -4
  96. package/testing/public-api.d.ts +0 -1
  97. package/testing/public-api.js +0 -1
  98. package/src/index.d.ts.map +0 -1
  99. package/src/index.js.map +0 -1
  100. package/src/lib/a11y-control.d.ts.map +0 -1
  101. package/src/lib/a11y-control.js.map +0 -1
  102. package/src/lib/a11y.d.ts.map +0 -1
  103. package/src/lib/a11y.js.map +0 -1
  104. package/src/lib/ai/ai-context-menu.d.ts.map +0 -1
  105. package/src/lib/ai/ai-context-menu.js.map +0 -1
  106. package/src/lib/ai/ai-send-dialog.d.ts.map +0 -1
  107. package/src/lib/ai/ai-send-dialog.js.map +0 -1
  108. package/src/lib/ai/send-context-to-ai.d.ts.map +0 -1
  109. package/src/lib/ai/send-context-to-ai.js.map +0 -1
  110. package/src/lib/assert-defined-input.d.ts.map +0 -1
  111. package/src/lib/assert-defined-input.js.map +0 -1
  112. package/src/lib/block.d.ts +0 -36
  113. package/src/lib/block.d.ts.map +0 -1
  114. package/src/lib/block.js.map +0 -1
  115. package/src/lib/bootstrap.d.ts.map +0 -1
  116. package/src/lib/bootstrap.js.map +0 -1
  117. package/src/lib/bridge.d.ts.map +0 -1
  118. package/src/lib/bridge.js.map +0 -1
  119. package/src/lib/component.d.ts.map +0 -1
  120. package/src/lib/component.js.map +0 -1
  121. package/src/lib/composition.d.ts.map +0 -1
  122. package/src/lib/composition.js.map +0 -1
  123. package/src/lib/craft-defaults.d.ts.map +0 -1
  124. package/src/lib/craft-defaults.js.map +0 -1
  125. package/src/lib/craft-host-tokens.d.ts.map +0 -1
  126. package/src/lib/craft-host-tokens.js.map +0 -1
  127. package/src/lib/craft-router-outlet.d.ts.map +0 -1
  128. package/src/lib/craft-router-outlet.js.map +0 -1
  129. package/src/lib/css-vars.d.ts.map +0 -1
  130. package/src/lib/css-vars.js.map +0 -1
  131. package/src/lib/css-vars.type.d.ts.map +0 -1
  132. package/src/lib/css-vars.type.js.map +0 -1
  133. package/src/lib/defer.d.ts.map +0 -1
  134. package/src/lib/defer.js.map +0 -1
  135. package/src/lib/directive.d.ts.map +0 -1
  136. package/src/lib/directive.js.map +0 -1
  137. package/src/lib/each-scheduling.d.ts +0 -59
  138. package/src/lib/each-scheduling.d.ts.map +0 -1
  139. package/src/lib/each-scheduling.js.map +0 -1
  140. package/src/lib/each.d.ts +0 -29
  141. package/src/lib/each.d.ts.map +0 -1
  142. package/src/lib/each.js.map +0 -1
  143. package/src/lib/factory-runtime.d.ts.map +0 -1
  144. package/src/lib/factory-runtime.js.map +0 -1
  145. package/src/lib/field-exception-block.d.ts.map +0 -1
  146. package/src/lib/field-exception-block.js.map +0 -1
  147. package/src/lib/host-runtime.d.ts.map +0 -1
  148. package/src/lib/host-runtime.js.map +0 -1
  149. package/src/lib/hydrate.d.ts.map +0 -1
  150. package/src/lib/hydrate.js.map +0 -1
  151. package/src/lib/hyperscript.d.ts.map +0 -1
  152. package/src/lib/hyperscript.js.map +0 -1
  153. package/src/lib/if-block.d.ts +0 -8
  154. package/src/lib/if-block.d.ts.map +0 -1
  155. package/src/lib/if-block.js.map +0 -1
  156. package/src/lib/locator.d.ts.map +0 -1
  157. package/src/lib/locator.js.map +0 -1
  158. package/src/lib/match-block.d.ts.map +0 -1
  159. package/src/lib/match-block.js.map +0 -1
  160. package/src/lib/pending-block.d.ts.map +0 -1
  161. package/src/lib/pending-block.js.map +0 -1
  162. package/src/lib/project.d.ts.map +0 -1
  163. package/src/lib/project.js.map +0 -1
  164. package/src/lib/render/hydration-metadata.d.ts.map +0 -1
  165. package/src/lib/render/hydration-metadata.js.map +0 -1
  166. package/src/lib/render/hydration.d.ts.map +0 -1
  167. package/src/lib/render/hydration.js.map +0 -1
  168. package/src/lib/render/interpreter.d.ts.map +0 -1
  169. package/src/lib/render/interpreter.js.map +0 -1
  170. package/src/lib/render/server-style-collector.d.ts.map +0 -1
  171. package/src/lib/render/server-style-collector.js.map +0 -1
  172. package/src/lib/render/ssr-coordinator.d.ts.map +0 -1
  173. package/src/lib/render/ssr-coordinator.js.map +0 -1
  174. package/src/lib/render/string-dom.d.ts.map +0 -1
  175. package/src/lib/render/string-dom.js.map +0 -1
  176. package/src/lib/render/style-registry.d.ts.map +0 -1
  177. package/src/lib/render/style-registry.js.map +0 -1
  178. package/src/lib/render/style-scope.d.ts.map +0 -1
  179. package/src/lib/render/style-scope.js.map +0 -1
  180. package/src/lib/render/vnode.d.ts.map +0 -1
  181. package/src/lib/render/vnode.js.map +0 -1
  182. package/src/lib/server-render.d.ts.map +0 -1
  183. package/src/lib/server-render.js.map +0 -1
  184. package/src/lib/start.d.ts.map +0 -1
  185. package/src/lib/start.js.map +0 -1
  186. package/src/lib/template-contract.d.ts.map +0 -1
  187. package/src/lib/template-contract.js.map +0 -1
  188. package/src/lib/template.d.ts.map +0 -1
  189. package/src/lib/template.js.map +0 -1
  190. package/src/lib/testing.d.ts.map +0 -1
  191. package/src/lib/testing.js.map +0 -1
  192. package/src/lib/types.d.ts.map +0 -1
  193. package/src/lib/types.js.map +0 -1
  194. package/testing/public-api.d.ts.map +0 -1
  195. package/testing/public-api.js.map +0 -1
@@ -1,13 +1,13 @@
1
1
  import type { AnyCraftException, CEmailException, CMaxException, CMaxLengthException, CMinException, CMinLengthException, CRequiredException, CraftField, FieldExceptionVisibility, FieldValidationCase } from '@craft-ts/core';
2
- import { COMPONENT_FIELD_EXCEPTION_BLOCK, FIELD_EXCEPTION_BLOCK_DIRECTIVE, type CraftDirective } from './types';
3
- import type { CraftNodeChildren, CraftNodeChildrenFieldExceptions } from './render/vnode';
4
- export { FIELD_EXCEPTION_BLOCK_DIRECTIVE } from './types';
5
- export type FieldExceptionBlockMode = 'first' | 'all';
6
- export type FieldExceptionBlockPosition = 'before' | 'after';
7
- export type FieldExceptionBlockOptions = {
2
+ import { COMPONENT_FIELD_ERROR_NODE, FIELD_ERROR_NODE_DIRECTIVE, type CraftDirective } from './types.js';
3
+ import type { CraftNodeChildren, CraftNodeChildrenFieldExceptions } from './render/vnode.js';
4
+ export { FIELD_ERROR_NODE_DIRECTIVE } from './types.js';
5
+ export type FieldErrorMode = 'first' | 'all';
6
+ export type FieldErrorPosition = 'before' | 'after';
7
+ export type FieldErrorOptions = {
8
8
  readonly visibility?: FieldExceptionVisibility;
9
- readonly mode?: FieldExceptionBlockMode;
10
- readonly position?: FieldExceptionBlockPosition;
9
+ readonly mode?: FieldErrorMode;
10
+ readonly position?: FieldErrorPosition;
11
11
  };
12
12
  export type FieldExceptionHandlerContext<Field extends CraftField<any> = CraftField<any>, Path extends string = string, Exception extends AnyCraftException = AnyCraftException> = {
13
13
  readonly field: Field;
@@ -58,39 +58,38 @@ type HasSeveralPaths<Cases> = true extends IsUnion<CasePath<Cases>> ? true : fal
58
58
  type HandlersAreLocal<Handlers> = Handlers[keyof Handlers] extends (...args: any[]) => any ? true : false;
59
59
  type ReachableHandlerKeys<Cases, Handlers> = HandlersAreLocal<Handlers> extends true ? HasSeveralPaths<Cases> extends true ? CaseIdentity<Cases> : CaseCode<Cases> : CaseIdentity<Cases>;
60
60
  type ProvidedHandlerKeys<Handlers> = HandlersAreLocal<Handlers> extends true ? HandlerIdentity<Handlers> : HandlerIdentity<Handlers>;
61
- export type FieldExceptionBlockExhaustiveCheck<Cases, Handlers> = [
61
+ export type FieldErrorExhaustiveCheck<Cases, Handlers> = [
62
62
  Exclude<ReachableHandlerKeys<Cases, Handlers>, ProvidedHandlerKeys<Handlers>>
63
63
  ] extends [never] ? [
64
64
  Exclude<ProvidedHandlerKeys<Handlers>, ReachableHandlerKeys<Cases, Handlers>>
65
65
  ] extends [never] ? unknown : {
66
- 'fieldExceptionBlock.exhaustive has handlers for unreachable field exceptions': Exclude<ProvidedHandlerKeys<Handlers>, ReachableHandlerKeys<Cases, Handlers>>;
66
+ 'fieldErrorNode.exhaustive has handlers for unreachable field exceptions': Exclude<ProvidedHandlerKeys<Handlers>, ReachableHandlerKeys<Cases, Handlers>>;
67
67
  } : {
68
- 'fieldExceptionBlock.exhaustive is missing handlers for field exceptions': Exclude<ReachableHandlerKeys<Cases, Handlers>, ProvidedHandlerKeys<Handlers>>;
68
+ 'fieldErrorNode.exhaustive is missing handlers for field exceptions': Exclude<ReachableHandlerKeys<Cases, Handlers>, ProvidedHandlerKeys<Handlers>>;
69
69
  };
70
- export type FieldExceptionBlockPartialCheck<Cases, Handlers> = [
70
+ export type FieldErrorPartialCheck<Cases, Handlers> = [
71
71
  Exclude<ProvidedHandlerKeys<Handlers>, ReachableHandlerKeys<Cases, Handlers>>
72
72
  ] extends [never] ? unknown : {
73
- 'fieldExceptionBlock.partial has handlers for unreachable field exceptions': Exclude<ProvidedHandlerKeys<Handlers>, ReachableHandlerKeys<Cases, Handlers>>;
73
+ 'fieldErrorNode.partial has handlers for unreachable field exceptions': Exclude<ProvidedHandlerKeys<Handlers>, ReachableHandlerKeys<Cases, Handlers>>;
74
74
  };
75
75
  type HandledIdentity<Cases, Handlers> = HandlersAreLocal<Handlers> extends true ? Cases extends FieldValidationCase<infer Path, any, infer Exception> ? Exception['_tag'] extends keyof Handlers ? `${Path}.${Exception['_tag']}` : never : never : HandlerIdentity<Handlers>;
76
76
  export type FieldValidationHandledIdentities<Cases, Handlers> = HandledIdentity<UnhandledFieldValidationCases<Cases>, Handlers> | ([UnhandledFieldValidationCases<Cases>] extends [never] ? HandlerIdentity<Handlers> : never);
77
77
  export type ResidualFieldValidationCases<Cases, Handlers> = Cases extends unknown ? CaseIdentity<Cases> extends HandledIdentity<Cases, Handlers> ? never : Cases : never;
78
78
  export type ResidualFieldValidationCasesByIdentity<Cases, Identities> = Cases extends unknown ? CaseIdentity<Cases> extends Identities ? never : Cases : never;
79
79
  export type FieldExceptionHandlerFieldExceptions<Handlers> = CraftNodeChildrenFieldExceptions<FieldExceptionHandlerChildren<Handlers[keyof Handlers]>>;
80
- export type FieldExceptionBlockDirective<Handlers extends FieldExceptionHandlers, Exhaustive extends boolean = boolean> = CraftDirective & {
81
- readonly [COMPONENT_FIELD_EXCEPTION_BLOCK]: true;
82
- readonly [FIELD_EXCEPTION_BLOCK_DIRECTIVE]: {
80
+ export type FieldErrorDirective<Handlers extends FieldExceptionHandlers, Exhaustive extends boolean = boolean> = CraftDirective & {
81
+ readonly [COMPONENT_FIELD_ERROR_NODE]: true;
82
+ readonly [FIELD_ERROR_NODE_DIRECTIVE]: {
83
83
  readonly handlers: Handlers;
84
84
  readonly exhaustive: Exhaustive;
85
- readonly options: Required<Pick<FieldExceptionBlockOptions, 'mode' | 'position'>> & Pick<FieldExceptionBlockOptions, 'visibility'>;
85
+ readonly options: Required<Pick<FieldErrorOptions, 'mode' | 'position'>> & Pick<FieldErrorOptions, 'visibility'>;
86
86
  };
87
87
  };
88
- declare function exhaustive<const Handlers extends LocalHandlerMap>(handlers: Handlers & ContextualLocalHandlers<Handlers>, options?: FieldExceptionBlockOptions): FieldExceptionBlockDirective<Handlers, true>;
89
- declare function exhaustive<const Handlers extends GroupedHandlerMap>(handlers: Handlers & ContextualGroupedHandlers<Handlers>, options?: FieldExceptionBlockOptions): FieldExceptionBlockDirective<Handlers, true>;
90
- declare function partial<const Handlers extends LocalHandlerMap>(handlers: Handlers & ContextualLocalHandlers<Handlers>, options?: FieldExceptionBlockOptions): FieldExceptionBlockDirective<Handlers, false>;
91
- declare function partial<const Handlers extends GroupedHandlerMap>(handlers: Handlers & ContextualGroupedHandlers<Handlers>, options?: FieldExceptionBlockOptions): FieldExceptionBlockDirective<Handlers, false>;
92
- export declare const fieldExceptionBlock: {
88
+ declare function exhaustive<const Handlers extends LocalHandlerMap>(handlers: Handlers & ContextualLocalHandlers<Handlers>, options?: FieldErrorOptions): FieldErrorDirective<Handlers, true>;
89
+ declare function exhaustive<const Handlers extends GroupedHandlerMap>(handlers: Handlers & ContextualGroupedHandlers<Handlers>, options?: FieldErrorOptions): FieldErrorDirective<Handlers, true>;
90
+ declare function partial<const Handlers extends LocalHandlerMap>(handlers: Handlers & ContextualLocalHandlers<Handlers>, options?: FieldErrorOptions): FieldErrorDirective<Handlers, false>;
91
+ declare function partial<const Handlers extends GroupedHandlerMap>(handlers: Handlers & ContextualGroupedHandlers<Handlers>, options?: FieldErrorOptions): FieldErrorDirective<Handlers, false>;
92
+ export declare const fieldErrorNode: {
93
93
  exhaustive: typeof exhaustive;
94
94
  partial: typeof partial;
95
95
  };
96
- //# sourceMappingURL=field-exception-block.d.ts.map
@@ -1,6 +1,6 @@
1
- import { CRAFT_DIRECTIVE, COMPONENT_FIELD_EXCEPTION_BLOCK, FIELD_EXCEPTION_BLOCK_DIRECTIVE, } from './types';
2
- export { FIELD_EXCEPTION_BLOCK_DIRECTIVE } from './types';
3
- function createFieldExceptionBlockDirective(name, handlers, options, exhaustive) {
1
+ import { CRAFT_DIRECTIVE, COMPONENT_FIELD_ERROR_NODE, FIELD_ERROR_NODE_DIRECTIVE, } from './types.js';
2
+ export { FIELD_ERROR_NODE_DIRECTIVE } from './types.js';
3
+ function createFieldErrorDirective(name, handlers, options, exhaustive) {
4
4
  const definition = {
5
5
  handlers,
6
6
  exhaustive,
@@ -24,21 +24,20 @@ function createFieldExceptionBlockDirective(name, handlers, options, exhaustive)
24
24
  },
25
25
  enumerable: false,
26
26
  });
27
- Object.defineProperty(directive, FIELD_EXCEPTION_BLOCK_DIRECTIVE, {
27
+ Object.defineProperty(directive, FIELD_ERROR_NODE_DIRECTIVE, {
28
28
  value: definition,
29
29
  enumerable: false,
30
30
  });
31
- Object.defineProperty(directive, COMPONENT_FIELD_EXCEPTION_BLOCK, {
31
+ Object.defineProperty(directive, COMPONENT_FIELD_ERROR_NODE, {
32
32
  value: true,
33
33
  enumerable: false,
34
34
  });
35
35
  return directive;
36
36
  }
37
37
  function exhaustive(handlers, options = {}) {
38
- return createFieldExceptionBlockDirective('fieldExceptionBlock.exhaustive', handlers, options, true);
38
+ return createFieldErrorDirective('fieldErrorNode.exhaustive', handlers, options, true);
39
39
  }
40
40
  function partial(handlers, options = {}) {
41
- return createFieldExceptionBlockDirective('fieldExceptionBlock.partial', handlers, options, false);
41
+ return createFieldErrorDirective('fieldErrorNode.partial', handlers, options, false);
42
42
  }
43
- export const fieldExceptionBlock = { exhaustive, partial };
44
- //# sourceMappingURL=field-exception-block.js.map
43
+ export const fieldErrorNode = { exhaustive, partial };
@@ -0,0 +1,28 @@
1
+ import type { CraftNodeChildrenDependencies, CraftNodeChildren, ForNode } from './render/vnode.js';
2
+ import type { InputValue } from './types.js';
3
+ import { YIELDABLE_VALUE } from '@craft-ts/core';
4
+ export interface ForOptions<Item, Key> {
5
+ readonly track: (item: Item, index: number) => Key;
6
+ readonly empty?: () => CraftNodeChildren;
7
+ }
8
+ type CallbackDependencies<Callback> = Callback extends (...args: any[]) => infer Output ? CraftNodeChildrenDependencies<Output> : {};
9
+ type EmptyDependencies<Options> = Options extends {
10
+ readonly empty?: infer Empty;
11
+ } ? CallbackDependencies<NonNullable<Empty>> : {};
12
+ type SourceName<Source> = Source extends {
13
+ readonly [YIELDABLE_VALUE]: infer Name extends string;
14
+ } ? Name : undefined;
15
+ type ForSource = readonly unknown[] | null | undefined | (() => readonly unknown[] | null | undefined) | Generator<unknown, readonly unknown[] | null | undefined, unknown> | (() => Generator<unknown, readonly unknown[] | null | undefined, unknown>);
16
+ type ForItemFromValue<Value> = [NonNullable<Value>] extends [never] ? never : NonNullable<Value> extends (...args: any[]) => infer Result ? ForItemFromValue<Result> : NonNullable<Value> extends Generator<any, infer Result, any> ? ForItemFromValue<Result> : NonNullable<Value> extends readonly (infer Item)[] ? Item : never;
17
+ type ForItem<Source> = [NonNullable<Source>] extends [never] ? unknown : ForItemFromValue<Source>;
18
+ type ForItemInput<Source> = InputValue<ForItem<Source>>;
19
+ export declare function forNode<Name extends string, Source extends ForSource, Key, Options extends ForOptions<NoInfer<ForItem<Source>>, Key>, ItemTemplate extends (item: NoInfer<ForItemInput<Source>>, index: number) => CraftNodeChildren>(source: Source & {
20
+ readonly [YIELDABLE_VALUE]: Name;
21
+ }, options: Options, itemTemplate: ItemTemplate): ForNode<ForItem<Source>, Key, CallbackDependencies<ItemTemplate> | EmptyDependencies<Options>, Name, ReturnType<ItemTemplate>, Options extends {
22
+ readonly empty?: (...args: any[]) => infer Empty;
23
+ } ? Empty : never>;
24
+ export declare function forNode<Source extends ForSource, Key, Options extends ForOptions<NoInfer<ForItem<Source>>, Key>, ItemTemplate extends (item: NoInfer<ForItemInput<Source>>, index: number) => CraftNodeChildren>(source: Source & ForSource, options: Options, itemTemplate: ItemTemplate): ForNode<ForItem<Source>, Key, CallbackDependencies<ItemTemplate> | EmptyDependencies<Options>, SourceName<Source>, ReturnType<ItemTemplate>, Options extends {
25
+ readonly empty?: (...args: any[]) => infer Empty;
26
+ } ? Empty : never>;
27
+ export type { ScheduleForDirective } from './for-scheduling.js';
28
+ export { FOR_SCHEDULER, FrameForScheduler, SyncForScheduler, createForScheduler, scheduleFor, } from './for-scheduling.js';
@@ -1,12 +1,12 @@
1
- import { pipeCraftNode } from './render/vnode';
1
+ import { pipeCraftNode } from './render/vnode.js';
2
2
  import { YIELDABLE_VALUE } from '@craft-ts/core';
3
- export function each(source, options, itemTemplate) {
3
+ export function forNode(source, options, itemTemplate) {
4
4
  const sourceName = typeof source === 'function' &&
5
5
  typeof source[YIELDABLE_VALUE] === 'string'
6
6
  ? source[YIELDABLE_VALUE]
7
7
  : undefined;
8
8
  const node = {
9
- kind: 'each',
9
+ kind: 'for',
10
10
  source: source,
11
11
  sourceName: sourceName,
12
12
  track: options.track,
@@ -19,5 +19,4 @@ export function each(source, options, itemTemplate) {
19
19
  });
20
20
  return node;
21
21
  }
22
- export { EACH_SCHEDULER, FrameEachScheduler, SyncEachScheduler, createEachScheduler, scheduleEach, } from './each-scheduling';
23
- //# sourceMappingURL=each.js.map
22
+ export { FOR_SCHEDULER, FrameForScheduler, SyncForScheduler, createForScheduler, scheduleFor, } from './for-scheduling.js';
@@ -0,0 +1,58 @@
1
+ import type { CraftDirective } from './types.js';
2
+ export type ForScheduleStrategy = 'sync' | 'frame';
3
+ export interface ForScheduleOptions {
4
+ readonly enabled?: boolean;
5
+ readonly strategy?: ForScheduleStrategy;
6
+ readonly frameBudgetMs?: number;
7
+ }
8
+ export interface ForSchedulePolicy {
9
+ readonly enabled: boolean;
10
+ readonly strategy: ForScheduleStrategy;
11
+ readonly frameBudgetMs: number;
12
+ }
13
+ export declare const SCHEDULE_FOR_DIRECTIVE: unique symbol;
14
+ export type ScheduleForDirective<Policy extends ForSchedulePolicy = ForSchedulePolicy> = CraftDirective & {
15
+ readonly [SCHEDULE_FOR_DIRECTIVE]: Policy;
16
+ };
17
+ type NormalizedPolicy<Options extends ForScheduleOptions> = {
18
+ readonly enabled: Options['enabled'] extends false ? false : true;
19
+ readonly strategy: Options['strategy'] extends ForScheduleStrategy ? Options['strategy'] : 'frame';
20
+ readonly frameBudgetMs: Options['frameBudgetMs'] extends number ? Options['frameBudgetMs'] : 4;
21
+ };
22
+ /**
23
+ * Adds progressive rendering metadata to an `each` block.
24
+ *
25
+ * This is registered through the normal Craft directive factory so it remains
26
+ * part of the directive authoring model. The renderer recognizes the marker
27
+ * before the generic directive path, so its identity does not imply a DOM
28
+ * wrapper or a CraftDirectiveRenderedNode.
29
+ */
30
+ export declare function scheduleFor<const Options extends ForScheduleOptions>(options?: Options): ScheduleForDirective<NormalizedPolicy<Options>>;
31
+ export interface CancelHandle {
32
+ cancel(): void;
33
+ }
34
+ export interface ForScheduler {
35
+ schedule(task: () => void): CancelHandle;
36
+ }
37
+ /** Injectable override used by deterministic tests and host integrations. */
38
+ export declare const FOR_SCHEDULER: import("../../../../dist/libs/core/src").InjectionToken<ForScheduler>;
39
+ export declare class SyncForScheduler implements ForScheduler {
40
+ schedule(task: () => void): CancelHandle;
41
+ }
42
+ export declare class FrameForScheduler implements ForScheduler {
43
+ private readonly queue;
44
+ private frame;
45
+ private destroyed;
46
+ private readonly frameBudgetMs;
47
+ constructor(frameBudgetMs?: number);
48
+ schedule(task: () => void): CancelHandle;
49
+ destroy(): void;
50
+ private requestFrame;
51
+ private flush;
52
+ private cancelFrame;
53
+ }
54
+ export declare function createForScheduler(policy: ForSchedulePolicy): ForScheduler & {
55
+ destroy?(): void;
56
+ };
57
+ export declare function isScheduleForDirective(value: unknown): value is ScheduleForDirective;
58
+ export {};
@@ -1,6 +1,6 @@
1
- import { InjectionToken } from './host-runtime';
2
- import { craftDirective } from './directive';
3
- export const SCHEDULE_EACH_DIRECTIVE = Symbol('schedule-each-directive');
1
+ import { InjectionToken } from './host-runtime.js';
2
+ import { craftDirective } from './directive.js';
3
+ export const SCHEDULE_FOR_DIRECTIVE = Symbol('schedule-for-directive');
4
4
  /**
5
5
  * Adds progressive rendering metadata to an `each` block.
6
6
  *
@@ -9,7 +9,7 @@ export const SCHEDULE_EACH_DIRECTIVE = Symbol('schedule-each-directive');
9
9
  * before the generic directive path, so its identity does not imply a DOM
10
10
  * wrapper or a CraftDirectiveRenderedNode.
11
11
  */
12
- export function scheduleEach(options = {}) {
12
+ export function scheduleFor(options = {}) {
13
13
  const frameBudgetMs = typeof options.frameBudgetMs === 'number' && options.frameBudgetMs > 0
14
14
  ? options.frameBudgetMs
15
15
  : 4;
@@ -18,23 +18,23 @@ export function scheduleEach(options = {}) {
18
18
  strategy: options.strategy ?? 'frame',
19
19
  frameBudgetMs,
20
20
  };
21
- const directive = craftDirective('scheduleEach', {}, (baseLogic) => baseLogic, (baseTemplate) => baseTemplate);
22
- Object.defineProperty(directive, SCHEDULE_EACH_DIRECTIVE, {
21
+ const directive = craftDirective('scheduleFor', {}, (baseLogic) => baseLogic, (baseTemplate) => baseTemplate);
22
+ Object.defineProperty(directive, SCHEDULE_FOR_DIRECTIVE, {
23
23
  value: Object.freeze(policy),
24
24
  enumerable: false,
25
25
  });
26
26
  return directive;
27
27
  }
28
28
  /** Injectable override used by deterministic tests and host integrations. */
29
- export const EACH_SCHEDULER = new InjectionToken('EACH_SCHEDULER');
29
+ export const FOR_SCHEDULER = new InjectionToken('FOR_SCHEDULER');
30
30
  const NOOP_CANCEL = { cancel: () => undefined };
31
- export class SyncEachScheduler {
31
+ export class SyncForScheduler {
32
32
  schedule(task) {
33
33
  task();
34
34
  return NOOP_CANCEL;
35
35
  }
36
36
  }
37
- export class FrameEachScheduler {
37
+ export class FrameForScheduler {
38
38
  queue = [];
39
39
  frame;
40
40
  destroyed = false;
@@ -106,15 +106,14 @@ function now() {
106
106
  ? globalThis.performance.now()
107
107
  : Date.now();
108
108
  }
109
- export function createEachScheduler(policy) {
109
+ export function createForScheduler(policy) {
110
110
  if (!policy.enabled || policy.strategy === 'sync') {
111
- return new SyncEachScheduler();
111
+ return new SyncForScheduler();
112
112
  }
113
- return new FrameEachScheduler(policy.frameBudgetMs);
113
+ return new FrameForScheduler(policy.frameBudgetMs);
114
114
  }
115
- export function isScheduleEachDirective(value) {
115
+ export function isScheduleForDirective(value) {
116
116
  return ((typeof value === 'function' ||
117
117
  (typeof value === 'object' && value !== null)) &&
118
- SCHEDULE_EACH_DIRECTIVE in value);
118
+ SCHEDULE_FOR_DIRECTIVE in value);
119
119
  }
120
- //# sourceMappingURL=each-scheduling.js.map
@@ -57,4 +57,3 @@ export declare const ɵEffectScheduler: CraftInjectionToken<{
57
57
  }>;
58
58
  export declare const ɵINJECTOR_SCOPE: CraftInjectionToken<string>;
59
59
  export {};
60
- //# sourceMappingURL=host-runtime.d.ts.map
@@ -13,4 +13,3 @@ export const signal = ɵsignal;
13
13
  export const untracked = ɵuntracked;
14
14
  export const ɵEffectScheduler = CraftEffectScheduler;
15
15
  export const ɵINJECTOR_SCOPE = CraftInjectorScope;
16
- //# sourceMappingURL=host-runtime.js.map
@@ -1,6 +1,6 @@
1
1
  import { type CraftTransferSnapshot } from '@craft-ts/core';
2
- import { type CraftAppRef, type BootstrapCraftOptions } from './bootstrap';
3
- import { type HydrationMismatchError } from './render/hydration';
2
+ import { type CraftAppRef, type BootstrapCraftOptions } from './bootstrap.js';
3
+ import { type HydrationMismatchError } from './render/hydration.js';
4
4
  export type HydrateCraftOptions = BootstrapCraftOptions & Readonly<{
5
5
  snapshot?: CraftTransferSnapshot;
6
6
  props?: object;
@@ -12,4 +12,3 @@ export type HydratedCraftAppRef = CraftAppRef & Readonly<{
12
12
  }>;
13
13
  /** Claims server DOM, restores state, then attaches bindings and listeners. */
14
14
  export declare function hydrateCraft(options: HydrateCraftOptions): HydratedCraftAppRef;
15
- //# sourceMappingURL=hydrate.d.ts.map
@@ -1,25 +1,27 @@
1
- import { CRAFT_PLATFORM, CRAFT_PRIMITIVE_REGISTRY, createBrowserDomAdapter, createBrowserPlatform, createCraftRenderIdentity, primeCraftTransferSnapshot, } from '@craft-ts/core';
2
- import { ɵcreateCraftApplicationInjector, ɵrunCraftAppInitializers, } from './bootstrap';
3
- import { CRAFT_ROOT_COMPONENT } from './craft-host-tokens';
4
- import { CRAFT_STYLE_REGISTRY, ɵfallbackCraftStyleRegistry, } from './render/style-registry';
5
- import { mountInterpretedComponentWithOptions, } from './render/interpreter';
6
- import { createHydrationCursor, } from './render/hydration';
7
- import { CRAFT_TRANSFER_SCRIPT_ID } from './server-render';
8
- import { CRAFT_COMPONENT } from './types';
1
+ import { CRAFT_HYDRATION_RUNTIME, CRAFT_PLATFORM, CRAFT_PRIMITIVE_REGISTRY, CRAFT_SECURITY_POLICY, CraftCspNonce, createCraftSecurityPolicy, createBrowserDomAdapter, createBrowserPlatform, createCraftRenderIdentity, primeCraftTransferSnapshot, } from '@craft-ts/core';
2
+ import { ɵcreateCraftApplicationInjector, ɵrunCraftAppInitializers, } from './bootstrap.js';
3
+ import { CRAFT_ROOT_COMPONENT } from './craft-host-tokens.js';
4
+ import { CRAFT_STYLE_REGISTRY, createCraftStyleRegistry, } from './render/style-registry.js';
5
+ import { mountInterpretedComponentWithOptions, } from './render/interpreter.js';
6
+ import { createHydrationCursor, } from './render/hydration.js';
7
+ import { CRAFT_TRANSFER_SCRIPT_ID } from './server-render.js';
8
+ import { CRAFT_COMPONENT } from './types.js';
9
9
  /** Claims server DOM, restores state, then attaches bindings and listeners. */
10
10
  export function hydrateCraft(options) {
11
11
  const host = options.host ?? document.querySelector('craft-root') ?? document.body;
12
12
  const win = host.ownerDocument.defaultView ?? window;
13
13
  const platform = createBrowserPlatform(win, { hydrating: true });
14
+ const hydrationRuntime = createHydrationRuntime();
14
15
  const injector = ɵcreateCraftApplicationInjector(options.config, [
15
16
  { provide: CRAFT_PLATFORM, useValue: platform },
16
- ]);
17
+ { provide: CRAFT_HYDRATION_RUNTIME, useValue: hydrationRuntime },
18
+ ], options.mode);
17
19
  const mismatches = [];
18
20
  let mounted;
19
21
  try {
20
22
  const snapshot = options.snapshot ?? readTransferSnapshot(host.ownerDocument);
21
23
  if (snapshot) {
22
- primeCraftTransferSnapshot(injector.get(CRAFT_PRIMITIVE_REGISTRY), snapshot);
24
+ primeCraftTransferSnapshot(injector.get(CRAFT_PRIMITIVE_REGISTRY), snapshot, injector.get(CRAFT_SECURITY_POLICY, createCraftSecurityPolicy()).transfer);
23
25
  }
24
26
  ɵrunCraftAppInitializers(injector);
25
27
  const root = injector.get(CRAFT_ROOT_COMPONENT);
@@ -36,7 +38,9 @@ export function hydrateCraft(options) {
36
38
  (typeof ShadowRoot !== 'undefined' && rootNode instanceof ShadowRoot)
37
39
  ? rootNode
38
40
  : host.ownerDocument;
39
- const styles = injector.get(CRAFT_STYLE_REGISTRY, ɵfallbackCraftStyleRegistry);
41
+ const styles = injector.get(CRAFT_STYLE_REGISTRY, createCraftStyleRegistry({
42
+ nonce: injector.get(CraftCspNonce, null) ?? undefined,
43
+ }));
40
44
  mounted = mountInterpretedComponentWithOptions(root, host, injector, (options.props ?? {}), {
41
45
  renderer: createBrowserDomAdapter(host.ownerDocument),
42
46
  mode: 'hydrate',
@@ -46,13 +50,23 @@ export function hydrateCraft(options) {
46
50
  styleRoot,
47
51
  styles,
48
52
  });
49
- cursor.finish();
50
- platform.hydrating = false;
51
- if (options.removeTransferScript !== false) {
52
- host.ownerDocument.getElementById(CRAFT_TRANSFER_SCRIPT_ID)?.remove();
53
+ const finishHydration = () => {
54
+ cursor.finish();
55
+ platform.hydrating = false;
56
+ if (options.removeTransferScript !== false) {
57
+ host.ownerDocument.getElementById(CRAFT_TRANSFER_SCRIPT_ID)?.remove();
58
+ }
59
+ for (const style of host.ownerDocument.querySelectorAll('style[data-craft-ssr]')) {
60
+ style.remove();
61
+ }
62
+ };
63
+ if (hydrationRuntime.hasPending()) {
64
+ void hydrationRuntime.whenSettled().then(() => {
65
+ queueMicrotask(finishHydration);
66
+ });
53
67
  }
54
- for (const style of host.ownerDocument.querySelectorAll('style[data-craft-ssr]')) {
55
- style.remove();
68
+ else {
69
+ finishHydration();
56
70
  }
57
71
  }
58
72
  catch (error) {
@@ -70,10 +84,35 @@ export function hydrateCraft(options) {
70
84
  },
71
85
  };
72
86
  }
87
+ function createHydrationRuntime() {
88
+ let pending = 0;
89
+ let waiters = [];
90
+ const settle = () => {
91
+ pending -= 1;
92
+ if (pending !== 0)
93
+ return;
94
+ const current = waiters;
95
+ waiters = [];
96
+ current.forEach((resolve) => resolve());
97
+ };
98
+ return {
99
+ track(_source, work) {
100
+ pending += 1;
101
+ Promise.resolve(work).then(settle, settle);
102
+ },
103
+ hasPending() {
104
+ return pending > 0;
105
+ },
106
+ whenSettled() {
107
+ if (pending === 0)
108
+ return Promise.resolve();
109
+ return new Promise((resolve) => waiters.push(resolve));
110
+ },
111
+ };
112
+ }
73
113
  function readTransferSnapshot(documentRef) {
74
114
  const script = documentRef.getElementById(CRAFT_TRANSFER_SCRIPT_ID);
75
115
  if (!script?.textContent)
76
116
  return undefined;
77
117
  return JSON.parse(script.textContent);
78
118
  }
79
- //# sourceMappingURL=hydrate.js.map
@@ -1,4 +1,4 @@
1
- import type { CraftNodeChildrenDependencies, CraftNodeChildrenCssVars, CraftNodeChildrenHandledExceptionCodes, CraftNodeChildren, ElementNode, RequireCaughtComponentExceptions } from './render/vnode';
1
+ import type { CraftNodeChildrenDependencies, CraftNodeChildrenCssVars, CraftNodeChildrenHandledExceptionCodes, CraftNodeChildren, ElementNode, RequireCaughtComponentExceptions } from './render/vnode.js';
2
2
  import type { Yieldable } from '@craft-ts/core';
3
3
  type ClassValueResult = string | null | undefined | false | readonly ClassValueResult[] | Readonly<Record<string, boolean | null | undefined>>;
4
4
  /** Properties that can be supplied to a component's host element. */
@@ -145,4 +145,3 @@ export declare const area: RequiredAltTagHelper<"area">;
145
145
  /** SVG is not an HTMLElement; the helper still produces a typed Craft element node. */
146
146
  export declare const svg: TagHelper<keyof HTMLElementTagNameMap>;
147
147
  export {};
148
- //# sourceMappingURL=hyperscript.d.ts.map
@@ -1,4 +1,4 @@
1
- import { pipeCraftNode } from './render/vnode';
1
+ import { pipeCraftNode } from './render/vnode.js';
2
2
  function looksLikeChildren(value) {
3
3
  return (value === null ||
4
4
  value === undefined ||
@@ -93,4 +93,3 @@ export const iframe = tagHelper('iframe');
93
93
  export const area = tagHelper('area');
94
94
  /** SVG is not an HTMLElement; the helper still produces a typed Craft element node. */
95
95
  export const svg = tagHelper('svg');
96
- //# sourceMappingURL=hyperscript.js.map
@@ -0,0 +1,7 @@
1
+ import { type NamedYieldableValue } from '@craft-ts/core';
2
+ import type { CraftNodeChildren, CraftNodeChildrenDependencies, IfNode } from './render/vnode.js';
3
+ type Condition<Name extends string> = NamedYieldableValue<Name, () => unknown>;
4
+ type BranchDependencies<Branch> = Branch extends (...args: any[]) => infer Output ? CraftNodeChildrenDependencies<Output> : {};
5
+ /** Creates a conditionally rendered Craft template block. */
6
+ export declare function ifNode<Name extends string, TrueBranch extends () => CraftNodeChildren, FalseBranch extends (() => CraftNodeChildren) | undefined = undefined>(condition: Condition<Name>, whenTrue: TrueBranch, whenFalse?: FalseBranch): IfNode<Name, BranchDependencies<TrueBranch> | BranchDependencies<FalseBranch>, ReturnType<TrueBranch>, FalseBranch extends (...args: any[]) => infer False ? False : never>;
7
+ export {};
@@ -1,9 +1,9 @@
1
1
  import { YIELDABLE_VALUE } from '@craft-ts/core';
2
2
  /** Creates a conditionally rendered Craft template block. */
3
- export function ifBlock(condition, whenTrue, whenFalse) {
3
+ export function ifNode(condition, whenTrue, whenFalse) {
4
4
  const conditionName = condition[YIELDABLE_VALUE];
5
5
  if (typeof conditionName !== 'string') {
6
- throw new Error('ifBlock(...) requires a named Craft reactive value as its condition.');
6
+ throw new Error('ifNode(...) requires a named Craft reactive value as its condition.');
7
7
  }
8
8
  return {
9
9
  kind: 'if',
@@ -13,4 +13,3 @@ export function ifBlock(condition, whenTrue, whenFalse) {
13
13
  whenFalse: whenFalse,
14
14
  };
15
15
  }
16
- //# sourceMappingURL=if-block.js.map
@@ -1,6 +1,6 @@
1
- import type { CraftComponent, ComponentTemplateOf } from './types';
1
+ import type { CraftComponent, ComponentTemplateOf } from './types.js';
2
2
  import { YIELDABLE_VALUE } from '@craft-ts/core';
3
- import type { CraftDirectiveNode, ElementNodeBase, CraftNodeChildren } from './render/vnode';
3
+ import type { CraftDirectiveNode, ElementNodeBase, CraftNodeChildren } from './render/vnode.js';
4
4
  type IsAny<Value> = 0 extends 1 & Value ? true : false;
5
5
  type LiteralString<Value> = Value extends string ? string extends Value ? never : Value : never;
6
6
  type ClassTokens<Value> = [Value] extends [string] ? LiteralString<Value> extends infer Text extends string ? Text extends '' ? never : Text extends `${infer Head} ${infer Tail}` ? Head extends '' ? ClassTokens<Tail> : Head | ClassTokens<Tail> : Text : never : [Value] extends [readonly unknown[]] ? ClassTokens<Value[number]> : [Value] extends [Readonly<Record<string, boolean | null | undefined>>] ? string extends keyof Value ? never : Extract<keyof Value, string> : never;
@@ -53,7 +53,7 @@ type VisitContentNode<Node, Optional extends boolean, Repeated extends boolean,
53
53
  ...Depth,
54
54
  unknown
55
55
  ]> : Node extends {
56
- readonly kind: 'each';
56
+ readonly kind: 'for';
57
57
  readonly itemTemplate: (...args: any[]) => infer ItemChildren;
58
58
  readonly empty?: () => infer EmptyChildren;
59
59
  } ? VisitContentNode<ItemChildren | EmptyChildren, true, true, Seen, [
@@ -91,7 +91,7 @@ type VisitOptionalTag<Node, Tag extends keyof HTMLElementTagNameMap, Optional ex
91
91
  ...Depth,
92
92
  unknown
93
93
  ]> : Node extends {
94
- readonly kind: 'each';
94
+ readonly kind: 'for';
95
95
  readonly itemTemplate: (...args: any[]) => infer ItemChildren;
96
96
  readonly empty?: () => infer EmptyChildren;
97
97
  } ? VisitOptionalTag<ItemChildren | EmptyChildren, Tag, true, Seen, [
@@ -116,7 +116,7 @@ type VisitNode<Node, Depth extends readonly unknown[], Optional extends boolean,
116
116
  readonly whenTrue: () => infer TrueChildren;
117
117
  readonly whenFalse?: () => infer FalseChildren;
118
118
  } ? VisitChildren<TrueChildren | FalseChildren, NextDepth<Depth>, true, Repeated, Seen> : Node extends {
119
- readonly kind: 'each';
119
+ readonly kind: 'for';
120
120
  readonly itemTemplate: (...args: any[]) => infer ItemChildren;
121
121
  readonly empty?: () => infer EmptyChildren;
122
122
  } ? VisitChildren<ItemChildren | EmptyChildren, NextDepth<Depth>, true, true, Seen> : Node extends {
@@ -167,4 +167,3 @@ export declare const CRAFT_LOCATOR_CONTENT_NAMES: unique symbol;
167
167
  export declare function directCraftContentNames(children: CraftNodeChildren): readonly string[];
168
168
  export declare function findCraftTemplateLocator(host: Element, template: CraftNodeChildren, tag: string, criteria: RuntimeLocatorCriteria): Element | undefined;
169
169
  export {};
170
- //# sourceMappingURL=locator.d.ts.map
@@ -97,7 +97,7 @@ function runtimeTemplateMatches(children, tag, criteria, optional = false, repea
97
97
  ? runtimeTemplateMatches(node.whenFalse(), tag, criteria, true, repeated, seen)
98
98
  : []));
99
99
  break;
100
- case 'each':
100
+ case 'for':
101
101
  matches.push(...runtimeTemplateMatches(node.itemTemplate(undefined, 0), tag, criteria, true, true, seen));
102
102
  if (node.empty) {
103
103
  matches.push(...runtimeTemplateMatches(node.empty(), tag, criteria, true, true, seen));
@@ -148,4 +148,3 @@ export function findCraftTemplateLocator(host, template, tag, criteria) {
148
148
  }
149
149
  return matches[0];
150
150
  }
151
- //# sourceMappingURL=locator.js.map
@@ -1,10 +1,10 @@
1
1
  import type { YieldableReactiveValue } from '@craft-ts/core';
2
- import type { CraftNodeChildren, CraftNodeChildrenDependencies, MatchBlockNode } from './render/vnode';
2
+ import type { CraftNodeChildren, CraftNodeChildrenDependencies, MatchNode } from './render/vnode.js';
3
3
  type ExceptionCode<Value extends object, Key extends keyof Value> = Extract<Value[Key], string | number>;
4
4
  type ExceptionHandlerMap<Value extends object, Key extends keyof Value> = {
5
5
  [Code in ExceptionCode<Value, Key>]: (exception: Extract<Value, Record<Key, Code>>) => CraftNodeChildren;
6
6
  };
7
- type MatchBlockDependencies<Handlers> = Handlers extends Record<string, (...args: any[]) => infer Output> ? CraftNodeChildrenDependencies<Output> : Record<never, never>;
7
+ type MatchDependencies<Handlers> = Handlers extends Record<string, (...args: any[]) => infer Output> ? CraftNodeChildrenDependencies<Output> : Record<never, never>;
8
8
  type ExceptionKey<Value extends object> = {
9
9
  [K in keyof Value]-?: Value[K] extends string | number ? K : never;
10
10
  }[keyof Value];
@@ -19,20 +19,19 @@ type GeneratorSourceValue<Source> = Source extends (...args: any[]) => Generator
19
19
  * discriminated-union matching without importing the component template
20
20
  * layer into core's component primitives.
21
21
  */
22
- declare function exhaustive<Source extends ((...args: any[]) => Generator<any, any, any>) | undefined, Value extends object = GeneratorSourceValue<Source>, Key extends ExceptionKey<Value> = ExceptionKey<Value>, Handlers extends ExceptionHandlerMap<Value, Key> = ExceptionHandlerMap<Value, Key>>(source: Source, key: Key, handlers: Handlers): MatchBlockNode<MatchBlockDependencies<Handlers>, NonNullable<Source>, ReturnType<Handlers[ExceptionCode<Value, Key>]>, Extract<ExceptionCode<Value, Key>, string>>;
23
- declare function exhaustive<Value extends object, Key extends ExceptionKey<Value>, Handlers extends ExceptionHandlerMap<Value, Key>>(source: YieldableReactiveValue<Value>, key: Key, handlers: Handlers): MatchBlockNode<MatchBlockDependencies<Handlers>, YieldableReactiveValue<Value>, ReturnType<Handlers[ExceptionCode<Value, Key>]>, Extract<ExceptionCode<Value, Key>, string>>;
24
- declare function exhaustive<Value extends object, Key extends ExceptionKey<Value>, Handlers extends ExceptionHandlerMap<Value, Key>>(source: (() => Value | undefined) | Value, key: Key, handlers: Handlers): MatchBlockNode<MatchBlockDependencies<Handlers>, (() => Value | undefined) | Value, ReturnType<Handlers[ExceptionCode<Value, Key>]>, Extract<ExceptionCode<Value, Key>, string>>;
25
- declare function exhaustive<Value extends ScalarValue, Handlers extends ScalarHandlerMap<Value>>(source: YieldableReactiveValue<Value>, handlers: Handlers): MatchBlockNode<MatchBlockDependencies<Handlers>, YieldableReactiveValue<{
22
+ declare function exhaustive<Source extends ((...args: any[]) => Generator<any, any, any>) | undefined, Value extends object = GeneratorSourceValue<Source>, Key extends ExceptionKey<Value> = ExceptionKey<Value>, Handlers extends ExceptionHandlerMap<Value, Key> = ExceptionHandlerMap<Value, Key>>(source: Source, key: Key, handlers: Handlers): MatchNode<MatchDependencies<Handlers>, NonNullable<Source>, ReturnType<Handlers[ExceptionCode<Value, Key>]>, Extract<ExceptionCode<Value, Key>, string>>;
23
+ declare function exhaustive<Value extends object, Key extends ExceptionKey<Value>, Handlers extends ExceptionHandlerMap<Value, Key>>(source: YieldableReactiveValue<Value>, key: Key, handlers: Handlers): MatchNode<MatchDependencies<Handlers>, YieldableReactiveValue<Value>, ReturnType<Handlers[ExceptionCode<Value, Key>]>, Extract<ExceptionCode<Value, Key>, string>>;
24
+ declare function exhaustive<Value extends object, Key extends ExceptionKey<Value>, Handlers extends ExceptionHandlerMap<Value, Key>>(source: (() => Value | undefined) | Value, key: Key, handlers: Handlers): MatchNode<MatchDependencies<Handlers>, (() => Value | undefined) | Value, ReturnType<Handlers[ExceptionCode<Value, Key>]>, Extract<ExceptionCode<Value, Key>, string>>;
25
+ declare function exhaustive<Value extends ScalarValue, Handlers extends ScalarHandlerMap<Value>>(source: YieldableReactiveValue<Value>, handlers: Handlers): MatchNode<MatchDependencies<Handlers>, YieldableReactiveValue<{
26
26
  value: Value;
27
27
  }>, ReturnType<Handlers[Extract<Value, string | number>]>, Extract<Value, string>>;
28
- declare function exhaustive<Value extends ScalarValue, Handlers extends ScalarHandlerMap<Value>>(source: (() => Value | Generator<unknown, Value, unknown>) | Value, handlers: Handlers): MatchBlockNode<MatchBlockDependencies<Handlers>, (() => {
28
+ declare function exhaustive<Value extends ScalarValue, Handlers extends ScalarHandlerMap<Value>>(source: (() => Value | Generator<unknown, Value, unknown>) | Value, handlers: Handlers): MatchNode<MatchDependencies<Handlers>, (() => {
29
29
  value: Value;
30
30
  }) | {
31
31
  value: Value;
32
32
  }, ReturnType<Handlers[Extract<Value, string | number>]>, Extract<Value, string>>;
33
33
  /** Reactive template counterpart of discriminated-union matching. */
34
- export declare const matchBlock: {
34
+ export declare const matchNode: {
35
35
  exhaustive: typeof exhaustive;
36
36
  };
37
37
  export {};
38
- //# sourceMappingURL=match-block.d.ts.map
@@ -8,7 +8,7 @@ function exhaustive(source, keyOrHandlers, maybeHandlers) {
8
8
  })
9
9
  : { value: source };
10
10
  return {
11
- kind: 'match-block',
11
+ kind: 'match',
12
12
  source: scalarSource,
13
13
  key: 'value',
14
14
  handlers: Object.fromEntries(Object.entries(handlers).map(([code, handler]) => [
@@ -18,12 +18,11 @@ function exhaustive(source, keyOrHandlers, maybeHandlers) {
18
18
  };
19
19
  }
20
20
  return {
21
- kind: 'match-block',
21
+ kind: 'match',
22
22
  source,
23
23
  key: keyOrHandlers,
24
24
  handlers: maybeHandlers,
25
25
  };
26
26
  }
27
27
  /** Reactive template counterpart of discriminated-union matching. */
28
- export const matchBlock = { exhaustive };
29
- //# sourceMappingURL=match-block.js.map
28
+ export const matchNode = { exhaustive };