mirror of
https://github.com/microsoft/playwright.git
synced 2025-01-07 03:39:48 +03:00
chore: implement mixins in protocol.yml (#5932)
This commit is contained in:
parent
7678112242
commit
2cf4caa4cf
@ -236,8 +236,8 @@ export type BrowserTypeLaunchParams = {
|
|||||||
password?: string,
|
password?: string,
|
||||||
},
|
},
|
||||||
downloadsPath?: string,
|
downloadsPath?: string,
|
||||||
firefoxUserPrefs?: any,
|
|
||||||
chromiumSandbox?: boolean,
|
chromiumSandbox?: boolean,
|
||||||
|
firefoxUserPrefs?: any,
|
||||||
slowMo?: number,
|
slowMo?: number,
|
||||||
};
|
};
|
||||||
export type BrowserTypeLaunchOptions = {
|
export type BrowserTypeLaunchOptions = {
|
||||||
@ -260,8 +260,8 @@ export type BrowserTypeLaunchOptions = {
|
|||||||
password?: string,
|
password?: string,
|
||||||
},
|
},
|
||||||
downloadsPath?: string,
|
downloadsPath?: string,
|
||||||
firefoxUserPrefs?: any,
|
|
||||||
chromiumSandbox?: boolean,
|
chromiumSandbox?: boolean,
|
||||||
|
firefoxUserPrefs?: any,
|
||||||
slowMo?: number,
|
slowMo?: number,
|
||||||
};
|
};
|
||||||
export type BrowserTypeLaunchResult = {
|
export type BrowserTypeLaunchResult = {
|
||||||
@ -269,8 +269,6 @@ export type BrowserTypeLaunchResult = {
|
|||||||
};
|
};
|
||||||
export type BrowserTypeLaunchPersistentContextParams = {
|
export type BrowserTypeLaunchPersistentContextParams = {
|
||||||
channel?: 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary',
|
channel?: 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary',
|
||||||
userDataDir: string,
|
|
||||||
sdkLanguage: string,
|
|
||||||
executablePath?: string,
|
executablePath?: string,
|
||||||
args?: string[],
|
args?: string[],
|
||||||
ignoreAllDefaultArgs?: boolean,
|
ignoreAllDefaultArgs?: boolean,
|
||||||
@ -290,7 +288,7 @@ export type BrowserTypeLaunchPersistentContextParams = {
|
|||||||
},
|
},
|
||||||
downloadsPath?: string,
|
downloadsPath?: string,
|
||||||
chromiumSandbox?: boolean,
|
chromiumSandbox?: boolean,
|
||||||
slowMo?: number,
|
sdkLanguage: string,
|
||||||
noDefaultViewport?: boolean,
|
noDefaultViewport?: boolean,
|
||||||
viewport?: {
|
viewport?: {
|
||||||
width: number,
|
width: number,
|
||||||
@ -317,7 +315,7 @@ export type BrowserTypeLaunchPersistentContextParams = {
|
|||||||
deviceScaleFactor?: number,
|
deviceScaleFactor?: number,
|
||||||
isMobile?: boolean,
|
isMobile?: boolean,
|
||||||
hasTouch?: boolean,
|
hasTouch?: boolean,
|
||||||
colorScheme?: 'light' | 'dark' | 'no-preference',
|
colorScheme?: 'dark' | 'light' | 'no-preference',
|
||||||
acceptDownloads?: boolean,
|
acceptDownloads?: boolean,
|
||||||
_traceDir?: string,
|
_traceDir?: string,
|
||||||
_debugName?: string,
|
_debugName?: string,
|
||||||
@ -332,6 +330,8 @@ export type BrowserTypeLaunchPersistentContextParams = {
|
|||||||
omitContent?: boolean,
|
omitContent?: boolean,
|
||||||
path: string,
|
path: string,
|
||||||
},
|
},
|
||||||
|
userDataDir: string,
|
||||||
|
slowMo?: number,
|
||||||
};
|
};
|
||||||
export type BrowserTypeLaunchPersistentContextOptions = {
|
export type BrowserTypeLaunchPersistentContextOptions = {
|
||||||
channel?: 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary',
|
channel?: 'chrome' | 'chrome-beta' | 'chrome-dev' | 'chrome-canary' | 'msedge' | 'msedge-beta' | 'msedge-dev' | 'msedge-canary',
|
||||||
@ -354,7 +354,6 @@ export type BrowserTypeLaunchPersistentContextOptions = {
|
|||||||
},
|
},
|
||||||
downloadsPath?: string,
|
downloadsPath?: string,
|
||||||
chromiumSandbox?: boolean,
|
chromiumSandbox?: boolean,
|
||||||
slowMo?: number,
|
|
||||||
noDefaultViewport?: boolean,
|
noDefaultViewport?: boolean,
|
||||||
viewport?: {
|
viewport?: {
|
||||||
width: number,
|
width: number,
|
||||||
@ -381,7 +380,7 @@ export type BrowserTypeLaunchPersistentContextOptions = {
|
|||||||
deviceScaleFactor?: number,
|
deviceScaleFactor?: number,
|
||||||
isMobile?: boolean,
|
isMobile?: boolean,
|
||||||
hasTouch?: boolean,
|
hasTouch?: boolean,
|
||||||
colorScheme?: 'light' | 'dark' | 'no-preference',
|
colorScheme?: 'dark' | 'light' | 'no-preference',
|
||||||
acceptDownloads?: boolean,
|
acceptDownloads?: boolean,
|
||||||
_traceDir?: string,
|
_traceDir?: string,
|
||||||
_debugName?: string,
|
_debugName?: string,
|
||||||
@ -396,6 +395,7 @@ export type BrowserTypeLaunchPersistentContextOptions = {
|
|||||||
omitContent?: boolean,
|
omitContent?: boolean,
|
||||||
path: string,
|
path: string,
|
||||||
},
|
},
|
||||||
|
slowMo?: number,
|
||||||
};
|
};
|
||||||
export type BrowserTypeLaunchPersistentContextResult = {
|
export type BrowserTypeLaunchPersistentContextResult = {
|
||||||
context: BrowserContextChannel,
|
context: BrowserContextChannel,
|
||||||
|
@ -223,6 +223,110 @@ SerializedError:
|
|||||||
value: SerializedValue?
|
value: SerializedValue?
|
||||||
|
|
||||||
|
|
||||||
|
LaunchOptions:
|
||||||
|
type: mixin
|
||||||
|
properties:
|
||||||
|
channel:
|
||||||
|
type: enum?
|
||||||
|
literals:
|
||||||
|
- chrome
|
||||||
|
- chrome-beta
|
||||||
|
- chrome-dev
|
||||||
|
- chrome-canary
|
||||||
|
- msedge
|
||||||
|
- msedge-beta
|
||||||
|
- msedge-dev
|
||||||
|
- msedge-canary
|
||||||
|
executablePath: string?
|
||||||
|
args:
|
||||||
|
type: array?
|
||||||
|
items: string
|
||||||
|
ignoreAllDefaultArgs: boolean?
|
||||||
|
ignoreDefaultArgs:
|
||||||
|
type: array?
|
||||||
|
items: string
|
||||||
|
handleSIGINT: boolean?
|
||||||
|
handleSIGTERM: boolean?
|
||||||
|
handleSIGHUP: boolean?
|
||||||
|
timeout: number?
|
||||||
|
env:
|
||||||
|
type: array?
|
||||||
|
items: NameValue
|
||||||
|
headless: boolean?
|
||||||
|
devtools: boolean?
|
||||||
|
proxy:
|
||||||
|
type: object?
|
||||||
|
properties:
|
||||||
|
server: string
|
||||||
|
bypass: string?
|
||||||
|
username: string?
|
||||||
|
password: string?
|
||||||
|
downloadsPath: string?
|
||||||
|
chromiumSandbox: boolean?
|
||||||
|
|
||||||
|
|
||||||
|
ContextOptions:
|
||||||
|
type: mixin
|
||||||
|
properties:
|
||||||
|
sdkLanguage: string
|
||||||
|
noDefaultViewport: boolean?
|
||||||
|
viewport:
|
||||||
|
type: object?
|
||||||
|
properties:
|
||||||
|
width: number
|
||||||
|
height: number
|
||||||
|
ignoreHTTPSErrors: boolean?
|
||||||
|
javaScriptEnabled: boolean?
|
||||||
|
bypassCSP: boolean?
|
||||||
|
userAgent: string?
|
||||||
|
locale: string?
|
||||||
|
timezoneId: string?
|
||||||
|
geolocation:
|
||||||
|
type: object?
|
||||||
|
properties:
|
||||||
|
longitude: number
|
||||||
|
latitude: number
|
||||||
|
accuracy: number?
|
||||||
|
permissions:
|
||||||
|
type: array?
|
||||||
|
items: string
|
||||||
|
extraHTTPHeaders:
|
||||||
|
type: array?
|
||||||
|
items: NameValue
|
||||||
|
offline: boolean?
|
||||||
|
httpCredentials:
|
||||||
|
type: object?
|
||||||
|
properties:
|
||||||
|
username: string
|
||||||
|
password: string
|
||||||
|
deviceScaleFactor: number?
|
||||||
|
isMobile: boolean?
|
||||||
|
hasTouch: boolean?
|
||||||
|
colorScheme:
|
||||||
|
type: enum?
|
||||||
|
literals:
|
||||||
|
- dark
|
||||||
|
- light
|
||||||
|
- no-preference
|
||||||
|
acceptDownloads: boolean?
|
||||||
|
_traceDir: string?
|
||||||
|
_debugName: string?
|
||||||
|
recordVideo:
|
||||||
|
type: object?
|
||||||
|
properties:
|
||||||
|
dir: string
|
||||||
|
size:
|
||||||
|
type: object?
|
||||||
|
properties:
|
||||||
|
width: number
|
||||||
|
height: number
|
||||||
|
recordHar:
|
||||||
|
type: object?
|
||||||
|
properties:
|
||||||
|
omitContent: boolean?
|
||||||
|
path: string
|
||||||
|
|
||||||
|
|
||||||
Playwright:
|
Playwright:
|
||||||
type: interface
|
type: interface
|
||||||
|
|
||||||
@ -300,146 +404,18 @@ BrowserType:
|
|||||||
|
|
||||||
launch:
|
launch:
|
||||||
parameters:
|
parameters:
|
||||||
channel:
|
$mixin: LaunchOptions
|
||||||
type: enum?
|
|
||||||
literals:
|
|
||||||
- chrome
|
|
||||||
- chrome-beta
|
|
||||||
- chrome-dev
|
|
||||||
- chrome-canary
|
|
||||||
- msedge
|
|
||||||
- msedge-beta
|
|
||||||
- msedge-dev
|
|
||||||
- msedge-canary
|
|
||||||
executablePath: string?
|
|
||||||
args:
|
|
||||||
type: array?
|
|
||||||
items: string
|
|
||||||
ignoreAllDefaultArgs: boolean?
|
|
||||||
ignoreDefaultArgs:
|
|
||||||
type: array?
|
|
||||||
items: string
|
|
||||||
handleSIGINT: boolean?
|
|
||||||
handleSIGTERM: boolean?
|
|
||||||
handleSIGHUP: boolean?
|
|
||||||
timeout: number?
|
|
||||||
env:
|
|
||||||
type: array?
|
|
||||||
items: NameValue
|
|
||||||
headless: boolean?
|
|
||||||
devtools: boolean?
|
|
||||||
proxy:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
server: string
|
|
||||||
bypass: string?
|
|
||||||
username: string?
|
|
||||||
password: string?
|
|
||||||
downloadsPath: string?
|
|
||||||
firefoxUserPrefs: json?
|
firefoxUserPrefs: json?
|
||||||
chromiumSandbox: boolean?
|
|
||||||
slowMo: number?
|
slowMo: number?
|
||||||
returns:
|
returns:
|
||||||
browser: Browser
|
browser: Browser
|
||||||
|
|
||||||
launchPersistentContext:
|
launchPersistentContext:
|
||||||
parameters:
|
parameters:
|
||||||
channel:
|
$mixin1: LaunchOptions
|
||||||
type: enum?
|
$mixin2: ContextOptions
|
||||||
literals:
|
|
||||||
- chrome
|
|
||||||
- chrome-beta
|
|
||||||
- chrome-dev
|
|
||||||
- chrome-canary
|
|
||||||
- msedge
|
|
||||||
- msedge-beta
|
|
||||||
- msedge-dev
|
|
||||||
- msedge-canary
|
|
||||||
userDataDir: string
|
userDataDir: string
|
||||||
sdkLanguage: string
|
|
||||||
executablePath: string?
|
|
||||||
args:
|
|
||||||
type: array?
|
|
||||||
items: string
|
|
||||||
ignoreAllDefaultArgs: boolean?
|
|
||||||
ignoreDefaultArgs:
|
|
||||||
type: array?
|
|
||||||
items: string
|
|
||||||
handleSIGINT: boolean?
|
|
||||||
handleSIGTERM: boolean?
|
|
||||||
handleSIGHUP: boolean?
|
|
||||||
timeout: number?
|
|
||||||
env:
|
|
||||||
type: array?
|
|
||||||
items: NameValue
|
|
||||||
headless: boolean?
|
|
||||||
devtools: boolean?
|
|
||||||
proxy:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
server: string
|
|
||||||
bypass: string?
|
|
||||||
username: string?
|
|
||||||
password: string?
|
|
||||||
downloadsPath: string?
|
|
||||||
chromiumSandbox: boolean?
|
|
||||||
slowMo: number?
|
slowMo: number?
|
||||||
noDefaultViewport: boolean?
|
|
||||||
viewport:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
width: number
|
|
||||||
height: number
|
|
||||||
ignoreHTTPSErrors: boolean?
|
|
||||||
javaScriptEnabled: boolean?
|
|
||||||
bypassCSP: boolean?
|
|
||||||
userAgent: string?
|
|
||||||
locale: string?
|
|
||||||
timezoneId: string?
|
|
||||||
geolocation:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
longitude: number
|
|
||||||
latitude: number
|
|
||||||
accuracy: number?
|
|
||||||
permissions:
|
|
||||||
type: array?
|
|
||||||
items: string
|
|
||||||
extraHTTPHeaders:
|
|
||||||
type: array?
|
|
||||||
items: NameValue
|
|
||||||
offline: boolean?
|
|
||||||
httpCredentials:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
username: string
|
|
||||||
password: string
|
|
||||||
deviceScaleFactor: number?
|
|
||||||
isMobile: boolean?
|
|
||||||
hasTouch: boolean?
|
|
||||||
colorScheme:
|
|
||||||
type: enum?
|
|
||||||
literals:
|
|
||||||
- light
|
|
||||||
- dark
|
|
||||||
- no-preference
|
|
||||||
acceptDownloads: boolean?
|
|
||||||
_traceDir: string?
|
|
||||||
_debugName: string?
|
|
||||||
recordVideo:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
dir: string
|
|
||||||
size:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
width: number
|
|
||||||
height: number
|
|
||||||
recordHar:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
omitContent: boolean?
|
|
||||||
path: string
|
|
||||||
returns:
|
returns:
|
||||||
context: BrowserContext
|
context: BrowserContext
|
||||||
|
|
||||||
@ -466,63 +442,7 @@ Browser:
|
|||||||
|
|
||||||
newContext:
|
newContext:
|
||||||
parameters:
|
parameters:
|
||||||
sdkLanguage: string
|
$mixin: ContextOptions
|
||||||
noDefaultViewport: boolean?
|
|
||||||
viewport:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
width: number
|
|
||||||
height: number
|
|
||||||
ignoreHTTPSErrors: boolean?
|
|
||||||
javaScriptEnabled: boolean?
|
|
||||||
bypassCSP: boolean?
|
|
||||||
userAgent: string?
|
|
||||||
locale: string?
|
|
||||||
timezoneId: string?
|
|
||||||
geolocation:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
longitude: number
|
|
||||||
latitude: number
|
|
||||||
accuracy: number?
|
|
||||||
permissions:
|
|
||||||
type: array?
|
|
||||||
items: string
|
|
||||||
extraHTTPHeaders:
|
|
||||||
type: array?
|
|
||||||
items: NameValue
|
|
||||||
offline: boolean?
|
|
||||||
httpCredentials:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
username: string
|
|
||||||
password: string
|
|
||||||
deviceScaleFactor: number?
|
|
||||||
isMobile: boolean?
|
|
||||||
hasTouch: boolean?
|
|
||||||
colorScheme:
|
|
||||||
type: enum?
|
|
||||||
literals:
|
|
||||||
- dark
|
|
||||||
- light
|
|
||||||
- no-preference
|
|
||||||
acceptDownloads: boolean?
|
|
||||||
_traceDir: string?
|
|
||||||
_debugName: string?
|
|
||||||
recordVideo:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
dir: string
|
|
||||||
size:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
width: number
|
|
||||||
height: number
|
|
||||||
recordHar:
|
|
||||||
type: object?
|
|
||||||
properties:
|
|
||||||
omitContent: boolean?
|
|
||||||
path: string
|
|
||||||
proxy:
|
proxy:
|
||||||
type: object?
|
type: object?
|
||||||
properties:
|
properties:
|
||||||
|
@ -173,14 +173,12 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
|||||||
password: tOptional(tString),
|
password: tOptional(tString),
|
||||||
})),
|
})),
|
||||||
downloadsPath: tOptional(tString),
|
downloadsPath: tOptional(tString),
|
||||||
firefoxUserPrefs: tOptional(tAny),
|
|
||||||
chromiumSandbox: tOptional(tBoolean),
|
chromiumSandbox: tOptional(tBoolean),
|
||||||
|
firefoxUserPrefs: tOptional(tAny),
|
||||||
slowMo: tOptional(tNumber),
|
slowMo: tOptional(tNumber),
|
||||||
});
|
});
|
||||||
scheme.BrowserTypeLaunchPersistentContextParams = tObject({
|
scheme.BrowserTypeLaunchPersistentContextParams = tObject({
|
||||||
channel: tOptional(tEnum(['chrome', 'chrome-beta', 'chrome-dev', 'chrome-canary', 'msedge', 'msedge-beta', 'msedge-dev', 'msedge-canary'])),
|
channel: tOptional(tEnum(['chrome', 'chrome-beta', 'chrome-dev', 'chrome-canary', 'msedge', 'msedge-beta', 'msedge-dev', 'msedge-canary'])),
|
||||||
userDataDir: tString,
|
|
||||||
sdkLanguage: tString,
|
|
||||||
executablePath: tOptional(tString),
|
executablePath: tOptional(tString),
|
||||||
args: tOptional(tArray(tString)),
|
args: tOptional(tArray(tString)),
|
||||||
ignoreAllDefaultArgs: tOptional(tBoolean),
|
ignoreAllDefaultArgs: tOptional(tBoolean),
|
||||||
@ -200,7 +198,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
|||||||
})),
|
})),
|
||||||
downloadsPath: tOptional(tString),
|
downloadsPath: tOptional(tString),
|
||||||
chromiumSandbox: tOptional(tBoolean),
|
chromiumSandbox: tOptional(tBoolean),
|
||||||
slowMo: tOptional(tNumber),
|
sdkLanguage: tString,
|
||||||
noDefaultViewport: tOptional(tBoolean),
|
noDefaultViewport: tOptional(tBoolean),
|
||||||
viewport: tOptional(tObject({
|
viewport: tOptional(tObject({
|
||||||
width: tNumber,
|
width: tNumber,
|
||||||
@ -227,7 +225,7 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
|||||||
deviceScaleFactor: tOptional(tNumber),
|
deviceScaleFactor: tOptional(tNumber),
|
||||||
isMobile: tOptional(tBoolean),
|
isMobile: tOptional(tBoolean),
|
||||||
hasTouch: tOptional(tBoolean),
|
hasTouch: tOptional(tBoolean),
|
||||||
colorScheme: tOptional(tEnum(['light', 'dark', 'no-preference'])),
|
colorScheme: tOptional(tEnum(['dark', 'light', 'no-preference'])),
|
||||||
acceptDownloads: tOptional(tBoolean),
|
acceptDownloads: tOptional(tBoolean),
|
||||||
_traceDir: tOptional(tString),
|
_traceDir: tOptional(tString),
|
||||||
_debugName: tOptional(tString),
|
_debugName: tOptional(tString),
|
||||||
@ -242,6 +240,8 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
|||||||
omitContent: tOptional(tBoolean),
|
omitContent: tOptional(tBoolean),
|
||||||
path: tString,
|
path: tString,
|
||||||
})),
|
})),
|
||||||
|
userDataDir: tString,
|
||||||
|
slowMo: tOptional(tNumber),
|
||||||
});
|
});
|
||||||
scheme.BrowserTypeConnectOverCDPParams = tObject({
|
scheme.BrowserTypeConnectOverCDPParams = tObject({
|
||||||
sdkLanguage: tString,
|
sdkLanguage: tString,
|
||||||
|
@ -21,6 +21,8 @@ const path = require('path');
|
|||||||
const yaml = require('yaml');
|
const yaml = require('yaml');
|
||||||
|
|
||||||
const channels = new Set();
|
const channels = new Set();
|
||||||
|
const inherits = new Map();
|
||||||
|
const mixins = new Map();
|
||||||
|
|
||||||
function raise(item) {
|
function raise(item) {
|
||||||
throw new Error('Invalid item: ' + JSON.stringify(item, null, 2));
|
throw new Error('Invalid item: ' + JSON.stringify(item, null, 2));
|
||||||
@ -73,17 +75,24 @@ function inlineType(type, indent, wrapEnums = false) {
|
|||||||
raise(type);
|
raise(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function properties(props, indent, onlyOptional) {
|
function properties(properties, indent, onlyOptional) {
|
||||||
const ts = [];
|
const ts = [];
|
||||||
const scheme = [];
|
const scheme = [];
|
||||||
for (const [name, value] of Object.entries(props)) {
|
const visitProperties = props => {
|
||||||
const inner = inlineType(value, indent);
|
for (const [name, value] of Object.entries(props)) {
|
||||||
if (onlyOptional && !inner.optional)
|
if (name.startsWith('$mixin')) {
|
||||||
continue;
|
visitProperties(mixins.get(value).properties);
|
||||||
ts.push(`${indent}${name}${inner.optional ? '?' : ''}: ${inner.ts},`);
|
continue;
|
||||||
const wrapped = inner.optional ? `tOptional(${inner.scheme})` : inner.scheme;
|
}
|
||||||
scheme.push(`${indent}${name}: ${wrapped},`);
|
const inner = inlineType(value, indent);
|
||||||
}
|
if (onlyOptional && !inner.optional)
|
||||||
|
continue;
|
||||||
|
ts.push(`${indent}${name}${inner.optional ? '?' : ''}: ${inner.ts},`);
|
||||||
|
const wrapped = inner.optional ? `tOptional(${inner.scheme})` : inner.scheme;
|
||||||
|
scheme.push(`${indent}${name}: ${wrapped},`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
visitProperties(properties);
|
||||||
return { ts: ts.join('\n'), scheme: scheme.join('\n') };
|
return { ts: ts.join('\n'), scheme: scheme.join('\n') };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,13 +175,14 @@ function addScheme(name, s) {
|
|||||||
validator_ts.push(...lines.map(line => ' ' + line));
|
validator_ts.push(...lines.map(line => ' ' + line));
|
||||||
}
|
}
|
||||||
|
|
||||||
const inherits = new Map();
|
|
||||||
for (const [name, value] of Object.entries(protocol)) {
|
for (const [name, value] of Object.entries(protocol)) {
|
||||||
if (value.type === 'interface') {
|
if (value.type === 'interface') {
|
||||||
channels.add(name);
|
channels.add(name);
|
||||||
if (value.extends)
|
if (value.extends)
|
||||||
inherits.set(name, value.extends);
|
inherits.set(name, value.extends);
|
||||||
}
|
}
|
||||||
|
if (value.type === 'mixin')
|
||||||
|
mixins.set(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [name, item] of Object.entries(protocol)) {
|
for (const [name, item] of Object.entries(protocol)) {
|
||||||
@ -219,12 +229,13 @@ for (const [name, item] of Object.entries(protocol)) {
|
|||||||
channels_ts.push(`}`);
|
channels_ts.push(`}`);
|
||||||
for (const [typeName, typeValue] of ts_types)
|
for (const [typeName, typeValue] of ts_types)
|
||||||
channels_ts.push(`export type ${typeName} = ${typeValue};`);
|
channels_ts.push(`export type ${typeName} = ${typeValue};`);
|
||||||
|
channels_ts.push(``);
|
||||||
} else if (item.type === 'object') {
|
} else if (item.type === 'object') {
|
||||||
const inner = objectType(item.properties, '');
|
const inner = objectType(item.properties, '');
|
||||||
channels_ts.push(`export type ${name} = ${inner.ts};`);
|
channels_ts.push(`export type ${name} = ${inner.ts};`);
|
||||||
|
channels_ts.push(``);
|
||||||
addScheme(name, inner.scheme);
|
addScheme(name, inner.scheme);
|
||||||
}
|
}
|
||||||
channels_ts.push(``);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
validator_ts.push(`
|
validator_ts.push(`
|
||||||
|
Loading…
Reference in New Issue
Block a user