resuxjs 0.4.0-beta.2 → 0.4.0-beta.4
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/dist/bin.d.ts +1 -1
- package/dist/bin.js +3 -2
- package/dist/bin.js.map +1 -1
- package/dist/build/index.d.ts +9 -8
- package/dist/build/index.js +2 -2
- package/dist/build/index.js.map +1 -1
- package/dist/cli.d.ts +5 -4
- package/dist/cli.js +115 -127
- package/dist/cli.js.map +1 -1
- package/dist/compiler/adapter.d.ts +6 -5
- package/dist/compiler/adapter.js +2 -1
- package/dist/compiler/adapter.js.map +1 -1
- package/dist/compiler/dev-warnings.d.ts +6 -5
- package/dist/compiler/dev-warnings.js +7 -6
- package/dist/compiler/dev-warnings.js.map +1 -1
- package/dist/compiler/directives.d.ts +4 -3
- package/dist/compiler/directives.js +2 -1
- package/dist/compiler/directives.js.map +1 -1
- package/dist/compiler/implementation.d.ts +21 -19
- package/dist/compiler/implementation.js +124 -133
- package/dist/compiler/index.d.ts +6 -5
- package/dist/compiler/index.js +2 -1
- package/dist/compiler/index.js.map +1 -1
- package/dist/core/config.d.ts +7 -5
- package/dist/core/config.js +1 -1
- package/dist/core/config.js.map +1 -1
- package/dist/core/hooks.d.ts +7 -6
- package/dist/core/hooks.js +1 -1
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/module-container.d.ts +22 -20
- package/dist/core/module-container.js +3 -3
- package/dist/core/module-container.js.map +1 -1
- package/dist/core/resux.d.ts +5 -3
- package/dist/core/resux.js +2 -1
- package/dist/core/resux.js.map +1 -1
- package/dist/create-bin.d.ts +1 -1
- package/dist/create-bin.js +3 -2
- package/dist/create-bin.js.map +1 -1
- package/dist/create.d.ts +3 -2
- package/dist/create.js +7 -10
- package/dist/create.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +3 -1
- package/dist/deploy/cloudflare.js +2 -1
- package/dist/deploy/cloudflare.js.map +1 -1
- package/dist/deploy/common.d.ts +13 -11
- package/dist/deploy/common.js +2 -1
- package/dist/deploy/common.js.map +1 -1
- package/dist/deploy/framework-runtime.d.ts +2 -1
- package/dist/deploy/framework-runtime.js +5 -1
- package/dist/deploy/framework-runtime.js.map +1 -1
- package/dist/deploy/index.d.ts +4 -2
- package/dist/deploy/index.js +4 -6
- package/dist/deploy/index.js.map +1 -1
- package/dist/deploy/netlify.d.ts +3 -1
- package/dist/deploy/netlify.js +3 -2
- package/dist/deploy/netlify.js.map +1 -1
- package/dist/deploy/node.d.ts +3 -1
- package/dist/deploy/node.js +3 -3
- package/dist/deploy/node.js.map +1 -1
- package/dist/deploy/production-report.d.ts +2 -1
- package/dist/deploy/production-report.js +2 -1
- package/dist/deploy/production-report.js.map +1 -1
- package/dist/deploy/runtime-dependencies.d.ts +5 -4
- package/dist/deploy/runtime-dependencies.js +3 -3
- package/dist/deploy/runtime-dependencies.js.map +1 -1
- package/dist/deploy/static.d.ts +3 -1
- package/dist/deploy/static.js +2 -1
- package/dist/deploy/static.js.map +1 -1
- package/dist/deploy/types.d.ts +8 -7
- package/dist/deploy/types.js +1 -1
- package/dist/deploy/vercel.d.ts +4 -2
- package/dist/deploy/vercel.js +3 -2
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/fonts/index.d.ts +5 -4
- package/dist/fonts/index.js +3 -2
- package/dist/fonts/index.js.map +1 -1
- package/dist/globals.d.ts +2 -2
- package/dist/globals.js +1 -1
- package/dist/halal-core/ai/classifyProject.d.ts +5 -3
- package/dist/halal-core/ai/classifyProject.js +2 -1
- package/dist/halal-core/ai/classifyProject.js.map +1 -1
- package/dist/halal-core/ai/classifyRuntimeContent.d.ts +3 -1
- package/dist/halal-core/ai/classifyRuntimeContent.js +2 -1
- package/dist/halal-core/ai/classifyRuntimeContent.js.map +1 -1
- package/dist/halal-core/ai/createProjectSummary.d.ts +2 -1
- package/dist/halal-core/ai/createProjectSummary.js +2 -1
- package/dist/halal-core/ai/createProjectSummary.js.map +1 -1
- package/dist/halal-core/ai/halalClassifierPrompt.d.ts +2 -1
- package/dist/halal-core/ai/halalClassifierPrompt.js +1 -1
- package/dist/halal-core/ai/redactSensitiveData.d.ts +2 -1
- package/dist/halal-core/ai/redactSensitiveData.js +1 -1
- package/dist/halal-core/ai/redactSensitiveData.js.map +1 -1
- package/dist/halal-core/ai/validateAiResponse.d.ts +3 -1
- package/dist/halal-core/ai/validateAiResponse.js +3 -3
- package/dist/halal-core/ai/validateAiResponse.js.map +1 -1
- package/dist/halal-core/cli/check.d.ts +2 -1
- package/dist/halal-core/cli/check.js +3 -3
- package/dist/halal-core/cli/check.js.map +1 -1
- package/dist/halal-core/cli/explain.d.ts +2 -1
- package/dist/halal-core/cli/explain.js +3 -3
- package/dist/halal-core/cli/explain.js.map +1 -1
- package/dist/halal-core/cli/report.d.ts +2 -1
- package/dist/halal-core/cli/report.js +3 -3
- package/dist/halal-core/cli/report.js.map +1 -1
- package/dist/halal-core/cli/submitReview.d.ts +2 -1
- package/dist/halal-core/cli/submitReview.js +3 -3
- package/dist/halal-core/cli/submitReview.js.map +1 -1
- package/dist/halal-core/cli/verifyReview.d.ts +2 -1
- package/dist/halal-core/cli/verifyReview.js +3 -4
- package/dist/halal-core/cli/verifyReview.js.map +1 -1
- package/dist/halal-core/config.d.ts +9 -8
- package/dist/halal-core/config.js +2 -1
- package/dist/halal-core/config.js.map +1 -1
- package/dist/halal-core/crypto/integrity.d.ts +6 -5
- package/dist/halal-core/crypto/integrity.js +2 -1
- package/dist/halal-core/crypto/integrity.js.map +1 -1
- package/dist/halal-core/enforce.d.ts +6 -5
- package/dist/halal-core/enforce.js +13 -15
- package/dist/halal-core/enforce.js.map +1 -1
- package/dist/halal-core/index.js +2 -1
- package/dist/halal-core/lifecycle.d.ts +2 -1
- package/dist/halal-core/lifecycle.js +2 -1
- package/dist/halal-core/lifecycle.js.map +1 -1
- package/dist/halal-core/policy.d.ts +3 -1
- package/dist/halal-core/policy.js +2 -1
- package/dist/halal-core/policy.js.map +1 -1
- package/dist/halal-core/report/formatBrowserOverlay.d.ts +3 -1
- package/dist/halal-core/report/formatBrowserOverlay.js +1 -1
- package/dist/halal-core/report/formatBrowserOverlay.js.map +1 -1
- package/dist/halal-core/report/formatTerminalReport.d.ts +3 -1
- package/dist/halal-core/report/formatTerminalReport.js +1 -1
- package/dist/halal-core/report/formatTerminalReport.js.map +1 -1
- package/dist/halal-core/report/generateHalalReport.d.ts +4 -2
- package/dist/halal-core/report/generateHalalReport.js +5 -7
- package/dist/halal-core/report/generateHalalReport.js.map +1 -1
- package/dist/halal-core/report/signReport.d.ts +4 -2
- package/dist/halal-core/report/signReport.js +2 -1
- package/dist/halal-core/report/signReport.js.map +1 -1
- package/dist/halal-core/report/verifyReport.d.ts +5 -3
- package/dist/halal-core/report/verifyReport.js +4 -3
- package/dist/halal-core/report/verifyReport.js.map +1 -1
- package/dist/halal-core/review/createReviewRequest.d.ts +3 -1
- package/dist/halal-core/review/createReviewRequest.js +3 -3
- package/dist/halal-core/review/createReviewRequest.js.map +1 -1
- package/dist/halal-core/review/reviewPolicy.d.ts +4 -3
- package/dist/halal-core/review/reviewPolicy.js +1 -1
- package/dist/halal-core/review/reviewPolicy.js.map +1 -1
- package/dist/halal-core/review/signedReviewFile.d.ts +6 -4
- package/dist/halal-core/review/signedReviewFile.js +2 -1
- package/dist/halal-core/review/signedReviewFile.js.map +1 -1
- package/dist/halal-core/review/verifyReviewApproval.d.ts +3 -2
- package/dist/halal-core/review/verifyReviewApproval.js +2 -1
- package/dist/halal-core/review/verifyReviewApproval.js.map +1 -1
- package/dist/halal-core/rules/adultContentRules.d.ts +3 -2
- package/dist/halal-core/rules/adultContentRules.js +1 -1
- package/dist/halal-core/rules/adultContentRules.js.map +1 -1
- package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +3 -2
- package/dist/halal-core/rules/alcoholDrugVapeRules.js +1 -1
- package/dist/halal-core/rules/alcoholDrugVapeRules.js.map +1 -1
- package/dist/halal-core/rules/childSafetyRules.d.ts +3 -2
- package/dist/halal-core/rules/childSafetyRules.js +1 -1
- package/dist/halal-core/rules/childSafetyRules.js.map +1 -1
- package/dist/halal-core/rules/coreCategories.d.ts +3 -2
- package/dist/halal-core/rules/coreCategories.js +1 -1
- package/dist/halal-core/rules/coreCategories.js.map +1 -1
- package/dist/halal-core/rules/cyberAbuseRules.d.ts +3 -2
- package/dist/halal-core/rules/cyberAbuseRules.js +1 -1
- package/dist/halal-core/rules/cyberAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/defaultBlockedRules.d.ts +3 -1
- package/dist/halal-core/rules/defaultBlockedRules.js +9 -11
- package/dist/halal-core/rules/defaultBlockedRules.js.map +1 -1
- package/dist/halal-core/rules/dependencyRules.d.ts +3 -2
- package/dist/halal-core/rules/dependencyRules.js +1 -1
- package/dist/halal-core/rules/dependencyRules.js.map +1 -1
- package/dist/halal-core/rules/endpointRules.d.ts +3 -2
- package/dist/halal-core/rules/endpointRules.js +1 -1
- package/dist/halal-core/rules/endpointRules.js.map +1 -1
- package/dist/halal-core/rules/environmentalHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/environmentalHarmRules.js +1 -1
- package/dist/halal-core/rules/environmentalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/financeRibaRules.d.ts +3 -2
- package/dist/halal-core/rules/financeRibaRules.js +1 -1
- package/dist/halal-core/rules/financeRibaRules.js.map +1 -1
- package/dist/halal-core/rules/gamblingRules.d.ts +3 -2
- package/dist/halal-core/rules/gamblingRules.js +1 -1
- package/dist/halal-core/rules/gamblingRules.js.map +1 -1
- package/dist/halal-core/rules/generalHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/generalHarmRules.js +1 -1
- package/dist/halal-core/rules/generalHarmRules.js.map +1 -1
- package/dist/halal-core/rules/healthHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/healthHarmRules.js +1 -1
- package/dist/halal-core/rules/healthHarmRules.js.map +1 -1
- package/dist/halal-core/rules/keywordRules.d.ts +2 -1
- package/dist/halal-core/rules/keywordRules.js +1 -1
- package/dist/halal-core/rules/keywordRules.js.map +1 -1
- package/dist/halal-core/rules/privacyAbuseRules.d.ts +3 -2
- package/dist/halal-core/rules/privacyAbuseRules.js +1 -1
- package/dist/halal-core/rules/privacyAbuseRules.js.map +1 -1
- package/dist/halal-core/rules/scamFraudRules.d.ts +3 -2
- package/dist/halal-core/rules/scamFraudRules.js +1 -1
- package/dist/halal-core/rules/scamFraudRules.js.map +1 -1
- package/dist/halal-core/rules/selfHarmRules.d.ts +3 -2
- package/dist/halal-core/rules/selfHarmRules.js +1 -1
- package/dist/halal-core/rules/selfHarmRules.js.map +1 -1
- package/dist/halal-core/rules/violenceExtremismRules.d.ts +3 -2
- package/dist/halal-core/rules/violenceExtremismRules.js +1 -1
- package/dist/halal-core/rules/violenceExtremismRules.js.map +1 -1
- package/dist/halal-core/runtime/guard.d.ts +5 -3
- package/dist/halal-core/runtime/guard.js +2 -1
- package/dist/halal-core/runtime/guard.js.map +1 -1
- package/dist/halal-core/runtime/index.js +2 -1
- package/dist/halal-core/runtime/reviewedMemory.d.ts +6 -4
- package/dist/halal-core/runtime/reviewedMemory.js +3 -2
- package/dist/halal-core/runtime/reviewedMemory.js.map +1 -1
- package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +7 -5
- package/dist/halal-core/runtime/serializeRuntimeContent.js +4 -3
- package/dist/halal-core/runtime/serializeRuntimeContent.js.map +1 -1
- package/dist/halal-core/runtime/types.d.ts +11 -9
- package/dist/halal-core/runtime/types.js +1 -1
- package/dist/halal-core/scanner/scanApiRoutes.d.ts +2 -1
- package/dist/halal-core/scanner/scanApiRoutes.js +2 -1
- package/dist/halal-core/scanner/scanApiRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanComponents.d.ts +2 -1
- package/dist/halal-core/scanner/scanComponents.js +2 -1
- package/dist/halal-core/scanner/scanComponents.js.map +1 -1
- package/dist/halal-core/scanner/scanContent.d.ts +3 -2
- package/dist/halal-core/scanner/scanContent.js +4 -3
- package/dist/halal-core/scanner/scanContent.js.map +1 -1
- package/dist/halal-core/scanner/scanDependencies.d.ts +2 -1
- package/dist/halal-core/scanner/scanDependencies.js +2 -1
- package/dist/halal-core/scanner/scanDependencies.js.map +1 -1
- package/dist/halal-core/scanner/scanDomains.d.ts +2 -1
- package/dist/halal-core/scanner/scanDomains.js +1 -1
- package/dist/halal-core/scanner/scanDomains.js.map +1 -1
- package/dist/halal-core/scanner/scanEnvNames.d.ts +2 -1
- package/dist/halal-core/scanner/scanEnvNames.js +2 -1
- package/dist/halal-core/scanner/scanEnvNames.js.map +1 -1
- package/dist/halal-core/scanner/scanMetadata.d.ts +3 -2
- package/dist/halal-core/scanner/scanMetadata.js +2 -1
- package/dist/halal-core/scanner/scanMetadata.js.map +1 -1
- package/dist/halal-core/scanner/scanPages.d.ts +2 -1
- package/dist/halal-core/scanner/scanPages.js +2 -1
- package/dist/halal-core/scanner/scanPages.js.map +1 -1
- package/dist/halal-core/scanner/scanProject.d.ts +4 -2
- package/dist/halal-core/scanner/scanProject.js +2 -1
- package/dist/halal-core/scanner/scanProject.js.map +1 -1
- package/dist/halal-core/scanner/scanRoutes.d.ts +2 -1
- package/dist/halal-core/scanner/scanRoutes.js +2 -1
- package/dist/halal-core/scanner/scanRoutes.js.map +1 -1
- package/dist/halal-core/scanner/scanTranslations.d.ts +2 -1
- package/dist/halal-core/scanner/scanTranslations.js +2 -1
- package/dist/halal-core/scanner/scanTranslations.js.map +1 -1
- package/dist/halal-core/status.d.ts +3 -2
- package/dist/halal-core/status.js +1 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +2 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.js +2 -1
- package/dist/halal-core/tamper/verifyCoreIntegrity.js.map +1 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +2 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.js +1 -1
- package/dist/halal-core/tamper/verifyLifecycleHooks.js.map +1 -1
- package/dist/halal-core/tamper/verifyReportSignature.d.ts +3 -1
- package/dist/halal-core/tamper/verifyReportSignature.js +3 -3
- package/dist/halal-core/tamper/verifyReportSignature.js.map +1 -1
- package/dist/halal.js +2 -1
- package/dist/i18n/index.d.ts +12 -11
- package/dist/i18n/index.js +5 -6
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/shared.d.ts +15 -14
- package/dist/i18n/shared.js +4 -4
- package/dist/i18n/shared.js.map +1 -1
- package/dist/icons/index.d.ts +18 -16
- package/dist/icons/index.js +5 -4
- package/dist/icons/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/kit/index.d.ts +23 -21
- package/dist/kit/index.js +2 -1
- package/dist/kit/index.js.map +1 -1
- package/dist/nitro-server/index.d.ts +3 -2
- package/dist/nitro-server/index.js +1 -1
- package/dist/nitro-server/index.js.map +1 -1
- package/dist/node.d.ts +4 -2
- package/dist/node.js +7 -6
- package/dist/node.js.map +1 -1
- package/dist/reactivity/computed.d.ts +5 -3
- package/dist/reactivity/computed.js +3 -3
- package/dist/reactivity/computed.js.map +1 -1
- package/dist/reactivity/effect.d.ts +15 -13
- package/dist/reactivity/effect.js +9 -10
- package/dist/reactivity/effect.js.map +1 -1
- package/dist/reactivity/index.js +2 -1
- package/dist/reactivity/reactive.d.ts +6 -5
- package/dist/reactivity/reactive.js +5 -4
- package/dist/reactivity/reactive.js.map +1 -1
- package/dist/reactivity/readonly.js +2 -1
- package/dist/reactivity/ref.d.ts +9 -7
- package/dist/reactivity/ref.js +2 -4
- package/dist/reactivity/ref.js.map +1 -1
- package/dist/reactivity/scheduler.d.ts +5 -4
- package/dist/reactivity/scheduler.js +1 -1
- package/dist/reactivity/scheduler.js.map +1 -1
- package/dist/reactivity/types.d.ts +12 -11
- package/dist/reactivity/types.js +1 -1
- package/dist/reactivity/utils.d.ts +10 -9
- package/dist/reactivity/utils.js +1 -1
- package/dist/reactivity/utils.js.map +1 -1
- package/dist/reactivity/watch.d.ts +4 -2
- package/dist/reactivity/watch.js +4 -5
- package/dist/reactivity/watch.js.map +1 -1
- package/dist/runtime/core.d.ts +5 -4
- package/dist/runtime/core.js +9 -10
- package/dist/runtime/core.js.map +1 -1
- package/dist/runtime/index.d.ts +123 -122
- package/dist/runtime/index.js +45 -58
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/reactivity.js +2 -1
- package/dist/runtime/resume.d.ts +15 -14
- package/dist/runtime/resume.js +3 -3
- package/dist/runtime/resume.js.map +1 -1
- package/dist/runtime/router.d.ts +5 -4
- package/dist/runtime/router.js +1 -1
- package/dist/runtime/router.js.map +1 -1
- package/dist/runtime/streaming.d.ts +7 -6
- package/dist/runtime/streaming.js +3 -3
- package/dist/runtime/streaming.js.map +1 -1
- package/dist/security/media-fetch.d.ts +11 -10
- package/dist/security/media-fetch.js +5 -4
- package/dist/security/media-fetch.js.map +1 -1
- package/dist/security/path-boundary.d.ts +5 -4
- package/dist/security/path-boundary.js +2 -1
- package/dist/security/path-boundary.js.map +1 -1
- package/dist/ui/index.d.ts +195 -193
- package/dist/ui/index.js +7 -8
- package/dist/ui/index.js.map +1 -1
- package/dist/vite-builder/index.d.ts +3 -2
- package/dist/vite-builder/index.js +1 -1
- package/dist/vite-builder/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -14,6 +14,7 @@ import { NodeTypes, parse } from "@vue/compiler-dom";
|
|
|
14
14
|
import { compileStyle, parse as parse$1 } from "@vue/compiler-sfc";
|
|
15
15
|
import vuePlugin from "@vitejs/plugin-vue";
|
|
16
16
|
import { build } from "vite";
|
|
17
|
+
|
|
17
18
|
//#region src/compiler/index.ts
|
|
18
19
|
const require = createRequire(import.meta.url);
|
|
19
20
|
var ResuxCompileError = class extends Error {
|
|
@@ -24,7 +25,7 @@ var ResuxCompileError = class extends Error {
|
|
|
24
25
|
this.location = location;
|
|
25
26
|
}
|
|
26
27
|
};
|
|
27
|
-
const RESUMABLE_HANDLER_ALLOWED_GLOBALS =
|
|
28
|
+
const RESUMABLE_HANDLER_ALLOWED_GLOBALS = new Set([
|
|
28
29
|
"Math",
|
|
29
30
|
"Number",
|
|
30
31
|
"String",
|
|
@@ -356,8 +357,8 @@ async function buildProject(appRoot, outDir = path.join(appRoot, ".resux"), opti
|
|
|
356
357
|
const layouts = layoutFiles.map((file) => compiledByFile.get(file));
|
|
357
358
|
const plugins = unique(pluginFiles).sort((left, right) => normalizePath(left).localeCompare(normalizePath(right))).map((file, pluginIndex) => {
|
|
358
359
|
const compiled = compilePluginFile(file, pluginIndex);
|
|
359
|
-
const mode = pluginModeByFile.get(file);
|
|
360
|
-
if (mode) compiled.mode = mode;
|
|
360
|
+
const mode$1 = pluginModeByFile.get(file);
|
|
361
|
+
if (mode$1) compiled.mode = mode$1;
|
|
361
362
|
return compiled;
|
|
362
363
|
});
|
|
363
364
|
const clientEnhancements = plugins.filter((plugin) => plugin.mode !== "server" && clientEnhancementFileSet.has(normalizePath(path.resolve(plugin.file)))).map((plugin) => ({
|
|
@@ -684,7 +685,8 @@ async function buildServerBundle(root, outDir) {
|
|
|
684
685
|
}
|
|
685
686
|
async function buildClientAssets(root, outDir, components, plugins, middleware, vueIslands, packageRegistry, hooks, contributions) {
|
|
686
687
|
const inputRoot = path.join(outDir, "vite-client");
|
|
687
|
-
const
|
|
688
|
+
const runtimeInput = await writeViteClientRuntime(outDir, packageRegistry);
|
|
689
|
+
const input = { "runtime-client": runtimeInput };
|
|
688
690
|
for (const component of components) input[`handlers/${component.id}`] = path.join(inputRoot, "handlers", `${component.id}.mjs`);
|
|
689
691
|
for (const plugin of plugins.filter((entry) => entry.mode !== "server")) input[`plugins/${plugin.id}`] = path.join(inputRoot, "plugins", `${plugin.id}.mjs`);
|
|
690
692
|
for (const entry of middleware.filter((candidate) => candidate.mode !== "server")) input[`middleware/${entry.id}`] = path.join(inputRoot, "middleware", `${entry.id}.mjs`);
|
|
@@ -955,30 +957,30 @@ function compileTemplateChildren(children, state) {
|
|
|
955
957
|
const conditionalDirective = resolveConditionalDirective(child, state);
|
|
956
958
|
if (!conditionalDirective) {
|
|
957
959
|
conditionalChainExpressions = null;
|
|
958
|
-
const compiledNode = compileTemplateNode(child, state);
|
|
959
|
-
if (compiledNode) nodes.push(compiledNode);
|
|
960
|
+
const compiledNode$2 = compileTemplateNode(child, state);
|
|
961
|
+
if (compiledNode$2) nodes.push(compiledNode$2);
|
|
960
962
|
continue;
|
|
961
963
|
}
|
|
962
964
|
if (conditionalDirective.kind === "if") {
|
|
963
965
|
const expressionResult = transformTemplateExpressionCode(conditionalDirective.expression, state.templateRefBindings, state.file, conditionalDirective.directive);
|
|
964
966
|
conditionalChainExpressions = [expressionResult.transformed];
|
|
965
|
-
const compiledNode = compileTemplateNode(child, state, { ifExpressionOverride: expressionResult.transformed });
|
|
966
|
-
if (compiledNode) nodes.push(compiledNode);
|
|
967
|
+
const compiledNode$2 = compileTemplateNode(child, state, { ifExpressionOverride: expressionResult.transformed });
|
|
968
|
+
if (compiledNode$2) nodes.push(compiledNode$2);
|
|
967
969
|
continue;
|
|
968
970
|
}
|
|
969
971
|
if (!conditionalChainExpressions || conditionalChainExpressions.length === 0) throw new ResuxCompileError(`v-${conditionalDirective.kind} must follow a sibling with v-if or v-else-if.`, locationFromVueNode(state.file, conditionalDirective.directive));
|
|
970
972
|
if (conditionalDirective.kind === "else-if") {
|
|
971
973
|
const branchExpressionResult = transformTemplateExpressionCode(conditionalDirective.expression, state.templateRefBindings, state.file, conditionalDirective.directive);
|
|
972
|
-
const expression = `${buildConditionalChainGuard(conditionalChainExpressions)} && (${branchExpressionResult.transformed})`;
|
|
974
|
+
const expression$1 = `${buildConditionalChainGuard(conditionalChainExpressions)} && (${branchExpressionResult.transformed})`;
|
|
973
975
|
conditionalChainExpressions.push(branchExpressionResult.transformed);
|
|
974
|
-
const compiledNode = compileTemplateNode(child, state, { ifExpressionOverride: expression });
|
|
975
|
-
if (compiledNode) nodes.push(compiledNode);
|
|
976
|
+
const compiledNode$2 = compileTemplateNode(child, state, { ifExpressionOverride: expression$1 });
|
|
977
|
+
if (compiledNode$2) nodes.push(compiledNode$2);
|
|
976
978
|
continue;
|
|
977
979
|
}
|
|
978
980
|
const expression = buildConditionalChainGuard(conditionalChainExpressions);
|
|
979
981
|
conditionalChainExpressions = null;
|
|
980
|
-
const compiledNode = compileTemplateNode(child, state, { ifExpressionOverride: expression });
|
|
981
|
-
if (compiledNode) nodes.push(compiledNode);
|
|
982
|
+
const compiledNode$1 = compileTemplateNode(child, state, { ifExpressionOverride: expression });
|
|
983
|
+
if (compiledNode$1) nodes.push(compiledNode$1);
|
|
982
984
|
continue;
|
|
983
985
|
}
|
|
984
986
|
if (child.type !== NodeTypes.TEXT || child.content.trim().length > 0) conditionalChainExpressions = null;
|
|
@@ -1071,27 +1073,27 @@ function compileTemplateNode(node, state, options = {}) {
|
|
|
1071
1073
|
if (prop.type !== NodeTypes.DIRECTIVE) continue;
|
|
1072
1074
|
if (prop.name === "bind") {
|
|
1073
1075
|
const arg = expressionContent(prop.arg);
|
|
1074
|
-
const expression = expressionContent(prop.exp);
|
|
1075
|
-
if (!arg || !expression) throw new ResuxCompileError("Dynamic bindings need an argument and expression.", locationFromVueNode(state.file, prop));
|
|
1076
|
+
const expression$1 = expressionContent(prop.exp);
|
|
1077
|
+
if (!arg || !expression$1) throw new ResuxCompileError("Dynamic bindings need an argument and expression.", locationFromVueNode(state.file, prop));
|
|
1076
1078
|
attrs.push({
|
|
1077
1079
|
kind: "dynamic",
|
|
1078
1080
|
name: arg,
|
|
1079
|
-
value: registerTemplateExpression(expression, state.templateRefBindings, state.file, prop, state),
|
|
1081
|
+
value: registerTemplateExpression(expression$1, state.templateRefBindings, state.file, prop, state),
|
|
1080
1082
|
bindingId: nextBindingId(state)
|
|
1081
1083
|
});
|
|
1082
1084
|
continue;
|
|
1083
1085
|
}
|
|
1084
1086
|
if (prop.name === "on") {
|
|
1085
1087
|
const arg = expressionContent(prop.arg);
|
|
1086
|
-
const expression = expressionContent(prop.exp);
|
|
1088
|
+
const expression$1 = expressionContent(prop.exp);
|
|
1087
1089
|
const modifiers = normalizeEventModifiers(prop.modifiers ?? [], state.file, prop);
|
|
1088
|
-
if (!arg || !expression) throw new ResuxCompileError("Events need an argument and expression.", locationFromVueNode(state.file, prop));
|
|
1089
|
-
const isSimpleIdentifier = /^[A-Za-z_$][\w$]*$/.test(expression);
|
|
1090
|
-
if (isSimpleIdentifier && state.activeLocals.includes(expression)) throw new ResuxCompileError(`Direct template-local event handler "${expression}" cannot be resumed because template locals are serialized by value. Call a top-level handler with serializable local data instead.`, locationFromVueNode(state.file, prop));
|
|
1091
|
-
const inlineHandler = !isSimpleIdentifier ? createInlineEventHandler(expression, state, prop) : null;
|
|
1090
|
+
if (!arg || !expression$1) throw new ResuxCompileError("Events need an argument and expression.", locationFromVueNode(state.file, prop));
|
|
1091
|
+
const isSimpleIdentifier = /^[A-Za-z_$][\w$]*$/.test(expression$1);
|
|
1092
|
+
if (isSimpleIdentifier && state.activeLocals.includes(expression$1)) throw new ResuxCompileError(`Direct template-local event handler "${expression$1}" cannot be resumed because template locals are serialized by value. Call a top-level handler with serializable local data instead.`, locationFromVueNode(state.file, prop));
|
|
1093
|
+
const inlineHandler = !isSimpleIdentifier ? createInlineEventHandler(expression$1, state, prop) : null;
|
|
1092
1094
|
const event = {
|
|
1093
1095
|
name: arg,
|
|
1094
|
-
handler: inlineHandler?.name ?? expression,
|
|
1096
|
+
handler: inlineHandler?.name ?? expression$1,
|
|
1095
1097
|
modifiers,
|
|
1096
1098
|
...inlineHandler?.locals.length ? { locals: inlineHandler.locals } : {}
|
|
1097
1099
|
};
|
|
@@ -1101,10 +1103,10 @@ function compileTemplateNode(node, state, options = {}) {
|
|
|
1101
1103
|
}
|
|
1102
1104
|
if (prop.name === "if") {
|
|
1103
1105
|
if (options.ifExpressionOverride) continue;
|
|
1104
|
-
const expression = expressionContent(prop.exp);
|
|
1105
|
-
if (!expression) throw new ResuxCompileError("v-if needs an expression.", locationFromVueNode(state.file, prop));
|
|
1106
|
+
const expression$1 = expressionContent(prop.exp);
|
|
1107
|
+
if (!expression$1) throw new ResuxCompileError("v-if needs an expression.", locationFromVueNode(state.file, prop));
|
|
1106
1108
|
element.if = {
|
|
1107
|
-
expression: registerTemplateExpression(expression, state.templateRefBindings, state.file, prop, state),
|
|
1109
|
+
expression: registerTemplateExpression(expression$1, state.templateRefBindings, state.file, prop, state),
|
|
1108
1110
|
blockId: nextBindingId(state)
|
|
1109
1111
|
};
|
|
1110
1112
|
continue;
|
|
@@ -1114,50 +1116,50 @@ function compileTemplateNode(node, state, options = {}) {
|
|
|
1114
1116
|
throw new ResuxCompileError(`v-${prop.name} must follow a sibling with v-if or v-else-if.`, locationFromVueNode(state.file, prop));
|
|
1115
1117
|
}
|
|
1116
1118
|
if (prop.name === "for") {
|
|
1117
|
-
const expression = expressionContent(prop.exp);
|
|
1118
|
-
if (!expression) throw new ResuxCompileError("v-for needs an expression.", locationFromVueNode(state.file, prop));
|
|
1119
|
-
element.for = parseForExpression(expression, state.file, prop, state);
|
|
1119
|
+
const expression$1 = expressionContent(prop.exp);
|
|
1120
|
+
if (!expression$1) throw new ResuxCompileError("v-for needs an expression.", locationFromVueNode(state.file, prop));
|
|
1121
|
+
element.for = parseForExpression(expression$1, state.file, prop, state);
|
|
1120
1122
|
element.for.source = registerTemplateExpression(element.for.source, state.templateRefBindings, state.file, prop, state);
|
|
1121
1123
|
continue;
|
|
1122
1124
|
}
|
|
1123
1125
|
if (prop.name === "show") {
|
|
1124
|
-
const expression = expressionContent(prop.exp);
|
|
1125
|
-
if (!expression) throw new ResuxCompileError("v-show needs an expression.", locationFromVueNode(state.file, prop));
|
|
1126
|
+
const expression$1 = expressionContent(prop.exp);
|
|
1127
|
+
if (!expression$1) throw new ResuxCompileError("v-show needs an expression.", locationFromVueNode(state.file, prop));
|
|
1126
1128
|
attrs.push({
|
|
1127
1129
|
kind: "dynamic",
|
|
1128
1130
|
name: "hidden",
|
|
1129
|
-
value: registerRawTemplateExpression(`!(${transformTemplateExpressionCode(expression, state.templateRefBindings, state.file, prop).transformed})`, expression, transformTemplateExpressionCode(expression, state.templateRefBindings, state.file, prop).identifiers, state),
|
|
1131
|
+
value: registerRawTemplateExpression(`!(${transformTemplateExpressionCode(expression$1, state.templateRefBindings, state.file, prop).transformed})`, expression$1, transformTemplateExpressionCode(expression$1, state.templateRefBindings, state.file, prop).identifiers, state),
|
|
1130
1132
|
bindingId: nextBindingId(state)
|
|
1131
1133
|
});
|
|
1132
1134
|
continue;
|
|
1133
1135
|
}
|
|
1134
1136
|
if (prop.name === "text") {
|
|
1135
|
-
const expression = expressionContent(prop.exp);
|
|
1136
|
-
if (!expression) throw new ResuxCompileError("v-text needs an expression.", locationFromVueNode(state.file, prop));
|
|
1137
|
+
const expression$1 = expressionContent(prop.exp);
|
|
1138
|
+
if (!expression$1) throw new ResuxCompileError("v-text needs an expression.", locationFromVueNode(state.file, prop));
|
|
1137
1139
|
element.children = [{
|
|
1138
1140
|
type: "interpolation",
|
|
1139
|
-
expression: registerTemplateExpression(expression, state.templateRefBindings, state.file, prop, state),
|
|
1141
|
+
expression: registerTemplateExpression(expression$1, state.templateRefBindings, state.file, prop, state),
|
|
1140
1142
|
bindingId: nextBindingId(state)
|
|
1141
1143
|
}];
|
|
1142
1144
|
continue;
|
|
1143
1145
|
}
|
|
1144
1146
|
if (prop.name === "html") {
|
|
1145
|
-
const expression = expressionContent(prop.exp);
|
|
1146
|
-
if (!expression) throw new ResuxCompileError("v-html needs an expression.", locationFromVueNode(state.file, prop));
|
|
1147
|
+
const expression$1 = expressionContent(prop.exp);
|
|
1148
|
+
if (!expression$1) throw new ResuxCompileError("v-html needs an expression.", locationFromVueNode(state.file, prop));
|
|
1147
1149
|
element.html = {
|
|
1148
|
-
expression: registerTemplateExpression(expression, state.templateRefBindings, state.file, prop, state),
|
|
1150
|
+
expression: registerTemplateExpression(expression$1, state.templateRefBindings, state.file, prop, state),
|
|
1149
1151
|
bindingId: nextBindingId(state)
|
|
1150
1152
|
};
|
|
1151
1153
|
element.children = [];
|
|
1152
1154
|
continue;
|
|
1153
1155
|
}
|
|
1154
1156
|
if (prop.name === "model") {
|
|
1155
|
-
const expression = expressionContent(prop.exp);
|
|
1156
|
-
if (!expression) throw new ResuxCompileError("v-model needs an expression.", locationFromVueNode(state.file, prop));
|
|
1157
|
-
if (!isAssignableExpression(expression)) throw new ResuxCompileError("v-model needs an assignable expression like \"message.value\".", locationFromVueNode(state.file, prop));
|
|
1158
|
-
const assignmentRoot = assignableExpressionRoot(expression);
|
|
1157
|
+
const expression$1 = expressionContent(prop.exp);
|
|
1158
|
+
if (!expression$1) throw new ResuxCompileError("v-model needs an expression.", locationFromVueNode(state.file, prop));
|
|
1159
|
+
if (!isAssignableExpression(expression$1)) throw new ResuxCompileError("v-model needs an assignable expression like \"message.value\".", locationFromVueNode(state.file, prop));
|
|
1160
|
+
const assignmentRoot = assignableExpressionRoot(expression$1);
|
|
1159
1161
|
if (assignmentRoot && state.activeLocals.includes(assignmentRoot)) throw new ResuxCompileError(`v-model cannot assign through template-local binding "${assignmentRoot}" because resumed event locals are serialized by value. Bind v-model to resumable component state instead.`, locationFromVueNode(state.file, prop));
|
|
1160
|
-
const model = createModelBinding(node.tag, node.props, expression, state, prop);
|
|
1162
|
+
const model = createModelBinding(node.tag, node.props, expression$1, state, prop);
|
|
1161
1163
|
attrs.push({
|
|
1162
1164
|
kind: "dynamic",
|
|
1163
1165
|
name: model.attribute,
|
|
@@ -1330,7 +1332,7 @@ function assignableExpressionRoot(expression) {
|
|
|
1330
1332
|
}
|
|
1331
1333
|
function normalizeEventModifiers(modifiers, file, node) {
|
|
1332
1334
|
const modifierNames = modifiers.map((modifier) => String(modifier.content));
|
|
1333
|
-
const supported =
|
|
1335
|
+
const supported = new Set([
|
|
1334
1336
|
"prevent",
|
|
1335
1337
|
"stop",
|
|
1336
1338
|
"self",
|
|
@@ -1424,7 +1426,7 @@ function findProjectRoot(startFile) {
|
|
|
1424
1426
|
}
|
|
1425
1427
|
return path.dirname(startFile);
|
|
1426
1428
|
}
|
|
1427
|
-
const IMAGE_VIDEO_FONT_EXTENSIONS =
|
|
1429
|
+
const IMAGE_VIDEO_FONT_EXTENSIONS = new Set([
|
|
1428
1430
|
".webp",
|
|
1429
1431
|
".png",
|
|
1430
1432
|
".jpg",
|
|
@@ -1442,7 +1444,7 @@ const IMAGE_VIDEO_FONT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
1442
1444
|
".ttf",
|
|
1443
1445
|
".eot"
|
|
1444
1446
|
]);
|
|
1445
|
-
const STYLESHEET_EXTENSIONS =
|
|
1447
|
+
const STYLESHEET_EXTENSIONS = new Set([
|
|
1446
1448
|
".css",
|
|
1447
1449
|
".scss",
|
|
1448
1450
|
".sass",
|
|
@@ -1475,11 +1477,11 @@ function ensureCompiledUserModule(resolvedFile, projectRoot, outDir, compiledSet
|
|
|
1475
1477
|
if (ext === ".ts" || ext === ".tsx" || ext === ".js" || ext === ".jsx") {
|
|
1476
1478
|
const compiledTarget = ensureCompiledUserModule(resolvedImported, projectRoot, outDir, compiledSet);
|
|
1477
1479
|
const relativeToCompiled = path.relative(path.dirname(targetJsFile), compiledTarget);
|
|
1478
|
-
const relativeImportPath = relativeToCompiled.startsWith(".") ? relativeToCompiled.replace(/\\/g, "/") : "./" + relativeToCompiled.replace(/\\/g, "/");
|
|
1480
|
+
const relativeImportPath$1 = relativeToCompiled.startsWith(".") ? relativeToCompiled.replace(/\\/g, "/") : "./" + relativeToCompiled.replace(/\\/g, "/");
|
|
1479
1481
|
replacements.push({
|
|
1480
1482
|
start: specifier.getStart(sourceFile),
|
|
1481
1483
|
end: specifier.getEnd(),
|
|
1482
|
-
replacement: JSON.stringify(relativeImportPath)
|
|
1484
|
+
replacement: JSON.stringify(relativeImportPath$1)
|
|
1483
1485
|
});
|
|
1484
1486
|
}
|
|
1485
1487
|
}
|
|
@@ -1505,45 +1507,41 @@ function processImportDeclaration(statement, sourceFile, file, client) {
|
|
|
1505
1507
|
const isRelative = importPath.startsWith(".");
|
|
1506
1508
|
const isAlias = importPath.startsWith("@/") || importPath.startsWith("~/");
|
|
1507
1509
|
const ext = path.extname(importPath).toLowerCase();
|
|
1508
|
-
if (IMAGE_VIDEO_FONT_EXTENSIONS.has(ext) || STYLESHEET_EXTENSIONS.has(ext)) {
|
|
1509
|
-
if (
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
if (isAlias) {
|
|
1518
|
-
const projectRoot = findProjectRoot(file);
|
|
1519
|
-
const normalized = fileUrl(path.resolve(projectRoot, importPath.slice(2)));
|
|
1520
|
-
const fullText = statement.getFullText(sourceFile);
|
|
1521
|
-
const start = specifier.getStart(sourceFile) - statement.getFullStart();
|
|
1522
|
-
const end = specifier.getEnd() - statement.getFullStart();
|
|
1523
|
-
return fullText.slice(0, start) + JSON.stringify(normalized) + fullText.slice(end);
|
|
1524
|
-
}
|
|
1525
|
-
return statement.getFullText(sourceFile);
|
|
1526
|
-
} else {
|
|
1527
|
-
if (STYLESHEET_EXTENSIONS.has(ext)) return "";
|
|
1510
|
+
if (IMAGE_VIDEO_FONT_EXTENSIONS.has(ext) || STYLESHEET_EXTENSIONS.has(ext)) if (client) {
|
|
1511
|
+
if (isRelative) {
|
|
1512
|
+
const normalized = fileUrl(path.resolve(path.dirname(file), importPath));
|
|
1513
|
+
const fullText = statement.getFullText(sourceFile);
|
|
1514
|
+
const start = specifier.getStart(sourceFile) - statement.getFullStart();
|
|
1515
|
+
const end = specifier.getEnd() - statement.getFullStart();
|
|
1516
|
+
return fullText.slice(0, start) + JSON.stringify(normalized) + fullText.slice(end);
|
|
1517
|
+
}
|
|
1518
|
+
if (isAlias) {
|
|
1528
1519
|
const projectRoot = findProjectRoot(file);
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
const relativeToRoot = path.relative(projectRoot, absolutePath);
|
|
1535
|
-
if (relativeToRoot === "" || relativeToRoot !== ".." && !relativeToRoot.startsWith(`..${path.sep}`) && !path.isAbsolute(relativeToRoot)) webPath = "/" + relativeToRoot.replace(/\\/g, "/");
|
|
1536
|
-
const clause = statement.importClause;
|
|
1537
|
-
if (!clause) return "";
|
|
1538
|
-
const bindings = [];
|
|
1539
|
-
if (clause.name) bindings.push(clause.name.text);
|
|
1540
|
-
if (clause.namedBindings) {
|
|
1541
|
-
if (ts.isNamespaceImport(clause.namedBindings)) bindings.push(clause.namedBindings.name.text);
|
|
1542
|
-
else for (const element of clause.namedBindings.elements) bindings.push(element.name.text);
|
|
1543
|
-
}
|
|
1544
|
-
if (bindings.length === 0) return "";
|
|
1545
|
-
return bindings.map((name) => `const ${name} = ${JSON.stringify(webPath)};`).join("\n");
|
|
1520
|
+
const normalized = fileUrl(path.resolve(projectRoot, importPath.slice(2)));
|
|
1521
|
+
const fullText = statement.getFullText(sourceFile);
|
|
1522
|
+
const start = specifier.getStart(sourceFile) - statement.getFullStart();
|
|
1523
|
+
const end = specifier.getEnd() - statement.getFullStart();
|
|
1524
|
+
return fullText.slice(0, start) + JSON.stringify(normalized) + fullText.slice(end);
|
|
1546
1525
|
}
|
|
1526
|
+
return statement.getFullText(sourceFile);
|
|
1527
|
+
} else {
|
|
1528
|
+
if (STYLESHEET_EXTENSIONS.has(ext)) return "";
|
|
1529
|
+
const projectRoot = findProjectRoot(file);
|
|
1530
|
+
let absolutePath = "";
|
|
1531
|
+
if (isAlias) absolutePath = path.resolve(projectRoot, importPath.slice(2));
|
|
1532
|
+
else if (isRelative) absolutePath = path.resolve(path.dirname(file), importPath);
|
|
1533
|
+
else absolutePath = importPath;
|
|
1534
|
+
let webPath = importPath;
|
|
1535
|
+
const relativeToRoot = path.relative(projectRoot, absolutePath);
|
|
1536
|
+
if (relativeToRoot === "" || relativeToRoot !== ".." && !relativeToRoot.startsWith(`..${path.sep}`) && !path.isAbsolute(relativeToRoot)) webPath = "/" + relativeToRoot.replace(/\\/g, "/");
|
|
1537
|
+
const clause = statement.importClause;
|
|
1538
|
+
if (!clause) return "";
|
|
1539
|
+
const bindings = [];
|
|
1540
|
+
if (clause.name) bindings.push(clause.name.text);
|
|
1541
|
+
if (clause.namedBindings) if (ts.isNamespaceImport(clause.namedBindings)) bindings.push(clause.namedBindings.name.text);
|
|
1542
|
+
else for (const element of clause.namedBindings.elements) bindings.push(element.name.text);
|
|
1543
|
+
if (bindings.length === 0) return "";
|
|
1544
|
+
return bindings.map((name) => `const ${name} = ${JSON.stringify(webPath)};`).join("\n");
|
|
1547
1545
|
}
|
|
1548
1546
|
if (isRelative) {
|
|
1549
1547
|
const resolvedPath = resolveFileExtension(path.resolve(path.dirname(file), importPath));
|
|
@@ -1578,37 +1576,35 @@ function processImportDeclaration(statement, sourceFile, file, client) {
|
|
|
1578
1576
|
const isRelative = importPath.startsWith(".");
|
|
1579
1577
|
const isAlias = importPath.startsWith("@/") || importPath.startsWith("~/");
|
|
1580
1578
|
const ext = path.extname(importPath).toLowerCase();
|
|
1581
|
-
if (IMAGE_VIDEO_FONT_EXTENSIONS.has(ext) || STYLESHEET_EXTENSIONS.has(ext)) {
|
|
1582
|
-
if (
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
if (isAlias) {
|
|
1591
|
-
const projectRoot = findProjectRoot(file);
|
|
1592
|
-
const normalized = fileUrl(path.resolve(projectRoot, importPath.slice(2)));
|
|
1593
|
-
const fullText = statement.getFullText(sourceFile);
|
|
1594
|
-
const start = specifier.getStart(sourceFile) - statement.getFullStart();
|
|
1595
|
-
const end = specifier.getEnd() - statement.getFullStart();
|
|
1596
|
-
return fullText.slice(0, start) + JSON.stringify(normalized) + fullText.slice(end);
|
|
1597
|
-
}
|
|
1598
|
-
return statement.getFullText(sourceFile);
|
|
1599
|
-
} else {
|
|
1600
|
-
if (STYLESHEET_EXTENSIONS.has(ext)) return "";
|
|
1579
|
+
if (IMAGE_VIDEO_FONT_EXTENSIONS.has(ext) || STYLESHEET_EXTENSIONS.has(ext)) if (client) {
|
|
1580
|
+
if (isRelative) {
|
|
1581
|
+
const normalized = fileUrl(path.resolve(path.dirname(file), importPath));
|
|
1582
|
+
const fullText = statement.getFullText(sourceFile);
|
|
1583
|
+
const start = specifier.getStart(sourceFile) - statement.getFullStart();
|
|
1584
|
+
const end = specifier.getEnd() - statement.getFullStart();
|
|
1585
|
+
return fullText.slice(0, start) + JSON.stringify(normalized) + fullText.slice(end);
|
|
1586
|
+
}
|
|
1587
|
+
if (isAlias) {
|
|
1601
1588
|
const projectRoot = findProjectRoot(file);
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
const relativeToRoot = path.relative(projectRoot, absolutePath);
|
|
1608
|
-
if (relativeToRoot === "" || relativeToRoot !== ".." && !relativeToRoot.startsWith(`..${path.sep}`) && !path.isAbsolute(relativeToRoot)) webPath = "/" + relativeToRoot.replace(/\\/g, "/");
|
|
1609
|
-
if (!statement.name) return "";
|
|
1610
|
-
return `const ${statement.name.text} = ${JSON.stringify(webPath)};`;
|
|
1589
|
+
const normalized = fileUrl(path.resolve(projectRoot, importPath.slice(2)));
|
|
1590
|
+
const fullText = statement.getFullText(sourceFile);
|
|
1591
|
+
const start = specifier.getStart(sourceFile) - statement.getFullStart();
|
|
1592
|
+
const end = specifier.getEnd() - statement.getFullStart();
|
|
1593
|
+
return fullText.slice(0, start) + JSON.stringify(normalized) + fullText.slice(end);
|
|
1611
1594
|
}
|
|
1595
|
+
return statement.getFullText(sourceFile);
|
|
1596
|
+
} else {
|
|
1597
|
+
if (STYLESHEET_EXTENSIONS.has(ext)) return "";
|
|
1598
|
+
const projectRoot = findProjectRoot(file);
|
|
1599
|
+
let absolutePath = "";
|
|
1600
|
+
if (isAlias) absolutePath = path.resolve(projectRoot, importPath.slice(2));
|
|
1601
|
+
else if (isRelative) absolutePath = path.resolve(path.dirname(file), importPath);
|
|
1602
|
+
else absolutePath = importPath;
|
|
1603
|
+
let webPath = importPath;
|
|
1604
|
+
const relativeToRoot = path.relative(projectRoot, absolutePath);
|
|
1605
|
+
if (relativeToRoot === "" || relativeToRoot !== ".." && !relativeToRoot.startsWith(`..${path.sep}`) && !path.isAbsolute(relativeToRoot)) webPath = "/" + relativeToRoot.replace(/\\/g, "/");
|
|
1606
|
+
if (!statement.name) return "";
|
|
1607
|
+
return `const ${statement.name.text} = ${JSON.stringify(webPath)};`;
|
|
1612
1608
|
}
|
|
1613
1609
|
if (isRelative) {
|
|
1614
1610
|
const resolvedPath = resolveFileExtension(path.resolve(path.dirname(file), importPath));
|
|
@@ -1665,14 +1661,12 @@ function analyzeScript(script, file, inlineHandlers = []) {
|
|
|
1665
1661
|
bindings.add(clause.name.text);
|
|
1666
1662
|
importedBindings.add(clause.name.text);
|
|
1667
1663
|
}
|
|
1668
|
-
if (clause.namedBindings) {
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
importedBindings.add(element.name.text);
|
|
1675
|
-
}
|
|
1664
|
+
if (clause.namedBindings) if (ts.isNamespaceImport(clause.namedBindings)) {
|
|
1665
|
+
bindings.add(clause.namedBindings.name.text);
|
|
1666
|
+
importedBindings.add(clause.namedBindings.name.text);
|
|
1667
|
+
} else for (const element of clause.namedBindings.elements) {
|
|
1668
|
+
bindings.add(element.name.text);
|
|
1669
|
+
importedBindings.add(element.name.text);
|
|
1676
1670
|
}
|
|
1677
1671
|
}
|
|
1678
1672
|
} else if (ts.isImportEqualsDeclaration(statement) && statement.name) {
|
|
@@ -1813,7 +1807,7 @@ function readPropertyName(name, sourceFile, file) {
|
|
|
1813
1807
|
throw new ResuxCompileError("Only simple property names are supported here.", locationFromTsNode(file, sourceFile, name));
|
|
1814
1808
|
}
|
|
1815
1809
|
function validateTemplateHandlers(events, analysis, file, fullSource, templateLocals = []) {
|
|
1816
|
-
const allowedHandlers =
|
|
1810
|
+
const allowedHandlers = new Set([...analysis.handlerNames, ...templateLocals]);
|
|
1817
1811
|
for (const event of events) {
|
|
1818
1812
|
if (!allowedHandlers.has(event.handler)) throw new ResuxCompileError(`Handler "${event.handler}" must be a top-level function or arrow function.`, locationFromOffset(file, fullSource, 0));
|
|
1819
1813
|
const handlerNode = analysis.handlers.get(event.handler);
|
|
@@ -1824,12 +1818,12 @@ function validateTemplateHandlers(events, analysis, file, fullSource, templateLo
|
|
|
1824
1818
|
}
|
|
1825
1819
|
}
|
|
1826
1820
|
function findUnsupportedCapture(node, handlerName, analysis, templateLocals = []) {
|
|
1827
|
-
const locals =
|
|
1821
|
+
const locals = new Set([
|
|
1828
1822
|
handlerName,
|
|
1829
1823
|
"event",
|
|
1830
1824
|
...templateLocals
|
|
1831
1825
|
]);
|
|
1832
|
-
const allowedTopLevel =
|
|
1826
|
+
const allowedTopLevel = new Set([
|
|
1833
1827
|
...analysis.resumableBindings,
|
|
1834
1828
|
...analysis.handlerNames,
|
|
1835
1829
|
...analysis.importedBindings
|
|
@@ -2355,7 +2349,7 @@ function createSupportModuleAutoImportPrefix(file, source, autoImports) {
|
|
|
2355
2349
|
for (const name of entry.names) {
|
|
2356
2350
|
if (seen.has(name) || declared.has(name)) continue;
|
|
2357
2351
|
seen.add(name);
|
|
2358
|
-
if (!new RegExp(`\\b${name}\\b`).test(source)) continue;
|
|
2352
|
+
if (!(/* @__PURE__ */ new RegExp(`\\b${name}\\b`)).test(source)) continue;
|
|
2359
2353
|
names.push(name);
|
|
2360
2354
|
}
|
|
2361
2355
|
if (names.length > 0) lines.push(`import { ${names.join(", ")} } from ${JSON.stringify(entry.from)};`);
|
|
@@ -2371,10 +2365,8 @@ function collectSupportModuleTopLevelBindings(file, source) {
|
|
|
2371
2365
|
const clause = statement.importClause;
|
|
2372
2366
|
if (!clause) continue;
|
|
2373
2367
|
if (clause.name) bindings.add(clause.name.text);
|
|
2374
|
-
if (clause.namedBindings)
|
|
2375
|
-
|
|
2376
|
-
else for (const element of clause.namedBindings.elements) bindings.add(element.name.text);
|
|
2377
|
-
}
|
|
2368
|
+
if (clause.namedBindings) if (ts.isNamespaceImport(clause.namedBindings)) bindings.add(clause.namedBindings.name.text);
|
|
2369
|
+
else for (const element of clause.namedBindings.elements) bindings.add(element.name.text);
|
|
2378
2370
|
continue;
|
|
2379
2371
|
}
|
|
2380
2372
|
if (ts.isVariableStatement(statement)) {
|
|
@@ -2488,8 +2480,7 @@ function createModuleOptions(module, options) {
|
|
|
2488
2480
|
return options;
|
|
2489
2481
|
}
|
|
2490
2482
|
function resolveBuiltinModule(specifier) {
|
|
2491
|
-
|
|
2492
|
-
return builtinModules$1[normalized] ?? null;
|
|
2483
|
+
return builtinModules$1[specifier.startsWith("resux:") ? specifier.slice(6) : specifier] ?? null;
|
|
2493
2484
|
}
|
|
2494
2485
|
const i18nBuiltinModule = { async setup(options, resux) {
|
|
2495
2486
|
const imported = await import("../i18n/index.js");
|
|
@@ -3161,7 +3152,7 @@ function resolveConfiguredPackageMode(packageName, config) {
|
|
|
3161
3152
|
async function analyzePackageUsage(appRoot, sources, runtimeConfig) {
|
|
3162
3153
|
const configuredPackages = readConfiguredPackages(runtimeConfig);
|
|
3163
3154
|
const map = /* @__PURE__ */ new Map();
|
|
3164
|
-
const ignoredPackages =
|
|
3155
|
+
const ignoredPackages = new Set([
|
|
3165
3156
|
"resuxjs",
|
|
3166
3157
|
"vue",
|
|
3167
3158
|
"h3",
|
|
@@ -3388,7 +3379,7 @@ function resolveFileExtension(filePath) {
|
|
|
3388
3379
|
function fileUrl(file) {
|
|
3389
3380
|
return pathToFileURL(file).href;
|
|
3390
3381
|
}
|
|
3382
|
+
|
|
3391
3383
|
//#endregion
|
|
3392
3384
|
export { ResuxCompileError, buildProject, compileVueFile, compileVueSource, createRouteManifest, fileUrl, resolveFileExtension };
|
|
3393
|
-
|
|
3394
3385
|
//# sourceMappingURL=index.js.map
|
package/dist/compiler/index.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { BuildOptions, BuildResult, ClientEnhancementManifestEntry, CompileErrorLocation, CompiledComponent, CompiledMiddleware, CompiledPlugin, CompiledServerMiddleware, ResuxCompileError, RouteManifestRecord, RouteRuleConfig, ServerHandlerRecord, VueIslandRecord, createRouteManifest, fileUrl, resolveFileExtension } from "./implementation.js";
|
|
2
2
|
import { normalizeResuxDirectiveSyntax, normalizeResuxSfcSource } from "./directives.js";
|
|
3
|
+
|
|
3
4
|
//#region src/compiler/adapter.d.ts
|
|
4
|
-
|
|
5
|
+
interface ResuxCompileVueSourceOptions {
|
|
5
6
|
file: string;
|
|
6
7
|
id: string;
|
|
7
8
|
name: string;
|
|
8
9
|
/** Enables development-only compiler diagnostics. */
|
|
9
10
|
dev?: boolean;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
declare function compileVueSource(source: string, options: ResuxCompileVueSourceOptions): CompiledComponent;
|
|
13
|
+
declare function compileVueFile(file: string, options: {
|
|
13
14
|
id: string;
|
|
14
15
|
name?: string;
|
|
15
16
|
dev?: boolean;
|
|
16
17
|
}): Promise<CompiledComponent>;
|
|
17
|
-
|
|
18
|
+
declare function buildProject(appRoot: string, outDir?: string, options?: BuildOptions): Promise<BuildResult>;
|
|
18
19
|
//#endregion
|
|
19
|
-
export { BuildOptions, BuildResult, ClientEnhancementManifestEntry, CompileErrorLocation, CompiledComponent, CompiledMiddleware, CompiledPlugin, CompiledServerMiddleware, ResuxCompileError, RouteManifestRecord, RouteRuleConfig, ServerHandlerRecord, VueIslandRecord, createRouteManifest, fileUrl, normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, resolveFileExtension };
|
|
20
|
+
export { BuildOptions, BuildResult, ClientEnhancementManifestEntry, CompileErrorLocation, CompiledComponent, CompiledMiddleware, CompiledPlugin, CompiledServerMiddleware, ResuxCompileError, ResuxCompileVueSourceOptions, RouteManifestRecord, RouteRuleConfig, ServerHandlerRecord, VueIslandRecord, buildProject, compileVueFile, compileVueSource, createRouteManifest, fileUrl, normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, resolveFileExtension };
|
|
20
21
|
//# sourceMappingURL=adapter.d.ts.map
|
package/dist/compiler/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { syncBuiltinESMExports } from "node:module";
|
|
|
5
5
|
import { promises } from "node:fs";
|
|
6
6
|
import { readFile } from "node:fs/promises";
|
|
7
7
|
import path from "node:path";
|
|
8
|
+
|
|
8
9
|
//#region src/compiler/adapter.ts
|
|
9
10
|
function compileVueSource(source, options) {
|
|
10
11
|
const usesResuxDirectives = source.includes("rx-");
|
|
@@ -75,7 +76,7 @@ async function withResuxDirectiveFileReads(task, emittedDevWarnings) {
|
|
|
75
76
|
function pascalCase(value) {
|
|
76
77
|
return value.replace(/\[[^\]]+\]/g, (match) => match.slice(1, -1)).split(/[^A-Za-z0-9]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
77
78
|
}
|
|
79
|
+
|
|
78
80
|
//#endregion
|
|
79
81
|
export { ResuxCompileError, buildProject, compileVueFile, compileVueSource, createRouteManifest, fileUrl, normalizeResuxDirectiveSyntax, normalizeResuxSfcSource, resolveFileExtension };
|
|
80
|
-
|
|
81
82
|
//# sourceMappingURL=adapter.js.map
|