@goji/core
Advanced tools
Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2
@@ -7,3 +7,8 @@ import { Container } from '../container'; | ||
declare type HydratableInstance = any; | ||
export declare const hostConfig: GojiHostConfig<string, InstanceProps, Container, ElementInstance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance | undefined, {}, boolean, unknown, unknown, unknown>; | ||
declare type HostContext = any; | ||
declare type UpdatePayload = boolean; | ||
declare type ChildSet = any; | ||
declare type TimeoutHandle = any; | ||
declare type NoTimeout = number; | ||
export declare const hostConfig: GojiHostConfig<string, InstanceProps, Container, ElementInstance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance | undefined, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>; | ||
export {}; |
@@ -8,3 +8,10 @@ "use strict"; | ||
const subtreeAttachEvents_1 = tslib_1.__importDefault(require("../subtreeAttachEvents")); | ||
const startDate = Date.now(); | ||
// docs: https://github.com/facebook/react/blob/d483463bc86555decb3e8caa18459d1d0f7c0148/packages/react-reconciler/README.md | ||
exports.hostConfig = { | ||
// no `performance.now` in Mini Program | ||
now: () => Date.now() - startDate, | ||
scheduleTimeout: setTimeout, | ||
cancelTimeout: clearTimeout, | ||
noTimeout: -1, | ||
supportsMutation: true, | ||
@@ -47,3 +54,3 @@ supportsHydration: false, | ||
}, | ||
getChildHostContext: () => ({}), | ||
getChildHostContext: parentHostContext => parentHostContext, | ||
prepareUpdate() { | ||
@@ -50,0 +57,0 @@ // FIXME: should use this hook correctly |
@@ -1,22 +0,5 @@ | ||
import { HostConfig, OpaqueHandle } from 'react-reconciler'; | ||
declare type OmittedSchedulerKeys = 'now' | 'setTimeout' | 'scheduleTimeout' | 'cancelTimeout' | 'clearTimeout' | 'noTimeout' | 'scheduleDeferredCallback' | 'cancelDeferredCallback'; | ||
declare type OmittedHydrationKeys = 'canHydrateInstance' | 'canHydrateTextInstance' | 'canHydrateSuspenseInstance' | 'isSuspenseInstancePending' | 'isSuspenseInstanceFallback' | 'registerSuspenseInstanceRetry' | 'getNextHydratableSibling' | 'getFirstHydratableChild' | 'hydrateInstance' | 'hydrateTextInstance' | 'hydrateSuspenseInstance' | 'getNextHydratableInstanceAfterSuspenseInstance' | 'commitHydratedContainer' | 'commitHydratedSuspenseInstance' | 'clearSuspenseBoundary' | 'clearSuspenseBoundaryFromContainer' | 'didNotMatchHydratedContainerTextInstance' | 'didNotMatchHydratedTextInstance' | 'didNotHydrateContainerInstance' | 'didNotHydrateInstance' | 'didNotFindHydratableContainerInstance' | 'didNotFindHydratableContainerTextInstance' | 'didNotFindHydratableContainerSuspenseInstance' | 'didNotFindHydratableInstance' | 'didNotFindHydratableTextInstance' | 'didNotFindHydratableSuspenseInstance'; | ||
declare type OmittedPersistenceKeys = 'cloneInstance' | 'cloneFundamentalInstance' | 'createContainerChildSet' | 'appendChildToContainerChildSet' | 'finalizeContainerChildren' | 'replaceContainerChildren' | 'cloneHiddenInstance' | 'cloneHiddenTextInstance'; | ||
declare type OmittedMicrotasksKeys = 'supportsMicrotasks' | 'scheduleMicrotask' | 'queueMicrotask'; | ||
export declare type GojiHostConfig<Type, Props, Container, Instance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout> = Omit<HostConfig<Type, Props, Container, Instance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>, OmittedSchedulerKeys | OmittedHydrationKeys | OmittedPersistenceKeys | OmittedMicrotasksKeys> & { | ||
appendChild(parentInstance: Instance, child: Instance | TextInstance): void; | ||
appendChildToContainer(container: Container, child: Instance | TextInstance): void; | ||
commitTextUpdate(textInstance: TextInstance, oldText: string, newText: string): void; | ||
commitMount(instance: Instance, type: Type, newProps: Props, internalInstanceHandle: OpaqueHandle): void; | ||
commitUpdate(instance: Instance, updatePayload: UpdatePayload, type: Type, oldProps: Props, newProps: Props, internalInstanceHandle: OpaqueHandle): void; | ||
insertBefore(parentInstance: Instance, child: Instance | TextInstance, beforeChild: Instance | TextInstance): void; | ||
insertInContainerBefore(container: Container, child: Instance | TextInstance, beforeChild: Instance | TextInstance): void; | ||
removeChild(parentInstance: Instance, child: Instance | TextInstance): void; | ||
removeChildFromContainer(container: Container, child: Instance | TextInstance): void; | ||
resetTextContent(instance: Instance): void; | ||
hideInstance(instance: Instance): void; | ||
hideTextInstance(textInstance: TextInstance): void; | ||
unhideInstance(instance: Instance, props: Props): void; | ||
unhideTextInstance(textInstance: TextInstance, text: string): void; | ||
}; | ||
import { HostConfig } from 'react-reconciler'; | ||
import { Required } from 'utility-types'; | ||
declare type RequiredKeys = 'appendChild' | 'appendChildToContainer' | 'commitTextUpdate' | 'commitMount' | 'commitUpdate' | 'insertBefore' | 'insertInContainerBefore' | 'removeChild' | 'removeChildFromContainer' | 'resetTextContent' | 'hideInstance' | 'hideTextInstance' | 'unhideInstance' | 'unhideTextInstance'; | ||
export declare type GojiHostConfig<Type, Props, Container, Instance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout> = Required<HostConfig<Type, Props, Container, Instance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>, RequiredKeys>; | ||
export {}; |
@@ -7,3 +7,8 @@ import { Container } from '../container'; | ||
declare type HydratableInstance = any; | ||
export declare const hostConfig: GojiHostConfig<string, InstanceProps, Container, ElementInstance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance | undefined, {}, boolean, unknown, unknown, unknown>; | ||
declare type HostContext = any; | ||
declare type UpdatePayload = boolean; | ||
declare type ChildSet = any; | ||
declare type TimeoutHandle = any; | ||
declare type NoTimeout = number; | ||
export declare const hostConfig: GojiHostConfig<string, InstanceProps, Container, ElementInstance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance | undefined, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>; | ||
export {}; |
@@ -5,3 +5,10 @@ import { __awaiter } from "tslib"; | ||
import events from '../subtreeAttachEvents'; | ||
const startDate = Date.now(); | ||
// docs: https://github.com/facebook/react/blob/d483463bc86555decb3e8caa18459d1d0f7c0148/packages/react-reconciler/README.md | ||
export const hostConfig = { | ||
// no `performance.now` in Mini Program | ||
now: () => Date.now() - startDate, | ||
scheduleTimeout: setTimeout, | ||
cancelTimeout: clearTimeout, | ||
noTimeout: -1, | ||
supportsMutation: true, | ||
@@ -44,3 +51,3 @@ supportsHydration: false, | ||
}, | ||
getChildHostContext: () => ({}), | ||
getChildHostContext: parentHostContext => parentHostContext, | ||
prepareUpdate() { | ||
@@ -47,0 +54,0 @@ // FIXME: should use this hook correctly |
@@ -1,22 +0,5 @@ | ||
import { HostConfig, OpaqueHandle } from 'react-reconciler'; | ||
declare type OmittedSchedulerKeys = 'now' | 'setTimeout' | 'scheduleTimeout' | 'cancelTimeout' | 'clearTimeout' | 'noTimeout' | 'scheduleDeferredCallback' | 'cancelDeferredCallback'; | ||
declare type OmittedHydrationKeys = 'canHydrateInstance' | 'canHydrateTextInstance' | 'canHydrateSuspenseInstance' | 'isSuspenseInstancePending' | 'isSuspenseInstanceFallback' | 'registerSuspenseInstanceRetry' | 'getNextHydratableSibling' | 'getFirstHydratableChild' | 'hydrateInstance' | 'hydrateTextInstance' | 'hydrateSuspenseInstance' | 'getNextHydratableInstanceAfterSuspenseInstance' | 'commitHydratedContainer' | 'commitHydratedSuspenseInstance' | 'clearSuspenseBoundary' | 'clearSuspenseBoundaryFromContainer' | 'didNotMatchHydratedContainerTextInstance' | 'didNotMatchHydratedTextInstance' | 'didNotHydrateContainerInstance' | 'didNotHydrateInstance' | 'didNotFindHydratableContainerInstance' | 'didNotFindHydratableContainerTextInstance' | 'didNotFindHydratableContainerSuspenseInstance' | 'didNotFindHydratableInstance' | 'didNotFindHydratableTextInstance' | 'didNotFindHydratableSuspenseInstance'; | ||
declare type OmittedPersistenceKeys = 'cloneInstance' | 'cloneFundamentalInstance' | 'createContainerChildSet' | 'appendChildToContainerChildSet' | 'finalizeContainerChildren' | 'replaceContainerChildren' | 'cloneHiddenInstance' | 'cloneHiddenTextInstance'; | ||
declare type OmittedMicrotasksKeys = 'supportsMicrotasks' | 'scheduleMicrotask' | 'queueMicrotask'; | ||
export declare type GojiHostConfig<Type, Props, Container, Instance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout> = Omit<HostConfig<Type, Props, Container, Instance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>, OmittedSchedulerKeys | OmittedHydrationKeys | OmittedPersistenceKeys | OmittedMicrotasksKeys> & { | ||
appendChild(parentInstance: Instance, child: Instance | TextInstance): void; | ||
appendChildToContainer(container: Container, child: Instance | TextInstance): void; | ||
commitTextUpdate(textInstance: TextInstance, oldText: string, newText: string): void; | ||
commitMount(instance: Instance, type: Type, newProps: Props, internalInstanceHandle: OpaqueHandle): void; | ||
commitUpdate(instance: Instance, updatePayload: UpdatePayload, type: Type, oldProps: Props, newProps: Props, internalInstanceHandle: OpaqueHandle): void; | ||
insertBefore(parentInstance: Instance, child: Instance | TextInstance, beforeChild: Instance | TextInstance): void; | ||
insertInContainerBefore(container: Container, child: Instance | TextInstance, beforeChild: Instance | TextInstance): void; | ||
removeChild(parentInstance: Instance, child: Instance | TextInstance): void; | ||
removeChildFromContainer(container: Container, child: Instance | TextInstance): void; | ||
resetTextContent(instance: Instance): void; | ||
hideInstance(instance: Instance): void; | ||
hideTextInstance(textInstance: TextInstance): void; | ||
unhideInstance(instance: Instance, props: Props): void; | ||
unhideTextInstance(textInstance: TextInstance, text: string): void; | ||
}; | ||
import { HostConfig } from 'react-reconciler'; | ||
import { Required } from 'utility-types'; | ||
declare type RequiredKeys = 'appendChild' | 'appendChildToContainer' | 'commitTextUpdate' | 'commitMount' | 'commitUpdate' | 'insertBefore' | 'insertInContainerBefore' | 'removeChild' | 'removeChildFromContainer' | 'resetTextContent' | 'hideInstance' | 'hideTextInstance' | 'unhideInstance' | 'unhideTextInstance'; | ||
export declare type GojiHostConfig<Type, Props, Container, Instance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout> = Required<HostConfig<Type, Props, Container, Instance, TextInstance, SuspenseInstance, HydratableInstance, PublicInstance, HostContext, UpdatePayload, ChildSet, TimeoutHandle, NoTimeout>, RequiredKeys>; | ||
export {}; |
{ | ||
"name": "@goji/core", | ||
"version": "1.0.0-alpha.1", | ||
"version": "1.0.0-alpha.2", | ||
"description": "GojiJS Core", | ||
@@ -40,3 +40,4 @@ "main": "dist/cjs/index.js", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.3.5" | ||
"typescript": "^4.3.5", | ||
"utility-types": "^3.10.0" | ||
}, | ||
@@ -56,3 +57,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "87cd25ae9662be68fd4c9be95f25be9861dc1cba" | ||
"gitHead": "842d66e81cac9ee1d142cce8c23cabeddf152e32" | ||
} |
@@ -9,3 +9,11 @@ import { Container } from '../container'; | ||
type HydratableInstance = any; | ||
type HostContext = any; | ||
type UpdatePayload = boolean; | ||
type ChildSet = any; | ||
type TimeoutHandle = any; | ||
type NoTimeout = number; | ||
const startDate = Date.now(); | ||
// docs: https://github.com/facebook/react/blob/d483463bc86555decb3e8caa18459d1d0f7c0148/packages/react-reconciler/README.md | ||
export const hostConfig: GojiHostConfig< | ||
@@ -20,8 +28,14 @@ string, | ||
PublicInstance | undefined, | ||
{}, | ||
boolean, | ||
unknown, | ||
unknown, | ||
unknown | ||
HostContext, | ||
UpdatePayload, | ||
ChildSet, | ||
TimeoutHandle, | ||
NoTimeout | ||
> = { | ||
// no `performance.now` in Mini Program | ||
now: () => Date.now() - startDate, | ||
scheduleTimeout: setTimeout, | ||
cancelTimeout: clearTimeout, | ||
noTimeout: -1, | ||
supportsMutation: true, | ||
@@ -76,3 +90,3 @@ supportsHydration: false, | ||
getChildHostContext: () => ({}), | ||
getChildHostContext: parentHostContext => parentHostContext, | ||
@@ -79,0 +93,0 @@ prepareUpdate() { |
@@ -1,62 +0,22 @@ | ||
import { HostConfig, OpaqueHandle } from 'react-reconciler'; | ||
import { HostConfig } from 'react-reconciler'; | ||
import { Required } from 'utility-types'; | ||
// This file is used to patch `HostConfig` interface typing from `@types/react-reconciler` | ||
// FIXME: we should create PRs to upstream later | ||
// Mark all mutation methods as required | ||
// https://github.com/facebook/react/blob/dac9202a9c5add480f853bcad2ee04d371e72c0c/packages/shared/HostConfigWithNoMutation.js | ||
type RequiredKeys = | ||
| 'appendChild' | ||
| 'appendChildToContainer' | ||
| 'commitTextUpdate' | ||
| 'commitMount' | ||
| 'commitUpdate' | ||
| 'insertBefore' | ||
| 'insertInContainerBefore' | ||
| 'removeChild' | ||
| 'removeChildFromContainer' | ||
| 'resetTextContent' | ||
| 'hideInstance' | ||
| 'hideTextInstance' | ||
| 'unhideInstance' | ||
| 'unhideTextInstance'; | ||
// Remove outdated scheduler configs | ||
// https://github.com/facebook/react/pull/14984 | ||
type OmittedSchedulerKeys = | ||
| 'now' | ||
| 'setTimeout' | ||
| 'scheduleTimeout' | ||
| 'cancelTimeout' | ||
| 'clearTimeout' | ||
| 'noTimeout' | ||
| 'scheduleDeferredCallback' | ||
| 'cancelDeferredCallback'; | ||
// Remove unsupported hydrate configs | ||
// https://github.com/facebook/react/blob/0a527707cd8befd21a741ca9646a8551842190b0/packages/shared/HostConfigWithNoHydration.js | ||
type OmittedHydrationKeys = | ||
| 'canHydrateInstance' | ||
| 'canHydrateTextInstance' | ||
| 'canHydrateSuspenseInstance' | ||
| 'isSuspenseInstancePending' | ||
| 'isSuspenseInstanceFallback' | ||
| 'registerSuspenseInstanceRetry' | ||
| 'getNextHydratableSibling' | ||
| 'getFirstHydratableChild' | ||
| 'hydrateInstance' | ||
| 'hydrateTextInstance' | ||
| 'hydrateSuspenseInstance' | ||
| 'getNextHydratableInstanceAfterSuspenseInstance' | ||
| 'commitHydratedContainer' | ||
| 'commitHydratedSuspenseInstance' | ||
| 'clearSuspenseBoundary' | ||
| 'clearSuspenseBoundaryFromContainer' | ||
| 'didNotMatchHydratedContainerTextInstance' | ||
| 'didNotMatchHydratedTextInstance' | ||
| 'didNotHydrateContainerInstance' | ||
| 'didNotHydrateInstance' | ||
| 'didNotFindHydratableContainerInstance' | ||
| 'didNotFindHydratableContainerTextInstance' | ||
| 'didNotFindHydratableContainerSuspenseInstance' | ||
| 'didNotFindHydratableInstance' | ||
| 'didNotFindHydratableTextInstance' | ||
| 'didNotFindHydratableSuspenseInstance'; | ||
// Remove unsupported persistence configs | ||
// from https://github.com/facebook/react/blob/2c4d61e1022ae383dd11fe237f6df8451e6f0310/packages/shared/HostConfigWithNoPersistence.js | ||
type OmittedPersistenceKeys = | ||
| 'cloneInstance' | ||
| 'cloneFundamentalInstance' | ||
| 'createContainerChildSet' | ||
| 'appendChildToContainerChildSet' | ||
| 'finalizeContainerChildren' | ||
| 'replaceContainerChildren' | ||
| 'cloneHiddenInstance' | ||
| 'cloneHiddenTextInstance'; | ||
type OmittedMicrotasksKeys = 'supportsMicrotasks' | 'scheduleMicrotask' | 'queueMicrotask'; | ||
export type GojiHostConfig< | ||
@@ -76,3 +36,3 @@ Type, | ||
NoTimeout, | ||
> = Omit< | ||
> = Required< | ||
HostConfig< | ||
@@ -93,41 +53,3 @@ Type, | ||
>, | ||
OmittedSchedulerKeys | OmittedHydrationKeys | OmittedPersistenceKeys | OmittedMicrotasksKeys | ||
> & { | ||
// Add missing mutation configs and mark all of them required | ||
// https://github.com/facebook/react/blob/dac9202a9c5add480f853bcad2ee04d371e72c0c/packages/shared/HostConfigWithNoMutation.js | ||
appendChild(parentInstance: Instance, child: Instance | TextInstance): void; | ||
appendChildToContainer(container: Container, child: Instance | TextInstance): void; | ||
commitTextUpdate(textInstance: TextInstance, oldText: string, newText: string): void; | ||
commitMount( | ||
instance: Instance, | ||
type: Type, | ||
newProps: Props, | ||
internalInstanceHandle: OpaqueHandle, | ||
): void; | ||
commitUpdate( | ||
instance: Instance, | ||
updatePayload: UpdatePayload, | ||
type: Type, | ||
oldProps: Props, | ||
newProps: Props, | ||
internalInstanceHandle: OpaqueHandle, | ||
): void; | ||
insertBefore( | ||
parentInstance: Instance, | ||
child: Instance | TextInstance, | ||
beforeChild: Instance | TextInstance, | ||
): void; | ||
insertInContainerBefore( | ||
container: Container, | ||
child: Instance | TextInstance, | ||
beforeChild: Instance | TextInstance, | ||
): void; | ||
removeChild(parentInstance: Instance, child: Instance | TextInstance): void; | ||
removeChildFromContainer(container: Container, child: Instance | TextInstance): void; | ||
resetTextContent(instance: Instance): void; | ||
hideInstance(instance: Instance): void; | ||
hideTextInstance(textInstance: TextInstance): void; | ||
unhideInstance(instance: Instance, props: Props): void; | ||
unhideTextInstance(textInstance: TextInstance, text: string): void; | ||
// FIXME: all fundamental configs are ignored yet | ||
}; | ||
RequiredKeys | ||
>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
772533
13
13698