@jirathip-dev/blocks 0.0.0-stage → 2.2.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.
Files changed (191) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +67 -2
  3. package/package.json +46 -4
  4. package/web/dist/blocks.css +1 -0
  5. package/web/dist/blocks.js +10 -0
  6. package/web/dist/blocks.scoped.css +1 -0
  7. package/web/dist/core.js +9749 -0
  8. package/web/dist/import.js +2 -0
  9. package/web/dist/react.js +4073 -0
  10. package/web/dist/scan.js +22 -0
  11. package/web/dist/types/react/src/act.d.ts +71 -0
  12. package/web/dist/types/react/src/arrange.d.ts +10 -0
  13. package/web/dist/types/react/src/block.d.ts +41 -0
  14. package/web/dist/types/react/src/draw.d.ts +34 -0
  15. package/web/dist/types/react/src/fields/_input.d.ts +16 -0
  16. package/web/dist/types/react/src/fields/_view.d.ts +27 -0
  17. package/web/dist/types/react/src/fields/picker.d.ts +3 -0
  18. package/web/dist/types/react/src/fields/scan.d.ts +3 -0
  19. package/web/dist/types/react/src/fields/search.d.ts +14 -0
  20. package/web/dist/types/react/src/fields/secret.d.ts +3 -0
  21. package/web/dist/types/react/src/fields/slider.d.ts +5 -0
  22. package/web/dist/types/react/src/fields/text.d.ts +3 -0
  23. package/web/dist/types/react/src/fields/toggle.d.ts +3 -0
  24. package/web/dist/types/react/src/fields/upload.d.ts +7 -0
  25. package/web/dist/types/react/src/gen/fields.d.ts +2 -0
  26. package/web/dist/types/react/src/gen/views.d.ts +2 -0
  27. package/web/dist/types/react/src/h.d.ts +7 -0
  28. package/web/dist/types/react/src/index.d.ts +3 -0
  29. package/web/dist/types/react/src/island.d.ts +7 -0
  30. package/web/dist/types/react/src/kinds/button.d.ts +5 -0
  31. package/web/dist/types/react/src/kinds/card.d.ts +5 -0
  32. package/web/dist/types/react/src/kinds/chips.d.ts +5 -0
  33. package/web/dist/types/react/src/kinds/choice.d.ts +5 -0
  34. package/web/dist/types/react/src/kinds/composer.d.ts +5 -0
  35. package/web/dist/types/react/src/kinds/config.d.ts +5 -0
  36. package/web/dist/types/react/src/kinds/diagram.d.ts +7 -0
  37. package/web/dist/types/react/src/kinds/diff.d.ts +7 -0
  38. package/web/dist/types/react/src/kinds/editor.d.ts +5 -0
  39. package/web/dist/types/react/src/kinds/form.d.ts +22 -0
  40. package/web/dist/types/react/src/kinds/hero.d.ts +5 -0
  41. package/web/dist/types/react/src/kinds/images.d.ts +5 -0
  42. package/web/dist/types/react/src/kinds/import.d.ts +5 -0
  43. package/web/dist/types/react/src/kinds/list.d.ts +6 -0
  44. package/web/dist/types/react/src/kinds/media.d.ts +6 -0
  45. package/web/dist/types/react/src/kinds/message.d.ts +5 -0
  46. package/web/dist/types/react/src/kinds/modal.d.ts +5 -0
  47. package/web/dist/types/react/src/kinds/nav.d.ts +5 -0
  48. package/web/dist/types/react/src/kinds/pages.d.ts +5 -0
  49. package/web/dist/types/react/src/kinds/prose.d.ts +5 -0
  50. package/web/dist/types/react/src/kinds/row.d.ts +5 -0
  51. package/web/dist/types/react/src/kinds/run.d.ts +5 -0
  52. package/web/dist/types/react/src/kinds/scene.d.ts +5 -0
  53. package/web/dist/types/react/src/kinds/screen.d.ts +5 -0
  54. package/web/dist/types/react/src/kinds/secret.d.ts +5 -0
  55. package/web/dist/types/react/src/kinds/section.d.ts +5 -0
  56. package/web/dist/types/react/src/kinds/sheet.d.ts +1 -0
  57. package/web/dist/types/react/src/kinds/sidebar.d.ts +5 -0
  58. package/web/dist/types/react/src/kinds/stat.d.ts +5 -0
  59. package/web/dist/types/react/src/kinds/steps.d.ts +7 -0
  60. package/web/dist/types/react/src/kinds/table.d.ts +5 -0
  61. package/web/dist/types/react/src/kinds/text.d.ts +5 -0
  62. package/web/dist/types/react/src/kinds/timeline.d.ts +5 -0
  63. package/web/dist/types/react/src/kinds/tool.d.ts +5 -0
  64. package/web/dist/types/react/src/kinds/web.d.ts +5 -0
  65. package/web/dist/types/react/src/view.d.ts +14 -0
  66. package/web/dist/types/src/arrange.d.ts +8 -0
  67. package/web/dist/types/src/behave.d.ts +1 -0
  68. package/web/dist/types/src/core/apply.d.ts +7 -0
  69. package/web/dist/types/src/core/built.d.ts +7 -0
  70. package/web/dist/types/src/core/check.d.ts +5 -0
  71. package/web/dist/types/src/core/code.d.ts +7 -0
  72. package/web/dist/types/src/core/eval.d.ts +25 -0
  73. package/web/dist/types/src/core/field/files.d.ts +53 -0
  74. package/web/dist/types/src/core/field/match.d.ts +15 -0
  75. package/web/dist/types/src/core/field/slider.d.ts +3 -0
  76. package/web/dist/types/src/core/gate.d.ts +7 -0
  77. package/web/dist/types/src/core/gesture.d.ts +53 -0
  78. package/web/dist/types/src/core/index.d.ts +21 -0
  79. package/web/dist/types/src/core/kind/boxplot.d.ts +7 -0
  80. package/web/dist/types/src/core/kind/chart.d.ts +18 -0
  81. package/web/dist/types/src/core/kind/diagram.d.ts +44 -0
  82. package/web/dist/types/src/core/kind/import.d.ts +40 -0
  83. package/web/dist/types/src/core/kind/list.d.ts +3 -0
  84. package/web/dist/types/src/core/kind/media.d.ts +36 -0
  85. package/web/dist/types/src/core/kind/message.d.ts +4 -0
  86. package/web/dist/types/src/core/kind/modal.d.ts +23 -0
  87. package/web/dist/types/src/core/kind/plot.d.ts +22 -0
  88. package/web/dist/types/src/core/kind/prose.d.ts +5 -0
  89. package/web/dist/types/src/core/kind/sidebar.d.ts +7 -0
  90. package/web/dist/types/src/core/kind/table.d.ts +26 -0
  91. package/web/dist/types/src/core/kind/timeline.d.ts +28 -0
  92. package/web/dist/types/src/core/layout.d.ts +9 -0
  93. package/web/dist/types/src/core/look.d.ts +11 -0
  94. package/web/dist/types/src/core/nonce.d.ts +1 -0
  95. package/web/dist/types/src/core/share.d.ts +1 -0
  96. package/web/dist/types/src/core/table.d.ts +6 -0
  97. package/web/dist/types/src/core/text.d.ts +6 -0
  98. package/web/dist/types/src/core/tree.d.ts +12 -0
  99. package/web/dist/types/src/dump.d.ts +2 -0
  100. package/web/dist/types/src/edits.d.ts +18 -0
  101. package/web/dist/types/src/gen/builders.d.ts +64 -0
  102. package/web/dist/types/src/gen/fields.d.ts +2 -0
  103. package/web/dist/types/src/gen/hooks.d.ts +11 -0
  104. package/web/dist/types/src/gen/kinds.d.ts +9 -0
  105. package/web/dist/types/src/gen/layout.d.ts +19 -0
  106. package/web/dist/types/src/gen/schemes.d.ts +73 -0
  107. package/web/dist/types/src/gen/shapes.d.ts +61 -0
  108. package/web/dist/types/src/gen/types.d.ts +1517 -0
  109. package/web/dist/types/src/gen/words-import.d.ts +1 -0
  110. package/web/dist/types/src/gen/words.d.ts +1 -0
  111. package/web/dist/types/src/gesture.d.ts +54 -0
  112. package/web/dist/types/src/island.d.ts +3 -0
  113. package/web/dist/types/src/lazy/import.d.ts +13 -0
  114. package/web/dist/types/src/modal.d.ts +14 -0
  115. package/web/dist/types/src/motion.d.ts +2 -0
  116. package/web/dist/types/src/paging.d.ts +2 -0
  117. package/web/dist/types/src/patch.d.ts +17 -0
  118. package/web/dist/types/src/render/act.d.ts +9 -0
  119. package/web/dist/types/src/render/block.d.ts +5 -0
  120. package/web/dist/types/src/render/ctx.d.ts +34 -0
  121. package/web/dist/types/src/render/dom.d.ts +16 -0
  122. package/web/dist/types/src/render/field/_input.d.ts +3 -0
  123. package/web/dist/types/src/render/field/_view.d.ts +26 -0
  124. package/web/dist/types/src/render/field/picker.d.ts +3 -0
  125. package/web/dist/types/src/render/field/scan.d.ts +3 -0
  126. package/web/dist/types/src/render/field/search.d.ts +5 -0
  127. package/web/dist/types/src/render/field/secret.d.ts +3 -0
  128. package/web/dist/types/src/render/field/slider.d.ts +5 -0
  129. package/web/dist/types/src/render/field/text.d.ts +3 -0
  130. package/web/dist/types/src/render/field/toggle.d.ts +3 -0
  131. package/web/dist/types/src/render/field/upload.d.ts +5 -0
  132. package/web/dist/types/src/render/kind/boxplot.d.ts +3 -0
  133. package/web/dist/types/src/render/kind/button.d.ts +3 -0
  134. package/web/dist/types/src/render/kind/card.d.ts +3 -0
  135. package/web/dist/types/src/render/kind/chart.d.ts +4 -0
  136. package/web/dist/types/src/render/kind/chips.d.ts +3 -0
  137. package/web/dist/types/src/render/kind/choice.d.ts +3 -0
  138. package/web/dist/types/src/render/kind/composer.d.ts +3 -0
  139. package/web/dist/types/src/render/kind/config.d.ts +3 -0
  140. package/web/dist/types/src/render/kind/diagram.d.ts +3 -0
  141. package/web/dist/types/src/render/kind/diff.d.ts +3 -0
  142. package/web/dist/types/src/render/kind/editor.d.ts +3 -0
  143. package/web/dist/types/src/render/kind/form.d.ts +14 -0
  144. package/web/dist/types/src/render/kind/heat.d.ts +3 -0
  145. package/web/dist/types/src/render/kind/hero.d.ts +3 -0
  146. package/web/dist/types/src/render/kind/images.d.ts +3 -0
  147. package/web/dist/types/src/render/kind/import.d.ts +3 -0
  148. package/web/dist/types/src/render/kind/island.d.ts +3 -0
  149. package/web/dist/types/src/render/kind/lines.d.ts +5 -0
  150. package/web/dist/types/src/render/kind/list.d.ts +3 -0
  151. package/web/dist/types/src/render/kind/media.d.ts +4 -0
  152. package/web/dist/types/src/render/kind/message.d.ts +3 -0
  153. package/web/dist/types/src/render/kind/modal.d.ts +9 -0
  154. package/web/dist/types/src/render/kind/nav.d.ts +2 -0
  155. package/web/dist/types/src/render/kind/pages.d.ts +2 -0
  156. package/web/dist/types/src/render/kind/plot.d.ts +3 -0
  157. package/web/dist/types/src/render/kind/prose.d.ts +4 -0
  158. package/web/dist/types/src/render/kind/row.d.ts +3 -0
  159. package/web/dist/types/src/render/kind/run.d.ts +3 -0
  160. package/web/dist/types/src/render/kind/scene.d.ts +3 -0
  161. package/web/dist/types/src/render/kind/screen.d.ts +3 -0
  162. package/web/dist/types/src/render/kind/secret.d.ts +3 -0
  163. package/web/dist/types/src/render/kind/section.d.ts +3 -0
  164. package/web/dist/types/src/render/kind/sheet.d.ts +1 -0
  165. package/web/dist/types/src/render/kind/sidebar.d.ts +3 -0
  166. package/web/dist/types/src/render/kind/stat.d.ts +2 -0
  167. package/web/dist/types/src/render/kind/steps.d.ts +3 -0
  168. package/web/dist/types/src/render/kind/table.d.ts +3 -0
  169. package/web/dist/types/src/render/kind/text.d.ts +3 -0
  170. package/web/dist/types/src/render/kind/timeline.d.ts +3 -0
  171. package/web/dist/types/src/render/kind/toast.d.ts +4 -0
  172. package/web/dist/types/src/render/kind/tool.d.ts +3 -0
  173. package/web/dist/types/src/render/kind/web.d.ts +2 -0
  174. package/web/dist/types/src/render/more.d.ts +11 -0
  175. package/web/dist/types/src/render/text.d.ts +5 -0
  176. package/web/dist/types/src/scan/index.d.ts +26 -0
  177. package/web/dist/types/src/scan/page.d.ts +18 -0
  178. package/web/dist/types/src/shell/adopt.d.ts +8 -0
  179. package/web/dist/types/src/shell/host.d.ts +30 -0
  180. package/web/dist/types/src/shell/layout.d.ts +29 -0
  181. package/web/dist/types/src/shell/local.d.ts +10 -0
  182. package/web/dist/types/src/shell/look.d.ts +15 -0
  183. package/web/dist/types/src/shell/mount.d.ts +34 -0
  184. package/web/dist/types/src/shell/sheet.d.ts +17 -0
  185. package/web/dist/types/src/shell/source.d.ts +12 -0
  186. package/web/dist/types/src/shell/store.d.ts +2 -0
  187. package/web/dist/types/src/shell.d.ts +26 -0
  188. package/web/dist/types/src/sidebar.d.ts +2 -0
  189. package/web/dist/types/src/stream.d.ts +28 -0
  190. package/web/dist/types/src/theme.d.ts +24 -0
  191. package/web/dist/types/src/toasts.d.ts +7 -0
