resuxjs 0.3.11 → 0.4.0-beta.3
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/README.md +23 -1
- package/dist/bin.d.ts +1 -2
- package/dist/bin.js +5 -0
- package/dist/bin.js.map +1 -1
- package/dist/build/index.d.ts +29 -0
- package/dist/build/index.js +51 -0
- package/dist/build/index.js.map +1 -0
- package/dist/cli.d.ts +19 -8
- package/dist/cli.js +2653 -3688
- package/dist/cli.js.map +1 -1
- package/dist/compiler/adapter.d.ts +19 -15
- package/dist/compiler/adapter.js +69 -93
- package/dist/compiler/adapter.js.map +1 -1
- package/dist/compiler/dev-warnings.d.ts +14 -10
- package/dist/compiler/dev-warnings.js +247 -319
- package/dist/compiler/dev-warnings.js.map +1 -1
- package/dist/compiler/directives.d.ts +7 -3
- package/dist/compiler/directives.js +125 -150
- package/dist/compiler/directives.js.map +1 -1
- package/dist/compiler/implementation.d.ts +117 -112
- package/dist/compiler/implementation.js +2954 -3426
- package/dist/compiler/index.d.ts +19 -15
- package/dist/compiler/index.js +69 -93
- package/dist/compiler/index.js.map +1 -1
- package/dist/core/config.d.ts +19 -10
- package/dist/core/config.js +42 -25
- package/dist/core/config.js.map +1 -1
- package/dist/core/hooks.d.ts +133 -131
- package/dist/core/hooks.js +45 -55
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/index.d.ts +5 -4
- package/dist/core/index.js +6 -5
- package/dist/core/module-container.d.ts +97 -93
- package/dist/core/module-container.js +180 -185
- package/dist/core/module-container.js.map +1 -1
- package/dist/core/resux.d.ts +20 -15
- package/dist/core/resux.js +18 -13
- package/dist/core/resux.js.map +1 -1
- package/dist/create-bin.d.ts +1 -2
- package/dist/create-bin.js +5 -0
- package/dist/create-bin.js.map +1 -1
- package/dist/create.d.ts +6 -2
- package/dist/create.js +496 -638
- package/dist/create.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +7 -2
- package/dist/deploy/cloudflare.js +31 -34
- package/dist/deploy/cloudflare.js.map +1 -1
- package/dist/deploy/common.d.ts +19 -15
- package/dist/deploy/common.js +119 -188
- package/dist/deploy/common.js.map +1 -1
- package/dist/deploy/framework-runtime.d.ts +5 -1
- package/dist/deploy/framework-runtime.js +44 -48
- package/dist/deploy/framework-runtime.js.map +1 -1
- package/dist/deploy/index.d.ts +8 -3
- package/dist/deploy/index.js +56 -80
- package/dist/deploy/index.js.map +1 -1
- package/dist/deploy/netlify.d.ts +7 -2
- package/dist/deploy/netlify.js +41 -41
- package/dist/deploy/netlify.js.map +1 -1
- package/dist/deploy/node.d.ts +7 -2
- package/dist/deploy/node.js +24 -19
- package/dist/deploy/node.js.map +1 -1
- package/dist/deploy/production-report.d.ts +5 -1
- package/dist/deploy/production-report.js +15 -14
- package/dist/deploy/production-report.js.map +1 -1
- package/dist/deploy/runtime-dependencies.d.ts +8 -4
- package/dist/deploy/runtime-dependencies.js +158 -220
- package/dist/deploy/runtime-dependencies.js.map +1 -1
- package/dist/deploy/static.d.ts +7 -2
- package/dist/deploy/static.js +17 -14
- package/dist/deploy/static.js.map +1 -1
- package/dist/deploy/types.d.ts +33 -29
- package/dist/deploy/types.js +1 -2
- package/dist/deploy/vercel.d.ts +8 -3
- package/dist/deploy/vercel.js +138 -188
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/fonts/index.d.ts +19 -14
- package/dist/fonts/index.js +115 -134
- package/dist/fonts/index.js.map +1 -1
- package/dist/globals.d.ts +79 -78
- package/dist/globals.js +1 -2
- package/dist/halal-core/ai/classifyProject.d.ts +9 -4
- package/dist/halal-core/ai/classifyProject.js +82 -95
- package/dist/halal-core/ai/classifyProject.js.map +1 -1
- package/dist/halal-core/ai/classifyRuntimeContent.d.ts +8 -3
- package/dist/halal-core/ai/classifyRuntimeContent.js +78 -95
- package/dist/halal-core/ai/classifyRuntimeContent.js.map +1 -1
- package/dist/halal-core/ai/createProjectSummary.d.ts +40 -36
- package/dist/halal-core/ai/createProjectSummary.js +39 -39
- package/dist/halal-core/ai/createProjectSummary.js.map +1 -1
- package/dist/halal-core/ai/halalClassifierPrompt.d.ts +5 -1
- package/dist/halal-core/ai/halalClassifierPrompt.js +5 -1
- package/dist/halal-core/ai/halalClassifierPrompt.js.map +1 -1
- package/dist/halal-core/ai/redactSensitiveData.d.ts +5 -1
- package/dist/halal-core/ai/redactSensitiveData.js +82 -110
- package/dist/halal-core/ai/redactSensitiveData.js.map +1 -1
- package/dist/halal-core/ai/validateAiResponse.d.ts +7 -2
- package/dist/halal-core/ai/validateAiResponse.js +56 -83
- package/dist/halal-core/ai/validateAiResponse.js.map +1 -1
- package/dist/halal-core/cli/check.d.ts +5 -1
- package/dist/halal-core/cli/check.js +28 -30
- package/dist/halal-core/cli/check.js.map +1 -1
- package/dist/halal-core/cli/explain.d.ts +5 -1
- package/dist/halal-core/cli/explain.js +27 -31
- package/dist/halal-core/cli/explain.js.map +1 -1
- package/dist/halal-core/cli/report.d.ts +5 -1
- package/dist/halal-core/cli/report.js +14 -10
- package/dist/halal-core/cli/report.js.map +1 -1
- package/dist/halal-core/cli/submitReview.d.ts +5 -1
- package/dist/halal-core/cli/submitReview.js +13 -9
- package/dist/halal-core/cli/submitReview.js.map +1 -1
- package/dist/halal-core/cli/verifyReview.d.ts +5 -1
- package/dist/halal-core/cli/verifyReview.js +17 -15
- package/dist/halal-core/cli/verifyReview.js.map +1 -1
- package/dist/halal-core/config.d.ts +39 -35
- package/dist/halal-core/config.js +77 -118
- package/dist/halal-core/config.js.map +1 -1
- package/dist/halal-core/crypto/integrity.d.ts +12 -8
- package/dist/halal-core/crypto/integrity.js +65 -87
- package/dist/halal-core/crypto/integrity.js.map +1 -1
- package/dist/halal-core/enforce.d.ts +9 -5
- package/dist/halal-core/enforce.js +90 -105
- package/dist/halal-core/enforce.js.map +1 -1
- package/dist/halal-core/index.d.ts +20 -16
- package/dist/halal-core/index.js +19 -19
- package/dist/halal-core/lifecycle.d.ts +5 -1
- package/dist/halal-core/lifecycle.js +16 -13
- package/dist/halal-core/lifecycle.js.map +1 -1
- package/dist/halal-core/policy.d.ts +7 -2
- package/dist/halal-core/policy.js +7 -2
- package/dist/halal-core/policy.js.map +1 -1
- package/dist/halal-core/report/formatBrowserOverlay.d.ts +7 -2
- package/dist/halal-core/report/formatBrowserOverlay.js +10 -8
- package/dist/halal-core/report/formatBrowserOverlay.js.map +1 -1
- package/dist/halal-core/report/formatTerminalReport.d.ts +7 -2
- package/dist/halal-core/report/formatTerminalReport.js +27 -37
- package/dist/halal-core/report/formatTerminalReport.js.map +1 -1
- package/dist/halal-core/report/generateHalalReport.d.ts +11 -6
- package/dist/halal-core/report/generateHalalReport.js +25 -27
- package/dist/halal-core/report/generateHalalReport.js.map +1 -1
- package/dist/halal-core/report/signReport.d.ts +8 -3
- package/dist/halal-core/report/signReport.js +17 -12
- package/dist/halal-core/report/signReport.js.map +1 -1
- package/dist/halal-core/report/verifyReport.d.ts +14 -9
- package/dist/halal-core/report/verifyReport.js +52 -41
- package/dist/halal-core/report/verifyReport.js.map +1 -1
- package/dist/halal-core/review/createReviewRequest.d.ts +7 -2
- package/dist/halal-core/review/createReviewRequest.js +21 -17
- package/dist/halal-core/review/createReviewRequest.js.map +1 -1
- package/dist/halal-core/review/reviewPolicy.d.ts +7 -3
- package/dist/halal-core/review/reviewPolicy.js +19 -17
- package/dist/halal-core/review/reviewPolicy.js.map +1 -1
- package/dist/halal-core/review/signedReviewFile.d.ts +17 -12
- package/dist/halal-core/review/signedReviewFile.js +25 -22
- package/dist/halal-core/review/signedReviewFile.js.map +1 -1
- package/dist/halal-core/review/verifyReviewApproval.d.ts +12 -8
- package/dist/halal-core/review/verifyReviewApproval.js +69 -62
- package/dist/halal-core/review/verifyReviewApproval.js.map +1 -1
- package/dist/halal-core/rules/adultContentRules.d.ts +6 -2
- package/dist/halal-core/rules/adultContentRules.js +23 -23
- package/dist/halal-core/rules/adultContentRules.js.map +1 -1
- package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +6 -2
- package/dist/halal-core/rules/alcoholDrugVapeRules.js +22 -22
- package/dist/halal-core/rules/alcoholDrugVapeRules.js.map +1 -1
- package/dist/halal-core/rules/childSafetyRules.d.ts +6 -2
- package/dist/halal-core/rules/childSafetyRules.js +19 -19
- package/dist/halal-core/rules/childSafetyRules.js.map +1 -1
- package/dist/halal-core/rules/coreCategories.d.ts +10 -6
- package/dist/halal-core/rules/coreCategories.js +237 -110
- package/dist/halal-core/rules/coreCategories.js.map +1 -1
- package/dist/halal-core/rules/cyberAbuseRules.d.ts +6 -2
- package/dist/halal-core/rules/cyberAbuseRules.js +27 -27
- package/dist/halal-core/rules/cyberAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/defaultBlockedRules.d.ts +24 -19
- package/dist/halal-core/rules/defaultBlockedRules.js +156 -199
- package/dist/halal-core/rules/defaultBlockedRules.js.map +1 -1
- package/dist/halal-core/rules/dependencyRules.d.ts +11 -7
- package/dist/halal-core/rules/dependencyRules.js +50 -56
- package/dist/halal-core/rules/dependencyRules.js.map +1 -1
- package/dist/halal-core/rules/endpointRules.d.ts +9 -5
- package/dist/halal-core/rules/endpointRules.js +21 -23
- package/dist/halal-core/rules/endpointRules.js.map +1 -1
- package/dist/halal-core/rules/environmentalHarmRules.d.ts +6 -2
- package/dist/halal-core/rules/environmentalHarmRules.js +17 -17
- package/dist/halal-core/rules/environmentalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/financeRibaRules.d.ts +6 -2
- package/dist/halal-core/rules/financeRibaRules.js +20 -20
- package/dist/halal-core/rules/financeRibaRules.js.map +1 -1
- package/dist/halal-core/rules/gamblingRules.d.ts +6 -2
- package/dist/halal-core/rules/gamblingRules.js +22 -22
- package/dist/halal-core/rules/gamblingRules.js.map +1 -1
- package/dist/halal-core/rules/generalHarmRules.d.ts +6 -2
- package/dist/halal-core/rules/generalHarmRules.js +15 -15
- package/dist/halal-core/rules/generalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/healthHarmRules.d.ts +6 -2
- package/dist/halal-core/rules/healthHarmRules.js +19 -19
- package/dist/halal-core/rules/healthHarmRules.js.map +1 -1
- package/dist/halal-core/rules/keywordRules.d.ts +13 -9
- package/dist/halal-core/rules/keywordRules.js +90 -39
- package/dist/halal-core/rules/keywordRules.js.map +1 -1
- package/dist/halal-core/rules/privacyAbuseRules.d.ts +6 -2
- package/dist/halal-core/rules/privacyAbuseRules.js +21 -21
- package/dist/halal-core/rules/privacyAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/scamFraudRules.d.ts +6 -2
- package/dist/halal-core/rules/scamFraudRules.js +29 -29
- package/dist/halal-core/rules/scamFraudRules.js.map +1 -1
- package/dist/halal-core/rules/selfHarmRules.d.ts +6 -2
- package/dist/halal-core/rules/selfHarmRules.js +17 -17
- package/dist/halal-core/rules/selfHarmRules.js.map +1 -1
- package/dist/halal-core/rules/violenceExtremismRules.d.ts +6 -2
- package/dist/halal-core/rules/violenceExtremismRules.js +30 -30
- package/dist/halal-core/rules/violenceExtremismRules.js.map +1 -1
- package/dist/halal-core/runtime/guard.d.ts +22 -17
- package/dist/halal-core/runtime/guard.js +163 -183
- package/dist/halal-core/runtime/guard.js.map +1 -1
- package/dist/halal-core/runtime/index.d.ts +5 -4
- package/dist/halal-core/runtime/index.js +5 -5
- package/dist/halal-core/runtime/reviewedMemory.d.ts +10 -5
- package/dist/halal-core/runtime/reviewedMemory.js +75 -110
- package/dist/halal-core/runtime/reviewedMemory.js.map +1 -1
- package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +17 -12
- package/dist/halal-core/runtime/serializeRuntimeContent.js +133 -156
- package/dist/halal-core/runtime/serializeRuntimeContent.js.map +1 -1
- package/dist/halal-core/runtime/types.d.ts +55 -50
- package/dist/halal-core/runtime/types.js +1 -2
- package/dist/halal-core/scanner/scanApiRoutes.d.ts +5 -1
- package/dist/halal-core/scanner/scanApiRoutes.js +33 -36
- package/dist/halal-core/scanner/scanApiRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanComponents.d.ts +5 -1
- package/dist/halal-core/scanner/scanComponents.js +13 -13
- package/dist/halal-core/scanner/scanComponents.js.map +1 -1
- package/dist/halal-core/scanner/scanContent.d.ts +8 -4
- package/dist/halal-core/scanner/scanContent.js +192 -261
- package/dist/halal-core/scanner/scanContent.js.map +1 -1
- package/dist/halal-core/scanner/scanDependencies.d.ts +5 -1
- package/dist/halal-core/scanner/scanDependencies.js +17 -15
- package/dist/halal-core/scanner/scanDependencies.js.map +1 -1
- package/dist/halal-core/scanner/scanDomains.d.ts +7 -3
- package/dist/halal-core/scanner/scanDomains.js +12 -12
- package/dist/halal-core/scanner/scanDomains.js.map +1 -1
- package/dist/halal-core/scanner/scanEnvNames.d.ts +5 -1
- package/dist/halal-core/scanner/scanEnvNames.js +24 -26
- package/dist/halal-core/scanner/scanEnvNames.js.map +1 -1
- package/dist/halal-core/scanner/scanMetadata.d.ts +9 -5
- package/dist/halal-core/scanner/scanMetadata.js +21 -29
- package/dist/halal-core/scanner/scanMetadata.js.map +1 -1
- package/dist/halal-core/scanner/scanPages.d.ts +5 -1
- package/dist/halal-core/scanner/scanPages.js +13 -15
- package/dist/halal-core/scanner/scanPages.js.map +1 -1
- package/dist/halal-core/scanner/scanProject.d.ts +19 -12
- package/dist/halal-core/scanner/scanProject.js +44 -49
- package/dist/halal-core/scanner/scanProject.js.map +1 -1
- package/dist/halal-core/scanner/scanRoutes.d.ts +5 -1
- package/dist/halal-core/scanner/scanRoutes.js +33 -39
- package/dist/halal-core/scanner/scanRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanTranslations.d.ts +5 -1
- package/dist/halal-core/scanner/scanTranslations.js +22 -29
- package/dist/halal-core/scanner/scanTranslations.js.map +1 -1
- package/dist/halal-core/status.d.ts +17 -13
- package/dist/halal-core/status.js +1 -2
- package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +5 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.js +27 -24
- package/dist/halal-core/tamper/verifyCoreIntegrity.js.map +1 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +5 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.js +13 -12
- package/dist/halal-core/tamper/verifyLifecycleHooks.js.map +1 -1
- package/dist/halal-core/tamper/verifyReportSignature.d.ts +9 -4
- package/dist/halal-core/tamper/verifyReportSignature.js +20 -14
- package/dist/halal-core/tamper/verifyReportSignature.js.map +1 -1
- package/dist/halal.d.ts +20 -1
- package/dist/halal.js +19 -2
- package/dist/i18n/index.d.ts +44 -40
- package/dist/i18n/index.js +218 -288
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/shared.d.ts +33 -29
- package/dist/i18n/shared.js +204 -266
- package/dist/i18n/shared.js.map +1 -1
- package/dist/icons/index.d.ts +160 -154
- package/dist/icons/index.js +323 -273
- package/dist/icons/index.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +8 -2
- package/dist/kit/index.d.ts +32 -27
- package/dist/kit/index.js +46 -43
- package/dist/kit/index.js.map +1 -1
- package/dist/nitro-server/index.d.ts +10 -6
- package/dist/nitro-server/index.js +6 -2
- package/dist/nitro-server/index.js.map +1 -1
- package/dist/node.d.ts +9 -4
- package/dist/node.js +89 -116
- package/dist/node.js.map +1 -1
- package/dist/reactivity/computed.d.ts +11 -6
- package/dist/reactivity/computed.js +46 -53
- package/dist/reactivity/computed.js.map +1 -1
- package/dist/reactivity/effect.d.ts +23 -18
- package/dist/reactivity/effect.js +105 -147
- package/dist/reactivity/effect.js.map +1 -1
- package/dist/reactivity/index.d.ts +8 -8
- package/dist/reactivity/index.js +8 -8
- package/dist/reactivity/reactive.d.ts +9 -5
- package/dist/reactivity/reactive.js +95 -134
- package/dist/reactivity/reactive.js.map +1 -1
- package/dist/reactivity/readonly.d.ts +2 -1
- package/dist/reactivity/readonly.js +3 -2
- package/dist/reactivity/ref.d.ts +23 -21
- package/dist/reactivity/ref.js +71 -81
- package/dist/reactivity/ref.js.map +1 -1
- package/dist/reactivity/scheduler.d.ts +8 -5
- package/dist/reactivity/scheduler.js +67 -69
- package/dist/reactivity/scheduler.js.map +1 -1
- package/dist/reactivity/types.d.ts +29 -25
- package/dist/reactivity/types.js +1 -2
- package/dist/reactivity/utils.d.ts +17 -13
- package/dist/reactivity/utils.js +25 -24
- package/dist/reactivity/utils.js.map +1 -1
- package/dist/reactivity/watch.d.ts +8 -4
- package/dist/reactivity/watch.js +74 -103
- package/dist/reactivity/watch.js.map +1 -1
- package/dist/runtime/core.d.ts +32 -0
- package/dist/runtime/core.js +155 -0
- package/dist/runtime/core.js.map +1 -0
- package/dist/runtime/index.d.ts +649 -622
- package/dist/runtime/index.js +4105 -5243
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/reactivity.d.ts +7 -0
- package/dist/runtime/reactivity.js +7 -0
- package/dist/runtime/resume.d.ts +80 -0
- package/dist/runtime/resume.js +482 -0
- package/dist/runtime/resume.js.map +1 -0
- package/dist/runtime/router.d.ts +21 -0
- package/dist/runtime/router.js +60 -0
- package/dist/runtime/router.js.map +1 -0
- package/dist/runtime/streaming.d.ts +25 -0
- package/dist/runtime/streaming.js +200 -0
- package/dist/runtime/streaming.js.map +1 -0
- package/dist/security/media-fetch.d.ts +33 -0
- package/dist/security/media-fetch.js +302 -0
- package/dist/security/media-fetch.js.map +1 -0
- package/dist/security/path-boundary.d.ts +8 -0
- package/dist/security/path-boundary.js +71 -0
- package/dist/security/path-boundary.js.map +1 -0
- package/dist/ui/index.d.ts +1774 -1768
- package/dist/ui/index.js +974 -674
- package/dist/ui/index.js.map +1 -1
- package/dist/vite-builder/index.d.ts +9 -5
- package/dist/vite-builder/index.js +6 -2
- package/dist/vite-builder/index.js.map +1 -1
- package/package.json +46 -86
- package/dist/compiler/implementation.js.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/deploy/types.js.map +0 -1
- package/dist/globals.js.map +0 -1
- package/dist/halal-core/index.js.map +0 -1
- package/dist/halal-core/runtime/index.js.map +0 -1
- package/dist/halal-core/runtime/types.js.map +0 -1
- package/dist/halal-core/status.js.map +0 -1
- package/dist/halal.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/reactivity/index.js.map +0 -1
- package/dist/reactivity/readonly.js.map +0 -1
- package/dist/reactivity/types.js.map +0 -1
|
@@ -1,148 +1,109 @@
|
|
|
1
1
|
import { ITERATE_KEY, track, trigger } from "./effect.js";
|
|
2
|
-
import { hasOwn, isObject
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
2
|
+
import { ReactiveFlags, hasOwn, isObject } from "./utils.js";
|
|
3
|
+
|
|
4
|
+
//#region src/reactivity/reactive.ts
|
|
5
|
+
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
const proxyToRaw = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
const reactiveProxies = /* @__PURE__ */ new WeakSet();
|
|
9
|
+
const readonlyProxies = /* @__PURE__ */ new WeakSet();
|
|
8
10
|
const mutableHandlers = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
trigger(target, key, hadKey ? "set" : "add", rawValue, oldLength);
|
|
42
|
-
}
|
|
43
|
-
return success;
|
|
44
|
-
},
|
|
45
|
-
deleteProperty(target, key) {
|
|
46
|
-
const hadKey = hasOwn(target, key);
|
|
47
|
-
const success = Reflect.deleteProperty(target, key);
|
|
48
|
-
if (hadKey && success) {
|
|
49
|
-
trigger(target, key, "delete");
|
|
50
|
-
}
|
|
51
|
-
return success;
|
|
52
|
-
}
|
|
11
|
+
get(target, key, receiver) {
|
|
12
|
+
if (key === ReactiveFlags.IS_REACTIVE) return true;
|
|
13
|
+
if (key === ReactiveFlags.IS_READONLY) return false;
|
|
14
|
+
if (key === ReactiveFlags.RAW) return target;
|
|
15
|
+
const result = Reflect.get(target, key, receiver);
|
|
16
|
+
track(target, key);
|
|
17
|
+
return isObject(result) ? reactive(result) : result;
|
|
18
|
+
},
|
|
19
|
+
has(target, key) {
|
|
20
|
+
const result = Reflect.has(target, key);
|
|
21
|
+
track(target, key);
|
|
22
|
+
return result;
|
|
23
|
+
},
|
|
24
|
+
ownKeys(target) {
|
|
25
|
+
track(target, ITERATE_KEY);
|
|
26
|
+
return Reflect.ownKeys(target);
|
|
27
|
+
},
|
|
28
|
+
set(target, key, value, receiver) {
|
|
29
|
+
const oldLength = Array.isArray(target) ? target.length : void 0;
|
|
30
|
+
const hadKey = hasOwn(target, key);
|
|
31
|
+
const oldValue = toRaw(Reflect.get(target, key, receiver));
|
|
32
|
+
const rawValue = toRaw(value);
|
|
33
|
+
const success = Reflect.set(target, key, rawValue, receiver);
|
|
34
|
+
if (success && target === toRaw(receiver) && (!hadKey || !Object.is(rawValue, oldValue))) trigger(target, key, hadKey ? "set" : "add", rawValue, oldLength);
|
|
35
|
+
return success;
|
|
36
|
+
},
|
|
37
|
+
deleteProperty(target, key) {
|
|
38
|
+
const hadKey = hasOwn(target, key);
|
|
39
|
+
const success = Reflect.deleteProperty(target, key);
|
|
40
|
+
if (hadKey && success) trigger(target, key, "delete");
|
|
41
|
+
return success;
|
|
42
|
+
}
|
|
53
43
|
};
|
|
54
44
|
const readonlyHandlers = {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
set() {
|
|
75
|
-
return true;
|
|
76
|
-
},
|
|
77
|
-
deleteProperty() {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
45
|
+
get(target, key, receiver) {
|
|
46
|
+
if (key === ReactiveFlags.IS_REACTIVE) return false;
|
|
47
|
+
if (key === ReactiveFlags.IS_READONLY) return true;
|
|
48
|
+
if (key === ReactiveFlags.RAW) return target;
|
|
49
|
+
const result = Reflect.get(target, key, receiver);
|
|
50
|
+
return isObject(result) ? readonly(result) : result;
|
|
51
|
+
},
|
|
52
|
+
has(target, key) {
|
|
53
|
+
return Reflect.has(target, key);
|
|
54
|
+
},
|
|
55
|
+
ownKeys(target) {
|
|
56
|
+
return Reflect.ownKeys(target);
|
|
57
|
+
},
|
|
58
|
+
set() {
|
|
59
|
+
return true;
|
|
60
|
+
},
|
|
61
|
+
deleteProperty() {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
80
64
|
};
|
|
81
|
-
|
|
82
|
-
|
|
65
|
+
function reactive(target) {
|
|
66
|
+
return createReactiveObject(target, false, reactiveMap, mutableHandlers);
|
|
83
67
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
return createReactiveObject(target, true, readonlyMap, readonlyHandlers);
|
|
68
|
+
function readonly(target) {
|
|
69
|
+
if (!isObject(target)) return target;
|
|
70
|
+
return createReactiveObject(target, true, readonlyMap, readonlyHandlers);
|
|
89
71
|
}
|
|
90
|
-
function createReactiveObject(target, isReadonly, proxyMap, baseHandlers) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const proxy = new Proxy(target, baseHandlers);
|
|
102
|
-
proxyMap.set(target, proxy);
|
|
103
|
-
proxyToRaw.set(proxy, target);
|
|
104
|
-
if (isReadonly) {
|
|
105
|
-
readonlyProxies.add(proxy);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
reactiveProxies.add(proxy);
|
|
109
|
-
}
|
|
110
|
-
return proxy;
|
|
72
|
+
function createReactiveObject(target, isReadonly$1, proxyMap, baseHandlers) {
|
|
73
|
+
if (!isObject(target) || !canUseBaseProxyHandlers(target)) return target;
|
|
74
|
+
if (proxyToRaw.has(target) && !(isReadonly$1 && reactiveProxies.has(target))) return target;
|
|
75
|
+
const existingProxy = proxyMap.get(target);
|
|
76
|
+
if (existingProxy) return existingProxy;
|
|
77
|
+
const proxy = new Proxy(target, baseHandlers);
|
|
78
|
+
proxyMap.set(target, proxy);
|
|
79
|
+
proxyToRaw.set(proxy, target);
|
|
80
|
+
if (isReadonly$1) readonlyProxies.add(proxy);
|
|
81
|
+
else reactiveProxies.add(proxy);
|
|
82
|
+
return proxy;
|
|
111
83
|
}
|
|
112
84
|
function canUseBaseProxyHandlers(target) {
|
|
113
|
-
|
|
114
|
-
|
|
85
|
+
const rawType = Object.prototype.toString.call(target);
|
|
86
|
+
return rawType === "[object Object]" || rawType === "[object Array]";
|
|
115
87
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
const wrapped = readonlyProxies.has(value) ? proxyToRaw.get(value) : undefined;
|
|
124
|
-
return wrapped ? isReactive(wrapped) : false;
|
|
88
|
+
function isReactive(value) {
|
|
89
|
+
if (!isObject(value)) return false;
|
|
90
|
+
if (reactiveProxies.has(value)) return true;
|
|
91
|
+
const wrapped = readonlyProxies.has(value) ? proxyToRaw.get(value) : void 0;
|
|
92
|
+
return wrapped ? isReactive(wrapped) : false;
|
|
125
93
|
}
|
|
126
|
-
|
|
127
|
-
|
|
94
|
+
function isReadonly(value) {
|
|
95
|
+
return Boolean(isObject(value) && readonlyProxies.has(value));
|
|
128
96
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
return current;
|
|
139
|
-
}
|
|
140
|
-
function isArrayIndex(key) {
|
|
141
|
-
if (typeof key === "symbol" || key === "length") {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
const value = String(key);
|
|
145
|
-
return /^(?:0|[1-9]\d*)$/.test(value)
|
|
146
|
-
&& Number(value) < 4_294_967_295;
|
|
97
|
+
function toRaw(value) {
|
|
98
|
+
let current = value;
|
|
99
|
+
while (isObject(current)) {
|
|
100
|
+
const raw = proxyToRaw.get(current);
|
|
101
|
+
if (!raw || raw === current) break;
|
|
102
|
+
current = raw;
|
|
103
|
+
}
|
|
104
|
+
return current;
|
|
147
105
|
}
|
|
106
|
+
|
|
107
|
+
//#endregion
|
|
108
|
+
export { isReactive, isReadonly, reactive, readonly, toRaw };
|
|
148
109
|
//# sourceMappingURL=reactive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactive.js","
|
|
1
|
+
{"version":3,"file":"reactive.js","names":["isReadonly"],"sources":["../../src/reactivity/reactive.ts"],"sourcesContent":["import { ITERATE_KEY, track, trigger } from \"./effect.js\";\nimport { hasOwn, isObject, ReactiveFlags } from \"./utils.js\";\n\nconst reactiveMap = new WeakMap<object, object>();\nconst readonlyMap = new WeakMap<object, object>();\nconst proxyToRaw = new WeakMap<object, object>();\nconst reactiveProxies = new WeakSet<object>();\nconst readonlyProxies = new WeakSet<object>();\n\nconst mutableHandlers: ProxyHandler<object> = {\n get(target, key, receiver) {\n if (key === ReactiveFlags.IS_REACTIVE) {\n return true;\n }\n if (key === ReactiveFlags.IS_READONLY) {\n return false;\n }\n if (key === ReactiveFlags.RAW) {\n return target;\n }\n\n const result = Reflect.get(target, key, receiver);\n track(target, key);\n\n return isObject(result) ? reactive(result) : result;\n },\n\n has(target, key) {\n const result = Reflect.has(target, key);\n track(target, key);\n return result;\n },\n\n ownKeys(target) {\n track(target, ITERATE_KEY);\n return Reflect.ownKeys(target);\n },\n\n set(target, key, value, receiver) {\n const oldLength = Array.isArray(target) ? target.length : undefined;\n const hadKey = hasOwn(target, key);\n const oldValue = toRaw(Reflect.get(target, key, receiver));\n const rawValue = toRaw(value);\n const success = Reflect.set(target, key, rawValue, receiver);\n\n if (\n success\n && target === toRaw(receiver)\n && (!hadKey || !Object.is(rawValue, oldValue))\n ) {\n trigger(target, key, hadKey ? \"set\" : \"add\", rawValue, oldLength);\n }\n return success;\n },\n\n deleteProperty(target, key) {\n const hadKey = hasOwn(target, key);\n const success = Reflect.deleteProperty(target, key);\n if (hadKey && success) {\n trigger(target, key, \"delete\");\n }\n return success;\n }\n};\n\nconst readonlyHandlers: ProxyHandler<object> = {\n get(target, key, receiver) {\n if (key === ReactiveFlags.IS_REACTIVE) {\n return false;\n }\n if (key === ReactiveFlags.IS_READONLY) {\n return true;\n }\n if (key === ReactiveFlags.RAW) {\n return target;\n }\n\n const result = Reflect.get(target, key, receiver);\n return isObject(result) ? readonly(result) : result;\n },\n\n has(target, key) {\n return Reflect.has(target, key);\n },\n\n ownKeys(target) {\n return Reflect.ownKeys(target);\n },\n\n set() {\n return true;\n },\n\n deleteProperty() {\n return true;\n }\n};\n\nexport function reactive<T extends object>(target: T): T {\n return createReactiveObject(target, false, reactiveMap, mutableHandlers) as T;\n}\n\nexport function readonly<T>(target: T): Readonly<T> {\n if (!isObject(target)) {\n return target as Readonly<T>;\n }\n return createReactiveObject(target, true, readonlyMap, readonlyHandlers) as Readonly<T>;\n}\n\nfunction createReactiveObject(\n target: object,\n isReadonly: boolean,\n proxyMap: WeakMap<object, object>,\n baseHandlers: ProxyHandler<object>\n): object {\n if (!isObject(target) || !canUseBaseProxyHandlers(target)) {\n return target;\n }\n\n if (proxyToRaw.has(target) && !(isReadonly && reactiveProxies.has(target))) {\n return target;\n }\n\n const existingProxy = proxyMap.get(target);\n if (existingProxy) {\n return existingProxy;\n }\n\n const proxy = new Proxy(target, baseHandlers);\n proxyMap.set(target, proxy);\n proxyToRaw.set(proxy, target);\n if (isReadonly) {\n readonlyProxies.add(proxy);\n } else {\n reactiveProxies.add(proxy);\n }\n return proxy;\n}\n\nfunction canUseBaseProxyHandlers(target: object): boolean {\n const rawType = Object.prototype.toString.call(target);\n return rawType === \"[object Object]\" || rawType === \"[object Array]\";\n}\n\nexport function isReactive(value: unknown): boolean {\n if (!isObject(value)) {\n return false;\n }\n if (reactiveProxies.has(value)) {\n return true;\n }\n const wrapped = readonlyProxies.has(value) ? proxyToRaw.get(value) : undefined;\n return wrapped ? isReactive(wrapped) : false;\n}\n\nexport function isReadonly(value: unknown): boolean {\n return Boolean(isObject(value) && readonlyProxies.has(value));\n}\n\nexport function toRaw<T>(value: T): T {\n let current: unknown = value;\n while (isObject(current)) {\n const raw = proxyToRaw.get(current);\n if (!raw || raw === current) {\n break;\n }\n current = raw;\n }\n return current as T;\n}\n\nfunction isArrayIndex(key: PropertyKey): boolean {\n if (typeof key === \"symbol\" || key === \"length\") {\n return false;\n }\n const value = String(key);\n return /^(?:0|[1-9]\\d*)$/.test(value)\n && Number(value) < 4_294_967_295;\n}\n"],"mappings":"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"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { isReadonly, readonly } from "./reactive.js";
|
|
2
|
+
export { isReadonly, readonly };
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { isReadonly, readonly } from "./reactive.js";
|
|
2
|
+
|
|
3
|
+
export { isReadonly, readonly };
|
package/dist/reactivity/ref.d.ts
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Ref } from "./types.js";
|
|
2
|
+
import { Dep } from "./effect.js";
|
|
3
|
+
|
|
4
|
+
//#region src/reactivity/ref.d.ts
|
|
3
5
|
declare class RefImpl<T> implements Ref<T> {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
readonly __v_isRef: true;
|
|
7
|
+
private dep?;
|
|
8
|
+
private _value;
|
|
9
|
+
private _rawValue;
|
|
10
|
+
constructor(value: T);
|
|
11
|
+
get value(): T;
|
|
12
|
+
set value(newValue: T);
|
|
13
|
+
_dep(): Dep;
|
|
14
|
+
_existingDep(): Dep | undefined;
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export
|
|
23
|
-
|
|
16
|
+
declare function ref<T>(value: T): Ref<T>;
|
|
17
|
+
declare function isRef(value: unknown): value is Ref;
|
|
18
|
+
declare function unref<T>(value: T | Ref<T>): T;
|
|
19
|
+
declare function toRef<T extends object, K$1 extends keyof T>(object: T, key: K$1, defaultValue?: T[K$1]): Ref<T[K$1]>;
|
|
20
|
+
declare function toRefs<T extends object>(object: T): { [K in keyof T]: Ref<T[K]> };
|
|
21
|
+
declare function trackRefValue(refValue: RefImpl<unknown>): void;
|
|
22
|
+
declare function triggerRefValue(refValue: RefImpl<unknown>): void;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { isRef, ref, toRef, toRefs, trackRefValue, triggerRefValue, unref };
|
|
25
|
+
//# sourceMappingURL=ref.d.ts.map
|
package/dist/reactivity/ref.js
CHANGED
|
@@ -1,92 +1,82 @@
|
|
|
1
|
-
import { trackEffects, triggerEffects
|
|
1
|
+
import { isTracking, trackEffects, triggerEffects } from "./effect.js";
|
|
2
|
+
import { ReactiveFlags, hasChanged, isObject } from "./utils.js";
|
|
2
3
|
import { reactive, toRaw } from "./reactive.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
4
|
+
|
|
5
|
+
//#region src/reactivity/ref.ts
|
|
6
|
+
var RefImpl = class {
|
|
7
|
+
__v_isRef = true;
|
|
8
|
+
dep;
|
|
9
|
+
_value;
|
|
10
|
+
_rawValue;
|
|
11
|
+
constructor(value) {
|
|
12
|
+
this._rawValue = toRaw(value);
|
|
13
|
+
this._value = toReactive(value);
|
|
14
|
+
}
|
|
15
|
+
get value() {
|
|
16
|
+
trackRefValue(this);
|
|
17
|
+
return this._value;
|
|
18
|
+
}
|
|
19
|
+
set value(newValue) {
|
|
20
|
+
const rawValue = toRaw(newValue);
|
|
21
|
+
if (!hasChanged(rawValue, this._rawValue)) return;
|
|
22
|
+
this._rawValue = rawValue;
|
|
23
|
+
this._value = toReactive(newValue);
|
|
24
|
+
triggerRefValue(this);
|
|
25
|
+
}
|
|
26
|
+
_dep() {
|
|
27
|
+
if (!this.dep) this.dep = /* @__PURE__ */ new Set();
|
|
28
|
+
return this.dep;
|
|
29
|
+
}
|
|
30
|
+
_existingDep() {
|
|
31
|
+
return this.dep;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var ObjectRefImpl = class {
|
|
35
|
+
__v_isRef = true;
|
|
36
|
+
constructor(object, key, defaultValue) {
|
|
37
|
+
this.object = object;
|
|
38
|
+
this.key = key;
|
|
39
|
+
this.defaultValue = defaultValue;
|
|
40
|
+
}
|
|
41
|
+
get value() {
|
|
42
|
+
const value = this.object[this.key];
|
|
43
|
+
return value === void 0 ? this.defaultValue : value;
|
|
44
|
+
}
|
|
45
|
+
set value(newValue) {
|
|
46
|
+
this.object[this.key] = newValue;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function ref(value) {
|
|
50
|
+
if (isRef(value)) return value;
|
|
51
|
+
return new RefImpl(value);
|
|
35
52
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
key;
|
|
39
|
-
defaultValue;
|
|
40
|
-
__v_isRef = true;
|
|
41
|
-
constructor(object, key, defaultValue) {
|
|
42
|
-
this.object = object;
|
|
43
|
-
this.key = key;
|
|
44
|
-
this.defaultValue = defaultValue;
|
|
45
|
-
}
|
|
46
|
-
get value() {
|
|
47
|
-
const value = this.object[this.key];
|
|
48
|
-
return value === undefined ? this.defaultValue : value;
|
|
49
|
-
}
|
|
50
|
-
set value(newValue) {
|
|
51
|
-
this.object[this.key] = newValue;
|
|
52
|
-
}
|
|
53
|
+
function isRef(value) {
|
|
54
|
+
return Boolean(value && typeof value === "object" && value[ReactiveFlags.IS_REF] === true);
|
|
53
55
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return value;
|
|
57
|
-
}
|
|
58
|
-
return new RefImpl(value);
|
|
56
|
+
function unref(value) {
|
|
57
|
+
return isRef(value) ? value.value : value;
|
|
59
58
|
}
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
function toRef(object, key, defaultValue) {
|
|
60
|
+
const value = object[key];
|
|
61
|
+
return isRef(value) ? value : new ObjectRefImpl(object, key, defaultValue);
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
function toRefs(object) {
|
|
64
|
+
const output = Array.isArray(object) ? new Array(object.length) : {};
|
|
65
|
+
for (const key of Object.keys(object)) output[key] = toRef(object, key);
|
|
66
|
+
return output;
|
|
65
67
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
function trackRefValue(refValue) {
|
|
69
|
+
if (!isTracking()) return;
|
|
70
|
+
trackEffects(refValue._dep());
|
|
69
71
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
output[key] = toRef(object, key);
|
|
74
|
-
}
|
|
75
|
-
return output;
|
|
76
|
-
}
|
|
77
|
-
export function trackRefValue(refValue) {
|
|
78
|
-
if (!isTracking()) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
trackEffects(refValue._dep());
|
|
82
|
-
}
|
|
83
|
-
export function triggerRefValue(refValue) {
|
|
84
|
-
const dep = refValue._existingDep();
|
|
85
|
-
if (dep) {
|
|
86
|
-
triggerEffects(dep);
|
|
87
|
-
}
|
|
72
|
+
function triggerRefValue(refValue) {
|
|
73
|
+
const dep = refValue._existingDep();
|
|
74
|
+
if (dep) triggerEffects(dep);
|
|
88
75
|
}
|
|
89
76
|
function toReactive(value) {
|
|
90
|
-
|
|
77
|
+
return isObject(value) ? reactive(value) : value;
|
|
91
78
|
}
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
export { isRef, ref, toRef, toRefs, trackRefValue, triggerRefValue, unref };
|
|
92
82
|
//# sourceMappingURL=ref.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.js","
|
|
1
|
+
{"version":3,"file":"ref.js","names":[],"sources":["../../src/reactivity/ref.ts"],"sourcesContent":["import { trackEffects, triggerEffects, isTracking, type Dep } from \"./effect.js\";\nimport { reactive, toRaw } from \"./reactive.js\";\nimport type { Ref } from \"./types.js\";\nimport { hasChanged, isObject, ReactiveFlags } from \"./utils.js\";\n\nclass RefImpl<T> implements Ref<T> {\n readonly __v_isRef = true as const;\n private dep?: Dep;\n private _value: T;\n private _rawValue: T;\n\n constructor(value: T) {\n this._rawValue = toRaw(value);\n this._value = toReactive(value);\n }\n\n get value(): T {\n trackRefValue(this);\n return this._value;\n }\n\n set value(newValue: T) {\n const rawValue = toRaw(newValue);\n if (!hasChanged(rawValue, this._rawValue)) {\n return;\n }\n this._rawValue = rawValue;\n this._value = toReactive(newValue);\n triggerRefValue(this);\n }\n\n _dep(): Dep {\n if (!this.dep) {\n this.dep = new Set();\n }\n return this.dep;\n }\n\n _existingDep(): Dep | undefined {\n return this.dep;\n }\n}\n\nclass ObjectRefImpl<T extends object, K extends keyof T> implements Ref<T[K]> {\n readonly __v_isRef = true as const;\n\n constructor(\n private readonly object: T,\n private readonly key: K,\n private readonly defaultValue?: T[K]\n ) {}\n\n get value(): T[K] {\n const value = this.object[this.key];\n return value === undefined ? this.defaultValue as T[K] : value;\n }\n\n set value(newValue: T[K]) {\n this.object[this.key] = newValue;\n }\n}\n\nexport function ref<T>(value: T): Ref<T> {\n if (isRef(value)) {\n return value as Ref<T>;\n }\n return new RefImpl(value);\n}\n\nexport function isRef(value: unknown): value is Ref {\n return Boolean(value && typeof value === \"object\" && (value as Record<string, unknown>)[ReactiveFlags.IS_REF] === true);\n}\n\nexport function unref<T>(value: T | Ref<T>): T {\n return isRef(value) ? value.value : value;\n}\n\nexport function toRef<T extends object, K extends keyof T>(object: T, key: K, defaultValue?: T[K]): Ref<T[K]> {\n const value = object[key];\n return isRef(value) ? value as Ref<T[K]> : new ObjectRefImpl(object, key, defaultValue);\n}\n\nexport function toRefs<T extends object>(object: T): { [K in keyof T]: Ref<T[K]> } {\n const output = (Array.isArray(object) ? new Array(object.length) : {}) as { [K in keyof T]: Ref<T[K]> };\n for (const key of Object.keys(object) as Array<keyof T>) {\n output[key] = toRef(object, key);\n }\n return output;\n}\n\nexport function trackRefValue(refValue: RefImpl<unknown>): void {\n if (!isTracking()) {\n return;\n }\n trackEffects(refValue._dep());\n}\n\nexport function triggerRefValue(refValue: RefImpl<unknown>): void {\n const dep = refValue._existingDep();\n if (dep) {\n triggerEffects(dep);\n }\n}\n\nfunction toReactive<T>(value: T): T {\n return isObject(value) ? reactive(value as object) as T : value;\n}\n"],"mappings":";;;;;AAKA,IAAM,UAAN,MAAmC;CACjC,AAAS,YAAY;CACrB,AAAQ;CACR,AAAQ;CACR,AAAQ;CAER,YAAY,OAAU;AACpB,OAAK,YAAY,MAAM,MAAM;AAC7B,OAAK,SAAS,WAAW,MAAM;;CAGjC,IAAI,QAAW;AACb,gBAAc,KAAK;AACnB,SAAO,KAAK;;CAGd,IAAI,MAAM,UAAa;EACrB,MAAM,WAAW,MAAM,SAAS;AAChC,MAAI,CAAC,WAAW,UAAU,KAAK,UAAU,CACvC;AAEF,OAAK,YAAY;AACjB,OAAK,SAAS,WAAW,SAAS;AAClC,kBAAgB,KAAK;;CAGvB,OAAY;AACV,MAAI,CAAC,KAAK,IACR,MAAK,sBAAM,IAAI,KAAK;AAEtB,SAAO,KAAK;;CAGd,eAAgC;AAC9B,SAAO,KAAK;;;AAIhB,IAAM,gBAAN,MAA8E;CAC5E,AAAS,YAAY;CAErB,YACE,AAAiB,QACjB,AAAiB,KACjB,AAAiB,cACjB;EAHiB;EACA;EACA;;CAGnB,IAAI,QAAc;EAChB,MAAM,QAAQ,KAAK,OAAO,KAAK;AAC/B,SAAO,UAAU,SAAY,KAAK,eAAuB;;CAG3D,IAAI,MAAM,UAAgB;AACxB,OAAK,OAAO,KAAK,OAAO;;;AAI5B,SAAgB,IAAO,OAAkB;AACvC,KAAI,MAAM,MAAM,CACd,QAAO;AAET,QAAO,IAAI,QAAQ,MAAM;;AAG3B,SAAgB,MAAM,OAA8B;AAClD,QAAO,QAAQ,SAAS,OAAO,UAAU,YAAa,MAAkC,cAAc,YAAY,KAAK;;AAGzH,SAAgB,MAAS,OAAsB;AAC7C,QAAO,MAAM,MAAM,GAAG,MAAM,QAAQ;;AAGtC,SAAgB,MAA2C,QAAW,KAAQ,cAAgC;CAC5G,MAAM,QAAQ,OAAO;AACrB,QAAO,MAAM,MAAM,GAAG,QAAqB,IAAI,cAAc,QAAQ,KAAK,aAAa;;AAGzF,SAAgB,OAAyB,QAA0C;CACjF,MAAM,SAAU,MAAM,QAAQ,OAAO,GAAG,IAAI,MAAM,OAAO,OAAO,GAAG,EAAE;AACrE,MAAK,MAAM,OAAO,OAAO,KAAK,OAAO,CACnC,QAAO,OAAO,MAAM,QAAQ,IAAI;AAElC,QAAO;;AAGT,SAAgB,cAAc,UAAkC;AAC9D,KAAI,CAAC,YAAY,CACf;AAEF,cAAa,SAAS,MAAM,CAAC;;AAG/B,SAAgB,gBAAgB,UAAkC;CAChE,MAAM,MAAM,SAAS,cAAc;AACnC,KAAI,IACF,gBAAe,IAAI;;AAIvB,SAAS,WAAc,OAAa;AAClC,QAAO,SAAS,MAAM,GAAG,SAAS,MAAgB,GAAQ"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
//#region src/reactivity/scheduler.d.ts
|
|
1
2
|
type Job = () => void;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
declare function nextTick<T = void>(fn?: () => T | PromiseLike<T>): Promise<T | void>;
|
|
4
|
+
declare function queueJob(job: Job): void;
|
|
5
|
+
declare function queuePostFlushCb(job: Job): void;
|
|
6
|
+
declare function currentFlushPromise(): Promise<void> | null;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { currentFlushPromise, nextTick, queueJob, queuePostFlushCb };
|
|
9
|
+
//# sourceMappingURL=scheduler.d.ts.map
|