@lynx-js/react 0.105.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.
- package/CHANGELOG.md +250 -0
- package/LICENSE +202 -0
- package/README.md +20 -0
- package/components/lib/Page.d.ts +3 -0
- package/components/lib/Page.js +56 -0
- package/components/lib/Page.js.map +1 -0
- package/components/lib/index.d.ts +1 -0
- package/components/lib/index.js +5 -0
- package/components/lib/index.js.map +1 -0
- package/components/src/Page.ts +75 -0
- package/components/src/index.ts +5 -0
- package/package.json +162 -0
- package/refresh/.gitignore +1 -0
- package/refresh/.npmignore +3 -0
- package/refresh/.turbo/turbo-build.log +8 -0
- package/refresh/dist/index.js +311 -0
- package/refresh/package.json +21 -0
- package/refresh/src/index.ts +6 -0
- package/refresh/src/prefresh.d.ts +11 -0
- package/refresh/tsconfig.json +4 -0
- package/refresh/turbo.json +15 -0
- package/runtime/jsx-dev-runtime/index.d.ts +5 -0
- package/runtime/jsx-dev-runtime/index.js +4 -0
- package/runtime/jsx-runtime/index.d.ts +4 -0
- package/runtime/jsx-runtime/index.js +4 -0
- package/runtime/lazy/import.d.ts +1 -0
- package/runtime/lazy/import.js +55 -0
- package/runtime/lazy/internal.js +39 -0
- package/runtime/lazy/jsx-dev-runtime.js +12 -0
- package/runtime/lazy/jsx-runtime.js +12 -0
- package/runtime/lazy/legacy-react-runtime.js +20 -0
- package/runtime/lazy/react-lepus.js +9 -0
- package/runtime/lazy/react.js +46 -0
- package/runtime/lazy/target.js +11 -0
- package/runtime/lepus/index.d.ts +4 -0
- package/runtime/lepus/index.js +43 -0
- package/runtime/lepus/jsx-dev-runtime/index.js +4 -0
- package/runtime/lepus/jsx-runtime/index.js +66 -0
- package/runtime/lib/backgroundSnapshot.d.ts +23 -0
- package/runtime/lib/backgroundSnapshot.js +348 -0
- package/runtime/lib/backgroundSnapshot.js.map +1 -0
- package/runtime/lib/compat/componentIs.d.ts +4 -0
- package/runtime/lib/compat/componentIs.js +20 -0
- package/runtime/lib/compat/componentIs.js.map +1 -0
- package/runtime/lib/compat/initData.d.ts +43 -0
- package/runtime/lib/compat/initData.js +93 -0
- package/runtime/lib/compat/initData.js.map +1 -0
- package/runtime/lib/compat/lynxComponent.d.ts +5 -0
- package/runtime/lib/compat/lynxComponent.js +71 -0
- package/runtime/lib/compat/lynxComponent.js.map +1 -0
- package/runtime/lib/debug/debug.d.ts +2 -0
- package/runtime/lib/debug/debug.js +9 -0
- package/runtime/lib/debug/debug.js.map +1 -0
- package/runtime/lib/debug/printSnapshot.d.ts +3 -0
- package/runtime/lib/debug/printSnapshot.js +21 -0
- package/runtime/lib/debug/printSnapshot.js.map +1 -0
- package/runtime/lib/debug/profile.d.ts +1 -0
- package/runtime/lib/debug/profile.js +51 -0
- package/runtime/lib/debug/profile.js.map +1 -0
- package/runtime/lib/document.d.ts +4 -0
- package/runtime/lib/document.js +49 -0
- package/runtime/lib/document.js.map +1 -0
- package/runtime/lib/gesture/processGesture.d.ts +4 -0
- package/runtime/lib/gesture/processGesture.js +48 -0
- package/runtime/lib/gesture/processGesture.js.map +1 -0
- package/runtime/lib/gesture/processGestureBagkround.d.ts +2 -0
- package/runtime/lib/gesture/processGestureBagkround.js +16 -0
- package/runtime/lib/gesture/processGestureBagkround.js.map +1 -0
- package/runtime/lib/gesture/types.d.ts +34 -0
- package/runtime/lib/gesture/types.js +13 -0
- package/runtime/lib/gesture/types.js.map +1 -0
- package/runtime/lib/hooks/react.d.ts +26 -0
- package/runtime/lib/hooks/react.js +35 -0
- package/runtime/lib/hooks/react.js.map +1 -0
- package/runtime/lib/hooks/useLynxGlobalEventListener.d.ts +29 -0
- package/runtime/lib/hooks/useLynxGlobalEventListener.js +53 -0
- package/runtime/lib/hooks/useLynxGlobalEventListener.js.map +1 -0
- package/runtime/lib/hydrate.d.ts +18 -0
- package/runtime/lib/hydrate.js +271 -0
- package/runtime/lib/hydrate.js.map +1 -0
- package/runtime/lib/index.d.ts +9 -0
- package/runtime/lib/index.js +46 -0
- package/runtime/lib/index.js.map +1 -0
- package/runtime/lib/internal.d.ts +26 -0
- package/runtime/lib/internal.js +41 -0
- package/runtime/lib/internal.js.map +1 -0
- package/runtime/lib/legacy-react-runtime/index.d.ts +7 -0
- package/runtime/lib/legacy-react-runtime/index.js +34 -0
- package/runtime/lib/legacy-react-runtime/index.js.map +1 -0
- package/runtime/lib/lifecycle/delayUnmount.d.ts +8 -0
- package/runtime/lib/lifecycle/delayUnmount.js +68 -0
- package/runtime/lib/lifecycle/delayUnmount.js.map +1 -0
- package/runtime/lib/lifecycle/destroy.d.ts +2 -0
- package/runtime/lib/lifecycle/destroy.js +21 -0
- package/runtime/lib/lifecycle/destroy.js.map +1 -0
- package/runtime/lib/lifecycle/pass.d.ts +3 -0
- package/runtime/lib/lifecycle/pass.js +12 -0
- package/runtime/lib/lifecycle/pass.js.map +1 -0
- package/runtime/lib/lifecycle/patchUpdate.d.ts +23 -0
- package/runtime/lib/lifecycle/patchUpdate.js +179 -0
- package/runtime/lib/lifecycle/patchUpdate.js.map +1 -0
- package/runtime/lib/lifecycle/reload.d.ts +3 -0
- package/runtime/lib/lifecycle/reload.js +63 -0
- package/runtime/lib/lifecycle/reload.js.map +1 -0
- package/runtime/lib/lifecycle/render.d.ts +2 -0
- package/runtime/lib/lifecycle/render.js +44 -0
- package/runtime/lib/lifecycle/render.js.map +1 -0
- package/runtime/lib/lifecycleConstant.d.ts +12 -0
- package/runtime/lib/lifecycleConstant.js +17 -0
- package/runtime/lib/lifecycleConstant.js.map +1 -0
- package/runtime/lib/list.d.ts +40 -0
- package/runtime/lib/list.js +305 -0
- package/runtime/lib/list.js.map +1 -0
- package/runtime/lib/lynx/calledByNative.d.ts +2 -0
- package/runtime/lib/lynx/calledByNative.js +113 -0
- package/runtime/lib/lynx/calledByNative.js.map +1 -0
- package/runtime/lib/lynx/component.d.ts +1 -0
- package/runtime/lib/lynx/component.js +69 -0
- package/runtime/lib/lynx/component.js.map +1 -0
- package/runtime/lib/lynx/dynamic-js.d.ts +2 -0
- package/runtime/lib/lynx/dynamic-js.js +31 -0
- package/runtime/lib/lynx/dynamic-js.js.map +1 -0
- package/runtime/lib/lynx/env.d.ts +1 -0
- package/runtime/lib/lynx/env.js +92 -0
- package/runtime/lib/lynx/env.js.map +1 -0
- package/runtime/lib/lynx/injectLepusMethods.d.ts +2 -0
- package/runtime/lib/lynx/injectLepusMethods.js +50 -0
- package/runtime/lib/lynx/injectLepusMethods.js.map +1 -0
- package/runtime/lib/lynx/lazy-bundle.d.ts +9 -0
- package/runtime/lib/lynx/lazy-bundle.js +119 -0
- package/runtime/lib/lynx/lazy-bundle.js.map +1 -0
- package/runtime/lib/lynx/performance.d.ts +29 -0
- package/runtime/lib/lynx/performance.js +100 -0
- package/runtime/lib/lynx/performance.js.map +1 -0
- package/runtime/lib/lynx/tt.d.ts +4 -0
- package/runtime/lib/lynx/tt.js +193 -0
- package/runtime/lib/lynx/tt.js.map +1 -0
- package/runtime/lib/lynx-api.d.ts +311 -0
- package/runtime/lib/lynx-api.js +116 -0
- package/runtime/lib/lynx-api.js.map +1 -0
- package/runtime/lib/lynx.d.ts +2 -0
- package/runtime/lib/lynx.js +91 -0
- package/runtime/lib/lynx.js.map +1 -0
- package/runtime/lib/opcodes.d.ts +2 -0
- package/runtime/lib/opcodes.js +59 -0
- package/runtime/lib/opcodes.js.map +1 -0
- package/runtime/lib/renderToOpcodes/constants.d.ts +17 -0
- package/runtime/lib/renderToOpcodes/constants.js +23 -0
- package/runtime/lib/renderToOpcodes/constants.js.map +1 -0
- package/runtime/lib/renderToOpcodes/index.d.ts +13 -0
- package/runtime/lib/renderToOpcodes/index.js +227 -0
- package/runtime/lib/renderToOpcodes/index.js.map +1 -0
- package/runtime/lib/root.d.ts +7 -0
- package/runtime/lib/root.js +17 -0
- package/runtime/lib/root.js.map +1 -0
- package/runtime/lib/snapshot/event.d.ts +3 -0
- package/runtime/lib/snapshot/event.js +24 -0
- package/runtime/lib/snapshot/event.js.map +1 -0
- package/runtime/lib/snapshot/gesture.d.ts +2 -0
- package/runtime/lib/snapshot/gesture.js +18 -0
- package/runtime/lib/snapshot/gesture.js.map +1 -0
- package/runtime/lib/snapshot/platformInfo.d.ts +4 -0
- package/runtime/lib/snapshot/platformInfo.js +35 -0
- package/runtime/lib/snapshot/platformInfo.js.map +1 -0
- package/runtime/lib/snapshot/ref.d.ts +10 -0
- package/runtime/lib/snapshot/ref.js +119 -0
- package/runtime/lib/snapshot/ref.js.map +1 -0
- package/runtime/lib/snapshot/spread.d.ts +5 -0
- package/runtime/lib/snapshot/spread.js +289 -0
- package/runtime/lib/snapshot/spread.js.map +1 -0
- package/runtime/lib/snapshot/workletEvent.d.ts +3 -0
- package/runtime/lib/snapshot/workletEvent.js +22 -0
- package/runtime/lib/snapshot/workletEvent.js.map +1 -0
- package/runtime/lib/snapshot/workletRef.d.ts +5 -0
- package/runtime/lib/snapshot/workletRef.js +52 -0
- package/runtime/lib/snapshot/workletRef.js.map +1 -0
- package/runtime/lib/snapshot.d.ts +81 -0
- package/runtime/lib/snapshot.js +477 -0
- package/runtime/lib/snapshot.js.map +1 -0
- package/runtime/lib/snapshotPatch.d.ts +14 -0
- package/runtime/lib/snapshotPatch.js +31 -0
- package/runtime/lib/snapshotPatch.js.map +1 -0
- package/runtime/lib/snapshotPatchApply.d.ts +2 -0
- package/runtime/lib/snapshotPatchApply.js +110 -0
- package/runtime/lib/snapshotPatchApply.js.map +1 -0
- package/runtime/lib/utils.d.ts +4 -0
- package/runtime/lib/utils.js +32 -0
- package/runtime/lib/utils.js.map +1 -0
- package/runtime/lib/worklet/ctx.d.ts +1 -0
- package/runtime/lib/worklet/ctx.js +17 -0
- package/runtime/lib/worklet/ctx.js.map +1 -0
- package/runtime/lib/worklet/execMap.d.ts +1 -0
- package/runtime/lib/worklet/execMap.js +42 -0
- package/runtime/lib/worklet/execMap.js.map +1 -0
- package/runtime/lib/worklet/functionality.d.ts +1 -0
- package/runtime/lib/worklet/functionality.js +11 -0
- package/runtime/lib/worklet/functionality.js.map +1 -0
- package/runtime/lib/worklet/hmr.d.ts +1 -0
- package/runtime/lib/worklet/hmr.js +21 -0
- package/runtime/lib/worklet/hmr.js.map +1 -0
- package/runtime/lib/worklet/indexMap.d.ts +8 -0
- package/runtime/lib/worklet/indexMap.js +17 -0
- package/runtime/lib/worklet/indexMap.js.map +1 -0
- package/runtime/lib/worklet/jsImpl.d.ts +11 -0
- package/runtime/lib/worklet/jsImpl.js +68 -0
- package/runtime/lib/worklet/jsImpl.js.map +1 -0
- package/runtime/lib/worklet/runWorklet.d.ts +14 -0
- package/runtime/lib/worklet/runWorklet.js +82 -0
- package/runtime/lib/worklet/runWorklet.js.map +1 -0
- package/runtime/lib/worklet/workletRef.d.ts +131 -0
- package/runtime/lib/worklet/workletRef.js +96 -0
- package/runtime/lib/worklet/workletRef.js.map +1 -0
- package/runtime/lib/worklet/workletRefPool.d.ts +2 -0
- package/runtime/lib/worklet/workletRefPool.js +22 -0
- package/runtime/lib/worklet/workletRefPool.js.map +1 -0
- package/runtime/src/backgroundSnapshot.ts +452 -0
- package/runtime/src/compat/componentIs.ts +30 -0
- package/runtime/src/compat/initData.ts +140 -0
- package/runtime/src/compat/lynxComponent.ts +80 -0
- package/runtime/src/debug/debug.ts +9 -0
- package/runtime/src/debug/printSnapshot.ts +28 -0
- package/runtime/src/debug/profile.ts +54 -0
- package/runtime/src/document.ts +53 -0
- package/runtime/src/gesture/processGesture.ts +77 -0
- package/runtime/src/gesture/processGestureBagkround.ts +15 -0
- package/runtime/src/gesture/types.ts +39 -0
- package/runtime/src/hooks/react.ts +62 -0
- package/runtime/src/hooks/useLynxGlobalEventListener.ts +59 -0
- package/runtime/src/hydrate.ts +364 -0
- package/runtime/src/index.ts +89 -0
- package/runtime/src/internal.ts +60 -0
- package/runtime/src/legacy-react-runtime/index.ts +40 -0
- package/runtime/src/lifecycle/delayUnmount.ts +77 -0
- package/runtime/src/lifecycle/destroy.ts +26 -0
- package/runtime/src/lifecycle/pass.ts +14 -0
- package/runtime/src/lifecycle/patchUpdate.ts +240 -0
- package/runtime/src/lifecycle/reload.ts +79 -0
- package/runtime/src/lifecycle/render.ts +46 -0
- package/runtime/src/lifecycleConstant.ts +16 -0
- package/runtime/src/list.ts +375 -0
- package/runtime/src/lynx/calledByNative.ts +132 -0
- package/runtime/src/lynx/component.ts +116 -0
- package/runtime/src/lynx/dynamic-js.ts +33 -0
- package/runtime/src/lynx/env.ts +110 -0
- package/runtime/src/lynx/injectLepusMethods.ts +53 -0
- package/runtime/src/lynx/lazy-bundle.ts +126 -0
- package/runtime/src/lynx/performance.ts +117 -0
- package/runtime/src/lynx/tt.ts +212 -0
- package/runtime/src/lynx-api.ts +374 -0
- package/runtime/src/lynx.ts +105 -0
- package/runtime/src/opcodes.ts +64 -0
- package/runtime/src/renderToOpcodes/constants.ts +24 -0
- package/runtime/src/renderToOpcodes/index.ts +301 -0
- package/runtime/src/root.ts +19 -0
- package/runtime/src/snapshot/event.ts +33 -0
- package/runtime/src/snapshot/gesture.ts +25 -0
- package/runtime/src/snapshot/platformInfo.ts +48 -0
- package/runtime/src/snapshot/ref.ts +151 -0
- package/runtime/src/snapshot/spread.ts +287 -0
- package/runtime/src/snapshot/workletEvent.ts +33 -0
- package/runtime/src/snapshot/workletRef.ts +63 -0
- package/runtime/src/snapshot.ts +576 -0
- package/runtime/src/snapshotPatch.ts +56 -0
- package/runtime/src/snapshotPatchApply.ts +117 -0
- package/runtime/src/utils.ts +35 -0
- package/runtime/src/worklet/ctx.ts +22 -0
- package/runtime/src/worklet/execMap.ts +50 -0
- package/runtime/src/worklet/functionality.ts +12 -0
- package/runtime/src/worklet/hmr.ts +26 -0
- package/runtime/src/worklet/indexMap.ts +20 -0
- package/runtime/src/worklet/jsImpl.ts +86 -0
- package/runtime/src/worklet/runWorklet.ts +88 -0
- package/runtime/src/worklet/workletRef.ts +229 -0
- package/runtime/src/worklet/workletRefPool.ts +25 -0
- package/transform/cjs/main.cjs +6 -0
- package/transform/cjs/main.d.cts +3 -0
- package/transform/cjs/package.json +3 -0
- package/transform/dist/wasm.cjs +8478 -0
- package/transform/index.d.ts +187 -0
- package/transform/main.js +15 -0
- package/types/react.d.ts +147 -0
- package/types/react.docs.d.ts +74 -0
- package/worklet-runtime/dist/dev.js +414 -0
- package/worklet-runtime/dist/dev.js.map +8 -0
- package/worklet-runtime/dist/main.js +414 -0
- package/worklet-runtime/dist/main.js.map +8 -0
- package/worklet-runtime/lib/api/element.d.ts +14 -0
- package/worklet-runtime/lib/api/element.js +71 -0
- package/worklet-runtime/lib/api/element.js.map +1 -0
- package/worklet-runtime/lib/api/lepusQuerySelector.d.ts +3 -0
- package/worklet-runtime/lib/api/lepusQuerySelector.js +23 -0
- package/worklet-runtime/lib/api/lepusQuerySelector.js.map +1 -0
- package/worklet-runtime/lib/api/lynxApi.d.ts +2 -0
- package/worklet-runtime/lib/api/lynxApi.js +35 -0
- package/worklet-runtime/lib/api/lynxApi.js.map +1 -0
- package/worklet-runtime/lib/bindings/bindings.d.ts +14 -0
- package/worklet-runtime/lib/bindings/bindings.js +61 -0
- package/worklet-runtime/lib/bindings/bindings.js.map +1 -0
- package/worklet-runtime/lib/bindings/events.d.ts +7 -0
- package/worklet-runtime/lib/bindings/events.js +9 -0
- package/worklet-runtime/lib/bindings/events.js.map +1 -0
- package/worklet-runtime/lib/bindings/index.d.ts +4 -0
- package/worklet-runtime/lib/bindings/index.js +7 -0
- package/worklet-runtime/lib/bindings/index.js.map +1 -0
- package/worklet-runtime/lib/bindings/loadRuntime.d.ts +8 -0
- package/worklet-runtime/lib/bindings/loadRuntime.js +25 -0
- package/worklet-runtime/lib/bindings/loadRuntime.js.map +1 -0
- package/worklet-runtime/lib/bindings/types.d.ts +35 -0
- package/worklet-runtime/lib/bindings/types.js +2 -0
- package/worklet-runtime/lib/bindings/types.js.map +1 -0
- package/worklet-runtime/lib/delayWorkletEvent.d.ts +11 -0
- package/worklet-runtime/lib/delayWorkletEvent.js +49 -0
- package/worklet-runtime/lib/delayWorkletEvent.js.map +1 -0
- package/worklet-runtime/lib/global.d.ts +15 -0
- package/worklet-runtime/lib/global.js +2 -0
- package/worklet-runtime/lib/global.js.map +1 -0
- package/worklet-runtime/lib/index.d.ts +1 -0
- package/worklet-runtime/lib/index.js +12 -0
- package/worklet-runtime/lib/index.js.map +1 -0
- package/worklet-runtime/lib/jsFunctionLifecycle.d.ts +18 -0
- package/worklet-runtime/lib/jsFunctionLifecycle.js +55 -0
- package/worklet-runtime/lib/jsFunctionLifecycle.js.map +1 -0
- package/worklet-runtime/lib/listeners.d.ts +2 -0
- package/worklet-runtime/lib/listeners.js +17 -0
- package/worklet-runtime/lib/listeners.js.map +1 -0
- package/worklet-runtime/lib/utils/profile.d.ts +1 -0
- package/worklet-runtime/lib/utils/profile.js +20 -0
- package/worklet-runtime/lib/utils/profile.js.map +1 -0
- package/worklet-runtime/lib/utils/version.d.ts +1 -0
- package/worklet-runtime/lib/utils/version.js +10 -0
- package/worklet-runtime/lib/utils/version.js.map +1 -0
- package/worklet-runtime/lib/workletRef.d.ts +12 -0
- package/worklet-runtime/lib/workletRef.js +50 -0
- package/worklet-runtime/lib/workletRef.js.map +1 -0
- package/worklet-runtime/lib/workletRuntime.d.ts +2 -0
- package/worklet-runtime/lib/workletRuntime.js +128 -0
- package/worklet-runtime/lib/workletRuntime.js.map +1 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
// modified from preact-render-to-string@6.0.3
|
|
5
|
+
// @ts-nocheck
|
|
6
|
+
import { Fragment, h, options } from 'preact';
|
|
7
|
+
import { CHILDREN, COMMIT, COMPONENT, DIFF, DIFFED, DIRTY, NEXT_STATE, PARENT, RENDER, SKIP_EFFECTS, VNODE, } from './constants.js';
|
|
8
|
+
/** @typedef {import('preact').VNode} VNode */
|
|
9
|
+
const EMPTY_ARR = [];
|
|
10
|
+
const isArray = /* @__PURE__ */ Array.isArray;
|
|
11
|
+
const assign = /* @__PURE__ */ Object.assign;
|
|
12
|
+
// Global state for the current render pass
|
|
13
|
+
let beforeDiff, afterDiff, renderHook, ummountHook;
|
|
14
|
+
/**
|
|
15
|
+
* Render Preact JSX + Components to an HTML string.
|
|
16
|
+
* @param {VNode} vnode JSX Element / VNode to render
|
|
17
|
+
* @param {object} [context] Initial root context object
|
|
18
|
+
*/
|
|
19
|
+
export function renderToString(vnode, context) {
|
|
20
|
+
// Performance optimization: `renderToString` is synchronous and we
|
|
21
|
+
// therefore don't execute any effects. To do that we pass an empty
|
|
22
|
+
// array to `options._commit` (`__c`). But we can go one step further
|
|
23
|
+
// and avoid a lot of dirty checks and allocations by setting
|
|
24
|
+
// `options._skipEffects` (`__s`) too.
|
|
25
|
+
const previousSkipEffects = options[SKIP_EFFECTS];
|
|
26
|
+
options[SKIP_EFFECTS] = true;
|
|
27
|
+
// store options hooks once before each synchronous render call
|
|
28
|
+
beforeDiff = options[DIFF];
|
|
29
|
+
afterDiff = options[DIFFED];
|
|
30
|
+
renderHook = options[RENDER];
|
|
31
|
+
ummountHook = options.unmount;
|
|
32
|
+
const parent = h(Fragment, null);
|
|
33
|
+
parent[CHILDREN] = [vnode];
|
|
34
|
+
const opcodes = [];
|
|
35
|
+
try {
|
|
36
|
+
_renderToString(vnode, context || EMPTY_OBJ, false, undefined, parent, opcodes);
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
// options._commit, we don't schedule any effects in this library right now,
|
|
40
|
+
// so we can pass an empty queue to this hook.
|
|
41
|
+
if (options[COMMIT])
|
|
42
|
+
options[COMMIT](vnode, EMPTY_ARR);
|
|
43
|
+
options[SKIP_EFFECTS] = previousSkipEffects;
|
|
44
|
+
EMPTY_ARR.length = 0;
|
|
45
|
+
}
|
|
46
|
+
return opcodes;
|
|
47
|
+
}
|
|
48
|
+
// Installed as setState/forceUpdate for function components
|
|
49
|
+
function markAsDirty() {
|
|
50
|
+
this.__d = true;
|
|
51
|
+
}
|
|
52
|
+
const EMPTY_OBJ = {};
|
|
53
|
+
export const __OpBegin = 0;
|
|
54
|
+
export const __OpEnd = 1;
|
|
55
|
+
export const __OpAttr = 2;
|
|
56
|
+
export const __OpText = 3;
|
|
57
|
+
/**
|
|
58
|
+
* @param {VNode} vnode
|
|
59
|
+
* @param {Record<string, unknown>} context
|
|
60
|
+
*/
|
|
61
|
+
function renderClassComponent(vnode, context) {
|
|
62
|
+
let type = /** @type {import("preact").ComponentClass<typeof vnode.props>} */ (vnode.type);
|
|
63
|
+
let c = new type(vnode.props, context);
|
|
64
|
+
vnode[COMPONENT] = c;
|
|
65
|
+
c[VNODE] = vnode;
|
|
66
|
+
c.props = vnode.props;
|
|
67
|
+
c.context = context;
|
|
68
|
+
// turn off stateful re-rendering:
|
|
69
|
+
c[DIRTY] = true;
|
|
70
|
+
if (c.state == null)
|
|
71
|
+
c.state = EMPTY_OBJ;
|
|
72
|
+
if (c[NEXT_STATE] == null) {
|
|
73
|
+
c[NEXT_STATE] = c.state;
|
|
74
|
+
}
|
|
75
|
+
if (type.getDerivedStateFromProps) {
|
|
76
|
+
c.state = assign({}, c.state, type.getDerivedStateFromProps(c.props, c.state));
|
|
77
|
+
}
|
|
78
|
+
if (renderHook)
|
|
79
|
+
renderHook(vnode);
|
|
80
|
+
return c.render(c.props, c.state, context);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Recursively render VNodes to HTML.
|
|
84
|
+
* @param {VNode|any} vnode
|
|
85
|
+
* @param {any} context
|
|
86
|
+
* @param {boolean} isSvgMode
|
|
87
|
+
* @param {any} selectValue
|
|
88
|
+
* @param {VNode} parent
|
|
89
|
+
* @param opcodes
|
|
90
|
+
*/
|
|
91
|
+
function _renderToString(vnode, context, isSvgMode, selectValue, parent, opcodes) {
|
|
92
|
+
// Ignore non-rendered VNodes/values
|
|
93
|
+
if (vnode == null || vnode === true || vnode === false || vnode === '') {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
// Text VNodes: escape as HTML
|
|
97
|
+
if (typeof vnode !== 'object') {
|
|
98
|
+
if (typeof vnode === 'function')
|
|
99
|
+
return;
|
|
100
|
+
opcodes.push(__OpText, vnode + '');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
// Recurse into children / Arrays
|
|
104
|
+
if (isArray(vnode)) {
|
|
105
|
+
parent[CHILDREN] = vnode;
|
|
106
|
+
for (let i = 0; i < vnode.length; i++) {
|
|
107
|
+
let child = vnode[i];
|
|
108
|
+
if (child == null || typeof child === 'boolean')
|
|
109
|
+
continue;
|
|
110
|
+
_renderToString(child, context, isSvgMode, selectValue, parent, opcodes);
|
|
111
|
+
}
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
// VNodes have {constructor:undefined} to prevent JSON injection:
|
|
115
|
+
// if (vnode.constructor !== undefined) return;
|
|
116
|
+
vnode[PARENT] = parent;
|
|
117
|
+
if (beforeDiff)
|
|
118
|
+
beforeDiff(vnode);
|
|
119
|
+
let type = vnode.type, props = vnode.props, cctx = context, contextType, rendered, component;
|
|
120
|
+
// Invoke rendering on Components
|
|
121
|
+
if (typeof type === 'function') {
|
|
122
|
+
if (type === Fragment) {
|
|
123
|
+
rendered = props.children;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
contextType = type.contextType;
|
|
127
|
+
if (contextType != null) {
|
|
128
|
+
let provider = context[contextType.__c];
|
|
129
|
+
cctx = provider ? provider.props.value : contextType.__;
|
|
130
|
+
}
|
|
131
|
+
if (type.prototype && typeof type.prototype.render === 'function') {
|
|
132
|
+
rendered = /**#__NOINLINE__**/ renderClassComponent(vnode, cctx);
|
|
133
|
+
component = vnode[COMPONENT];
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
component = {
|
|
137
|
+
__v: vnode,
|
|
138
|
+
props,
|
|
139
|
+
context: cctx,
|
|
140
|
+
// silently drop state updates
|
|
141
|
+
setState: markAsDirty,
|
|
142
|
+
forceUpdate: markAsDirty,
|
|
143
|
+
__d: true,
|
|
144
|
+
// hooks
|
|
145
|
+
__h: [],
|
|
146
|
+
};
|
|
147
|
+
vnode[COMPONENT] = component;
|
|
148
|
+
component.constructor = type;
|
|
149
|
+
component.render = doRender;
|
|
150
|
+
// If a hook invokes setState() to invalidate the component during rendering,
|
|
151
|
+
// re-render it up to 25 times to allow "settling" of memoized states.
|
|
152
|
+
// Note:
|
|
153
|
+
// This will need to be updated for Preact 11 to use internal.flags rather than component._dirty:
|
|
154
|
+
// https://github.com/preactjs/preact/blob/d4ca6fdb19bc715e49fd144e69f7296b2f4daa40/src/diff/component.js#L35-L44
|
|
155
|
+
let count = 0;
|
|
156
|
+
while (component[DIRTY] && count++ < 25) {
|
|
157
|
+
component[DIRTY] = false;
|
|
158
|
+
if (renderHook)
|
|
159
|
+
renderHook(vnode);
|
|
160
|
+
rendered = component.render(props, component.state, cctx);
|
|
161
|
+
}
|
|
162
|
+
component[DIRTY] = true;
|
|
163
|
+
}
|
|
164
|
+
if (component.getChildContext != null) {
|
|
165
|
+
context = assign({}, context, component.getChildContext());
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// When a component returns a Fragment node we flatten it in core, so we
|
|
169
|
+
// need to mirror that logic here too
|
|
170
|
+
let isTopLevelFragment = rendered != null && rendered.type === Fragment
|
|
171
|
+
&& rendered.key == null;
|
|
172
|
+
rendered = isTopLevelFragment ? rendered.props.children : rendered;
|
|
173
|
+
// Recurse into children before invoking the after-diff hook
|
|
174
|
+
_renderToString(rendered, context, isSvgMode, selectValue, vnode, opcodes);
|
|
175
|
+
if (afterDiff)
|
|
176
|
+
afterDiff(vnode);
|
|
177
|
+
vnode[PARENT] = undefined;
|
|
178
|
+
if (ummountHook)
|
|
179
|
+
ummountHook(vnode);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
let children;
|
|
183
|
+
opcodes.push(__OpBegin, vnode);
|
|
184
|
+
for (let name in props) {
|
|
185
|
+
let v = props[name];
|
|
186
|
+
switch (name) {
|
|
187
|
+
case 'children':
|
|
188
|
+
children = v;
|
|
189
|
+
continue;
|
|
190
|
+
// VDOM-specific props
|
|
191
|
+
/* c8 ignore next 5 */
|
|
192
|
+
case 'key':
|
|
193
|
+
case 'ref':
|
|
194
|
+
case '__self':
|
|
195
|
+
case '__source':
|
|
196
|
+
continue;
|
|
197
|
+
default: { }
|
|
198
|
+
}
|
|
199
|
+
// write this attribute to the buffer
|
|
200
|
+
if (v != null && v !== false && typeof v !== 'function') {
|
|
201
|
+
opcodes.push(__OpAttr, name, v);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (typeof children === 'string') {
|
|
205
|
+
// single text child
|
|
206
|
+
opcodes.push(__OpText, children);
|
|
207
|
+
}
|
|
208
|
+
else if (children != null && children !== false && children !== true) {
|
|
209
|
+
// recurse into this element VNode's children
|
|
210
|
+
_renderToString(children, context, false, selectValue, vnode, opcodes);
|
|
211
|
+
}
|
|
212
|
+
if (afterDiff)
|
|
213
|
+
afterDiff(vnode);
|
|
214
|
+
vnode[PARENT] = undefined;
|
|
215
|
+
if (ummountHook)
|
|
216
|
+
ummountHook(vnode);
|
|
217
|
+
opcodes.push(__OpEnd);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
/** The `.render()` method for a PFC backing instance. */
|
|
221
|
+
function doRender(props, state, context) {
|
|
222
|
+
return this.constructor(props, context);
|
|
223
|
+
}
|
|
224
|
+
export default renderToString;
|
|
225
|
+
export const render = renderToString;
|
|
226
|
+
export const renderToStaticMarkup = renderToString;
|
|
227
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/renderToOpcodes/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,8CAA8C;AAC9C,cAAc;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AAK,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,SAAS;QAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IAChC,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAC1B,IAAI,WAAW;QAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAEpC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEtB,OAAO;AACT,CAAC;AAED,yDAAyD;AACzD,SAAS,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO;IACrC,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC;AAED,eAAe,cAAc,CAAC;AAC9B,MAAM,CAAC,MAAM,MAAM,GAA0B,cAAc,CAAC;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAA0B,cAAc,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BackgroundSnapshotInstance } from './backgroundSnapshot.js';
|
|
2
|
+
import { SnapshotInstance } from './snapshot.js';
|
|
3
|
+
declare let __root: (SnapshotInstance | BackgroundSnapshotInstance) & {
|
|
4
|
+
__jsx?: React.ReactNode;
|
|
5
|
+
};
|
|
6
|
+
declare function setRoot(root: typeof __root): void;
|
|
7
|
+
export { __root, setRoot };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { BackgroundSnapshotInstance } from './backgroundSnapshot.js';
|
|
5
|
+
import { SnapshotInstance } from './snapshot.js';
|
|
6
|
+
let __root;
|
|
7
|
+
function setRoot(root) {
|
|
8
|
+
__root = root;
|
|
9
|
+
}
|
|
10
|
+
if (__LEPUS__) {
|
|
11
|
+
setRoot(new SnapshotInstance('root'));
|
|
12
|
+
}
|
|
13
|
+
else if (__JS__) {
|
|
14
|
+
setRoot(new BackgroundSnapshotInstance('root'));
|
|
15
|
+
}
|
|
16
|
+
export { __root, setRoot };
|
|
17
|
+
//# sourceMappingURL=root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.js","sourceRoot":"","sources":["../src/root.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,IAAI,MAAqF,CAAC;AAE1F,SAAS,OAAO,CAAC,IAAmB;IAClC,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC;AAED,IAAI,SAAS,EAAE,CAAC;IACd,OAAO,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;AACxC,CAAC;KAAM,IAAI,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,IAAI,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { SnapshotInstance } from '../snapshot.js';
|
|
5
|
+
function updateEvent(snapshot, expIndex, _oldValue, elementIndex, eventType, eventName, spreadKey) {
|
|
6
|
+
const value = snapshot.__values[expIndex];
|
|
7
|
+
let event;
|
|
8
|
+
if (!value) {
|
|
9
|
+
event = undefined;
|
|
10
|
+
}
|
|
11
|
+
else if (typeof value === 'string') {
|
|
12
|
+
event = value;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
event = `${snapshot.__id}:${expIndex}:${spreadKey}`;
|
|
16
|
+
}
|
|
17
|
+
// todo: reuseId?
|
|
18
|
+
snapshot.__values[expIndex] = event;
|
|
19
|
+
if (snapshot.__elements) {
|
|
20
|
+
__AddEvent(snapshot.__elements[elementIndex], eventType, eventName, event);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export { updateEvent };
|
|
24
|
+
//# sourceMappingURL=event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../src/snapshot/event.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,SAAS,WAAW,CAClB,QAA0B,EAC1B,QAAgB,EAChB,SAAc,EACd,YAAoB,EACpB,SAAiB,EACjB,SAAiB,EACjB,SAAiB;IAEjB,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAS,CAAC,QAAQ,CAAC,CAAC;IAC3C,IAAI,KAAK,CAAC;IACV,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,SAAS,CAAC;IACpB,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,KAAK,GAAG,KAAK,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,KAAK,GAAG,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,IAAI,SAAS,EAAE,CAAC;IACtD,CAAC;IAED,iBAAiB;IAEjB,QAAQ,CAAC,QAAS,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;IACrC,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;QACxB,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAE,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SnapshotInstance } from '../snapshot.js';
|
|
2
|
+
import { processGesture } from '../gesture/processGesture.js';
|
|
3
|
+
export function updateGesture(snapshot, expIndex, _oldValue, elementIndex, workletType) {
|
|
4
|
+
if (!snapshot.__elements) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
if (__PROFILE__) {
|
|
8
|
+
console.profile('updateGesture');
|
|
9
|
+
}
|
|
10
|
+
const value = snapshot.__values[expIndex];
|
|
11
|
+
if (workletType === 'main-thread') {
|
|
12
|
+
processGesture(snapshot.__elements[elementIndex], value);
|
|
13
|
+
}
|
|
14
|
+
if (__PROFILE__) {
|
|
15
|
+
console.profileEnd();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=gesture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gesture.js","sourceRoot":"","sources":["../../src/snapshot/gesture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,MAAM,UAAU,aAAa,CAC3B,QAA0B,EAC1B,QAAgB,EAChB,SAAc,EACd,YAAoB,EACpB,WAAmB;IAEnB,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QACzB,OAAO;IACT,CAAC;IACD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACnC,CAAC;IACD,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAS,CAAC,QAAQ,CAAC,CAAC;IAE3C,IAAI,WAAW,KAAK,aAAa,EAAE,CAAC;QAClC,cAAc,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAE,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;IACD,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,UAAU,EAAE,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SnapshotInstance } from '../snapshot.js';
|
|
2
|
+
declare const platformInfoAttributes: Set<string>;
|
|
3
|
+
declare function updateListItemPlatformInfo(ctx: SnapshotInstance, index: number, oldValue: any, elementIndex: number): void;
|
|
4
|
+
export { updateListItemPlatformInfo, platformInfoAttributes };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { __pendingListUpdates, ListUpdateInfoRecording } from '../list.js';
|
|
2
|
+
import { SnapshotInstance } from '../snapshot.js';
|
|
3
|
+
const platformInfoVirtualAttributes = /* @__PURE__ */ new Set(['reuse-identifier']);
|
|
4
|
+
const platformInfoAttributes = /* @__PURE__ */ new Set([
|
|
5
|
+
'reuse-identifier',
|
|
6
|
+
'full-span',
|
|
7
|
+
'item-key',
|
|
8
|
+
'sticky-top',
|
|
9
|
+
'sticky-bottom',
|
|
10
|
+
'estimated-height',
|
|
11
|
+
'estimated-height-px',
|
|
12
|
+
'estimated-main-axis-size-px',
|
|
13
|
+
]);
|
|
14
|
+
function updateListItemPlatformInfo(ctx, index, oldValue, elementIndex) {
|
|
15
|
+
const newValue = ctx.__listItemPlatformInfo = ctx.__values[index];
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const list = ctx.__parent;
|
|
18
|
+
if (list?.__snapshot_def.isListHolder) {
|
|
19
|
+
(__pendingListUpdates.values[list.__id] ??= new ListUpdateInfoRecording(list)).onSetAttribute(ctx, newValue, oldValue);
|
|
20
|
+
}
|
|
21
|
+
// In this updater, unlike `updateSpread`, the shape of the value is guaranteed to be an fixed object.
|
|
22
|
+
// No adding / removing keys.
|
|
23
|
+
if (ctx.__elements) {
|
|
24
|
+
const e = ctx.__elements[elementIndex];
|
|
25
|
+
const value = ctx.__values[index];
|
|
26
|
+
for (const k in value) {
|
|
27
|
+
if (platformInfoVirtualAttributes.has(k)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
__SetAttribute(e, k, value[k]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export { updateListItemPlatformInfo, platformInfoAttributes };
|
|
35
|
+
//# sourceMappingURL=platformInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformInfo.js","sourceRoot":"","sources":["../../src/snapshot/platformInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,6BAA6B,GAAgB,eAAe,CAAC,IAAI,GAAG,CAAS,CAAC,kBAAkB,CAAC,CAAC,CAAC;AACzG,MAAM,sBAAsB,GAAgB,eAAe,CAAC,IAAI,GAAG,CAAS;IAC1E,kBAAkB;IAClB,WAAW;IACX,UAAU;IACV,YAAY;IACZ,eAAe;IACf,kBAAkB;IAClB,qBAAqB;IACrB,6BAA6B;CAC9B,CAAC,CAAC;AAEH,SAAS,0BAA0B,CACjC,GAAqB,EACrB,KAAa,EACb,QAAa,EACb,YAAoB;IAEpB,MAAM,QAAQ,GAAG,GAAG,CAAC,sBAAsB,GAAG,GAAG,CAAC,QAAS,CAAC,KAAK,CAAC,CAAC;IAEnE,aAAa;IACb,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC1B,IAAI,IAAI,EAAE,cAAc,CAAC,YAAY,EAAE,CAAC;QACtC,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,uBAAuB,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAC3F,GAAG,EACH,QAAQ,EACR,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,sGAAsG;IACtG,6BAA6B;IAC7B,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;QACnB,MAAM,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,YAAY,CAAE,CAAC;QACxC,MAAM,KAAK,GAAG,GAAG,CAAC,QAAS,CAAC,KAAK,CAAC,CAAC;QACnC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,IAAI,6BAA6B,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzC,SAAS;YACX,CAAC;YACD,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;AACH,CAAC;AAED,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SnapshotInstance } from '../snapshot.js';
|
|
2
|
+
declare let globalRefsToRemove: Map</* commitId */ number, Map</* sign */ string, /* ref */ any>>;
|
|
3
|
+
declare let globalRefsToSet: Map</* commitId */ number, Record<string, number>>;
|
|
4
|
+
declare function unref(snapshot: SnapshotInstance, recursive: boolean): void;
|
|
5
|
+
declare function updateBackgroundRefs(commitId: number): void;
|
|
6
|
+
declare function updateRef(snapshot: SnapshotInstance, expIndex: number, oldValue: any, elementIndex: number, spreadKey: string): void;
|
|
7
|
+
declare function takeGlobalRefPatchMap(): Record<string, number | null>;
|
|
8
|
+
declare function transformRef(ref: unknown): Function | (object & Record<'current', unknown>) | null | undefined;
|
|
9
|
+
declare function markRefToRemove(sign: string, ref: unknown): void;
|
|
10
|
+
export { updateRef, takeGlobalRefPatchMap, updateBackgroundRefs, unref, transformRef, globalRefsToRemove, globalRefsToSet, markRefToRemove, };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { nextCommitTaskId } from '../lifecycle/patchUpdate.js';
|
|
2
|
+
import { SnapshotInstance, backgroundSnapshotInstanceManager } from '../snapshot.js';
|
|
3
|
+
import { workletUnRef } from './workletRef.js';
|
|
4
|
+
let globalRefPatch = {};
|
|
5
|
+
let globalRefsToRemove = /* @__PURE__ */ new Map();
|
|
6
|
+
let globalRefsToSet = /* @__PURE__ */ new Map();
|
|
7
|
+
let nextRefId = 1;
|
|
8
|
+
function unref(snapshot, recursive) {
|
|
9
|
+
snapshot.__ref_set?.forEach(v => {
|
|
10
|
+
globalRefPatch[v] = null;
|
|
11
|
+
});
|
|
12
|
+
snapshot.__ref_set?.clear();
|
|
13
|
+
snapshot.__worklet_ref_set?.forEach(v => {
|
|
14
|
+
if (v) {
|
|
15
|
+
workletUnRef(v);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
snapshot.__worklet_ref_set?.clear();
|
|
19
|
+
if (recursive) {
|
|
20
|
+
snapshot.childNodes.forEach(it => {
|
|
21
|
+
unref(it, recursive);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function applyRef(ref, value) {
|
|
26
|
+
// TODO: ref: exceptions thrown in user functions should be able to be caught by an Error Boundary
|
|
27
|
+
if (typeof ref == 'function') {
|
|
28
|
+
let hasRefUnmount = typeof ref._unmount == 'function';
|
|
29
|
+
if (hasRefUnmount) {
|
|
30
|
+
// @ts-ignore TS doesn't like moving narrowing checks into variables
|
|
31
|
+
ref._unmount();
|
|
32
|
+
}
|
|
33
|
+
if (!hasRefUnmount || value != null) {
|
|
34
|
+
// Store the cleanup function on the function
|
|
35
|
+
// instance object itself to avoid shape
|
|
36
|
+
// transitioning vnode
|
|
37
|
+
ref._unmount = ref(value);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else
|
|
41
|
+
ref.current = value;
|
|
42
|
+
}
|
|
43
|
+
function updateBackgroundRefs(commitId) {
|
|
44
|
+
const oldRefMap = globalRefsToRemove.get(commitId);
|
|
45
|
+
if (oldRefMap) {
|
|
46
|
+
globalRefsToRemove.delete(commitId);
|
|
47
|
+
for (let ref of oldRefMap.values()) {
|
|
48
|
+
applyRef(ref, null);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const newRefMap = globalRefsToSet.get(commitId);
|
|
52
|
+
if (newRefMap) {
|
|
53
|
+
globalRefsToSet.delete(commitId);
|
|
54
|
+
for (const sign in newRefMap) {
|
|
55
|
+
const ref = backgroundSnapshotInstanceManager.getValueBySign(sign);
|
|
56
|
+
if (ref) {
|
|
57
|
+
// TODO: ref: support __REF_FIRE_IMMEDIATELY__
|
|
58
|
+
const v = newRefMap[sign]
|
|
59
|
+
&& lynx.createSelectorQuery().selectUniqueID(newRefMap[sign]);
|
|
60
|
+
applyRef(ref, v);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function updateRef(snapshot, expIndex, oldValue, elementIndex, spreadKey) {
|
|
66
|
+
const value = snapshot.__values[expIndex];
|
|
67
|
+
let ref;
|
|
68
|
+
if (!value) {
|
|
69
|
+
ref = undefined;
|
|
70
|
+
}
|
|
71
|
+
else if (typeof value === 'string') {
|
|
72
|
+
ref = value;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
ref = `${snapshot.__id}:${expIndex}:${spreadKey}`;
|
|
76
|
+
}
|
|
77
|
+
snapshot.__values[expIndex] = ref;
|
|
78
|
+
if (snapshot.__elements && ref) {
|
|
79
|
+
__SetAttribute(snapshot.__elements[elementIndex], 'has-react-ref', true);
|
|
80
|
+
const uid = __GetElementUniqueID(snapshot.__elements[elementIndex]);
|
|
81
|
+
globalRefPatch[ref] = uid;
|
|
82
|
+
snapshot.__ref_set ??= new Set();
|
|
83
|
+
snapshot.__ref_set.add(ref);
|
|
84
|
+
}
|
|
85
|
+
if (oldValue !== ref) {
|
|
86
|
+
snapshot.__ref_set?.delete(oldValue);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function takeGlobalRefPatchMap() {
|
|
90
|
+
const patch = globalRefPatch;
|
|
91
|
+
globalRefPatch = {};
|
|
92
|
+
return patch;
|
|
93
|
+
}
|
|
94
|
+
function transformRef(ref) {
|
|
95
|
+
if (ref === undefined || ref === null) {
|
|
96
|
+
return ref;
|
|
97
|
+
}
|
|
98
|
+
if (typeof ref === 'function' || (typeof ref === 'object' && 'current' in ref)) {
|
|
99
|
+
if ('__ref' in ref) {
|
|
100
|
+
return ref;
|
|
101
|
+
}
|
|
102
|
+
return Object.defineProperty(ref, '__ref', { value: nextRefId++ });
|
|
103
|
+
}
|
|
104
|
+
throw new Error(`Elements' "ref" property should be a function, or an object created `
|
|
105
|
+
+ `by createRef(), but got [${typeof ref}] instead`);
|
|
106
|
+
}
|
|
107
|
+
function markRefToRemove(sign, ref) {
|
|
108
|
+
if (!ref) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
let oldRefs = globalRefsToRemove.get(nextCommitTaskId);
|
|
112
|
+
if (!oldRefs) {
|
|
113
|
+
oldRefs = new Map();
|
|
114
|
+
globalRefsToRemove.set(nextCommitTaskId, oldRefs);
|
|
115
|
+
}
|
|
116
|
+
oldRefs.set(sign, ref);
|
|
117
|
+
}
|
|
118
|
+
export { updateRef, takeGlobalRefPatchMap, updateBackgroundRefs, unref, transformRef, globalRefsToRemove, globalRefsToSet, markRefToRemove, };
|
|
119
|
+
//# sourceMappingURL=ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ref.js","sourceRoot":"","sources":["../../src/snapshot/ref.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,IAAI,cAAc,GAAkC,EAAE,CAAC;AACvD,IAAI,kBAAkB,GAAsE,eAAe,CAAC,IAAI,GAAG,EAAE,CAAC;AACtH,IAAI,eAAe,GAAuD,eAAe,CAAC,IAAI,GAAG,EAAE,CAAC;AACpG,IAAI,SAAS,GAAG,CAAC,CAAC;AAElB,SAAS,KAAK,CAAC,QAA0B,EAAE,SAAkB;IAC3D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE;QAC9B,cAAc,CAAC,CAAC,CAAC,GAAG,IAA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AkB,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACvD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACpB,kBAAkB,CAAC,GAAG,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,EACL,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,eAAe,GAChB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SnapshotInstance } from '../snapshot.js';
|
|
2
|
+
import { BackgroundSnapshotInstance } from '../backgroundSnapshot.js';
|
|
3
|
+
declare function updateSpread(snapshot: SnapshotInstance, index: number, oldValue: any, elementIndex: number): void;
|
|
4
|
+
declare function transformSpread(snapshot: BackgroundSnapshotInstance | SnapshotInstance, index: number, spread: Record<string, unknown>): Record<string, unknown>;
|
|
5
|
+
export { updateSpread, transformSpread };
|