@selfhelp/shared 1.2.5 → 1.3.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/CHANGELOG.md +341 -326
- package/LICENSE +381 -381
- package/README.md +57 -57
- package/dist/index.d.mts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +2 -0
- package/dist/index.mjs +2 -0
- package/package.json +102 -102
- package/src/api/__tests__/endpoints.test.ts +45 -0
- package/src/api/endpoints.ts +2 -0
- package/src/api/index.ts +5 -5
- package/src/assets/__tests__/resolveAssetUrl.test.ts +61 -61
- package/src/assets/index.ts +5 -5
- package/src/assets/resolveAssetUrl.ts +44 -44
- package/src/cms-classes/__tests__/classify.test.ts +63 -63
- package/src/cms-classes/allow-list.ts +158 -158
- package/src/cms-classes/classify.ts +90 -90
- package/src/cms-classes/index.ts +7 -7
- package/src/cms-classes/remap.ts +44 -44
- package/src/condition/__tests__/evaluate.test.ts +54 -54
- package/src/condition/evaluate.ts +121 -121
- package/src/condition/index.ts +5 -5
- package/src/index.ts +25 -25
- package/src/interpolation/__tests__/replaceCalcedValues.test.ts +41 -41
- package/src/interpolation/index.ts +5 -5
- package/src/interpolation/replaceCalcedValues.ts +27 -27
- package/src/plugin-sdk/define.ts +89 -89
- package/src/plugin-sdk/index.ts +103 -103
- package/src/plugin-sdk/lock.ts +124 -124
- package/src/plugin-sdk/manifest.ts +307 -307
- package/src/plugin-sdk/realtime.ts +277 -277
- package/src/plugin-sdk/registry.ts +105 -105
- package/src/plugin-sdk/runtime-shim.ts +140 -140
- package/src/plugin-sdk/types.ts +315 -315
- package/src/plugin-sdk/version.ts +209 -209
- package/src/registry/__tests__/registry.test.ts +135 -135
- package/src/registry/index.ts +94 -94
- package/src/registry/styles.registry.ts +295 -295
- package/src/testing/__tests__/testing-kit.test.ts +228 -228
- package/src/testing/index.ts +483 -483
- package/src/theme/index.ts +6 -6
- package/src/theme/tailwind.ts +73 -73
- package/src/theme/tokens.ts +177 -177
- package/src/types/api/auth.ts +22 -0
- package/src/types/api/envelope.ts +34 -34
- package/src/types/api/forms.ts +76 -76
- package/src/types/api/index.ts +9 -9
- package/src/types/api/language.ts +12 -12
- package/src/types/api/page.ts +9 -9
- package/src/types/index.ts +17 -17
- package/src/types/mantine/common.ts +142 -142
- package/src/types/pages.ts +107 -107
- package/src/types/styles/auth.ts +184 -184
- package/src/types/styles/base.ts +72 -72
- package/src/types/styles/composite.ts +131 -131
- package/src/types/styles/forms.ts +439 -439
- package/src/types/styles/interactive.ts +165 -165
- package/src/types/styles/layout.ts +184 -184
- package/src/types/styles/media.ts +68 -68
- package/src/types/styles/typography.ts +118 -118
- package/src/types/styles/unknown.ts +220 -220
- package/src/utils/__tests__/transformPageData.test.ts +69 -69
- package/src/utils/spacing.ts +64 -64
- package/src/utils/transformPageData.ts +99 -99
package/src/index.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/*
|
|
2
|
-
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
-
SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @selfhelp/shared — public surface.
|
|
7
|
-
*
|
|
8
|
-
* Each subpath also has its own export:
|
|
9
|
-
* - `@selfhelp/shared/registry`
|
|
10
|
-
* - `@selfhelp/shared/theme`
|
|
11
|
-
* - `@selfhelp/shared/tailwind`
|
|
12
|
-
*
|
|
13
|
-
* The default export aggregates everything so consumers can do:
|
|
14
|
-
* import { STYLE_REGISTRY, replaceCalcedValues, ENDPOINTS } from '@selfhelp/shared';
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
export * from './types';
|
|
18
|
-
export * from './registry';
|
|
19
|
-
export * from './api';
|
|
20
|
-
export * from './theme';
|
|
21
|
-
export * from './interpolation';
|
|
22
|
-
export * from './condition';
|
|
23
|
-
export * from './cms-classes';
|
|
24
|
-
export * from './assets';
|
|
25
|
-
export * from './utils';
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @selfhelp/shared — public surface.
|
|
7
|
+
*
|
|
8
|
+
* Each subpath also has its own export:
|
|
9
|
+
* - `@selfhelp/shared/registry`
|
|
10
|
+
* - `@selfhelp/shared/theme`
|
|
11
|
+
* - `@selfhelp/shared/tailwind`
|
|
12
|
+
*
|
|
13
|
+
* The default export aggregates everything so consumers can do:
|
|
14
|
+
* import { STYLE_REGISTRY, replaceCalcedValues, ENDPOINTS } from '@selfhelp/shared';
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export * from './types';
|
|
18
|
+
export * from './registry';
|
|
19
|
+
export * from './api';
|
|
20
|
+
export * from './theme';
|
|
21
|
+
export * from './interpolation';
|
|
22
|
+
export * from './condition';
|
|
23
|
+
export * from './cms-classes';
|
|
24
|
+
export * from './assets';
|
|
25
|
+
export * from './utils';
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
/*
|
|
2
|
-
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
-
SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect } from 'vitest';
|
|
6
|
-
import { replaceCalcedValues } from '../replaceCalcedValues';
|
|
7
|
-
|
|
8
|
-
describe('replaceCalcedValues', () => {
|
|
9
|
-
it('replaces a single {{name}} placeholder with its value', () => {
|
|
10
|
-
expect(replaceCalcedValues('Hello {{name}}!', { name: 'Ada' })).toBe('Hello Ada!');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('replaces the double-brace {{{{name}}}} form (backend regex parity)', () => {
|
|
14
|
-
expect(replaceCalcedValues('{{{{score}}}}', { score: 42 })).toBe('42');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('coerces number and boolean values to strings', () => {
|
|
18
|
-
expect(replaceCalcedValues('{{count}}/{{active}}', { count: 3, active: true })).toBe('3/true');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('leaves unknown placeholders intact so editors notice them', () => {
|
|
22
|
-
expect(replaceCalcedValues('Hi {{missing}}', { name: 'Ada' })).toBe('Hi {{missing}}');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('leaves the placeholder intact when the value is null or undefined', () => {
|
|
26
|
-
expect(replaceCalcedValues('{{a}}{{b}}', { a: null, b: undefined })).toBe('{{a}}{{b}}');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('returns an empty string for null/undefined input (never renders "undefined")', () => {
|
|
30
|
-
expect(replaceCalcedValues(null, {})).toBe('');
|
|
31
|
-
expect(replaceCalcedValues(undefined, {})).toBe('');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('trims whitespace inside the braces before lookup', () => {
|
|
35
|
-
expect(replaceCalcedValues('{{ name }}', { name: 'Ada' })).toBe('Ada');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('replaces multiple placeholders in one pass', () => {
|
|
39
|
-
expect(replaceCalcedValues('{{a}} and {{b}}', { a: 'x', b: 'y' })).toBe('x and y');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { describe, it, expect } from 'vitest';
|
|
6
|
+
import { replaceCalcedValues } from '../replaceCalcedValues';
|
|
7
|
+
|
|
8
|
+
describe('replaceCalcedValues', () => {
|
|
9
|
+
it('replaces a single {{name}} placeholder with its value', () => {
|
|
10
|
+
expect(replaceCalcedValues('Hello {{name}}!', { name: 'Ada' })).toBe('Hello Ada!');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('replaces the double-brace {{{{name}}}} form (backend regex parity)', () => {
|
|
14
|
+
expect(replaceCalcedValues('{{{{score}}}}', { score: 42 })).toBe('42');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('coerces number and boolean values to strings', () => {
|
|
18
|
+
expect(replaceCalcedValues('{{count}}/{{active}}', { count: 3, active: true })).toBe('3/true');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('leaves unknown placeholders intact so editors notice them', () => {
|
|
22
|
+
expect(replaceCalcedValues('Hi {{missing}}', { name: 'Ada' })).toBe('Hi {{missing}}');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('leaves the placeholder intact when the value is null or undefined', () => {
|
|
26
|
+
expect(replaceCalcedValues('{{a}}{{b}}', { a: null, b: undefined })).toBe('{{a}}{{b}}');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('returns an empty string for null/undefined input (never renders "undefined")', () => {
|
|
30
|
+
expect(replaceCalcedValues(null, {})).toBe('');
|
|
31
|
+
expect(replaceCalcedValues(undefined, {})).toBe('');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('trims whitespace inside the braces before lookup', () => {
|
|
35
|
+
expect(replaceCalcedValues('{{ name }}', { name: 'Ada' })).toBe('Ada');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('replaces multiple placeholders in one pass', () => {
|
|
39
|
+
expect(replaceCalcedValues('{{a}} and {{b}}', { a: 'x', b: 'y' })).toBe('x and y');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*
|
|
2
|
-
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
-
SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
*/
|
|
5
|
-
export * from './replaceCalcedValues';
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
export * from './replaceCalcedValues';
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/*
|
|
2
|
-
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
-
SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Mirrors the backend `PageDb::replace_calced_values()` regex:
|
|
7
|
-
*
|
|
8
|
-
* ~{{({{)?(.*?)(}})?}}~s
|
|
9
|
-
*
|
|
10
|
-
* Replaces every `{{name}}` or `{{{{name}}}}` occurrence in the input
|
|
11
|
-
* string with `values[name]`. Unknown placeholders are left intact so
|
|
12
|
-
* editors notice them and so we never accidentally render `undefined`.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const PLACEHOLDER_RE = /{{({{)?([^{}]+?)(}})?}}/g;
|
|
16
|
-
|
|
17
|
-
export type TCalcedValues = Record<string, string | number | boolean | null | undefined>;
|
|
18
|
-
|
|
19
|
-
export function replaceCalcedValues(input: string | null | undefined, values: TCalcedValues): string {
|
|
20
|
-
if (input === null || input === undefined) return '';
|
|
21
|
-
return String(input).replace(PLACEHOLDER_RE, (full, _open, key) => {
|
|
22
|
-
const trimmed = String(key).trim();
|
|
23
|
-
const value = values[trimmed];
|
|
24
|
-
if (value === undefined || value === null) return full;
|
|
25
|
-
return String(value);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Mirrors the backend `PageDb::replace_calced_values()` regex:
|
|
7
|
+
*
|
|
8
|
+
* ~{{({{)?(.*?)(}})?}}~s
|
|
9
|
+
*
|
|
10
|
+
* Replaces every `{{name}}` or `{{{{name}}}}` occurrence in the input
|
|
11
|
+
* string with `values[name]`. Unknown placeholders are left intact so
|
|
12
|
+
* editors notice them and so we never accidentally render `undefined`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const PLACEHOLDER_RE = /{{({{)?([^{}]+?)(}})?}}/g;
|
|
16
|
+
|
|
17
|
+
export type TCalcedValues = Record<string, string | number | boolean | null | undefined>;
|
|
18
|
+
|
|
19
|
+
export function replaceCalcedValues(input: string | null | undefined, values: TCalcedValues): string {
|
|
20
|
+
if (input === null || input === undefined) return '';
|
|
21
|
+
return String(input).replace(PLACEHOLDER_RE, (full, _open, key) => {
|
|
22
|
+
const trimmed = String(key).trim();
|
|
23
|
+
const value = values[trimmed];
|
|
24
|
+
if (value === undefined || value === null) return full;
|
|
25
|
+
return String(value);
|
|
26
|
+
});
|
|
27
|
+
}
|
package/src/plugin-sdk/define.ts
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
/*
|
|
2
|
-
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
-
SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* `definePlugin()` / `defineMobilePlugin()` are the only entry points
|
|
7
|
-
* plugins call. They validate the SDK version, register style entries
|
|
8
|
-
* in the shared registry, and return the registration object the host
|
|
9
|
-
* `PluginRuntime` reads.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
extendStyleRegistry,
|
|
14
|
-
type IStyleRegistryEntry,
|
|
15
|
-
} from '../registry/styles.registry';
|
|
16
|
-
|
|
17
|
-
import type {
|
|
18
|
-
IMobilePluginRegistration,
|
|
19
|
-
IPluginRealtimeTopic,
|
|
20
|
-
IPluginRegistration,
|
|
21
|
-
IStyleDefinition,
|
|
22
|
-
} from './types';
|
|
23
|
-
|
|
24
|
-
import { assertPluginApiVersion } from './version';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Plugin frontend / admin entry point.
|
|
28
|
-
*
|
|
29
|
-
* Example:
|
|
30
|
-
* export const register = definePlugin({
|
|
31
|
-
* id: 'sh2-shp-survey-js',
|
|
32
|
-
* version: '1.0.0',
|
|
33
|
-
* pluginApiVersion: '1.0',
|
|
34
|
-
* styles: [{ name: 'surveyjs', component: SurveyJsStyle, ... }],
|
|
35
|
-
* });
|
|
36
|
-
*/
|
|
37
|
-
export function definePlugin(registration: IPluginRegistration): IPluginRegistration {
|
|
38
|
-
assertPluginApiVersion(registration.pluginApiVersion);
|
|
39
|
-
if (registration.styles?.length) {
|
|
40
|
-
extendStyleRegistry(toRegistryRecord(registration.styles), {
|
|
41
|
-
pluginId: registration.id,
|
|
42
|
-
pluginVersion: registration.version,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return registration;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Plugin mobile entry point. Same contract as `definePlugin()` but
|
|
50
|
-
* mobile-only. Mobile builds bundle plugin packages per EAS profile,
|
|
51
|
-
* so this runs inside the mobile Metro bundle at app boot.
|
|
52
|
-
*/
|
|
53
|
-
export function defineMobilePlugin(
|
|
54
|
-
registration: IMobilePluginRegistration,
|
|
55
|
-
): IMobilePluginRegistration {
|
|
56
|
-
assertPluginApiVersion(registration.pluginApiVersion);
|
|
57
|
-
if (registration.styles?.length) {
|
|
58
|
-
extendStyleRegistry(toRegistryRecord(registration.styles), {
|
|
59
|
-
pluginId: registration.id,
|
|
60
|
-
pluginVersion: registration.version,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return registration;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Declare a realtime topic for type-safe publish/subscribe. Returns the
|
|
68
|
-
* topic descriptor; the host installer registers it through
|
|
69
|
-
* `PluginRealtimeTopicRegistryEvent` so admins can audit topics in the
|
|
70
|
-
* Plugin detail page.
|
|
71
|
-
*/
|
|
72
|
-
export function definePluginRealtimeTopic<TPayload>(
|
|
73
|
-
descriptor: IPluginRealtimeTopic<TPayload>,
|
|
74
|
-
): IPluginRealtimeTopic<TPayload> {
|
|
75
|
-
return descriptor;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function toRegistryRecord(styles: IStyleDefinition[]): Record<string, IStyleRegistryEntry> {
|
|
79
|
-
const out: Record<string, IStyleRegistryEntry> = {};
|
|
80
|
-
for (const style of styles) {
|
|
81
|
-
out[style.name] = {
|
|
82
|
-
description: style.description,
|
|
83
|
-
category: style.category,
|
|
84
|
-
frontendOnly: true,
|
|
85
|
-
canHaveChildren: style.canHaveChildren,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
return out;
|
|
89
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* `definePlugin()` / `defineMobilePlugin()` are the only entry points
|
|
7
|
+
* plugins call. They validate the SDK version, register style entries
|
|
8
|
+
* in the shared registry, and return the registration object the host
|
|
9
|
+
* `PluginRuntime` reads.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
extendStyleRegistry,
|
|
14
|
+
type IStyleRegistryEntry,
|
|
15
|
+
} from '../registry/styles.registry';
|
|
16
|
+
|
|
17
|
+
import type {
|
|
18
|
+
IMobilePluginRegistration,
|
|
19
|
+
IPluginRealtimeTopic,
|
|
20
|
+
IPluginRegistration,
|
|
21
|
+
IStyleDefinition,
|
|
22
|
+
} from './types';
|
|
23
|
+
|
|
24
|
+
import { assertPluginApiVersion } from './version';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Plugin frontend / admin entry point.
|
|
28
|
+
*
|
|
29
|
+
* Example:
|
|
30
|
+
* export const register = definePlugin({
|
|
31
|
+
* id: 'sh2-shp-survey-js',
|
|
32
|
+
* version: '1.0.0',
|
|
33
|
+
* pluginApiVersion: '1.0',
|
|
34
|
+
* styles: [{ name: 'surveyjs', component: SurveyJsStyle, ... }],
|
|
35
|
+
* });
|
|
36
|
+
*/
|
|
37
|
+
export function definePlugin(registration: IPluginRegistration): IPluginRegistration {
|
|
38
|
+
assertPluginApiVersion(registration.pluginApiVersion);
|
|
39
|
+
if (registration.styles?.length) {
|
|
40
|
+
extendStyleRegistry(toRegistryRecord(registration.styles), {
|
|
41
|
+
pluginId: registration.id,
|
|
42
|
+
pluginVersion: registration.version,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return registration;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Plugin mobile entry point. Same contract as `definePlugin()` but
|
|
50
|
+
* mobile-only. Mobile builds bundle plugin packages per EAS profile,
|
|
51
|
+
* so this runs inside the mobile Metro bundle at app boot.
|
|
52
|
+
*/
|
|
53
|
+
export function defineMobilePlugin(
|
|
54
|
+
registration: IMobilePluginRegistration,
|
|
55
|
+
): IMobilePluginRegistration {
|
|
56
|
+
assertPluginApiVersion(registration.pluginApiVersion);
|
|
57
|
+
if (registration.styles?.length) {
|
|
58
|
+
extendStyleRegistry(toRegistryRecord(registration.styles), {
|
|
59
|
+
pluginId: registration.id,
|
|
60
|
+
pluginVersion: registration.version,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return registration;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Declare a realtime topic for type-safe publish/subscribe. Returns the
|
|
68
|
+
* topic descriptor; the host installer registers it through
|
|
69
|
+
* `PluginRealtimeTopicRegistryEvent` so admins can audit topics in the
|
|
70
|
+
* Plugin detail page.
|
|
71
|
+
*/
|
|
72
|
+
export function definePluginRealtimeTopic<TPayload>(
|
|
73
|
+
descriptor: IPluginRealtimeTopic<TPayload>,
|
|
74
|
+
): IPluginRealtimeTopic<TPayload> {
|
|
75
|
+
return descriptor;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function toRegistryRecord(styles: IStyleDefinition[]): Record<string, IStyleRegistryEntry> {
|
|
79
|
+
const out: Record<string, IStyleRegistryEntry> = {};
|
|
80
|
+
for (const style of styles) {
|
|
81
|
+
out[style.name] = {
|
|
82
|
+
description: style.description,
|
|
83
|
+
category: style.category,
|
|
84
|
+
frontendOnly: true,
|
|
85
|
+
canHaveChildren: style.canHaveChildren,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
}
|
package/src/plugin-sdk/index.ts
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
/*
|
|
2
|
-
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
-
SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* `@selfhelp/shared/plugin-sdk` — public SDK consumed by every SelfHelp
|
|
7
|
-
* plugin's frontend and mobile package.
|
|
8
|
-
*
|
|
9
|
-
* Plugins import from this subpath ONLY. Importing from other internal
|
|
10
|
-
* paths of `@selfhelp/shared` is not supported.
|
|
11
|
-
*
|
|
12
|
-
* The SDK has its own `pluginApiVersion` (see `version.ts`). Plugins
|
|
13
|
-
* declare which `pluginApiVersion` they target in `plugin.json`; the
|
|
14
|
-
* host installer compares the declaration with `PLUGIN_API_VERSION`
|
|
15
|
-
* before allowing the plugin to load.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
PLUGIN_API_VERSION,
|
|
20
|
-
assertPluginApiVersion,
|
|
21
|
-
isPluginApiCompatible,
|
|
22
|
-
assertCmsCompatibility,
|
|
23
|
-
assertPluginVersionSemantics,
|
|
24
|
-
parseSemver,
|
|
25
|
-
compareSemver,
|
|
26
|
-
satisfiesSemverRange,
|
|
27
|
-
} from './version';
|
|
28
|
-
|
|
29
|
-
export type {
|
|
30
|
-
IPluginManifest,
|
|
31
|
-
IPluginManifestCompatibility,
|
|
32
|
-
IPluginManifestDependency,
|
|
33
|
-
IPluginManifestConflict,
|
|
34
|
-
IPluginManifestSecurity,
|
|
35
|
-
IPluginManifestCapability,
|
|
36
|
-
IPluginManifestTrustLevel,
|
|
37
|
-
IPluginManifestRealtimeTopic,
|
|
38
|
-
IPluginManifestFeatureFlag,
|
|
39
|
-
IPluginManifestLookupExtension,
|
|
40
|
-
IPluginManifestPermission,
|
|
41
|
-
IPluginManifestStyle,
|
|
42
|
-
IPluginManifestAdminPage,
|
|
43
|
-
IPluginManifestApiRoute,
|
|
44
|
-
IPluginManifestScheduledJob,
|
|
45
|
-
IPluginManifestAsset,
|
|
46
|
-
IPluginManifestMobile,
|
|
47
|
-
IPluginManifestExternalHost,
|
|
48
|
-
IPluginManifestDataAccess,
|
|
49
|
-
IPluginManifestHealth,
|
|
50
|
-
} from './manifest';
|
|
51
|
-
|
|
52
|
-
export type {
|
|
53
|
-
IPluginRegistry,
|
|
54
|
-
IPluginRegistryEntry,
|
|
55
|
-
IPluginRegistryVersionEntry,
|
|
56
|
-
TPluginRegistryChannel,
|
|
57
|
-
} from './registry';
|
|
58
|
-
|
|
59
|
-
export type {
|
|
60
|
-
IPluginLock,
|
|
61
|
-
IPluginLockEntry,
|
|
62
|
-
IPluginLockMobileEntry,
|
|
63
|
-
IPluginLockMigration,
|
|
64
|
-
} from './lock';
|
|
65
|
-
|
|
66
|
-
export type {
|
|
67
|
-
IPluginRegistration,
|
|
68
|
-
IMobilePluginRegistration,
|
|
69
|
-
IStyleDefinition,
|
|
70
|
-
IFieldRendererDefinition,
|
|
71
|
-
IPluginFieldRendererProps,
|
|
72
|
-
IAdminPageDefinition,
|
|
73
|
-
IMenuItemDefinition,
|
|
74
|
-
IPluginApi,
|
|
75
|
-
IMobilePluginApi,
|
|
76
|
-
IPluginHealthCheck,
|
|
77
|
-
IPluginFeatureFlag,
|
|
78
|
-
IPluginRealtimeTopic,
|
|
79
|
-
IPluginRealtimePublisher,
|
|
80
|
-
IRichTextEditorAdapter,
|
|
81
|
-
IRichTextEditorAdapterOptions,
|
|
82
|
-
IRichTextEditorValue,
|
|
83
|
-
} from './types';
|
|
84
|
-
|
|
85
|
-
export { definePlugin, defineMobilePlugin, definePluginRealtimeTopic } from './define';
|
|
86
|
-
|
|
87
|
-
export type {
|
|
88
|
-
IRealtimeTransport,
|
|
89
|
-
TRealtimeTransportFactory,
|
|
90
|
-
IUsePluginRealtimeOptions,
|
|
91
|
-
IUsePluginRealtimeResult,
|
|
92
|
-
} from './realtime';
|
|
93
|
-
export { usePluginRealtime } from './realtime';
|
|
94
|
-
|
|
95
|
-
export type { TPluginRuntimeShimSpecifier } from './runtime-shim';
|
|
96
|
-
export {
|
|
97
|
-
PLUGIN_RUNTIME_SHIM_SPECIFIERS,
|
|
98
|
-
PLUGIN_RUNTIME_SHIM_BASE_PATH,
|
|
99
|
-
PLUGIN_RUNTIME_GLOBAL_KEY,
|
|
100
|
-
PLUGIN_RUNTIME_IMPORT_MAP,
|
|
101
|
-
buildPluginRuntimeShimPath,
|
|
102
|
-
isPluginRuntimeShimSpecifier,
|
|
103
|
-
} from './runtime-shim';
|
|
1
|
+
/*
|
|
2
|
+
SPDX-FileCopyrightText: 2026 Humdek, University of Bern
|
|
3
|
+
SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* `@selfhelp/shared/plugin-sdk` — public SDK consumed by every SelfHelp
|
|
7
|
+
* plugin's frontend and mobile package.
|
|
8
|
+
*
|
|
9
|
+
* Plugins import from this subpath ONLY. Importing from other internal
|
|
10
|
+
* paths of `@selfhelp/shared` is not supported.
|
|
11
|
+
*
|
|
12
|
+
* The SDK has its own `pluginApiVersion` (see `version.ts`). Plugins
|
|
13
|
+
* declare which `pluginApiVersion` they target in `plugin.json`; the
|
|
14
|
+
* host installer compares the declaration with `PLUGIN_API_VERSION`
|
|
15
|
+
* before allowing the plugin to load.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
PLUGIN_API_VERSION,
|
|
20
|
+
assertPluginApiVersion,
|
|
21
|
+
isPluginApiCompatible,
|
|
22
|
+
assertCmsCompatibility,
|
|
23
|
+
assertPluginVersionSemantics,
|
|
24
|
+
parseSemver,
|
|
25
|
+
compareSemver,
|
|
26
|
+
satisfiesSemverRange,
|
|
27
|
+
} from './version';
|
|
28
|
+
|
|
29
|
+
export type {
|
|
30
|
+
IPluginManifest,
|
|
31
|
+
IPluginManifestCompatibility,
|
|
32
|
+
IPluginManifestDependency,
|
|
33
|
+
IPluginManifestConflict,
|
|
34
|
+
IPluginManifestSecurity,
|
|
35
|
+
IPluginManifestCapability,
|
|
36
|
+
IPluginManifestTrustLevel,
|
|
37
|
+
IPluginManifestRealtimeTopic,
|
|
38
|
+
IPluginManifestFeatureFlag,
|
|
39
|
+
IPluginManifestLookupExtension,
|
|
40
|
+
IPluginManifestPermission,
|
|
41
|
+
IPluginManifestStyle,
|
|
42
|
+
IPluginManifestAdminPage,
|
|
43
|
+
IPluginManifestApiRoute,
|
|
44
|
+
IPluginManifestScheduledJob,
|
|
45
|
+
IPluginManifestAsset,
|
|
46
|
+
IPluginManifestMobile,
|
|
47
|
+
IPluginManifestExternalHost,
|
|
48
|
+
IPluginManifestDataAccess,
|
|
49
|
+
IPluginManifestHealth,
|
|
50
|
+
} from './manifest';
|
|
51
|
+
|
|
52
|
+
export type {
|
|
53
|
+
IPluginRegistry,
|
|
54
|
+
IPluginRegistryEntry,
|
|
55
|
+
IPluginRegistryVersionEntry,
|
|
56
|
+
TPluginRegistryChannel,
|
|
57
|
+
} from './registry';
|
|
58
|
+
|
|
59
|
+
export type {
|
|
60
|
+
IPluginLock,
|
|
61
|
+
IPluginLockEntry,
|
|
62
|
+
IPluginLockMobileEntry,
|
|
63
|
+
IPluginLockMigration,
|
|
64
|
+
} from './lock';
|
|
65
|
+
|
|
66
|
+
export type {
|
|
67
|
+
IPluginRegistration,
|
|
68
|
+
IMobilePluginRegistration,
|
|
69
|
+
IStyleDefinition,
|
|
70
|
+
IFieldRendererDefinition,
|
|
71
|
+
IPluginFieldRendererProps,
|
|
72
|
+
IAdminPageDefinition,
|
|
73
|
+
IMenuItemDefinition,
|
|
74
|
+
IPluginApi,
|
|
75
|
+
IMobilePluginApi,
|
|
76
|
+
IPluginHealthCheck,
|
|
77
|
+
IPluginFeatureFlag,
|
|
78
|
+
IPluginRealtimeTopic,
|
|
79
|
+
IPluginRealtimePublisher,
|
|
80
|
+
IRichTextEditorAdapter,
|
|
81
|
+
IRichTextEditorAdapterOptions,
|
|
82
|
+
IRichTextEditorValue,
|
|
83
|
+
} from './types';
|
|
84
|
+
|
|
85
|
+
export { definePlugin, defineMobilePlugin, definePluginRealtimeTopic } from './define';
|
|
86
|
+
|
|
87
|
+
export type {
|
|
88
|
+
IRealtimeTransport,
|
|
89
|
+
TRealtimeTransportFactory,
|
|
90
|
+
IUsePluginRealtimeOptions,
|
|
91
|
+
IUsePluginRealtimeResult,
|
|
92
|
+
} from './realtime';
|
|
93
|
+
export { usePluginRealtime } from './realtime';
|
|
94
|
+
|
|
95
|
+
export type { TPluginRuntimeShimSpecifier } from './runtime-shim';
|
|
96
|
+
export {
|
|
97
|
+
PLUGIN_RUNTIME_SHIM_SPECIFIERS,
|
|
98
|
+
PLUGIN_RUNTIME_SHIM_BASE_PATH,
|
|
99
|
+
PLUGIN_RUNTIME_GLOBAL_KEY,
|
|
100
|
+
PLUGIN_RUNTIME_IMPORT_MAP,
|
|
101
|
+
buildPluginRuntimeShimPath,
|
|
102
|
+
isPluginRuntimeShimSpecifier,
|
|
103
|
+
} from './runtime-shim';
|