@@ -0,0 +1,29 @@
1
+ import type { LayoutPlace, LayoutTransition } from "../gen/layout.ts";
2
+ export type Placed<P> = {
3
+ type: string;
4
+ id: string;
5
+ source?: string;
6
+ path?: string;
7
+ label?: string;
8
+ place: P;
9
+ transition: LayoutTransition;
10
+ config?: Record<string, unknown>;
11
+ slots?: Record<string, Placed<P>[]>;
12
+ };
13
+ export type Layout = {
14
+ format: number;
15
+ theme?: string;
16
+ root: Placed<{
17
+ compact: LayoutPlace;
18
+ wide: LayoutPlace;
19
+ }>;
20
+ };
21
+ export type Resolved = Placed<LayoutPlace>;
22
+ export declare const ALWAYS: LayoutPlace[];
23
+ export declare const SHEET: LayoutPlace[];
24
+ export declare function resolved(n: Layout["root"], wide: boolean): Resolved;
25
+ export declare const walk: (n: Resolved) => Resolved[];
26
+ export declare const isScreen: (n: Resolved) => n is Resolved & {
27
+ source: string;
28
+ path: string;
29
+ };
@@ -0,0 +1,10 @@
1
+ import type { Action, Answer, Block, Op } from "../gen/types.ts";
2
+ import type { Source } from "./source.ts";
3
+ export type Local = {
4
+ screen(path: string): Block | Promise<Block>;
5
+ act(a: Action, path: string): Answer | Promise<Answer>;
6
+ close?(path: string): void;
7
+ };
8
+ export declare function local(app: Local): Source & {
9
+ push(path: string, ops: Op[]): void;
10
+ };
@@ -0,0 +1,15 @@
1
+ import { type Scheme } from "../gen/schemes.ts";
2
+ import { type Pair, type Scale } from "../core/look.ts";
3
+ import type { Store } from "../render/ctx.ts";
4
+ import { type Theme } from "../theme.ts";
5
+ export type Worn = Scheme | (Pair & {
6
+ style?: Scale;
7
+ });
8
+ export declare const row: (label: string, f: () => void, on?: boolean) => HTMLDivElement;
9
+ export declare function wearer(schemes: Record<string, Worn>, theme: Theme, own?: Element | null, ownLook?: string | null): {
10
+ look: HTMLStyleElement;
11
+ wear: (name: string | null, keep?: Store) => void;
12
+ code: () => string;
13
+ named: (code: string) => string | null;
14
+ };
15
+ export declare function looks(schemes: Record<string, Worn>, store: Store, wear: (name: string | null, keep?: Store) => void, again: () => void): HTMLElement;
@@ -0,0 +1,34 @@
1
+ import type { Scheme } from "../gen/schemes.ts";
2
+ import { type Editing } from "../arrange.ts";
3
+ import type { OnFile } from "../core/field/files.ts";
4
+ import { type Store } from "../render/ctx.ts";
5
+ import { type Theme } from "../theme.ts";
6
+ import { type AppBlocks } from "./host.ts";
7
+ import { type Layout, type Resolved } from "./layout.ts";
8
+ import { type Source } from "./source.ts";
9
+ type FromServers = {
10
+ url: (source: string, path: string) => string;
11
+ sources?: Record<string, Source>;
12
+ };
13
+ type FromTheApp = {
14
+ url?: undefined;
15
+ sources: Record<string, Source>;
16
+ };
17
+ export type Mount = {
18
+ root: HTMLElement;
19
+ layout: Layout;
20
+ blocks?: AppBlocks;
21
+ components?: Record<string, (n: Resolved) => HTMLElement | null>;
22
+ css?: string[];
23
+ theme?: Theme;
24
+ schemes?: Record<string, Scheme>;
25
+ look?: string;
26
+ store?: Store;
27
+ edit?: Editing;
28
+ file?: OnFile;
29
+ } & (FromServers | FromTheApp);
30
+ export declare function mount(o: Mount): {
31
+ layout(next: Layout): void;
32
+ close(): void;
33
+ };
34
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { Blk } from "../core/tree.ts";
2
+ export type Sheet = ReturnType<typeof sheet>;
3
+ export type Back = {
4
+ title: string;
5
+ go: () => void;
6
+ };
7
+ export declare function sheet(closed: () => void): {
8
+ box: HTMLDivElement;
9
+ body: HTMLDivElement;
10
+ close: () => void;
11
+ frame: (title: string, prev?: Back, own?: boolean) => void;
12
+ show: (title: string, kids: HTMLElement[], prev?: Back) => void;
13
+ };
14
+ export declare function confirmer(): {
15
+ box: HTMLDivElement;
16
+ ask: (c: Blk) => Promise<boolean>;
17
+ };
@@ -0,0 +1,12 @@
1
+ import type { Action, Answer, Block, Op, Toast } from "../gen/types.ts";
2
+ import { type State } from "../stream.ts";
3
+ export type Source = {
4
+ open(path: string, on: (screen: Block, ops?: Op[]) => void): void;
5
+ close(path: string): void;
6
+ act(path: string, a: Action): Promise<Answer>;
7
+ };
8
+ export declare class Refused extends Error {
9
+ readonly toast: Toast;
10
+ constructor(toast: Toast);
11
+ }
12
+ export declare function served(url: (path: string) => string, state: (s: State) => void): Source;
@@ -0,0 +1,2 @@
1
+ import type { Store } from "../render/ctx.ts";
2
+ export declare function local(): Store;
@@ -0,0 +1,26 @@
1
+ import { adopt } from "./shell/adopt.ts";
2
+ export type { Editing } from "./arrange.ts";
3
+ export { evaluate, start, view } from "./core/eval.ts";
4
+ export { dump } from "./dump.ts";
5
+ export { behave } from "./behave.ts";
6
+ export { apply } from "./core/apply.ts";
7
+ export * as lookCode from "./core/code.ts";
8
+ export { patcher } from "./patch.ts";
9
+ export { grow } from "./render/kind/prose.ts";
10
+ export { sync as plotSync } from "./render/kind/plot.ts";
11
+ export { settle } from "./motion.ts";
12
+ export { kids, render } from "./render/block.ts";
13
+ export { el, h } from "./render/dom.ts";
14
+ export type { OnFile, Picked } from "./core/field/files.ts";
15
+ export { packs, plain, tiles } from "./theme.ts";
16
+ export type { Layout, Placed, Resolved } from "./shell/layout.ts";
17
+ export { resolved } from "./shell/layout.ts";
18
+ export type { AppBlocks } from "./shell/host.ts";
19
+ export type { Worn } from "./shell/look.ts";
20
+ export type { Mount } from "./shell/mount.ts";
21
+ export { mount } from "./shell/mount.ts";
22
+ export type { Local } from "./shell/local.ts";
23
+ export { local } from "./shell/local.ts";
24
+ export type { Source } from "./shell/source.ts";
25
+ export { Refused } from "./shell/source.ts";
26
+ export { adopt };
@@ -0,0 +1,2 @@
1
+ import type { Store } from "./render/ctx.ts";
2
+ export declare function behave(root: HTMLElement, key: string, store: Store, open?: Set<string>): () => void;
@@ -0,0 +1,28 @@
1
+ import type { Block, Frame, Have, Hello, Op, Synced } from "./gen/types.ts";
2
+ export type Took = "patched" | "replaced" | "old" | "gap";
3
+ export type Outdated = "app" | "server";
4
+ export type State = "off" | "connecting" | "syncing" | "live" | "waiting" | "parked";
5
+ export declare class Mirror {
6
+ readonly v: number;
7
+ private epoch;
8
+ private outdated;
9
+ private keys;
10
+ constructor(v?: number);
11
+ hello(h: Hello): Outdated | undefined;
12
+ open(k: string): void;
13
+ close(k: string): void;
14
+ have(): Have[];
15
+ screen(k: string): Block | undefined;
16
+ frame(f: Frame): Took;
17
+ synced(sent: Have[], s: Synced): Took[];
18
+ private state;
19
+ }
20
+ type On = (screen: Block, ops?: Op[]) => void;
21
+ export declare function stream(o: {
22
+ url: string;
23
+ state?: (s: State) => void;
24
+ }): {
25
+ open(k: string, f: On): void;
26
+ close(k: string): void;
27
+ };
28
+ export {};
@@ -0,0 +1,24 @@
1
+ import { type Pair, type Scale } from "./core/look.ts";
2
+ import type { Scheme } from "./gen/schemes.ts";
3
+ import type { Figure } from "./gen/types.ts";
4
+ export type ThemeJson = {
5
+ label: string;
6
+ scheme: {
7
+ dark: string;
8
+ light: string;
9
+ };
10
+ sprites: boolean;
11
+ moments: boolean;
12
+ words: Record<string, string>;
13
+ };
14
+ export type Theme = {
15
+ figure(f: Figure): Node | null;
16
+ word(key: string, plain: string): Node;
17
+ css(look: Scheme | Pair, style?: Scale): string;
18
+ };
19
+ export { css, tiles } from "./core/look.ts";
20
+ export declare const plain: Theme;
21
+ export declare function packs(look: {
22
+ theme: ThemeJson;
23
+ base: string;
24
+ }): Theme;
@@ -0,0 +1,7 @@
1
+ import type { Toast } from "./gen/types.ts";
2
+ export type Undo = (b: HTMLElement) => Promise<boolean>;
3
+ export declare function toasts(): {
4
+ box: HTMLElement;
5
+ say(t: Toast, undo?: Undo, first?: boolean): void;
6
+ close(): void;
7
+ };