@jay-framework/rollup-plugin 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +18 -6
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -7,12 +7,12 @@ var __publicField = (obj, key, value) => {
7
7
  import { generateElementDefinitionFile, parseGenericTypescriptFile, generateImportsFileFromJayFile, generateElementFile, transformComponent, transformComponentBridge, compileFunctionSplitPatternsBlock, createTsSourceFileFromSource, FunctionRepositoryBuilder } from "@jay-framework/compiler";
8
8
  export * from "@jay-framework/compiler";
9
9
  import path from "node:path";
10
- import { getBasePath, JAY_EXTENSION, hasExtension, JAY_CONTRACT_EXTENSION, JAY_ACTION_EXTENSION, checkValidationErrors, JAY_DTS_EXTENSION, JAY_CONTRACT_DTS_EXTENSION, JAY_ACTION_DTS_EXTENSION, SourceFileFormat, getModeFromExtension, GenerateTarget, RuntimeMode, TS_EXTENSION, TSX_EXTENSION, parseJayModuleSpecifier, JAY_QUERY_WORKER_TRUSTED_TS, CSS_EXTENSION, JAY_QUERY_MAIN_SANDBOX, hasJayExtension, hasJayModeExtension, Import } from "@jay-framework/compiler-shared";
10
+ import { getBasePath, JAY_EXTENSION, hasExtension, JAY_CONTRACT_EXTENSION, JAY_ACTION_EXTENSION, checkValidationErrors, JAY_DTS_EXTENSION, JAY_CONTRACT_DTS_EXTENSION, JAY_ACTION_DTS_EXTENSION, SourceFileFormat, getModeFromExtension, GenerateTarget, parseJayModuleSpecifier, RuntimeMode, TS_EXTENSION, TSX_EXTENSION, JAY_QUERY_WORKER_TRUSTED_TS, CSS_EXTENSION, JAY_QUERY_MAIN_SANDBOX, JAY_QUERY_HYDRATE, hasJayExtension, hasJayModeExtension, Import } from "@jay-framework/compiler-shared";
11
11
  import { readFile, mkdir } from "node:fs/promises";
12
12
  import { writeFile } from "fs/promises";
13
13
  import { getLogger } from "@jay-framework/logger";
14
14
  import fs from "node:fs";
15
- import { getJayHtmlImports, parseJayFile, JAY_IMPORT_RESOLVER, parseContract, compileContract, parseAction, compileAction, defaultContractResolver, generateSandboxRootFile, generateElementBridgeFile } from "@jay-framework/compiler-jay-html";
15
+ import { getJayHtmlImports, parseJayFile, JAY_IMPORT_RESOLVER, parseContract, compileContract, parseAction, compileAction, defaultContractResolver, generateSandboxRootFile, generateElementBridgeFile, generateElementHydrateFile } from "@jay-framework/compiler-jay-html";
16
16
  import { createRequire } from "module";
17
17
  import fs$1 from "fs";
18
18
  function getFileContext(filename, extension = JAY_EXTENSION) {
@@ -33,7 +33,10 @@ async function writeDefinitionFile(dirname, filename, source, extension) {
33
33
  async function writeGeneratedFile(jayContext, context, id, code) {
34
34
  if (!jayContext.outputDir)
35
35
  return;
36
- const relativePath = path.dirname(path.relative(jayContext.projectRoot, id));
36
+ let relativePath = path.dirname(path.relative(jayContext.projectRoot, id));
37
+ if (relativePath.startsWith("build" + path.sep)) {
38
+ relativePath = relativePath.slice(("build" + path.sep).length);
39
+ }
37
40
  const filePath = path.resolve(jayContext.outputDir, relativePath, path.basename(id));
38
41
  await mkdir(path.dirname(filePath), { recursive: true });
39
42
  await writeFile(filePath, code, { encoding: "utf8", flag: "w" });
@@ -245,14 +248,23 @@ async function generateCodeFromStructure(jayContext, context, code, id, meta, ja
245
248
  const { format } = meta;
246
249
  const mode = getModeFromExtension(id);
247
250
  const generationTarget = jayContext.jayOptions.generationTarget || GenerateTarget.jay;
248
- const tsCode = format === SourceFileFormat.JayHtml ? generateCodeFromJayHtmlFile(mode, jayFile, generationTarget) : generateCodeFromTsFile(jayContext, mode, jayFile, id, code);
251
+ const isHydrate = parseJayModuleSpecifier(id).isHydrate === true;
252
+ const tsCode = format === SourceFileFormat.JayHtml ? generateCodeFromJayHtmlFile(
253
+ mode,
254
+ jayFile,
255
+ generationTarget,
256
+ isHydrate
257
+ ) : generateCodeFromTsFile(jayContext, mode, jayFile, id, code);
249
258
  await writeGeneratedFile(jayContext, context, id, tsCode);
250
259
  return tsCode;
251
260
  }
252
- function generateCodeFromJayHtmlFile(mode, jayFile, generationTarget) {
261
+ function generateCodeFromJayHtmlFile(mode, jayFile, generationTarget, isHydrate = false) {
253
262
  switch (mode) {
254
263
  case RuntimeMode.MainTrusted:
255
264
  case RuntimeMode.MainSandbox:
265
+ if (isHydrate) {
266
+ return checkValidationErrors(generateElementHydrateFile(jayFile, mode));
267
+ }
256
268
  return checkValidationErrors(generateElementFile(jayFile, mode, generationTarget));
257
269
  case RuntimeMode.WorkerSandbox:
258
270
  return generateElementBridgeFile(jayFile);
@@ -502,7 +514,7 @@ function getResolvedId(resolved, mode, originId) {
502
514
  return `${originId}?${mode}.${extension}`;
503
515
  }
504
516
  function hasCssImportedByJayHtml(source, importer) {
505
- return hasExtension(source, CSS_EXTENSION) && importer && (hasExtension(importer, JAY_EXTENSION, { withTs: true }) || hasExtension(importer, JAY_EXTENSION + JAY_QUERY_MAIN_SANDBOX, { withTs: true }));
517
+ return hasExtension(source, CSS_EXTENSION) && importer && (hasExtension(importer, JAY_EXTENSION, { withTs: true }) || hasExtension(importer, JAY_EXTENSION + JAY_QUERY_MAIN_SANDBOX, { withTs: true }) || hasExtension(importer, JAY_EXTENSION + JAY_QUERY_HYDRATE, { withTs: true }));
506
518
  }
507
519
  function resolveCssFileImportedByJayHtml(context, importer, root) {
508
520
  const originImporter = importer.split("?")[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/rollup-plugin",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -27,17 +27,17 @@
27
27
  "test:watch": "vitest"
28
28
  },
29
29
  "dependencies": {
30
- "@jay-framework/compiler": "^0.13.0",
31
- "@jay-framework/compiler-jay-html": "^0.13.0",
32
- "@jay-framework/logger": "^0.13.0",
30
+ "@jay-framework/compiler": "^0.15.0",
31
+ "@jay-framework/compiler-jay-html": "^0.15.0",
32
+ "@jay-framework/logger": "^0.15.0",
33
33
  "fast-glob": "^3.3.2",
34
34
  "typescript": "^5.3.3"
35
35
  },
36
36
  "devDependencies": {
37
- "@jay-framework/component": "^0.13.0",
38
- "@jay-framework/dev-environment": "^0.13.0",
39
- "@jay-framework/runtime": "^0.13.0",
40
- "@jay-framework/secure": "^0.13.0",
37
+ "@jay-framework/component": "^0.15.0",
38
+ "@jay-framework/dev-environment": "^0.15.0",
39
+ "@jay-framework/runtime": "^0.15.0",
40
+ "@jay-framework/secure": "^0.15.0",
41
41
  "@types/node": "^20.11.5",
42
42
  "rimraf": "^5.0.5",
43
43
  "rollup": "^4.9.5",