@theaiplatform/miniapp-sdk 0.3.2 → 0.4.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.
- package/README.md +126 -0
- package/dist/bin/tap-miniapp-test.d.ts +1 -0
- package/dist/bin/tap-miniapp-test.js +1293 -0
- package/dist/index.d.ts +50 -0
- package/dist/internal/json-schema.d.ts +10 -0
- package/dist/internal/json-schema.js +53 -0
- package/dist/rspack/index.d.ts +72 -6
- package/dist/rspack/index.js +177 -31
- package/dist/sdk.d.ts +50 -0
- package/dist/surface.d.ts +14 -0
- package/dist/testing/rstest-config.d.ts +38 -0
- package/dist/testing/rstest-config.js +59 -0
- package/dist/testing/rstest.d.ts +514 -41
- package/dist/testing/rstest.js +1734 -167
- package/dist/testing/tap.test.schema.json +361 -0
- package/dist/ui/styles.css +504 -6
- package/dist/ui/wasm.js +9231 -510
- package/dist/ui/wasm.js.LICENSE.txt +12 -0
- package/dist/ui.d.ts +14 -4
- package/dist/ui.js +9493 -540
- package/dist/ui.js.LICENSE.txt +12 -0
- package/dist/vscode-webview.d.ts +147 -0
- package/dist/vscode-webview.js +594 -0
- package/dist/web.d.ts +50 -0
- package/package.json +31 -13
package/dist/surface.d.ts
CHANGED
|
@@ -4,6 +4,19 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare function resolvePackageAssetUrl(context: Pick<TapFederatedSurfaceMountContext, 'packageAssetBaseUrl'>, relativePath: string): URL;
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Host-owned entropy for release-scoped identifiers.
|
|
9
|
+
*
|
|
10
|
+
* Ordinary TAP surfaces use the browser's cryptographically strong UUID
|
|
11
|
+
* source. Test Lab mounts derive a deterministic stream from the selected
|
|
12
|
+
* profile seed and exact frame identity, then reset it before each mount so
|
|
13
|
+
* app-owned state is reproducible without weakening production identifiers,
|
|
14
|
+
* colliding across retained remounts, or relying on ambient test globals.
|
|
15
|
+
*/
|
|
16
|
+
export declare interface TapFederatedSurfaceEntropy {
|
|
17
|
+
randomUUID(): string;
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
/**
|
|
8
21
|
* Read-only authority projected by TAP for the exact package release/frame.
|
|
9
22
|
* A candidate frame starts without authority and may only perform host-backed
|
|
@@ -34,6 +47,7 @@ export declare interface TapFederatedSurfaceMountContext {
|
|
|
34
47
|
readonly channelId?: string;
|
|
35
48
|
readonly conversationId?: string;
|
|
36
49
|
readonly events: TapPackageEventPublisher;
|
|
50
|
+
readonly entropy: TapFederatedSurfaceEntropy;
|
|
37
51
|
readonly hostAuthority: TapFederatedSurfaceHostAuthority;
|
|
38
52
|
}
|
|
39
53
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { RstestConfig } from '@rstest/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Define an Rstest suite with TAP's exact, deterministic Test Lab policy.
|
|
5
|
+
*
|
|
6
|
+
* User configuration remains composable, but isolation, worker count,
|
|
7
|
+
* concurrency, retries, environment, and empty-suite behavior fail closed.
|
|
8
|
+
*/
|
|
9
|
+
export declare function defineTapRstestConfig(options?: TapRstestConfigOptions): RstestConfig;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Rstest configuration accepted by TAP's deterministic miniapp runner.
|
|
13
|
+
*
|
|
14
|
+
* The literal fields document runner invariants for JavaScript callers while
|
|
15
|
+
* preventing TypeScript callers from selecting incompatible values.
|
|
16
|
+
*/
|
|
17
|
+
export declare type TapRstestConfigOptions = Omit<RstestConfig, 'include' | 'isolate' | 'maxConcurrency' | 'passWithNoTests' | 'pool' | 'retry' | 'testEnvironment'> & {
|
|
18
|
+
/** Test files owned by the Test Lab suite. */
|
|
19
|
+
include?: string[];
|
|
20
|
+
/** TAP cases share one exact host session and therefore cannot be isolated. */
|
|
21
|
+
isolate?: false;
|
|
22
|
+
/** TAP serializes cases against one deterministic fixture realm. */
|
|
23
|
+
maxConcurrency?: 1;
|
|
24
|
+
/** An empty Test Lab suite is an error. */
|
|
25
|
+
passWithNoTests?: false;
|
|
26
|
+
/** Additional pool options; worker count is fixed at one. */
|
|
27
|
+
pool?: TapRstestPoolConfig & {
|
|
28
|
+
maxWorkers?: 1;
|
|
29
|
+
};
|
|
30
|
+
/** Assertion retries would hide fixture or lifecycle nondeterminism. */
|
|
31
|
+
retry?: 0;
|
|
32
|
+
/** The TAP adapter controls Chromium through a Node runner. */
|
|
33
|
+
testEnvironment?: 'node';
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
declare type TapRstestPoolConfig = Exclude<Extract<RstestConfig['pool'], object>, readonly unknown[]>;
|
|
37
|
+
|
|
38
|
+
export { }
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const DEFAULT_INCLUDE = Object.freeze([
|
|
2
|
+
'tests/e2e/**/*.test.ts',
|
|
3
|
+
'tests/e2e/**/*.test.tsx'
|
|
4
|
+
]);
|
|
5
|
+
const MAX_TEST_TIMEOUT_MS = 600000;
|
|
6
|
+
const LOCKED_CONFIG_ERROR_PREFIX = 'defineTapRstestConfig owns deterministic TAP runner setting';
|
|
7
|
+
function configError(setting, expected) {
|
|
8
|
+
return new Error(`${LOCKED_CONFIG_ERROR_PREFIX} "${setting}"; use ${expected}.`);
|
|
9
|
+
}
|
|
10
|
+
function assertDataObject(value, label) {
|
|
11
|
+
if (null === value || 'object' != typeof value || Array.isArray(value) || Object.getPrototypeOf(value) !== Object.prototype) throw new TypeError(`${label} must be a plain object.`);
|
|
12
|
+
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(value)))if (descriptor.get || descriptor.set) throw new TypeError(`${label}.${key} must be a data property.`);
|
|
13
|
+
}
|
|
14
|
+
function assertLockedValue(options, setting, expected, expectedDescription) {
|
|
15
|
+
const value = options[setting];
|
|
16
|
+
if (void 0 !== value && value !== expected) throw configError(setting, expectedDescription);
|
|
17
|
+
}
|
|
18
|
+
function validateInclude(value) {
|
|
19
|
+
if (void 0 === value) return [
|
|
20
|
+
...DEFAULT_INCLUDE
|
|
21
|
+
];
|
|
22
|
+
if (!Array.isArray(value) || 0 === value.length) throw new TypeError('defineTapRstestConfig "include" must be a non-empty array of project-relative globs.');
|
|
23
|
+
return value.map((entry, index)=>{
|
|
24
|
+
if ('string' != typeof entry || 0 === entry.length || entry.length > 512 || entry.includes('\0') || entry.includes('\\') || entry.startsWith('/') || /^[a-zA-Z]:/u.test(entry) || entry.split('/').includes('..')) throw new TypeError(`defineTapRstestConfig "include[${index}]" must be a bounded, project-relative POSIX glob.`);
|
|
25
|
+
return entry;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function validateTestTimeout(value) {
|
|
29
|
+
if (void 0 !== value && ('number' != typeof value || !Number.isSafeInteger(value) || value < 1 || value > MAX_TEST_TIMEOUT_MS)) throw new TypeError(`defineTapRstestConfig "testTimeout" must be an integer from 1 through ${MAX_TEST_TIMEOUT_MS} milliseconds.`);
|
|
30
|
+
}
|
|
31
|
+
function defineTapRstestConfig(options = {}) {
|
|
32
|
+
assertDataObject(options, 'defineTapRstestConfig options');
|
|
33
|
+
assertLockedValue(options, 'isolate', false, '`isolate: false`');
|
|
34
|
+
assertLockedValue(options, 'maxConcurrency', 1, '`maxConcurrency: 1`');
|
|
35
|
+
assertLockedValue(options, 'passWithNoTests', false, '`passWithNoTests: false`');
|
|
36
|
+
assertLockedValue(options, 'retry', 0, '`retry: 0`');
|
|
37
|
+
assertLockedValue(options, 'testEnvironment', 'node', '`testEnvironment: "node"`');
|
|
38
|
+
validateTestTimeout(options.testTimeout);
|
|
39
|
+
const pool = options.pool;
|
|
40
|
+
if (void 0 !== pool) {
|
|
41
|
+
assertDataObject(pool, 'defineTapRstestConfig pool');
|
|
42
|
+
assertLockedValue(pool, 'maxWorkers', 1, '`pool.maxWorkers: 1`');
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
...options,
|
|
46
|
+
include: validateInclude(options.include),
|
|
47
|
+
isolate: false,
|
|
48
|
+
maxConcurrency: 1,
|
|
49
|
+
passWithNoTests: false,
|
|
50
|
+
pool: {
|
|
51
|
+
...pool,
|
|
52
|
+
maxWorkers: 1
|
|
53
|
+
},
|
|
54
|
+
retry: 0,
|
|
55
|
+
testEnvironment: 'node',
|
|
56
|
+
testTimeout: options.testTimeout ?? 30000
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export { defineTapRstestConfig };
|