solid-js 1.9.11 → 2.0.0-beta.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 (82) hide show
  1. package/dist/dev.cjs +733 -1678
  2. package/dist/dev.js +598 -1643
  3. package/dist/server.cjs +769 -703
  4. package/dist/server.js +682 -670
  5. package/dist/solid.cjs +699 -1618
  6. package/dist/solid.js +563 -1582
  7. package/package.json +7 -151
  8. package/types/{render → client}/component.d.ts +1 -38
  9. package/types/client/core.d.ts +65 -0
  10. package/types/client/flow.d.ts +100 -0
  11. package/types/client/hydration.d.ts +76 -0
  12. package/types/index.d.ts +11 -14
  13. package/types/jsx.d.ts +1508 -1633
  14. package/types/server/component.d.ts +66 -0
  15. package/types/server/core.d.ts +44 -0
  16. package/types/server/flow.d.ts +60 -0
  17. package/types/server/hydration.d.ts +21 -0
  18. package/types/server/index.d.ts +12 -3
  19. package/types/server/shared.d.ts +45 -0
  20. package/types/server/signals.d.ts +60 -0
  21. package/h/dist/h.cjs +0 -115
  22. package/h/dist/h.js +0 -113
  23. package/h/jsx-dev-runtime/package.json +0 -8
  24. package/h/jsx-runtime/dist/jsx.cjs +0 -15
  25. package/h/jsx-runtime/dist/jsx.js +0 -10
  26. package/h/jsx-runtime/package.json +0 -8
  27. package/h/jsx-runtime/types/index.d.ts +0 -11
  28. package/h/jsx-runtime/types/jsx.d.ts +0 -4242
  29. package/h/package.json +0 -8
  30. package/h/types/hyperscript.d.ts +0 -20
  31. package/h/types/index.d.ts +0 -3
  32. package/html/dist/html.cjs +0 -583
  33. package/html/dist/html.js +0 -581
  34. package/html/package.json +0 -8
  35. package/html/types/index.d.ts +0 -3
  36. package/html/types/lit.d.ts +0 -41
  37. package/store/dist/dev.cjs +0 -458
  38. package/store/dist/dev.js +0 -449
  39. package/store/dist/server.cjs +0 -126
  40. package/store/dist/server.js +0 -114
  41. package/store/dist/store.cjs +0 -438
  42. package/store/dist/store.js +0 -429
  43. package/store/package.json +0 -46
  44. package/store/types/index.d.ts +0 -12
  45. package/store/types/modifiers.d.ts +0 -6
  46. package/store/types/mutable.d.ts +0 -5
  47. package/store/types/server.d.ts +0 -17
  48. package/store/types/store.d.ts +0 -107
  49. package/types/reactive/array.d.ts +0 -44
  50. package/types/reactive/observable.d.ts +0 -36
  51. package/types/reactive/scheduler.d.ts +0 -10
  52. package/types/reactive/signal.d.ts +0 -577
  53. package/types/render/Suspense.d.ts +0 -26
  54. package/types/render/flow.d.ts +0 -118
  55. package/types/render/hydration.d.ts +0 -24
  56. package/types/render/index.d.ts +0 -4
  57. package/types/server/reactive.d.ts +0 -98
  58. package/types/server/rendering.d.ts +0 -159
  59. package/universal/dist/dev.cjs +0 -245
  60. package/universal/dist/dev.js +0 -243
  61. package/universal/dist/universal.cjs +0 -245
  62. package/universal/dist/universal.js +0 -243
  63. package/universal/package.json +0 -20
  64. package/universal/types/index.d.ts +0 -3
  65. package/universal/types/universal.d.ts +0 -30
  66. package/web/dist/dev.cjs +0 -894
  67. package/web/dist/dev.js +0 -782
  68. package/web/dist/server.cjs +0 -892
  69. package/web/dist/server.js +0 -782
  70. package/web/dist/web.cjs +0 -883
  71. package/web/dist/web.js +0 -771
  72. package/web/package.json +0 -46
  73. package/web/storage/dist/storage.cjs +0 -12
  74. package/web/storage/dist/storage.js +0 -10
  75. package/web/storage/package.json +0 -15
  76. package/web/storage/types/index.d.ts +0 -2
  77. package/web/types/client.d.ts +0 -79
  78. package/web/types/core.d.ts +0 -2
  79. package/web/types/index.d.ts +0 -50
  80. package/web/types/jsx.d.ts +0 -1
  81. package/web/types/server-mock.d.ts +0 -65
  82. package/web/types/server.d.ts +0 -177
