fimo 0.7.0-experimental.3 → 0.7.0-staging.1
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 +2 -3
- package/assets/skills/fimo/SKILL.md +1 -1
- package/assets/skills/fimo/references/assets.md +2 -2
- package/assets/skills/fimo/references/content.md +1 -1
- package/assets/skills/fimo/references/design.md +1 -1
- package/assets/skills/fimo-cli/SKILL.md +1 -1
- package/assets/skills/fimo-cli/references/assets.md +24 -7
- package/assets/skills/fimo-cli/references/content.md +2 -2
- package/assets/skills/fimo-cli/references/domains.md +1 -1
- package/assets/skills/fimo-cli/references/media.md +142 -132
- package/assets/skills/fimo-studio/references/custom-domains.md +1 -1
- package/dist/build/vite/index.d.ts.map +1 -0
- package/dist/build/vite/plugins/content-sync.d.ts.map +1 -0
- package/dist/build/vite/plugins/content-sync.test.d.ts +2 -0
- package/dist/build/vite/plugins/content-sync.test.d.ts.map +1 -0
- package/dist/build/vite/plugins/content-sync.test.js +64 -0
- package/dist/build/vite/plugins/data-id.d.ts.map +1 -0
- package/dist/build/vite/plugins/fimo-config.d.ts.map +1 -0
- package/dist/build/vite/plugins/fimo-config.test.d.ts +2 -0
- package/dist/build/vite/plugins/fimo-config.test.d.ts.map +1 -0
- package/dist/build/vite/plugins/fimo-config.test.js +46 -0
- package/dist/build/vite/plugins/overlay.d.ts.map +1 -0
- package/dist/build/vite/plugins/robots.d.ts.map +1 -0
- package/dist/build/vite/plugins/seo.d.ts.map +1 -0
- package/dist/build/vite/plugins/server-config.d.ts.map +1 -0
- package/dist/build/vite/plugins/sitemap.d.ts.map +1 -0
- package/dist/build/vite/plugins/translations.d.ts.map +1 -0
- package/dist/build/vite/plugins/translations.test.d.ts +2 -0
- package/dist/build/vite/plugins/translations.test.d.ts.map +1 -0
- package/dist/build/vite/plugins/translations.test.js +266 -0
- package/dist/cli/bundle.json +2 -3
- package/dist/cli/index.js +110670 -1196
- package/dist/runtime/app/FimoProviders.d.ts.map +1 -0
- package/dist/runtime/app/FimoScripts.d.ts.map +1 -0
- package/dist/runtime/app/index.d.ts.map +1 -0
- package/dist/runtime/app/prefetch.d.ts.map +1 -0
- package/dist/runtime/content/DataSourcesProvider.d.ts.map +1 -0
- package/dist/runtime/content/RefreshContentProvider.d.ts.map +1 -0
- package/dist/runtime/content/RefreshContentProvider.test.d.ts +2 -0
- package/dist/runtime/content/RefreshContentProvider.test.d.ts.map +1 -0
- package/dist/runtime/content/RefreshContentProvider.test.js +33 -0
- package/dist/runtime/content/parseCollectionResponse.d.ts.map +1 -0
- package/dist/runtime/content/parseCollectionResponse.test.d.ts +2 -0
- package/dist/runtime/content/parseCollectionResponse.test.d.ts.map +1 -0
- package/dist/runtime/content/parseCollectionResponse.test.js +20 -0
- package/dist/runtime/content/utils/retrieve-data-sources.d.ts.map +1 -0
- package/dist/runtime/core/AppErrorBoundary.d.ts.map +1 -0
- package/dist/runtime/core/ViteLifecycles.d.ts.map +1 -0
- package/dist/runtime/i18n/FimoLocaleContext.d.ts.map +1 -0
- package/dist/runtime/i18n/locale.d.ts.map +1 -0
- package/dist/runtime/i18n/locale.test.d.ts +2 -0
- package/dist/runtime/i18n/locale.test.d.ts.map +1 -0
- package/dist/runtime/i18n/locale.test.js +58 -0
- package/dist/runtime/iframe/ConsoleErrorProvider.d.ts.map +1 -0
- package/dist/runtime/iframe/ScreenshotProvider.d.ts.map +1 -0
- package/dist/runtime/iframe/runtime/overlay-hmr.d.ts.map +1 -0
- package/dist/runtime/iframe/runtime/overlay-runtime.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +0 -3
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +0 -2
- package/dist/runtime/paths/get-fimo-paths.d.ts.map +1 -0
- package/dist/runtime/paths/get-fimo-paths.test.d.ts +2 -0
- package/dist/runtime/paths/get-fimo-paths.test.d.ts.map +1 -0
- package/dist/runtime/paths/get-fimo-paths.test.js +69 -0
- package/dist/runtime/paths/index.d.ts.map +1 -0
- package/dist/runtime/paths/types.d.ts.map +1 -0
- package/dist/runtime/primitives/components/Boolean.d.ts.map +1 -0
- package/dist/runtime/primitives/components/Date.d.ts.map +1 -0
- package/dist/runtime/primitives/components/Image.d.ts.map +1 -0
- package/dist/runtime/primitives/components/RichText.d.ts.map +1 -0
- package/dist/runtime/primitives/components/StaticImage.d.ts.map +1 -0
- package/dist/runtime/primitives/components/Text.d.ts.map +1 -0
- package/dist/runtime/primitives/components/Video.d.ts.map +1 -0
- package/dist/runtime/primitives/components/index.d.ts.map +1 -0
- package/dist/runtime/primitives/index.d.ts.map +1 -0
- package/dist/runtime/primitives/lib/image-optimization.d.ts.map +1 -0
- package/dist/runtime/primitives/lib/index.d.ts.map +1 -0
- package/dist/runtime/primitives/lib/primitives.d.ts.map +1 -0
- package/dist/runtime/primitives/lib/query.d.ts.map +1 -0
- package/dist/runtime/primitives/lib/template.d.ts.map +1 -0
- package/dist/runtime/primitives/lib/useFimoLiveValue.d.ts.map +1 -0
- package/dist/runtime/primitives/public-surface.test.d.ts +2 -0
- package/dist/runtime/primitives/public-surface.test.d.ts.map +1 -0
- package/dist/runtime/primitives/public-surface.test.js +49 -0
- package/dist/runtime/primitives/translations.d.ts.map +1 -0
- package/dist/runtime/react-router/index.d.ts.map +1 -0
- package/dist/runtime/react-router/navigation-utils.d.ts.map +1 -0
- package/dist/runtime/react-router/navigation.d.ts.map +1 -0
- package/dist/runtime/react-router/navigation.test.d.ts +2 -0
- package/dist/runtime/react-router/navigation.test.d.ts.map +1 -0
- package/dist/runtime/react-router/navigation.test.js +35 -0
- package/dist/runtime/react-router/routes.d.ts.map +1 -0
- package/dist/runtime/react-router/routes.test.d.ts +2 -0
- package/dist/runtime/react-router/routes.test.d.ts.map +1 -0
- package/dist/runtime/react-router/routes.test.js +67 -0
- package/dist/runtime/routing/AppResetScrollOnNavigate.d.ts.map +1 -0
- package/dist/runtime/routing/AppRoutesProvider.d.ts.map +1 -0
- package/dist/runtime/seo/buildSeoForPath.d.ts.map +1 -0
- package/dist/runtime/seo/htmlProps.d.ts.map +1 -0
- package/dist/runtime/seo/index.d.ts.map +1 -0
- package/dist/runtime/seo/resolver.d.ts.map +1 -0
- package/dist/runtime/shared/fimo-config.server.d.ts.map +1 -0
- package/dist/runtime/shared/fimo-config.types.d.ts.map +1 -0
- package/dist/runtime/t/OptionalTracking.d.ts.map +1 -0
- package/dist/runtime/t/OptionalTracking.test.d.ts +2 -0
- package/dist/runtime/t/OptionalTracking.test.d.ts.map +1 -0
- package/dist/runtime/t/OptionalTracking.test.js +11 -0
- package/dist/runtime/t/Pageview.d.ts.map +1 -0
- package/dist/runtime/templates.d.ts.map +1 -0
- package/dist/scripts/generated-types.test.js +212 -0
- package/dist/scripts/lint-translation-keys.test.d.ts +1 -0
- package/dist/scripts/lint-translation-keys.test.js +16 -0
- package/dist/scripts/sync-schemas.test.d.ts +1 -0
- package/dist/scripts/sync-schemas.test.js +144 -0
- package/dist/scripts/validate-route-metadata.test.d.ts +1 -0
- package/dist/scripts/validate-route-metadata.test.js +116 -0
- package/dist/scripts/validate-schemas.test.d.ts +1 -0
- package/dist/scripts/validate-schemas.test.js +263 -0
- package/package.json +13 -31
- package/scripts/add-ext.mjs +47 -0
- package/scripts/bump-version.mjs +58 -0
- package/scripts/bundle-cli.mjs +123 -0
- package/scripts/install-cli.mjs +36 -0
- package/scripts/lib/channels.mjs +70 -0
- package/scripts/lib/dev-release-state.mjs +44 -0
- package/scripts/lib/dev-release-state.test.ts +36 -0
- package/scripts/lib/postinstall-onboarding.test.ts +82 -0
- package/scripts/lib/release-core.mjs +225 -0
- package/scripts/lib/release-core.test.ts +147 -0
- package/scripts/migration-qa-gate.test.ts +155 -0
- package/scripts/publish-npm.mjs +180 -0
- package/templates/react-router/package.json +1 -1
- package/templates/react-router/src/pages/Index.tsx +1 -1
- package/dist/runtime/content/client/createContentClient.d.ts +0 -5
- package/dist/runtime/content/client/createContentClient.js +0 -300
- package/dist/runtime/content/client/createSingletonClient.d.ts +0 -5
- package/dist/runtime/content/client/createSingletonClient.js +0 -108
- package/dist/runtime/content/client/internal.d.ts +0 -44
- package/dist/runtime/content/client/internal.js +0 -236
- package/dist/runtime/content/client/types.d.ts +0 -136
- package/dist/runtime/content/client/useQueryLocale.d.ts +0 -2
- package/dist/runtime/content/client/useQueryLocale.js +0 -6
- /package/dist/{runtime/content/client/types.js → scripts/generated-types.test.d.ts} +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import fimoConfigPlugin from './fimo-config';
|
|
6
|
+
let scratch = null;
|
|
7
|
+
const pluginContext = {
|
|
8
|
+
meta: {},
|
|
9
|
+
error: (error) => {
|
|
10
|
+
throw error;
|
|
11
|
+
},
|
|
12
|
+
info: () => undefined,
|
|
13
|
+
warn: () => undefined,
|
|
14
|
+
debug: () => undefined,
|
|
15
|
+
};
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
if (scratch) {
|
|
18
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
19
|
+
scratch = null;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
function createPluginWithConfig(config) {
|
|
23
|
+
scratch = mkdtempSync(join(tmpdir(), 'fimo-config-plugin-'));
|
|
24
|
+
writeFileSync(join(scratch, 'fimo-config.json'), JSON.stringify(config, null, 2));
|
|
25
|
+
const plugin = fimoConfigPlugin();
|
|
26
|
+
if (typeof plugin.config === 'function') {
|
|
27
|
+
plugin.config.call(pluginContext, { root: scratch }, { command: 'build', mode: 'production' });
|
|
28
|
+
}
|
|
29
|
+
return plugin;
|
|
30
|
+
}
|
|
31
|
+
function transformHtml(plugin, html) {
|
|
32
|
+
if (typeof plugin.transformIndexHtml !== 'function') {
|
|
33
|
+
throw new Error('Expected transformIndexHtml function');
|
|
34
|
+
}
|
|
35
|
+
return plugin.transformIndexHtml.call(pluginContext, html, {});
|
|
36
|
+
}
|
|
37
|
+
describe('fimoConfigPlugin', () => {
|
|
38
|
+
it('sets html lang from i18n.defaultLocale', () => {
|
|
39
|
+
const plugin = createPluginWithConfig({ seo: { locale: 'es_ES' }, i18n: { defaultLocale: 'fr' } });
|
|
40
|
+
expect(transformHtml(plugin, '<html><head></head><body></body></html>')).toContain('<html lang="fr">');
|
|
41
|
+
});
|
|
42
|
+
it('falls back to en when i18n.defaultLocale is absent', () => {
|
|
43
|
+
const plugin = createPluginWithConfig({ seo: { locale: 'es_ES' } });
|
|
44
|
+
expect(transformHtml(plugin, '<html lang="fr"><head></head><body></body></html>')).toContain('<html lang="en">');
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../../src/build/vite/plugins/overlay.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAoEnC,MAAM,CAAC,OAAO,UAAU,aAAa,IAAI,MAAM,CA+E9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"robots.d.ts","sourceRoot":"","sources":["../../../../src/build/vite/plugins/robots.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AA6BnC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,IAAI,MAAM,CAuB7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seo.d.ts","sourceRoot":"","sources":["../../../../src/build/vite/plugins/seo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AA2BnC,MAAM,CAAC,OAAO,UAAU,SAAS,IAAI,MAAM,CA2G1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../../../src/build/vite/plugins/server-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,MAAM,CAAC,OAAO,UAAU,kBAAkB,IAAI,MAAM,CAsBnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sitemap.d.ts","sourceRoot":"","sources":["../../../../src/build/vite/plugins/sitemap.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAkDnC,MAAM,CAAC,OAAO,UAAU,aAAa,IAAI,MAAM,CA8B9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../../src/build/vite/plugins/translations.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAQlD,UAAU,WAAW;IACnB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAwCD,MAAM,CAAC,OAAO,UAAU,kBAAkB,IAAI,MAAM,CAmOnD;AAoED,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAwC3E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translations.test.d.ts","sourceRoot":"","sources":["../../../../src/build/vite/plugins/translations.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import translationsPlugin from './translations';
|
|
6
|
+
let scratch = null;
|
|
7
|
+
let activePlugin = null;
|
|
8
|
+
const originalFimoApiToken = process.env.FIMO_API_TOKEN;
|
|
9
|
+
const pluginContext = {
|
|
10
|
+
addWatchFile: vi.fn(),
|
|
11
|
+
meta: {},
|
|
12
|
+
error: (error) => {
|
|
13
|
+
throw error;
|
|
14
|
+
},
|
|
15
|
+
info: () => undefined,
|
|
16
|
+
warn: () => undefined,
|
|
17
|
+
debug: () => undefined,
|
|
18
|
+
};
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
if (activePlugin && typeof activePlugin.closeBundle === 'function') {
|
|
21
|
+
activePlugin.closeBundle.call(pluginContext);
|
|
22
|
+
activePlugin = null;
|
|
23
|
+
}
|
|
24
|
+
if (scratch) {
|
|
25
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
26
|
+
scratch = null;
|
|
27
|
+
}
|
|
28
|
+
if (originalFimoApiToken === undefined) {
|
|
29
|
+
delete process.env.FIMO_API_TOKEN;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
process.env.FIMO_API_TOKEN = originalFimoApiToken;
|
|
33
|
+
}
|
|
34
|
+
vi.unstubAllGlobals();
|
|
35
|
+
vi.clearAllMocks();
|
|
36
|
+
});
|
|
37
|
+
function createProjectRoot() {
|
|
38
|
+
scratch = mkdtempSync(join(tmpdir(), 'fimo-translations-plugin-'));
|
|
39
|
+
writeFileSync(join(scratch, 'fimo-config.json'), JSON.stringify({ i18n: { defaultLocale: 'es', locales: ['es'] } }, null, 2));
|
|
40
|
+
writeFileSync(join(scratch, '.env'), 'VITE_API_URL=https://tenant.example.test\n');
|
|
41
|
+
return scratch;
|
|
42
|
+
}
|
|
43
|
+
function createPlugin(root, command) {
|
|
44
|
+
const plugin = translationsPlugin();
|
|
45
|
+
activePlugin = plugin;
|
|
46
|
+
if (typeof plugin.configResolved === 'function') {
|
|
47
|
+
plugin.configResolved.call(pluginContext, { root, command });
|
|
48
|
+
}
|
|
49
|
+
return plugin;
|
|
50
|
+
}
|
|
51
|
+
async function buildStart(plugin) {
|
|
52
|
+
if (typeof plugin.buildStart !== 'function') {
|
|
53
|
+
throw new Error('Expected buildStart hook');
|
|
54
|
+
}
|
|
55
|
+
await plugin.buildStart.call(pluginContext, {});
|
|
56
|
+
}
|
|
57
|
+
async function loadTranslations(plugin) {
|
|
58
|
+
if (typeof plugin.resolveId !== 'function' || typeof plugin.load !== 'function') {
|
|
59
|
+
throw new Error('Expected resolveId/load hooks');
|
|
60
|
+
}
|
|
61
|
+
const id = await plugin.resolveId.call(pluginContext, 'virtual:translations', undefined, {});
|
|
62
|
+
if (typeof id !== 'string') {
|
|
63
|
+
throw new Error('Expected virtual translations module id');
|
|
64
|
+
}
|
|
65
|
+
const result = await plugin.load.call(pluginContext, id, {});
|
|
66
|
+
if (typeof result !== 'string') {
|
|
67
|
+
throw new Error('Expected virtual translations source');
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
function createDevServer() {
|
|
72
|
+
return {
|
|
73
|
+
watcher: { add: vi.fn() },
|
|
74
|
+
moduleGraph: {
|
|
75
|
+
getModuleById: vi.fn(() => null),
|
|
76
|
+
idToModuleMap: new Map(),
|
|
77
|
+
},
|
|
78
|
+
ws: { send: vi.fn() },
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function mockLabels(labels) {
|
|
82
|
+
const fetchMock = vi.fn(async () => jsonResponse({ data: { labels, updatedAt: '2026-06-24T00:00:00.000Z' } }));
|
|
83
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
84
|
+
return fetchMock;
|
|
85
|
+
}
|
|
86
|
+
function jsonResponse(body) {
|
|
87
|
+
return {
|
|
88
|
+
ok: true,
|
|
89
|
+
json: async () => body,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
async function waitFor(condition) {
|
|
93
|
+
const deadline = Date.now() + 1000;
|
|
94
|
+
while (Date.now() < deadline) {
|
|
95
|
+
if (condition()) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
99
|
+
}
|
|
100
|
+
throw new Error('Timed out waiting for condition');
|
|
101
|
+
}
|
|
102
|
+
describe('translationsPlugin', () => {
|
|
103
|
+
it('does not block dev startup on the initial label fetch', async () => {
|
|
104
|
+
const root = createProjectRoot();
|
|
105
|
+
const fetchMock = mockLabels({ headline: 'Hola' });
|
|
106
|
+
const plugin = createPlugin(root, 'serve');
|
|
107
|
+
await buildStart(plugin);
|
|
108
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
109
|
+
const source = await loadTranslations(plugin);
|
|
110
|
+
expect(source).toContain('export const translations = {};');
|
|
111
|
+
expect(source).toContain('export const defaultLocale = "es";');
|
|
112
|
+
});
|
|
113
|
+
it('pushes updated labels over custom HMR without a full page reload', async () => {
|
|
114
|
+
const root = createProjectRoot();
|
|
115
|
+
mockLabels({ headline: 'Hola' });
|
|
116
|
+
const plugin = createPlugin(root, 'serve');
|
|
117
|
+
await buildStart(plugin);
|
|
118
|
+
const server = createDevServer();
|
|
119
|
+
if (typeof plugin.configureServer !== 'function') {
|
|
120
|
+
throw new Error('Expected configureServer hook');
|
|
121
|
+
}
|
|
122
|
+
plugin.configureServer.call(pluginContext, server);
|
|
123
|
+
await waitFor(() => server.ws.send.mock.calls.length > 0);
|
|
124
|
+
expect(server.ws.send).toHaveBeenCalledWith({
|
|
125
|
+
type: 'custom',
|
|
126
|
+
event: 'fimo:labels-updated',
|
|
127
|
+
data: expect.objectContaining({
|
|
128
|
+
defaultLocale: 'es',
|
|
129
|
+
dictionaries: { es: { headline: 'Hola' } },
|
|
130
|
+
locales: ['es'],
|
|
131
|
+
signature: expect.any(String),
|
|
132
|
+
updatedAt: '2026-06-24T00:00:00.000Z',
|
|
133
|
+
}),
|
|
134
|
+
});
|
|
135
|
+
expect(server.ws.send).not.toHaveBeenCalledWith({ type: 'full-reload', path: '*' });
|
|
136
|
+
const source = await loadTranslations(plugin);
|
|
137
|
+
expect(source).toContain('"headline":"Hola"');
|
|
138
|
+
});
|
|
139
|
+
it('discovers the events URL from tenant runtime config when env is absent', async () => {
|
|
140
|
+
const root = createProjectRoot();
|
|
141
|
+
const projectId = '11111111-1111-4111-8111-111111111111';
|
|
142
|
+
writeFileSync(join(root, '.fimo.settings.json'), JSON.stringify({ projectId, apiUrl: 'https://api.example.test' }));
|
|
143
|
+
process.env.FIMO_API_TOKEN = 'test-api-token';
|
|
144
|
+
const socketUrls = [];
|
|
145
|
+
vi.stubGlobal('WebSocket', class {
|
|
146
|
+
onopen = null;
|
|
147
|
+
onmessage = null;
|
|
148
|
+
onclose = null;
|
|
149
|
+
onerror = null;
|
|
150
|
+
constructor(url) {
|
|
151
|
+
socketUrls.push(url);
|
|
152
|
+
}
|
|
153
|
+
close() { }
|
|
154
|
+
});
|
|
155
|
+
const fetchMock = vi.fn(async (input, init) => {
|
|
156
|
+
const url = new URL(input.toString());
|
|
157
|
+
if (url.pathname === '/labels') {
|
|
158
|
+
return jsonResponse({ data: { labels: {}, updatedAt: null } });
|
|
159
|
+
}
|
|
160
|
+
if (url.pathname === '/runtime-config') {
|
|
161
|
+
return jsonResponse({ data: { eventsServerUrl: 'https://events.example.test' } });
|
|
162
|
+
}
|
|
163
|
+
if (url.pathname === '/api/auth/one-time-token/generate') {
|
|
164
|
+
expect(init?.method).toBe('GET');
|
|
165
|
+
return jsonResponse({ token: 'event-token' });
|
|
166
|
+
}
|
|
167
|
+
return { ok: false, json: async () => ({}) };
|
|
168
|
+
});
|
|
169
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
170
|
+
const plugin = createPlugin(root, 'serve');
|
|
171
|
+
await buildStart(plugin);
|
|
172
|
+
const server = createDevServer();
|
|
173
|
+
if (typeof plugin.configureServer !== 'function') {
|
|
174
|
+
throw new Error('Expected configureServer hook');
|
|
175
|
+
}
|
|
176
|
+
plugin.configureServer.call(pluginContext, server);
|
|
177
|
+
await waitFor(() => socketUrls.length > 0);
|
|
178
|
+
expect(socketUrls[0]).toContain(`wss://events.example.test/parties/events/${projectId}`);
|
|
179
|
+
expect(socketUrls[0]).toContain('authToken=event-token');
|
|
180
|
+
});
|
|
181
|
+
it('forwards content changes over custom HMR without a full page reload', async () => {
|
|
182
|
+
const root = createProjectRoot();
|
|
183
|
+
const projectId = '11111111-1111-4111-8111-111111111111';
|
|
184
|
+
writeFileSync(join(root, '.fimo.settings.json'), JSON.stringify({ projectId, apiUrl: 'https://api.example.test' }));
|
|
185
|
+
process.env.FIMO_API_TOKEN = 'test-api-token';
|
|
186
|
+
const sockets = [];
|
|
187
|
+
vi.stubGlobal('WebSocket', class {
|
|
188
|
+
onopen = null;
|
|
189
|
+
onmessage = null;
|
|
190
|
+
onclose = null;
|
|
191
|
+
onerror = null;
|
|
192
|
+
constructor(_url) {
|
|
193
|
+
sockets.push(this);
|
|
194
|
+
}
|
|
195
|
+
close() { }
|
|
196
|
+
});
|
|
197
|
+
vi.stubGlobal('fetch', vi.fn(async (input) => {
|
|
198
|
+
const url = new URL(input.toString());
|
|
199
|
+
if (url.pathname === '/labels') {
|
|
200
|
+
return jsonResponse({ data: { labels: {}, updatedAt: null } });
|
|
201
|
+
}
|
|
202
|
+
if (url.pathname === '/runtime-config') {
|
|
203
|
+
return jsonResponse({ data: { eventsServerUrl: 'https://events.example.test' } });
|
|
204
|
+
}
|
|
205
|
+
if (url.pathname === '/api/auth/one-time-token/generate') {
|
|
206
|
+
return jsonResponse({ data: { token: 'event-token' } });
|
|
207
|
+
}
|
|
208
|
+
return { ok: false, json: async () => ({}) };
|
|
209
|
+
}));
|
|
210
|
+
const plugin = createPlugin(root, 'serve');
|
|
211
|
+
await buildStart(plugin);
|
|
212
|
+
const server = createDevServer();
|
|
213
|
+
if (typeof plugin.configureServer !== 'function') {
|
|
214
|
+
throw new Error('Expected configureServer hook');
|
|
215
|
+
}
|
|
216
|
+
plugin.configureServer.call(pluginContext, server);
|
|
217
|
+
await waitFor(() => sockets.length > 0);
|
|
218
|
+
sockets[0].onmessage?.({
|
|
219
|
+
data: JSON.stringify({
|
|
220
|
+
type: 'content:changed',
|
|
221
|
+
payload: {
|
|
222
|
+
changes: [{ action: 'update', contentType: 'LiveNote', id: 'entry-1', locale: 'en' }],
|
|
223
|
+
updatedAt: '2026-06-24T00:00:00.000Z',
|
|
224
|
+
},
|
|
225
|
+
}),
|
|
226
|
+
});
|
|
227
|
+
expect(server.ws.send).toHaveBeenCalledWith({
|
|
228
|
+
type: 'custom',
|
|
229
|
+
event: 'fimo:content-updated',
|
|
230
|
+
data: {
|
|
231
|
+
changes: [{ action: 'update', contentType: 'LiveNote', id: 'entry-1', locale: 'en' }],
|
|
232
|
+
updatedAt: '2026-06-24T00:00:00.000Z',
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
expect(server.ws.send).not.toHaveBeenCalledWith({ type: 'full-reload', path: '*' });
|
|
236
|
+
});
|
|
237
|
+
it('still waits for labels during production builds', async () => {
|
|
238
|
+
const root = createProjectRoot();
|
|
239
|
+
const fetchMock = mockLabels({ headline: 'Hola' });
|
|
240
|
+
const plugin = createPlugin(root, 'build');
|
|
241
|
+
await buildStart(plugin);
|
|
242
|
+
expect(fetchMock).toHaveBeenCalled();
|
|
243
|
+
const source = await loadTranslations(plugin);
|
|
244
|
+
expect(source).toContain('"headline":"Hola"');
|
|
245
|
+
});
|
|
246
|
+
it('loads one dictionary per configured locale', async () => {
|
|
247
|
+
const root = createProjectRoot();
|
|
248
|
+
writeFileSync(join(root, 'fimo-config.json'), JSON.stringify({ i18n: { defaultLocale: 'en', locales: ['en', 'es'] } }, null, 2));
|
|
249
|
+
vi.stubGlobal('fetch', vi.fn(async (input) => {
|
|
250
|
+
const url = new URL(input.toString());
|
|
251
|
+
const locale = url.searchParams.get('locale');
|
|
252
|
+
return jsonResponse({
|
|
253
|
+
data: {
|
|
254
|
+
labels: locale === 'es' ? { headline: 'Hola' } : { headline: 'Hello' },
|
|
255
|
+
updatedAt: `2026-06-24T00:00:0${locale === 'es' ? '2' : '1'}.000Z`,
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
}));
|
|
259
|
+
const plugin = createPlugin(root, 'build');
|
|
260
|
+
await buildStart(plugin);
|
|
261
|
+
const source = await loadTranslations(plugin);
|
|
262
|
+
expect(source).toContain('export const dictionaries = {"en":{"headline":"Hello"},"es":{"headline":"Hola"}};');
|
|
263
|
+
expect(source).toContain('export const translations = {"headline":"Hello"};');
|
|
264
|
+
expect(source).toContain('export const updatedAt = "2026-06-24T00:00:02.000Z";');
|
|
265
|
+
});
|
|
266
|
+
});
|
package/dist/cli/bundle.json
CHANGED