@joplo-app/server 0.2.12 → 0.2.14
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/build.d.ts +2 -2
- package/dist/build.js +5 -5
- package/dist/feature-diff-locales.json +882 -0
- package/dist/feature-diff-runtime.js +427 -0
- package/dist/feature-diff-viewer.d.ts +3 -0
- package/dist/feature-diff-viewer.js +130 -0
- package/dist/feature-diff.d.ts +14 -0
- package/dist/feature-diff.js +56 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +5 -4
package/dist/build.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Project } from '@joplo-app/core';
|
|
1
|
+
import { type StepIdentity, type Project } from '@joplo-app/core';
|
|
2
2
|
import type { BuildOptions, BuildResult } from './contract.js';
|
|
3
3
|
import type { DistWeb } from './web-assets.js';
|
|
4
4
|
/** 发布站只需要的 IR:去掉创作侧字段(publish 模式下它们本来就为空)。层级、镜头、角色(说话人、过渡卡、层级的 role)与 featureIds 顺序属于演示,保留(D43 / D56 / D61)。 */
|
|
@@ -13,7 +13,7 @@ export declare function finalizeHtml(html: string, readAsset: (rel: string) => s
|
|
|
13
13
|
project: unknown;
|
|
14
14
|
home: string | null;
|
|
15
15
|
scoped?: true;
|
|
16
|
-
}): {
|
|
16
|
+
}, identity?: StepIdentity): {
|
|
17
17
|
html: string;
|
|
18
18
|
inlined: string[];
|
|
19
19
|
};
|
package/dist/build.js
CHANGED
|
@@ -19,7 +19,7 @@ import os from 'node:os';
|
|
|
19
19
|
import path from 'node:path';
|
|
20
20
|
import tailwindcss from '@tailwindcss/vite';
|
|
21
21
|
import { build as viteBuild, createServer } from 'vite';
|
|
22
|
-
import { hasScope, JoploError, orderedFeatures, resolveScope, scopeProject } from '@joplo-app/core';
|
|
22
|
+
import { stepIdentity, hasScope, JoploError, orderedFeatures, resolveScope, scopeProject } from '@joplo-app/core';
|
|
23
23
|
import { compileProject } from "./project.js";
|
|
24
24
|
import { joploProjectPlugin, kitAliases, locateWebAssets, realProjectDir } from "./vite-shared.js";
|
|
25
25
|
import { subsetSiteFonts } from "./site-fonts.js";
|
|
@@ -33,14 +33,14 @@ export function publishPayload(project, home) {
|
|
|
33
33
|
const options = Object.fromEntries(Object.entries(project.options).map(([id, o]) => [id, { id: o.id, featureId: o.featureId, key: o.key, name: o.name, idea: o.idea, routes: o.routes, coverage: {}, layers: o.layers ?? {} }]));
|
|
34
34
|
const scenarios = Object.fromEntries(Object.entries(project.scenarios).map(([id, s]) => {
|
|
35
35
|
const { caseIds: _ci, ...sr } = s;
|
|
36
|
-
return [id, { ...sr, caseIds: [], steps: s.steps.map(({ ruleIds: _ri, ...st }) => ({ ...st, ruleIds: [] })) }];
|
|
36
|
+
return [id, { ...sr, caseIds: [], steps: s.steps.map(({ ruleIds: _ri, key: _key, ...st }) => ({ ...st, ruleIds: [] })) }];
|
|
37
37
|
}));
|
|
38
38
|
return { project: { ...rest, features, options, scenarios }, home: home && project.routes[home] ? home : null };
|
|
39
39
|
}
|
|
40
40
|
/** 把 JSON 安全地放进 <script type="application/json">。 */
|
|
41
41
|
export const jsonForHtml = (v) => JSON.stringify(v).replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026').replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
|
|
42
42
|
/** 后处理 vite 产出的 HTML:内联 IR、内联入口脚本、去掉 crossorigin(file:// 下 CORS 会失败)。 */
|
|
43
|
-
export function finalizeHtml(html, readAsset, inline) {
|
|
43
|
+
export function finalizeHtml(html, readAsset, inline, identity) {
|
|
44
44
|
const inlined = [];
|
|
45
45
|
let out = html.replace(/\s+crossorigin(?:="[^"]*")?/g, '');
|
|
46
46
|
out = out.replace(/<link rel="modulepreload"[^>]*>\s*/g, '');
|
|
@@ -49,7 +49,7 @@ export function finalizeHtml(html, readAsset, inline) {
|
|
|
49
49
|
const code = readAsset(rel).replace(/<\/script/gi, '<\\/script');
|
|
50
50
|
return `<script type="module">${code}</script>`;
|
|
51
51
|
});
|
|
52
|
-
const data = `<script type="application/json" id="joplo-ir">${jsonForHtml(inline)}</script
|
|
52
|
+
const data = `<meta name="joplo-feature-diff-player" content="1"><script type="application/json" id="joplo-ir">${jsonForHtml(inline)}</script>` + (identity ? `\n<script type="application/json" id="joplo-step-keys">${jsonForHtml(identity)}</script>` : '');
|
|
53
53
|
out = out.replace('</head>', ` ${data}\n </head>`);
|
|
54
54
|
return { html: out, inlined };
|
|
55
55
|
}
|
|
@@ -151,7 +151,7 @@ export async function buildSite(opts) {
|
|
|
151
151
|
voiceReport = voice.report;
|
|
152
152
|
// 3. 后处理
|
|
153
153
|
const siteHtml = path.join(staging, 'site.html');
|
|
154
|
-
const { html, inlined } = finalizeHtml(fs.readFileSync(siteHtml, 'utf8'), (rel) => fs.readFileSync(path.join(staging, rel), 'utf8'), inline);
|
|
154
|
+
const { html, inlined } = finalizeHtml(fs.readFileSync(siteHtml, 'utf8'), (rel) => fs.readFileSync(path.join(staging, rel), 'utf8'), inline, stepIdentity(project));
|
|
155
155
|
fs.rmSync(siteHtml);
|
|
156
156
|
for (const rel of inlined)
|
|
157
157
|
fs.rmSync(path.join(staging, rel));
|