@remix-run/ui 0.0.0 → 0.1.1
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/LICENSE +21 -0
- package/README.md +195 -2
- package/dist/animation/animate-layout-mixin.d.ts +12 -0
- package/dist/animation/animate-layout-mixin.js +214 -0
- package/dist/animation/animate-layout-mixin.js.map +1 -0
- package/dist/animation/animate-mixins.d.ts +29 -0
- package/dist/animation/animate-mixins.js +235 -0
- package/dist/animation/animate-mixins.js.map +1 -0
- package/dist/animation/index.d.ts +6 -0
- package/dist/animation/index.js +5 -0
- package/dist/animation/index.js.map +1 -0
- package/dist/animation/spring.d.ts +75 -0
- package/dist/animation/spring.js +183 -0
- package/dist/animation/spring.js.map +1 -0
- package/dist/animation/tween.d.ts +70 -0
- package/dist/animation/tween.js +93 -0
- package/dist/animation/tween.js.map +1 -0
- package/dist/components/accordion/accordion.d.ts +92 -0
- package/dist/components/accordion/accordion.js +337 -0
- package/dist/components/accordion/accordion.js.map +1 -0
- package/dist/components/anchor/anchor.d.ts +13 -0
- package/dist/components/anchor/anchor.js +558 -0
- package/dist/components/anchor/anchor.js.map +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +11 -0
- package/dist/components/breadcrumbs/breadcrumbs.js +78 -0
- package/dist/components/breadcrumbs/breadcrumbs.js.map +1 -0
- package/dist/components/button/button.d.ts +23 -0
- package/dist/components/button/button.js +147 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/combobox/combobox.d.ts +101 -0
- package/dist/components/combobox/combobox.js +708 -0
- package/dist/components/combobox/combobox.js.map +1 -0
- package/dist/components/glyph/glyph.d.ts +14 -0
- package/dist/components/glyph/glyph.js +65 -0
- package/dist/components/glyph/glyph.js.map +1 -0
- package/dist/components/listbox/listbox.d.ts +67 -0
- package/dist/components/listbox/listbox.js +340 -0
- package/dist/components/listbox/listbox.js.map +1 -0
- package/dist/components/menu/hover-aim.d.ts +5 -0
- package/dist/components/menu/hover-aim.js +308 -0
- package/dist/components/menu/hover-aim.js.map +1 -0
- package/dist/components/menu/menu.d.ts +164 -0
- package/dist/components/menu/menu.js +1106 -0
- package/dist/components/menu/menu.js.map +1 -0
- package/dist/components/popover/popover.d.ts +35 -0
- package/dist/components/popover/popover.js +138 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/select/select.d.ts +67 -0
- package/dist/components/select/select.js +397 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/separator/separator.d.ts +2 -0
- package/dist/components/separator/separator.js +15 -0
- package/dist/components/separator/separator.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +78 -0
- package/dist/components/tabs/tabs.js +341 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/interactions/keydown/keydown.d.ts +1 -0
- package/dist/interactions/keydown/keydown.js +8 -0
- package/dist/interactions/keydown/keydown.js.map +1 -0
- package/dist/interactions/outside-click/outside-click-mixin.d.ts +2 -0
- package/dist/interactions/outside-click/outside-click-mixin.js +29 -0
- package/dist/interactions/outside-click/outside-click-mixin.js.map +1 -0
- package/dist/interactions/typeahead/typeahead-mixin.d.ts +8 -0
- package/dist/interactions/typeahead/typeahead-mixin.js +59 -0
- package/dist/interactions/typeahead/typeahead-mixin.js.map +1 -0
- package/dist/jsx-runtime.d.ts +2 -0
- package/dist/jsx-runtime.js +3 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/runtime/client-entries.d.ts +91 -0
- package/dist/runtime/client-entries.js +40 -0
- package/dist/runtime/client-entries.js.map +1 -0
- package/dist/runtime/component.d.ts +223 -0
- package/dist/runtime/component.js +152 -0
- package/dist/runtime/component.js.map +1 -0
- package/dist/runtime/create-element.d.ts +10 -0
- package/dist/runtime/create-element.js +29 -0
- package/dist/runtime/create-element.js.map +1 -0
- package/dist/runtime/diff-dom.d.ts +2 -0
- package/dist/runtime/diff-dom.js +364 -0
- package/dist/runtime/diff-dom.js.map +1 -0
- package/dist/runtime/diff-props.d.ts +9 -0
- package/dist/runtime/diff-props.js +195 -0
- package/dist/runtime/diff-props.js.map +1 -0
- package/dist/runtime/document-state.d.ts +11 -0
- package/dist/runtime/document-state.js +106 -0
- package/dist/runtime/document-state.js.map +1 -0
- package/dist/runtime/dom.d.ts +3189 -0
- package/dist/runtime/dom.js +2 -0
- package/dist/runtime/dom.js.map +1 -0
- package/dist/runtime/error-event.d.ts +20 -0
- package/dist/runtime/error-event.js +19 -0
- package/dist/runtime/error-event.js.map +1 -0
- package/dist/runtime/event-listeners.d.ts +50 -0
- package/dist/runtime/event-listeners.js +31 -0
- package/dist/runtime/event-listeners.js.map +1 -0
- package/dist/runtime/frame.d.ts +119 -0
- package/dist/runtime/frame.js +920 -0
- package/dist/runtime/frame.js.map +1 -0
- package/dist/runtime/invariant.d.ts +23 -0
- package/dist/runtime/invariant.js +33 -0
- package/dist/runtime/invariant.js.map +1 -0
- package/dist/runtime/jsx.d.ts +320 -0
- package/dist/runtime/jsx.js +32 -0
- package/dist/runtime/jsx.js.map +1 -0
- package/dist/runtime/mixins/attrs-mixin.d.ts +9 -0
- package/dist/runtime/mixins/attrs-mixin.js +23 -0
- package/dist/runtime/mixins/attrs-mixin.js.map +1 -0
- package/dist/runtime/mixins/link-mixin.d.ts +17 -0
- package/dist/runtime/mixins/link-mixin.js +101 -0
- package/dist/runtime/mixins/link-mixin.js.map +1 -0
- package/dist/runtime/mixins/mixin.d.ts +145 -0
- package/dist/runtime/mixins/mixin.js +570 -0
- package/dist/runtime/mixins/mixin.js.map +1 -0
- package/dist/runtime/mixins/on-mixin.d.ts +16 -0
- package/dist/runtime/mixins/on-mixin.js +49 -0
- package/dist/runtime/mixins/on-mixin.js.map +1 -0
- package/dist/runtime/mixins/ref-mixin.d.ts +9 -0
- package/dist/runtime/mixins/ref-mixin.js +21 -0
- package/dist/runtime/mixins/ref-mixin.js.map +1 -0
- package/dist/runtime/navigation.d.ts +28 -0
- package/dist/runtime/navigation.js +107 -0
- package/dist/runtime/navigation.js.map +1 -0
- package/dist/runtime/reconcile.d.ts +11 -0
- package/dist/runtime/reconcile.js +1262 -0
- package/dist/runtime/reconcile.js.map +1 -0
- package/dist/runtime/render.d.ts +54 -0
- package/dist/runtime/render.js +50 -0
- package/dist/runtime/render.js.map +1 -0
- package/dist/runtime/run.d.ts +45 -0
- package/dist/runtime/run.js +68 -0
- package/dist/runtime/run.js.map +1 -0
- package/dist/runtime/scheduler.d.ts +30 -0
- package/dist/runtime/scheduler.js +195 -0
- package/dist/runtime/scheduler.js.map +1 -0
- package/dist/runtime/svg-attributes.d.ts +5 -0
- package/dist/runtime/svg-attributes.js +124 -0
- package/dist/runtime/svg-attributes.js.map +1 -0
- package/dist/runtime/to-vnode.d.ts +3 -0
- package/dist/runtime/to-vnode.js +46 -0
- package/dist/runtime/to-vnode.js.map +1 -0
- package/dist/runtime/typed-event-target.d.ts +50 -0
- package/dist/runtime/typed-event-target.js +6 -0
- package/dist/runtime/typed-event-target.js.map +1 -0
- package/dist/runtime/vdom.d.ts +55 -0
- package/dist/runtime/vdom.js +198 -0
- package/dist/runtime/vdom.js.map +1 -0
- package/dist/runtime/vnode.d.ts +79 -0
- package/dist/runtime/vnode.js +38 -0
- package/dist/runtime/vnode.js.map +1 -0
- package/dist/server/stream.d.ts +57 -0
- package/dist/server/stream.js +1011 -0
- package/dist/server/stream.js.map +1 -0
- package/dist/style/css-mixin.d.ts +8 -0
- package/dist/style/css-mixin.js +54 -0
- package/dist/style/css-mixin.js.map +1 -0
- package/dist/style/index.d.ts +5 -0
- package/dist/style/index.js +4 -0
- package/dist/style/index.js.map +1 -0
- package/dist/style/style.d.ts +24 -0
- package/dist/style/style.js +269 -0
- package/dist/style/style.js.map +1 -0
- package/dist/style/stylesheet.d.ts +11 -0
- package/dist/style/stylesheet.js +174 -0
- package/dist/style/stylesheet.js.map +1 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.js +2 -0
- package/dist/test.js.map +1 -0
- package/dist/theme/contract.d.ts +259 -0
- package/dist/theme/contract.js +131 -0
- package/dist/theme/contract.js.map +1 -0
- package/dist/theme/glyph-contract.d.ts +13 -0
- package/dist/theme/glyph-contract.js +34 -0
- package/dist/theme/glyph-contract.js.map +1 -0
- package/dist/theme/presets/rmx-01/glyphs.d.ts +2 -0
- package/dist/theme/presets/rmx-01/glyphs.js +252 -0
- package/dist/theme/presets/rmx-01/glyphs.js.map +1 -0
- package/dist/theme/presets/rmx-01/index.d.ts +2 -0
- package/dist/theme/presets/rmx-01/index.js +119 -0
- package/dist/theme/presets/rmx-01/index.js.map +1 -0
- package/dist/theme/runtime.d.ts +2 -0
- package/dist/theme/runtime.js +81 -0
- package/dist/theme/runtime.js.map +1 -0
- package/dist/theme/theme.d.ts +6 -0
- package/dist/theme/theme.js +5 -0
- package/dist/theme/theme.js.map +1 -0
- package/dist/utils/flash-attribute.d.ts +1 -0
- package/dist/utils/flash-attribute.js +11 -0
- package/dist/utils/flash-attribute.js.map +1 -0
- package/dist/utils/scroll-lock.d.ts +3 -0
- package/dist/utils/scroll-lock.js +69 -0
- package/dist/utils/scroll-lock.js.map +1 -0
- package/dist/utils/wait-for-css-transition.d.ts +1 -0
- package/dist/utils/wait-for-css-transition.js +58 -0
- package/dist/utils/wait-for-css-transition.js.map +1 -0
- package/dist/utils/wait.d.ts +1 -0
- package/dist/utils/wait.js +6 -0
- package/dist/utils/wait.js.map +1 -0
- package/package.json +124 -5
- package/src/animation/animate-layout-mixin.ts +266 -0
- package/src/animation/animate-mixins.ts +292 -0
- package/src/animation/index.ts +6 -0
- package/src/animation/spring.ts +299 -0
- package/src/animation/tween.ts +134 -0
- package/src/components/accordion/accordion.tsx +565 -0
- package/src/components/anchor/anchor.ts +904 -0
- package/src/components/breadcrumbs/breadcrumbs.tsx +124 -0
- package/src/components/button/README.md +44 -0
- package/src/components/button/button.tsx +188 -0
- package/src/components/combobox/README.md +145 -0
- package/src/components/combobox/combobox.tsx +1014 -0
- package/src/components/glyph/glyph.tsx +110 -0
- package/src/components/listbox/listbox.ts +447 -0
- package/src/components/menu/hover-aim.ts +428 -0
- package/src/components/menu/menu.tsx +1547 -0
- package/src/components/popover/README.md +122 -0
- package/src/components/popover/popover.ts +201 -0
- package/src/components/select/select.tsx +585 -0
- package/src/components/separator/separator.ts +19 -0
- package/src/components/tabs/README.md +105 -0
- package/src/components/tabs/tabs.tsx +499 -0
- package/src/index.ts +72 -0
- package/src/interactions/keydown/keydown.ts +14 -0
- package/src/interactions/outside-click/outside-click-mixin.ts +55 -0
- package/src/interactions/typeahead/typeahead-mixin.ts +89 -0
- package/src/jsx-runtime.ts +2 -0
- package/src/runtime/client-entries.ts +137 -0
- package/src/runtime/component.ts +402 -0
- package/src/runtime/create-element.ts +38 -0
- package/src/runtime/diff-dom.ts +404 -0
- package/src/runtime/diff-props.ts +209 -0
- package/src/runtime/document-state.ts +130 -0
- package/src/runtime/dom.ts +3971 -0
- package/src/runtime/error-event.ts +26 -0
- package/src/runtime/event-listeners.ts +171 -0
- package/src/runtime/frame.ts +1218 -0
- package/src/runtime/invariant.ts +31 -0
- package/src/runtime/jsx.ts +397 -0
- package/src/runtime/mixins/attrs-mixin.ts +35 -0
- package/src/runtime/mixins/link-mixin.ts +131 -0
- package/src/runtime/mixins/mixin.ts +908 -0
- package/src/runtime/mixins/on-mixin.ts +89 -0
- package/src/runtime/mixins/ref-mixin.ts +32 -0
- package/src/runtime/navigation.ts +148 -0
- package/src/runtime/reconcile.ts +1757 -0
- package/src/runtime/render.ts +101 -0
- package/src/runtime/run.ts +100 -0
- package/src/runtime/scheduler.ts +269 -0
- package/src/runtime/svg-attributes.ts +133 -0
- package/src/runtime/to-vnode.ts +51 -0
- package/src/runtime/typed-event-target.ts +67 -0
- package/src/runtime/vdom.ts +295 -0
- package/src/runtime/vnode.ts +137 -0
- package/src/server/stream.ts +1347 -0
- package/src/style/css-mixin.ts +82 -0
- package/src/style/index.ts +10 -0
- package/src/style/style.ts +312 -0
- package/src/style/stylesheet.ts +209 -0
- package/src/test/utils.ts +45 -0
- package/src/test.ts +2 -0
- package/src/theme/contract.ts +183 -0
- package/src/theme/glyph-contract.ts +57 -0
- package/src/theme/presets/rmx-01/glyphs.tsx +308 -0
- package/src/theme/presets/rmx-01/index.ts +121 -0
- package/src/theme/runtime.ts +116 -0
- package/src/theme/theme.ts +15 -0
- package/src/utils/flash-attribute.ts +11 -0
- package/src/utils/scroll-lock.ts +97 -0
- package/src/utils/wait-for-css-transition.ts +66 -0
- package/src/utils/wait.ts +5 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Implementation
|
|
2
|
+
export function clientEntry(entryId, component) {
|
|
3
|
+
if (!entryId) {
|
|
4
|
+
throw new Error('clientEntry() requires an entry ID');
|
|
5
|
+
}
|
|
6
|
+
// Augment the component with entry metadata
|
|
7
|
+
component.$entry = true;
|
|
8
|
+
component.$entryId = entryId;
|
|
9
|
+
return component;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Type guard to check if a component is an entry component
|
|
13
|
+
*
|
|
14
|
+
* @param component The component to check
|
|
15
|
+
* @returns True if the component has entry metadata
|
|
16
|
+
*/
|
|
17
|
+
export function isEntry(component) {
|
|
18
|
+
return Boolean(component && typeof component === 'function' && component.$entry === true);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Logs a client-hydration mismatch to the console.
|
|
22
|
+
*
|
|
23
|
+
* @param msg Message parts to forward to the logger.
|
|
24
|
+
*/
|
|
25
|
+
export function logHydrationMismatch(...msg) {
|
|
26
|
+
console.error('Hydration mismatch:', ...msg);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Advances a DOM cursor past consecutive comment nodes.
|
|
30
|
+
*
|
|
31
|
+
* @param cursor Starting DOM node.
|
|
32
|
+
* @returns The first non-comment node, or `null` when none remains.
|
|
33
|
+
*/
|
|
34
|
+
export function skipComments(cursor) {
|
|
35
|
+
while (cursor && cursor.nodeType === Node.COMMENT_NODE) {
|
|
36
|
+
cursor = cursor.nextSibling;
|
|
37
|
+
}
|
|
38
|
+
return cursor;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=client-entries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-entries.js","sourceRoot":"","sources":["../../src/runtime/client-entries.ts"],"names":[],"mappings":"AA6FA,iBAAiB;AACjB,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,SAAc;IACzD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IACvD,CAAC;IAED,4CAA4C;IAC5C,SAAS,CAAC,MAAM,GAAG,IAAI,CAAA;IACvB,SAAS,CAAC,QAAQ,GAAG,OAAO,CAAA;IAE5B,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,SAAkB;IACxC,OAAO,OAAO,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,UAAU,IAAK,SAAiB,CAAC,MAAM,KAAK,IAAI,CAAC,CAAA;AACpG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAG,GAAU;IAChD,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,GAAG,CAAC,CAAA;AAC9C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAmB;IAC9C,OAAO,MAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC;QACvD,MAAM,GAAG,MAAM,CAAC,WAAW,CAAA;IAC7B,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import type { ElementProps, ElementType, RemixNode, Renderable } from './jsx.ts';
|
|
2
|
+
import { TypedEventTarget } from './typed-event-target.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Task queued to run after a component update completes.
|
|
5
|
+
*/
|
|
6
|
+
export type Task = (signal: AbortSignal) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Runtime handle passed to component setup functions.
|
|
9
|
+
*/
|
|
10
|
+
export interface Handle<Props = Record<string, never>, ContextValue = NoContext> {
|
|
11
|
+
/**
|
|
12
|
+
* Stable identifier per component instance. Useful for HTML APIs like
|
|
13
|
+
* htmlFor, aria-owns, etc. so consumers don't have to supply an id.
|
|
14
|
+
*/
|
|
15
|
+
id: string;
|
|
16
|
+
/**
|
|
17
|
+
* Stable props object for the component instance. The object identity does not
|
|
18
|
+
* change across updates, but its values are updated before each render.
|
|
19
|
+
*/
|
|
20
|
+
props: Props;
|
|
21
|
+
/**
|
|
22
|
+
* Set and get values in an element tree for indirect ancestor/descendant
|
|
23
|
+
* communication.
|
|
24
|
+
*/
|
|
25
|
+
context: Context<ContextValue>;
|
|
26
|
+
/**
|
|
27
|
+
* Schedules an update for the component to render again. Returns a promise
|
|
28
|
+
* that resolves with an AbortSignal after the update completes. The signal
|
|
29
|
+
* is aborted when the component re-renders or is removed.
|
|
30
|
+
*
|
|
31
|
+
* @returns A promise that resolves with an AbortSignal after the update
|
|
32
|
+
*/
|
|
33
|
+
update(): Promise<AbortSignal>;
|
|
34
|
+
/**
|
|
35
|
+
* Schedules a task to run after the next update.
|
|
36
|
+
*
|
|
37
|
+
* @param task
|
|
38
|
+
*/
|
|
39
|
+
queueTask(task: Task): void;
|
|
40
|
+
/**
|
|
41
|
+
* The component's closest frame
|
|
42
|
+
*/
|
|
43
|
+
frame: FrameHandle;
|
|
44
|
+
/**
|
|
45
|
+
* Access named frames in the current runtime tree.
|
|
46
|
+
*/
|
|
47
|
+
frames: {
|
|
48
|
+
/**
|
|
49
|
+
* The root frame for the current runtime tree.
|
|
50
|
+
*/
|
|
51
|
+
readonly top: FrameHandle;
|
|
52
|
+
get(name: string): FrameHandle | undefined;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* A signal indicating the connected status of the component. When the
|
|
56
|
+
* component is disconnected from the tree the signal will be aborted.
|
|
57
|
+
* Useful for setup scope cleanup.
|
|
58
|
+
*
|
|
59
|
+
* @example Clear a timer
|
|
60
|
+
* ```ts
|
|
61
|
+
* function Clock(handle: Handle) {
|
|
62
|
+
* let interval = setInterval(() => {
|
|
63
|
+
* if (handle.signal.aborted) {
|
|
64
|
+
* clearInterval(interval)
|
|
65
|
+
* return
|
|
66
|
+
* }
|
|
67
|
+
* handle.update()
|
|
68
|
+
* }, 1000)
|
|
69
|
+
* return () => <span>{new Date().toString()}</span>
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* Because signals are event targets, you can also add an event instead.
|
|
74
|
+
* ```ts
|
|
75
|
+
* function Clock(handle: Handle) {
|
|
76
|
+
* let interval = setInterval(handle.update)
|
|
77
|
+
* handle.signal.addEventListener("abort", () => clearInterval(interval))
|
|
78
|
+
* return () => <span>{new Date().toString()}</span>
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* You don't need to check both this.signal and a render/event signal as
|
|
83
|
+
* render/event signals are aborted when the component disconnects.
|
|
84
|
+
*/
|
|
85
|
+
signal: AbortSignal;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Default Handle context so types must be declared explicitly.
|
|
89
|
+
*/
|
|
90
|
+
export type NoContext = Record<string, never>;
|
|
91
|
+
/**
|
|
92
|
+
* Component factory shape used by the Remix component runtime.
|
|
93
|
+
*/
|
|
94
|
+
export type Component<Props = ElementProps, ContextValue = NoContext> = (handle: Handle<Props, ContextValue>) => RenderFn;
|
|
95
|
+
/**
|
|
96
|
+
* Infers the context provided by a component or handle-compatible function.
|
|
97
|
+
*/
|
|
98
|
+
export type ContextFrom<ComponentType> = ComponentType extends Component<any, infer Provided> ? Provided : ComponentType extends (handle: Handle<any, infer Provided>, ...args: any[]) => any ? Provided : never;
|
|
99
|
+
/**
|
|
100
|
+
* Context storage API exposed on component handles.
|
|
101
|
+
*/
|
|
102
|
+
export interface Context<C> {
|
|
103
|
+
/** Replaces the current context value for this component instance. */
|
|
104
|
+
set(values: C): void;
|
|
105
|
+
/** Reads the context value associated with the given component type. */
|
|
106
|
+
get<ComponentType>(component: ComponentType): ContextFrom<ComponentType>;
|
|
107
|
+
/** Reads the context value associated with the given component key. */
|
|
108
|
+
get(component: ElementType | symbol): unknown | undefined;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Content that can be rendered into a frame.
|
|
112
|
+
*/
|
|
113
|
+
export type FrameContent = ReadableStream<Uint8Array> | string | RemixNode;
|
|
114
|
+
/**
|
|
115
|
+
* Events emitted by frame handles during reloads.
|
|
116
|
+
*/
|
|
117
|
+
export type FrameHandleEventMap = {
|
|
118
|
+
reloadStart: Event;
|
|
119
|
+
reloadComplete: Event;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Public API for interacting with a frame instance.
|
|
123
|
+
*/
|
|
124
|
+
export type FrameHandle = TypedEventTarget<FrameHandleEventMap> & {
|
|
125
|
+
src: string;
|
|
126
|
+
reload(): Promise<AbortSignal>;
|
|
127
|
+
replace(content: FrameContent): Promise<void>;
|
|
128
|
+
$runtime?: unknown;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Props accepted by the built-in {@link Frame} component.
|
|
132
|
+
*/
|
|
133
|
+
export interface FrameProps {
|
|
134
|
+
/** Optional frame name used for targeted navigation and lookups. */
|
|
135
|
+
name?: string;
|
|
136
|
+
/** Source URL used when the frame loads or reloads its content. */
|
|
137
|
+
src: string;
|
|
138
|
+
/** Fallback content to render while the frame is pending. */
|
|
139
|
+
fallback?: Renderable;
|
|
140
|
+
/** Event handlers invoked for events dispatched from the frame element. */
|
|
141
|
+
on?: Record<string, (event: Event, signal: AbortSignal) => void | Promise<void>>;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Component factory function that receives a handle and returns a render function.
|
|
145
|
+
*/
|
|
146
|
+
export type ComponentFn<Props = Record<string, never>, ContextValue = NoContext> = (handle: Handle<Props, ContextValue>) => RenderFn;
|
|
147
|
+
/**
|
|
148
|
+
* Render function returned by a component factory.
|
|
149
|
+
*/
|
|
150
|
+
export type RenderFn<Props = ElementProps> = (props: Props) => RemixNode;
|
|
151
|
+
export type { RemixNode } from './jsx.ts';
|
|
152
|
+
/**
|
|
153
|
+
* Props accepted by the built-in {@link Fragment} component.
|
|
154
|
+
*/
|
|
155
|
+
export interface FragmentProps {
|
|
156
|
+
/** Child nodes to render without adding an extra host element. */
|
|
157
|
+
children?: RemixNode;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Mapping of built-in component names to their prop shapes.
|
|
161
|
+
*/
|
|
162
|
+
export interface BuiltinElements {
|
|
163
|
+
/** Props accepted by the built-in fragment component. */
|
|
164
|
+
Fragment: FragmentProps;
|
|
165
|
+
/** Props accepted by the built-in frame component. */
|
|
166
|
+
Frame: FrameProps;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Key type used to stabilize host elements and components during reconciliation.
|
|
170
|
+
*/
|
|
171
|
+
export type Key = string | number | bigint;
|
|
172
|
+
type ComponentConfig = {
|
|
173
|
+
id: string;
|
|
174
|
+
type: Function;
|
|
175
|
+
frame: FrameHandle;
|
|
176
|
+
getContext: (type: Component) => unknown;
|
|
177
|
+
getFrameByName: (name: string) => FrameHandle | undefined;
|
|
178
|
+
getTopFrame?: () => FrameHandle | undefined;
|
|
179
|
+
signal?: AbortSignal;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Runtime handle returned by {@link createComponent}.
|
|
183
|
+
*/
|
|
184
|
+
export type ComponentHandle = ReturnType<typeof createComponent>;
|
|
185
|
+
/**
|
|
186
|
+
* Creates the internal runtime wrapper for a component instance.
|
|
187
|
+
*
|
|
188
|
+
* @param config Component runtime configuration.
|
|
189
|
+
* @returns Component runtime helpers used by the reconciler.
|
|
190
|
+
*/
|
|
191
|
+
export declare function createComponent<C = NoContext>(config: ComponentConfig): {
|
|
192
|
+
render: (props: ElementProps) => [RemixNode, Array<() => void>];
|
|
193
|
+
remove: () => (() => void)[];
|
|
194
|
+
setScheduleUpdate: (nextScheduleUpdate: () => void) => void;
|
|
195
|
+
frame: FrameHandle;
|
|
196
|
+
getContextValue: () => C | undefined;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Built-in component used to render nested frame content.
|
|
200
|
+
*
|
|
201
|
+
* @param handle Component handle for the frame instance.
|
|
202
|
+
* @returns A placeholder render function handled by the reconciler.
|
|
203
|
+
*/
|
|
204
|
+
export declare function Frame(handle: Handle<FrameProps, FrameHandle>): () => null;
|
|
205
|
+
/**
|
|
206
|
+
* Built-in component used to group children without adding a host element.
|
|
207
|
+
*
|
|
208
|
+
* @param handle Component handle for the fragment instance.
|
|
209
|
+
* @returns A placeholder render function handled by the reconciler.
|
|
210
|
+
*/
|
|
211
|
+
export declare function Fragment(handle: Handle<FragmentProps>): () => null;
|
|
212
|
+
/**
|
|
213
|
+
* Creates a frame handle with default no-op implementations for testing and internal wiring.
|
|
214
|
+
*
|
|
215
|
+
* @param def Partial frame-handle implementation to merge with the defaults.
|
|
216
|
+
* @returns A frame handle object.
|
|
217
|
+
*/
|
|
218
|
+
export declare function createFrameHandle(def?: Partial<{
|
|
219
|
+
src: string;
|
|
220
|
+
replace: FrameHandle['replace'];
|
|
221
|
+
reload: FrameHandle['reload'];
|
|
222
|
+
$runtime: FrameHandle['$runtime'];
|
|
223
|
+
}>): FrameHandle;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { TypedEventTarget } from "./typed-event-target.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates the internal runtime wrapper for a component instance.
|
|
4
|
+
*
|
|
5
|
+
* @param config Component runtime configuration.
|
|
6
|
+
* @returns Component runtime helpers used by the reconciler.
|
|
7
|
+
*/
|
|
8
|
+
export function createComponent(config) {
|
|
9
|
+
let taskQueue = [];
|
|
10
|
+
let renderCtrl = null;
|
|
11
|
+
let connectedCtrl = null;
|
|
12
|
+
let contextValue = undefined;
|
|
13
|
+
function getConnectedSignal() {
|
|
14
|
+
if (!connectedCtrl)
|
|
15
|
+
connectedCtrl = new AbortController();
|
|
16
|
+
return connectedCtrl.signal;
|
|
17
|
+
}
|
|
18
|
+
let getContent = null;
|
|
19
|
+
let scheduleUpdate = () => {
|
|
20
|
+
throw new Error('scheduleUpdate not implemented');
|
|
21
|
+
};
|
|
22
|
+
let props = {};
|
|
23
|
+
let context = {
|
|
24
|
+
set: (value) => {
|
|
25
|
+
contextValue = value;
|
|
26
|
+
},
|
|
27
|
+
get: (type) => config.getContext(type),
|
|
28
|
+
};
|
|
29
|
+
let handle = {
|
|
30
|
+
id: config.id,
|
|
31
|
+
props,
|
|
32
|
+
update: () => new Promise((resolve) => {
|
|
33
|
+
taskQueue.push((signal) => resolve(signal));
|
|
34
|
+
scheduleUpdate();
|
|
35
|
+
}),
|
|
36
|
+
queueTask: (task) => {
|
|
37
|
+
taskQueue.push(task);
|
|
38
|
+
},
|
|
39
|
+
frame: config.frame,
|
|
40
|
+
frames: {
|
|
41
|
+
get top() {
|
|
42
|
+
return config.getTopFrame?.() ?? config.frame;
|
|
43
|
+
},
|
|
44
|
+
get(name) {
|
|
45
|
+
return config.getFrameByName(name);
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
context: context,
|
|
49
|
+
get signal() {
|
|
50
|
+
return config.signal ?? getConnectedSignal();
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
function dequeueTasks() {
|
|
54
|
+
// Only create render controller if any task expects a signal (has length >= 1)
|
|
55
|
+
let needsSignal = taskQueue.some((task) => task.length >= 1);
|
|
56
|
+
if (needsSignal && !renderCtrl) {
|
|
57
|
+
renderCtrl = new AbortController();
|
|
58
|
+
}
|
|
59
|
+
let signal = renderCtrl?.signal;
|
|
60
|
+
return taskQueue.splice(0, taskQueue.length).map((task) => () => task(signal));
|
|
61
|
+
}
|
|
62
|
+
function render(props) {
|
|
63
|
+
if (connectedCtrl?.signal.aborted) {
|
|
64
|
+
console.warn('render called after component was removed, potential application memory leak');
|
|
65
|
+
return [null, []];
|
|
66
|
+
}
|
|
67
|
+
// Only abort render controller if it was initialized
|
|
68
|
+
if (renderCtrl) {
|
|
69
|
+
renderCtrl.abort();
|
|
70
|
+
renderCtrl = null;
|
|
71
|
+
}
|
|
72
|
+
syncProps(handle.props, props);
|
|
73
|
+
let renderContent = getContent;
|
|
74
|
+
if (!renderContent) {
|
|
75
|
+
let result = config.type(handle);
|
|
76
|
+
if (typeof result !== 'function') {
|
|
77
|
+
let name = config.type.name || 'Anonymous';
|
|
78
|
+
throw new Error(`${name} must return a render function, received ${typeof result}`);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
getContent = result;
|
|
82
|
+
renderContent = result;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!renderContent) {
|
|
86
|
+
throw new Error('component render function was not initialized');
|
|
87
|
+
}
|
|
88
|
+
let node = renderContent(handle.props);
|
|
89
|
+
return [node, dequeueTasks()];
|
|
90
|
+
}
|
|
91
|
+
function remove() {
|
|
92
|
+
connectedCtrl?.abort();
|
|
93
|
+
renderCtrl?.abort();
|
|
94
|
+
return dequeueTasks();
|
|
95
|
+
}
|
|
96
|
+
function setScheduleUpdate(nextScheduleUpdate) {
|
|
97
|
+
scheduleUpdate = nextScheduleUpdate;
|
|
98
|
+
}
|
|
99
|
+
function getContextValue() {
|
|
100
|
+
return contextValue;
|
|
101
|
+
}
|
|
102
|
+
return { render, remove, setScheduleUpdate, frame: config.frame, getContextValue };
|
|
103
|
+
}
|
|
104
|
+
function syncProps(target, next) {
|
|
105
|
+
for (let key in target) {
|
|
106
|
+
if (!(key in next)) {
|
|
107
|
+
delete target[key];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (let key in next) {
|
|
111
|
+
target[key] = next[key];
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Built-in component used to render nested frame content.
|
|
116
|
+
*
|
|
117
|
+
* @param handle Component handle for the frame instance.
|
|
118
|
+
* @returns A placeholder render function handled by the reconciler.
|
|
119
|
+
*/
|
|
120
|
+
export function Frame(handle) {
|
|
121
|
+
void handle;
|
|
122
|
+
return () => null; // reconciler renders
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Built-in component used to group children without adding a host element.
|
|
126
|
+
*
|
|
127
|
+
* @param handle Component handle for the fragment instance.
|
|
128
|
+
* @returns A placeholder render function handled by the reconciler.
|
|
129
|
+
*/
|
|
130
|
+
export function Fragment(handle) {
|
|
131
|
+
void handle;
|
|
132
|
+
return () => null; // reconciler renders
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Creates a frame handle with default no-op implementations for testing and internal wiring.
|
|
136
|
+
*
|
|
137
|
+
* @param def Partial frame-handle implementation to merge with the defaults.
|
|
138
|
+
* @returns A frame handle object.
|
|
139
|
+
*/
|
|
140
|
+
export function createFrameHandle(def) {
|
|
141
|
+
return Object.assign(new TypedEventTarget(), {
|
|
142
|
+
src: '/',
|
|
143
|
+
replace: notImplemented('replace not implemented'),
|
|
144
|
+
reload: notImplemented('reload not implemented'),
|
|
145
|
+
}, def);
|
|
146
|
+
}
|
|
147
|
+
function notImplemented(msg) {
|
|
148
|
+
return () => {
|
|
149
|
+
throw new Error(msg);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/runtime/component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AA6N1D;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAgB,MAAuB;IACpE,IAAI,SAAS,GAAW,EAAE,CAAA;IAC1B,IAAI,UAAU,GAA2B,IAAI,CAA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AC3D,KAAK,MAAM,CAAA;IACX,OAAO,GAAG,EAAE,CAAC,IAAI,CAAA,CAAC,qBAAqB;AACzC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,MAA6B;IACpD,KAAK,MAAM,CAAA;IACX,OAAO,GAAG,EAAE,CAAC,IAAI,CAAA,CAAC,qBAAqB;AACzC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,GAKE;IAEF,OAAO,MAAM,CAAC,MAAM,CAClB,IAAI,gBAAgB,EAAuB,EAC3C;QACE,GAAG,EAAE,GAAG;QACR,OAAO,EAAE,cAAc,CAAC,yBAAyB,CAAC;QAClD,MAAM,EAAE,cAAc,CAAC,wBAAwB,CAAC;KACjD,EACD,GAAG,CACJ,CAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAC,GAAW;IACjC,OAAO,GAAU,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;IACtB,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ElementType, RemixElement } from './jsx.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Remix virtual element from a JSX-like call signature.
|
|
4
|
+
*
|
|
5
|
+
* @param type Host tag, component function, or mixin host placeholder.
|
|
6
|
+
* @param props Element props.
|
|
7
|
+
* @param children Child nodes.
|
|
8
|
+
* @returns A Remix virtual element.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createElement(type: ElementType, props?: Record<string, any>, ...children: any[]): RemixElement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx } from "./jsx.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Remix virtual element from a JSX-like call signature.
|
|
4
|
+
*
|
|
5
|
+
* @param type Host tag, component function, or mixin host placeholder.
|
|
6
|
+
* @param props Element props.
|
|
7
|
+
* @param children Child nodes.
|
|
8
|
+
* @returns A Remix virtual element.
|
|
9
|
+
*/
|
|
10
|
+
export function createElement(type, props, ...children) {
|
|
11
|
+
let nextProps = { ...(props ?? {}) };
|
|
12
|
+
if (isMixinElementType(type)) {
|
|
13
|
+
if (children.length > 0) {
|
|
14
|
+
console.error(new Error('mixin elements must not receive children'));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
nextProps.children = children;
|
|
19
|
+
}
|
|
20
|
+
if (nextProps.key != null) {
|
|
21
|
+
let { key, ...rest } = nextProps;
|
|
22
|
+
return jsx(type, rest, key);
|
|
23
|
+
}
|
|
24
|
+
return jsx(type, nextProps);
|
|
25
|
+
}
|
|
26
|
+
function isMixinElementType(type) {
|
|
27
|
+
return typeof type === 'function' && '__rmxMixinElementType' in type;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=create-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-element.js","sourceRoot":"","sources":["../../src/runtime/create-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAG9B;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAiB,EACjB,KAA2B,EAC3B,GAAG,QAAe;IAElB,IAAI,SAAS,GAAG,EAAE,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAA;IACpC,IAAI,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7B,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC,CAAA;QACtE,CAAC;IACH,CAAC;SAAM,CAAC;QACN,SAAS,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC/B,CAAC;IAED,IAAI,SAAS,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;QAC1B,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,SAAS,CAAA;QAChC,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IAC7B,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;AAC7B,CAAC;AAED,SAAS,kBAAkB,CACzB,IAAiB;IAEjB,OAAO,OAAO,IAAI,KAAK,UAAU,IAAI,uBAAuB,IAAI,IAAI,CAAA;AACtE,CAAC"}
|