@@ -0,0 +1,66 @@
1
+ import type { JSX } from "../jsx.js";
2
+ export declare function enableHydration(): void;
3
+ /**
4
+ * A general `Component` has no implicit `children` prop. If desired, you can
5
+ * specify one as in `Component<{name: String, children: JSX.Element}>`.
6
+ */
7
+ export type Component<P extends Record<string, any> = {}> = (props: P) => JSX.Element;
8
+ /**
9
+ * Extend props to forbid the `children` prop.
10
+ */
11
+ export type VoidProps<P extends Record<string, any> = {}> = P & {
12
+ children?: never;
13
+ };
14
+ /**
15
+ * `VoidComponent` forbids the `children` prop.
16
+ */
17
+ export type VoidComponent<P extends Record<string, any> = {}> = Component<VoidProps<P>>;
18
+ /**
19
+ * Extend props to allow an optional `children` prop with the usual type in JSX.
20
+ */
21
+ export type ParentProps<P extends Record<string, any> = {}> = P & {
22
+ children?: JSX.Element;
23
+ };
24
+ /**
25
+ * `ParentComponent` allows an optional `children` prop with the usual type in JSX.
26
+ */
27
+ export type ParentComponent<P extends Record<string, any> = {}> = Component<ParentProps<P>>;
28
+ /**
29
+ * Extend props to require a `children` prop with the specified type.
30
+ */
31
+ export type FlowProps<P extends Record<string, any> = {}, C = JSX.Element> = P & {
32
+ children: C;
33
+ };
34
+ /**
35
+ * `FlowComponent` requires a `children` prop with the specified type.
36
+ */
37
+ export type FlowComponent<P extends Record<string, any> = {}, C = JSX.Element> = Component<FlowProps<P, C>>;
38
+ export type ValidComponent = keyof JSX.IntrinsicElements | Component<any> | (string & {});
39
+ /**
40
+ * Takes the props of the passed component and returns its type
41
+ */
42
+ export type ComponentProps<T extends ValidComponent> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : Record<string, unknown>;
43
+ /**
44
+ * Type of `props.ref`, for use in `Component` or `props` typing.
45
+ */
46
+ export type Ref<T> = T | ((val: T) => void);
47
+ /**
48
+ * Creates a component. On server, just calls the function directly (no untrack needed).
49
+ */
50
+ export declare function createComponent<T extends Record<string, any>>(Comp: Component<T>, props: T): JSX.Element;
51
+ /**
52
+ * Lazy load a function component asynchronously.
53
+ * On server, returns a createMemo that throws NotReadyError until the module resolves,
54
+ * allowing resolveSSRNode to capture it as a fine-grained hole. The memo naturally
55
+ * scopes the owner so hydration IDs align with the client's createMemo in lazy().
56
+ * Requires `moduleUrl` for SSR — the bundler plugin injects the module specifier
57
+ * so the server can look up client chunk URLs from the asset manifest.
58
+ */
59
+ export declare function lazy<T extends Component<any>>(fn: () => Promise<{
60
+ default: T;
61
+ }>, moduleUrl?: string): T & {
62
+ preload: () => Promise<{
63
+ default: T;
64
+ }>;
65
+ };
66
+ export declare function createUniqueId(): string;
@@ -0,0 +1,44 @@
1
+ import type { Accessor, EffectOptions } from "./signals.js";
2
+ import type { JSX } from "../jsx.js";
3
+ import type { FlowComponent } from "./component.js";
4
+ export declare const $DEVCOMP: unique symbol;
5
+ export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
6
+ export type ContextProviderComponent<T> = FlowComponent<{
7
+ value: T;
8
+ }>;
9
+ export interface Context<T> extends ContextProviderComponent<T> {
10
+ id: symbol;
11
+ defaultValue: T;
12
+ }
13
+ /**
14
+ * Creates a Context to handle a state scoped for the children of a component
15
+ * @param defaultValue optional default to inject into context
16
+ * @param options allows to set a name in dev mode for debugging purposes
17
+ * @returns The context that contains the Provider Component and that can be used with `useContext`
18
+ */
19
+ export declare function createContext<T>(defaultValue?: undefined, options?: EffectOptions): Context<T | undefined>;
20
+ export declare function createContext<T>(defaultValue: T, options?: EffectOptions): Context<T>;
21
+ /**
22
+ * Uses a context to receive a scoped state from a parent's Context.Provider
23
+ * @param context Context object made by `createContext`
24
+ * @returns the current or `defaultValue`, if present
25
+ */
26
+ export declare function useContext<T>(context: Context<T>): T;
27
+ export type ResolvedJSXElement = Exclude<JSX.Element, JSX.ArrayElement>;
28
+ export type ResolvedChildren = ResolvedJSXElement | ResolvedJSXElement[];
29
+ export type ChildrenReturn = Accessor<ResolvedChildren> & {
30
+ toArray: () => ResolvedJSXElement[];
31
+ };
32
+ /**
33
+ * Resolves child elements to help interact with children
34
+ * @param fn an accessor for the children
35
+ * @returns a accessor of the same children, but resolved
36
+ */
37
+ export declare function children(fn: Accessor<JSX.Element>): ChildrenReturn;
38
+ /**
39
+ * Pass-through for SSR dynamic expressions.
40
+ * On the client, insert() render effects are transparent (0 owner slots),
41
+ * so the server doesn't need to create owners for these either.
42
+ */
43
+ export declare function ssrRunInScope(fn: () => any): () => any;
44
+ export declare function ssrRunInScope(array: (() => any)[]): (() => any)[];
@@ -0,0 +1,60 @@
1
+ import type { Accessor } from "./signals.js";
2
+ import type { JSX } from "../jsx.js";
3
+ /**
4
+ * Creates a list of elements from a list
5
+ *
6
+ * @description https://docs.solidjs.com/reference/components/for
7
+ */
8
+ export declare function For<T extends readonly any[], U extends JSX.Element>(props: {
9
+ each: T | undefined | null | false;
10
+ fallback?: JSX.Element;
11
+ keyed?: boolean | ((item: T[number]) => any);
12
+ children: (item: Accessor<T[number]>, index: Accessor<number>) => U;
13
+ }): JSX.Element;
14
+ /**
15
+ * Creates a list elements from a count
16
+ *
17
+ * @description https://docs.solidjs.com/reference/components/repeat
18
+ */
19
+ export declare function Repeat<T extends JSX.Element>(props: {
20
+ count: number;
21
+ from?: number | undefined;
22
+ fallback?: JSX.Element;
23
+ children: ((index: number) => T) | T;
24
+ }): JSX.Element;
25
+ /**
26
+ * Conditionally render its children or an optional fallback component
27
+ * @description https://docs.solidjs.com/reference/components/show
28
+ */
29
+ export declare function Show<T>(props: {
30
+ when: T | undefined | null | false;
31
+ keyed?: boolean;
32
+ fallback?: JSX.Element;
33
+ children: JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element);
34
+ }): JSX.Element;
35
+ /**
36
+ * Switches between content based on mutually exclusive conditions
37
+ * @description https://docs.solidjs.com/reference/components/switch-and-match
38
+ */
39
+ export declare function Switch(props: {
40
+ fallback?: JSX.Element;
41
+ children: JSX.Element;
42
+ }): JSX.Element;
43
+ export type MatchProps<T> = {
44
+ when: T | undefined | null | false;
45
+ keyed?: boolean;
46
+ children: JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element);
47
+ };
48
+ /**
49
+ * Selects a content based on condition when inside a `<Switch>` control flow
50
+ * @description https://docs.solidjs.com/reference/components/switch-and-match
51
+ */
52
+ export declare function Match<T>(props: MatchProps<T>): JSX.Element;
53
+ /**
54
+ * Catches uncaught errors inside components and renders a fallback content
55
+ * @description https://docs.solidjs.com/reference/components/error-boundary
56
+ */
57
+ export declare function Errored(props: {
58
+ fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
59
+ children: JSX.Element;
60
+ }): JSX.Element;
@@ -0,0 +1,21 @@
1
+ import type { JSX } from "../jsx.js";
2
+ export { sharedConfig } from "./shared.js";
3
+ export type { HydrationContext } from "./shared.js";
4
+ /**
5
+ * Handles errors during SSR rendering.
6
+ * Returns the promise source for NotReadyError (for async handling),
7
+ * or delegates to the ErrorContext handler.
8
+ */
9
+ export declare function ssrHandleError(err: any): Promise<any> | undefined;
10
+ /**
11
+ * Tracks all resources inside a component and renders a fallback until they are all resolved
12
+ *
13
+ * On the server, this is SSR-aware: it handles async mode (streaming) by registering
14
+ * fragments and resolving asynchronously, and sync mode by serializing fallback markers.
15
+ *
16
+ * @description https://docs.solidjs.com/reference/components/suspense
17
+ */
18
+ export declare function Loading(props: {
19
+ fallback?: JSX.Element;
20
+ children: JSX.Element;
21
+ }): JSX.Element;
@@ -1,3 +1,12 @@
1
- export { catchError, createRoot, createSignal, createComputed, createRenderEffect, createEffect, createReaction, createDeferred, createSelector, createMemo, getListener, onMount, onCleanup, onError, untrack, batch, on, children, createContext, useContext, getOwner, runWithOwner, equalFn, requestCallback, mapArray, indexArray, observable, from, $PROXY, $DEVCOMP, $TRACK, DEV, enableExternalSource } from "./reactive.js";
2
- export { mergeProps, splitProps, createComponent, For, Index, Show, Switch, Match, ErrorBoundary, Suspense, SuspenseList, createResource, resetErrorBoundaries, enableScheduling, enableHydration, startTransition, useTransition, createUniqueId, lazy, sharedConfig } from "./rendering.js";
3
- export type { Component, Resource } from "./rendering.js";
1
+ export { $PROXY, $TRACK, action, createEffect, createMemo, createOptimistic, createOptimisticStore, createOwner, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, storePath, createDeepProxy, untrack } from "./signals.js";
2
+ export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter, PatchOp } from "./signals.js";
3
+ export { $DEVCOMP, children, createContext, useContext, ssrRunInScope } from "./core.js";
4
+ export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./core.js";
5
+ export * from "./component.js";
6
+ export * from "./flow.js";
7
+ export { sharedConfig, Loading, ssrHandleError } from "./hydration.js";
8
+ export type { HydrationContext } from "./hydration.js";
9
+ import type { JSX } from "../jsx.js";
10
+ type JSXElement = JSX.Element;
11
+ export type { JSXElement, JSX };
12
+ export declare const DEV: undefined;
@@ -0,0 +1,45 @@
1
+ type SSRTemplateObject = {
2
+ t: string[];
3
+ h: Function[];
4
+ p: Promise<any>[];
5
+ };
6
+ export type HydrationContext = {
7
+ id: string;
8
+ count: number;
9
+ /**
10
+ * Serialize a value for client hydration.
11
+ * In renderToStream (async: true), accepts promises and async iterables.
12
+ * In renderToString (async: false), only synchronous values are allowed —
13
+ * passing async values will throw.
14
+ */
15
+ serialize: (id: string, v: any, deferStream?: boolean) => void;
16
+ resolve(value: any): SSRTemplateObject;
17
+ ssr(template: string[], ...values: any[]): SSRTemplateObject;
18
+ escape(value: any): string;
19
+ replace: (id: string, replacement: () => any) => void;
20
+ block: (p: Promise<any>) => void;
21
+ registerFragment: (v: string) => (v?: string, err?: any) => boolean;
22
+ /** Register a client-side asset URL discovered during SSR (e.g. from lazy()). */
23
+ registerAsset?: (type: "module" | "style", url: string) => void;
24
+ /** Register a moduleUrl-to-entryUrl mapping for the current boundary. */
25
+ registerModule?: (moduleUrl: string, entryUrl: string) => void;
26
+ /** Resolve a module's JS and CSS assets from the asset manifest. Set by dom-expressions. */
27
+ resolveAssets?: (moduleUrl: string) => {
28
+ js: string[];
29
+ css: string[];
30
+ } | null;
31
+ /** Retrieve the moduleUrl-to-entryUrl map for a boundary. */
32
+ getBoundaryModules?: (id: string) => Record<string, string> | null;
33
+ /** @internal Tracks which Loading boundary is currently rendering. Set by dom-expressions via applyAssetTracking(). */
34
+ _currentBoundaryId?: string | null;
35
+ assets: any[];
36
+ /** True only in renderToStream — enables async data serialization and streaming. */
37
+ async?: boolean;
38
+ noHydrate: boolean;
39
+ };
40
+ type SharedConfig = {
41
+ context?: HydrationContext;
42
+ getNextContextId(): string;
43
+ };
44
+ export declare const sharedConfig: SharedConfig;
45
+ export {};
@@ -0,0 +1,60 @@
1
+ export { createRoot, createOwner, runWithOwner, getOwner, onCleanup, getNextChildId, createContext, setContext, getContext, NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY } from "@solidjs/signals";
2
+ export { flatten } from "@solidjs/signals";
3
+ export { snapshot, merge, omit, storePath, $PROXY, $TRACK } from "@solidjs/signals";
4
+ export type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, NoInfer, SignalOptions, Setter, Signal, Owner, Maybe, Store, StoreSetter, StoreNode, NotWrappable, SolidStore, Merge, Omit, Context, ContextRecord, IQueue, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
5
+ import type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, SignalOptions, Signal, Owner, Store, StoreSetter, Context } from "@solidjs/signals";
6
+ interface ServerComputation<T = any> {
7
+ owner: Owner;
8
+ value: T;
9
+ compute: ComputeFunction<any, T>;
10
+ error: unknown;
11
+ computed: boolean;
12
+ disposed: boolean;
13
+ }
14
+ export declare function getObserver(): ServerComputation<any> | null;
15
+ export declare function createSignal<T>(): Signal<T | undefined>;
16
+ export declare function createSignal<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
17
+ export declare function createSignal<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T>): Signal<T>;
18
+ export declare function createMemo<Next extends Prev, Prev = Next>(compute: ComputeFunction<undefined | NoInfer<Prev>, Next>): Accessor<Next>;
19
+ export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(compute: ComputeFunction<Init | Prev, Next>, value: Init, options?: MemoOptions<Next>): Accessor<Next>;
20
+ export type PatchOp = [path: PropertyKey[]] | [path: PropertyKey[], value: any] | [path: PropertyKey[], value: any, insert: 1];
21
+ export declare function createDeepProxy<T extends object>(target: T, patches: PatchOp[], basePath?: PropertyKey[]): T;
22
+ export declare function createEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next> | EffectBundle<NoInfer<Next>, Next>): void;
23
+ export declare function createEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effect: EffectFunction<Next, Next> | EffectBundle<Next, Next>, value: Init, options?: EffectOptions): void;
24
+ export declare function createRenderEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next>): void;
25
+ export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effectFn: EffectFunction<Next, Next>, value: Init, options?: EffectOptions): void;
26
+ export declare function createTrackedEffect(compute: () => void | (() => void), options?: EffectOptions): void;
27
+ export declare function createReaction(effectFn: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): (tracking: () => void) => void;
28
+ export declare function createOptimistic<T>(): Signal<T | undefined>;
29
+ export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
30
+ export declare function createOptimistic<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T>): Signal<T>;
31
+ export declare function createStore<T extends object>(first: T | Store<T> | ((store: T) => void | T | Promise<void | T>), second?: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
32
+ export declare const createOptimisticStore: typeof createStore;
33
+ export declare function createProjection<T extends object>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: {
34
+ deferStream?: boolean;
35
+ ssrSource?: string;
36
+ }): Store<T>;
37
+ export declare function reconcile<T extends U, U extends object>(value: T): (state: U) => T;
38
+ export declare function deep<T extends object>(store: Store<T>): Store<T>;
39
+ export declare function mapArray<T, U>(list: Accessor<readonly T[] | undefined | null | false>, mapFn: (v: Accessor<T>, i: Accessor<number>) => U, options?: {
40
+ keyed?: boolean | ((item: T) => any);
41
+ fallback?: Accessor<any>;
42
+ }): () => U[];
43
+ export declare function repeat<T>(count: Accessor<number>, mapFn: (i: number) => T, options?: {
44
+ fallback?: Accessor<any>;
45
+ from?: Accessor<number | undefined>;
46
+ }): () => T[];
47
+ declare const ErrorContext: Context<((err: any) => void) | null>;
48
+ export { ErrorContext };
49
+ export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => unknown;
50
+ export declare function createLoadBoundary(fn: () => any, fallback: () => any): () => unknown;
51
+ export declare function untrack<T>(fn: () => T): T;
52
+ export declare function flush(): void;
53
+ export declare function resolve<T>(fn: () => T): Promise<T>;
54
+ export declare function isPending(fn: () => any, fallback?: boolean): boolean;
55
+ export declare function latest<T>(fn: () => T): T;
56
+ export declare function isRefreshing(): boolean;
57
+ export declare function refresh<T>(fn: () => T): T;
58
+ export declare function action<T extends (...args: any[]) => any>(fn: T): T;
59
+ export declare function onSettled(callback: () => void | (() => void)): void;
60
+ type NoInfer<T extends any> = [T][T extends any ? 0 : never];
package/h/dist/h.cjs DELETED
@@ -1,115 +0,0 @@
1
- 'use strict';
2
-
3
- var web = require('solid-js/web');
4
-
5
- const $ELEMENT = Symbol("hyper-element");
6
- function createHyperScript(r) {
7
- function h() {
8
- let args = [].slice.call(arguments),
9
- e,
10
- classes = [],
11
- multiExpression = false;
12
- while (Array.isArray(args[0])) args = args[0];
13
- if (args[0][$ELEMENT]) args.unshift(h.Fragment);
14
- typeof args[0] === "string" && detectMultiExpression(args);
15
- const ret = () => {
16
- while (args.length) item(args.shift());
17
- if (e instanceof Element && classes.length) e.classList.add(...classes);
18
- return e;
19
- };
20
- ret[$ELEMENT] = true;
21
- return ret;
22
- function item(l) {
23
- const type = typeof l;
24
- if (l == null) ;else if ("string" === type) {
25
- if (!e) parseClass(l);else e.appendChild(document.createTextNode(l));
26
- } else if ("number" === type || "boolean" === type || "bigint" === type || "symbol" === type || l instanceof Date || l instanceof RegExp) {
27
- e.appendChild(document.createTextNode(l.toString()));
28
- } else if (Array.isArray(l)) {
29
- for (let i = 0; i < l.length; i++) item(l[i]);
30
- } else if (l instanceof Element) {
31
- r.insert(e, l, multiExpression ? null : undefined);
32
- } else if ("object" === type) {
33
- let dynamic = false;
34
- const d = Object.getOwnPropertyDescriptors(l);
35
- for (const k in d) {
36
- if (k === "class" && classes.length !== 0) {
37
- const fixedClasses = classes.join(" "),
38
- value = typeof d["class"].value === "function" ? () => fixedClasses + " " + d["class"].value() : fixedClasses + " " + l["class"];
39
- Object.defineProperty(l, "class", {
40
- ...d[k],
41
- value
42
- });
43
- classes = [];
44
- }
45
- if (k !== "ref" && k.slice(0, 2) !== "on" && typeof d[k].value === "function") {
46
- r.dynamicProperty(l, k);
47
- dynamic = true;
48
- } else if (d[k].get) dynamic = true;
49
- }
50
- dynamic ? r.spread(e, l, e instanceof SVGElement, !!args.length) : r.assign(e, l, e instanceof SVGElement, !!args.length);
51
- } else if ("function" === type) {
52
- if (!e) {
53
- let props,
54
- next = args[0];
55
- if (next == null || typeof next === "object" && !Array.isArray(next) && !(next instanceof Element)) props = args.shift();
56
- props || (props = {});
57
- if (args.length) {
58
- props.children = args.length > 1 ? args : args[0];
59
- }
60
- const d = Object.getOwnPropertyDescriptors(props);
61
- for (const k in d) {
62
- if (Array.isArray(d[k].value)) {
63
- const list = d[k].value;
64
- props[k] = () => {
65
- for (let i = 0; i < list.length; i++) {
66
- while (list[i][$ELEMENT]) list[i] = list[i]();
67
- }
68
- return list;
69
- };
70
- r.dynamicProperty(props, k);
71
- } else if (typeof d[k].value === "function" && !d[k].value.length) r.dynamicProperty(props, k);
72
- }
73
- e = r.createComponent(l, props);
74
- args = [];
75
- } else {
76
- while (l[$ELEMENT]) l = l();
77
- r.insert(e, l, multiExpression ? null : undefined);
78
- }
79
- }
80
- }
81
- function parseClass(string) {
82
- const m = string.split(/([\.#]?[^\s#.]+)/);
83
- if (/^\.|#/.test(m[1])) e = document.createElement("div");
84
- for (let i = 0; i < m.length; i++) {
85
- const v = m[i],
86
- s = v.substring(1, v.length);
87
- if (!v) continue;
88
- if (!e) e = r.SVGElements.has(v) ? document.createElementNS("http://www.w3.org/2000/svg", v) : document.createElement(v);else if (v[0] === ".") classes.push(s);else if (v[0] === "#") e.setAttribute("id", s);
89
- }
90
- }
91
- function detectMultiExpression(list) {
92
- for (let i = 1; i < list.length; i++) {
93
- if (typeof list[i] === "function") {
94
- multiExpression = true;
95
- return;
96
- } else if (Array.isArray(list[i])) {
97
- detectMultiExpression(list[i]);
98
- }
99
- }
100
- }
101
- }
102
- h.Fragment = props => props.children;
103
- return h;
104
- }
105
-
106
- const h = createHyperScript({
107
- spread: web.spread,
108
- assign: web.assign,
109
- insert: web.insert,
110
- createComponent: web.createComponent,
111
- dynamicProperty: web.dynamicProperty,
112
- SVGElements: web.SVGElements
113
- });
114
-
115
- module.exports = h;
package/h/dist/h.js DELETED
@@ -1,113 +0,0 @@
1
- import { spread, assign, insert, createComponent, dynamicProperty, SVGElements } from 'solid-js/web';
2
-
3
- const $ELEMENT = Symbol("hyper-element");
4
- function createHyperScript(r) {
5
- function h() {
6
- let args = [].slice.call(arguments),
7
- e,
8
- classes = [],
9
- multiExpression = false;
10
- while (Array.isArray(args[0])) args = args[0];
11
- if (args[0][$ELEMENT]) args.unshift(h.Fragment);
12
- typeof args[0] === "string" && detectMultiExpression(args);
13
- const ret = () => {
14
- while (args.length) item(args.shift());
15
- if (e instanceof Element && classes.length) e.classList.add(...classes);
16
- return e;
17
- };
18
- ret[$ELEMENT] = true;
19
- return ret;
20
- function item(l) {
21
- const type = typeof l;
22
- if (l == null) ;else if ("string" === type) {
23
- if (!e) parseClass(l);else e.appendChild(document.createTextNode(l));
24
- } else if ("number" === type || "boolean" === type || "bigint" === type || "symbol" === type || l instanceof Date || l instanceof RegExp) {
25
- e.appendChild(document.createTextNode(l.toString()));
26
- } else if (Array.isArray(l)) {
27
- for (let i = 0; i < l.length; i++) item(l[i]);
28
- } else if (l instanceof Element) {
29
- r.insert(e, l, multiExpression ? null : undefined);
30
- } else if ("object" === type) {
31
- let dynamic = false;
32
- const d = Object.getOwnPropertyDescriptors(l);
33
- for (const k in d) {
34
- if (k === "class" && classes.length !== 0) {
35
- const fixedClasses = classes.join(" "),
36
- value = typeof d["class"].value === "function" ? () => fixedClasses + " " + d["class"].value() : fixedClasses + " " + l["class"];
37
- Object.defineProperty(l, "class", {
38
- ...d[k],
39
- value
40
- });
41
- classes = [];
42
- }
43
- if (k !== "ref" && k.slice(0, 2) !== "on" && typeof d[k].value === "function") {
44
- r.dynamicProperty(l, k);
45
- dynamic = true;
46
- } else if (d[k].get) dynamic = true;
47
- }
48
- dynamic ? r.spread(e, l, e instanceof SVGElement, !!args.length) : r.assign(e, l, e instanceof SVGElement, !!args.length);
49
- } else if ("function" === type) {
50
- if (!e) {
51
- let props,
52
- next = args[0];
53
- if (next == null || typeof next === "object" && !Array.isArray(next) && !(next instanceof Element)) props = args.shift();
54
- props || (props = {});
55
- if (args.length) {
56
- props.children = args.length > 1 ? args : args[0];
57
- }
58
- const d = Object.getOwnPropertyDescriptors(props);
59
- for (const k in d) {
60
- if (Array.isArray(d[k].value)) {
61
- const list = d[k].value;
62
- props[k] = () => {
63
- for (let i = 0; i < list.length; i++) {
64
- while (list[i][$ELEMENT]) list[i] = list[i]();
65
- }
66
- return list;
67
- };
68
- r.dynamicProperty(props, k);
69
- } else if (typeof d[k].value === "function" && !d[k].value.length) r.dynamicProperty(props, k);
70
- }
71
- e = r.createComponent(l, props);
72
- args = [];
73
- } else {
74
- while (l[$ELEMENT]) l = l();
75
- r.insert(e, l, multiExpression ? null : undefined);
76
- }
77
- }
78
- }
79
- function parseClass(string) {
80
- const m = string.split(/([\.#]?[^\s#.]+)/);
81
- if (/^\.|#/.test(m[1])) e = document.createElement("div");
82
- for (let i = 0; i < m.length; i++) {
83
- const v = m[i],
84
- s = v.substring(1, v.length);
85
- if (!v) continue;
86
- if (!e) e = r.SVGElements.has(v) ? document.createElementNS("http://www.w3.org/2000/svg", v) : document.createElement(v);else if (v[0] === ".") classes.push(s);else if (v[0] === "#") e.setAttribute("id", s);
87
- }
88
- }
89
- function detectMultiExpression(list) {
90
- for (let i = 1; i < list.length; i++) {
91
- if (typeof list[i] === "function") {
92
- multiExpression = true;
93
- return;
94
- } else if (Array.isArray(list[i])) {
95
- detectMultiExpression(list[i]);
96
- }
97
- }
98
- }
99
- }
100
- h.Fragment = props => props.children;
101
- return h;
102
- }
103
-
104
- const h = createHyperScript({
105
- spread,
106
- assign,
107
- insert,
108
- createComponent,
109
- dynamicProperty,
110
- SVGElements
111
- });
112
-
113
- export { h as default };
@@ -1,8 +0,0 @@
1
- {
2
- "name": "solid-js/h/jsx-dev-runtime",
3
- "main": "../jsx-runtime/dist/jsx.cjs",
4
- "module": "../jsx-runtime/dist/jsx.js",
5
- "types": "../jsx-runtime/types/index.d.ts",
6
- "type": "module",
7
- "sideEffects": false
8
- }
@@ -1,15 +0,0 @@
1
- 'use strict';
2
-
3
- var h = require('solid-js/h');
4
-
5
- function Fragment(props) {
6
- return props.children;
7
- }
8
- function jsx(type, props) {
9
- return h(type, props);
10
- }
11
-
12
- exports.Fragment = Fragment;
13
- exports.jsx = jsx;
14
- exports.jsxDEV = jsx;
15
- exports.jsxs = jsx;
@@ -1,10 +0,0 @@
1
- import h from 'solid-js/h';
2
-
3
- function Fragment(props) {
4
- return props.children;
5
- }
6
- function jsx(type, props) {
7
- return h(type, props);
8
- }
9
-
10
- export { Fragment, jsx, jsx as jsxDEV, jsx as jsxs };
@@ -1,8 +0,0 @@
1
- {
2
- "name": "solid-js/h/jsx-runtime",
3
- "main": "./dist/jsx.cjs",
4
- "module": "./dist/jsx.js",
5
- "types": "./types/index.d.ts",
6
- "type": "module",
7
- "sideEffects": false
8
- }
@@ -1,11 +0,0 @@
1
- export type { JSX } from "./jsx.d.ts";
2
- import type { JSX } from "./jsx.d.ts";
3
- declare function Fragment(props: {
4
- children: JSX.Element;
5
- }): JSX.Element;
6
- declare function jsx(type: any, props: any): () => (Node & {
7
- [key: string]: any;
8
- }) | (Node & {
9
- [key: string]: any;
10
- })[];
11
- export { jsx, jsx as jsxs, jsx as jsxDEV, Fragment };