@vivliostyle/cli 9.0.0-next.3 → 9.0.0-next.4
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/chunk-BIEQXUOY.js +50 -0
- package/dist/chunk-DMARNPN5.js +1073 -0
- package/dist/chunk-DMGAKSPH.js +590 -0
- package/dist/{core/init.js → chunk-E7QOXL6M.js} +39 -27
- package/dist/chunk-EX7EA34F.js +64 -0
- package/dist/chunk-LASMQBPP.js +85 -0
- package/dist/chunk-QC3BOE2G.js +74 -0
- package/dist/chunk-VBEHGS67.js +4990 -0
- package/dist/chunk-WX6JHPSL.js +16 -0
- package/dist/chunk-Y3ETBU5J.js +54 -0
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +17 -18
- package/dist/commands/build.d.ts +2 -2
- package/dist/commands/build.js +165 -17
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.js +35 -12
- package/dist/commands/preview.d.ts +2 -2
- package/dist/commands/preview.js +98 -12
- package/dist/config/schema.d.ts +2332 -2325
- package/dist/config/schema.js +50 -588
- package/dist/index.d.ts +116 -7
- package/dist/index.js +38 -42
- package/dist/node-modules.d.ts +21 -0
- package/dist/node-modules.js +9 -0
- package/dist/vite-adapter.d.ts +8 -2
- package/dist/vite-adapter.js +11 -43
- package/package.json +32 -13
- package/dist/browser.d.ts +0 -19
- package/dist/browser.d.ts.map +0 -1
- package/dist/browser.js +0 -154
- package/dist/browser.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/build.d.ts.map +0 -1
- package/dist/commands/build.js.map +0 -1
- package/dist/commands/build.parser.d.ts +0 -3
- package/dist/commands/build.parser.d.ts.map +0 -1
- package/dist/commands/build.parser.js +0 -104
- package/dist/commands/build.parser.js.map +0 -1
- package/dist/commands/cli-flags.d.ts +0 -42
- package/dist/commands/cli-flags.d.ts.map +0 -1
- package/dist/commands/cli-flags.js +0 -58
- package/dist/commands/cli-flags.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/init.parser.d.ts +0 -3
- package/dist/commands/init.parser.d.ts.map +0 -1
- package/dist/commands/init.parser.js +0 -17
- package/dist/commands/init.parser.js.map +0 -1
- package/dist/commands/preview.d.ts.map +0 -1
- package/dist/commands/preview.js.map +0 -1
- package/dist/commands/preview.parser.d.ts +0 -3
- package/dist/commands/preview.parser.d.ts.map +0 -1
- package/dist/commands/preview.parser.js +0 -52
- package/dist/commands/preview.parser.js.map +0 -1
- package/dist/config/load.d.ts +0 -4
- package/dist/config/load.d.ts.map +0 -1
- package/dist/config/load.js +0 -75
- package/dist/config/load.js.map +0 -1
- package/dist/config/merge.d.ts +0 -4
- package/dist/config/merge.d.ts.map +0 -1
- package/dist/config/merge.js +0 -59
- package/dist/config/merge.js.map +0 -1
- package/dist/config/resolve.d.ts +0 -205
- package/dist/config/resolve.d.ts.map +0 -1
- package/dist/config/resolve.js +0 -770
- package/dist/config/resolve.js.map +0 -1
- package/dist/config/schema.d.ts.map +0 -1
- package/dist/config/schema.js.map +0 -1
- package/dist/config/vite.d.ts +0 -6
- package/dist/config/vite.d.ts.map +0 -1
- package/dist/config/vite.js +0 -49
- package/dist/config/vite.js.map +0 -1
- package/dist/const.d.ts +0 -20
- package/dist/const.d.ts.map +0 -1
- package/dist/const.js +0 -41
- package/dist/const.js.map +0 -1
- package/dist/container.d.ts +0 -21
- package/dist/container.d.ts.map +0 -1
- package/dist/container.js +0 -175
- package/dist/container.js.map +0 -1
- package/dist/core/build.d.ts +0 -3
- package/dist/core/build.d.ts.map +0 -1
- package/dist/core/build.js +0 -168
- package/dist/core/build.js.map +0 -1
- package/dist/core/init.d.ts +0 -3
- package/dist/core/init.d.ts.map +0 -1
- package/dist/core/init.js.map +0 -1
- package/dist/core/preview.d.ts +0 -4
- package/dist/core/preview.d.ts.map +0 -1
- package/dist/core/preview.js +0 -114
- package/dist/core/preview.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger.d.ts +0 -30
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -172
- package/dist/logger.js.map +0 -1
- package/dist/output/epub.d.ts +0 -10
- package/dist/output/epub.d.ts.map +0 -1
- package/dist/output/epub.js +0 -505
- package/dist/output/epub.js.map +0 -1
- package/dist/output/pdf-postprocess.d.ts +0 -30
- package/dist/output/pdf-postprocess.d.ts.map +0 -1
- package/dist/output/pdf-postprocess.js +0 -270
- package/dist/output/pdf-postprocess.js.map +0 -1
- package/dist/output/pdf.d.ts +0 -6
- package/dist/output/pdf.d.ts.map +0 -1
- package/dist/output/pdf.js +0 -200
- package/dist/output/pdf.js.map +0 -1
- package/dist/output/webbook.d.ts +0 -45
- package/dist/output/webbook.d.ts.map +0 -1
- package/dist/output/webbook.js +0 -413
- package/dist/output/webbook.js.map +0 -1
- package/dist/processor/compile.d.ts +0 -30
- package/dist/processor/compile.d.ts.map +0 -1
- package/dist/processor/compile.js +0 -348
- package/dist/processor/compile.js.map +0 -1
- package/dist/processor/html.d.ts +0 -107
- package/dist/processor/html.d.ts.map +0 -1
- package/dist/processor/html.js +0 -494
- package/dist/processor/html.js.map +0 -1
- package/dist/processor/markdown.d.ts +0 -12
- package/dist/processor/markdown.d.ts.map +0 -1
- package/dist/processor/markdown.js +0 -23
- package/dist/processor/markdown.js.map +0 -1
- package/dist/processor/theme.d.ts +0 -4
- package/dist/processor/theme.d.ts.map +0 -1
- package/dist/processor/theme.js +0 -41
- package/dist/processor/theme.js.map +0 -1
- package/dist/schema/pub-manifest.d.ts +0 -4
- package/dist/schema/pub-manifest.d.ts.map +0 -1
- package/dist/schema/pub-manifest.js +0 -41
- package/dist/schema/pub-manifest.js.map +0 -1
- package/dist/schema/publication.schema.d.ts +0 -104
- package/dist/schema/publication.schema.d.ts.map +0 -1
- package/dist/schema/publication.schema.js +0 -8
- package/dist/schema/publication.schema.js.map +0 -1
- package/dist/server.d.ts +0 -20
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -126
- package/dist/server.js.map +0 -1
- package/dist/util.d.ts +0 -55
- package/dist/util.d.ts.map +0 -1
- package/dist/util.js +0 -274
- package/dist/util.js.map +0 -1
- package/dist/vite/plugin-util.d.ts +0 -6
- package/dist/vite/plugin-util.d.ts.map +0 -1
- package/dist/vite/plugin-util.js +0 -18
- package/dist/vite/plugin-util.js.map +0 -1
- package/dist/vite/vite-plugin-browser.d.ts +0 -8
- package/dist/vite/vite-plugin-browser.d.ts.map +0 -1
- package/dist/vite/vite-plugin-browser.js +0 -54
- package/dist/vite/vite-plugin-browser.js.map +0 -1
- package/dist/vite/vite-plugin-dev-server.d.ts +0 -8
- package/dist/vite/vite-plugin-dev-server.d.ts.map +0 -1
- package/dist/vite/vite-plugin-dev-server.js +0 -270
- package/dist/vite/vite-plugin-dev-server.js.map +0 -1
- package/dist/vite/vite-plugin-static-serve.d.ts +0 -8
- package/dist/vite/vite-plugin-static-serve.d.ts.map +0 -1
- package/dist/vite/vite-plugin-static-serve.js +0 -31
- package/dist/vite/vite-plugin-static-serve.js.map +0 -1
- package/dist/vite/vite-plugin-viewer.d.ts +0 -8
- package/dist/vite/vite-plugin-viewer.d.ts.map +0 -1
- package/dist/vite/vite-plugin-viewer.js +0 -52
- package/dist/vite/vite-plugin-viewer.js.map +0 -1
- package/dist/vite-adapter.d.ts.map +0 -1
- package/dist/vite-adapter.js.map +0 -1
- package/schemas/pub-manifest/README.md +0 -5
- package/schemas/pub-manifest/module/ItemList.schema.json +0 -32
- package/schemas/pub-manifest/module/bcp.schema.json +0 -7
- package/schemas/pub-manifest/module/context.schema.json +0 -62
- package/schemas/pub-manifest/module/contributor-object.schema.json +0 -42
- package/schemas/pub-manifest/module/contributor.schema.json +0 -26
- package/schemas/pub-manifest/module/date.schema.json +0 -7
- package/schemas/pub-manifest/module/duration.schema.json +0 -7
- package/schemas/pub-manifest/module/item-lists.schema.json +0 -16
- package/schemas/pub-manifest/module/language.schema.json +0 -16
- package/schemas/pub-manifest/module/link.schema.json +0 -60
- package/schemas/pub-manifest/module/localizable-object.schema.json +0 -15
- package/schemas/pub-manifest/module/localizable.schema.json +0 -26
- package/schemas/pub-manifest/module/resource.categorization.schema.json +0 -31
- package/schemas/pub-manifest/module/strings.schema.json +0 -9
- package/schemas/pub-manifest/module/url.schema.json +0 -7
- package/schemas/pub-manifest/module/urls.schema.json +0 -18
- package/schemas/pub-manifest/publication.schema.json +0 -123
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
// TODO: Change to static import after JSON module becomes stable
|
|
3
|
-
const require = createRequire(import.meta.url);
|
|
4
|
-
const bcpSchema = require('../../schemas/pub-manifest/module/bcp.schema.json');
|
|
5
|
-
const contextSchema = require('../../schemas/pub-manifest/module/context.schema.json');
|
|
6
|
-
const contributorObjectSchema = require('../../schemas/pub-manifest/module/contributor-object.schema.json');
|
|
7
|
-
const contributorSchema = require('../../schemas/pub-manifest/module/contributor.schema.json');
|
|
8
|
-
const dateSchema = require('../../schemas/pub-manifest/module/date.schema.json');
|
|
9
|
-
const durationSchema = require('../../schemas/pub-manifest/module/duration.schema.json');
|
|
10
|
-
const itemListsSchema = require('../../schemas/pub-manifest/module/item-lists.schema.json');
|
|
11
|
-
const itemListSchema = require('../../schemas/pub-manifest/module/ItemList.schema.json');
|
|
12
|
-
const languageSchema = require('../../schemas/pub-manifest/module/language.schema.json');
|
|
13
|
-
const linkSchema = require('../../schemas/pub-manifest/module/link.schema.json');
|
|
14
|
-
const localizableObjectSchema = require('../../schemas/pub-manifest/module/localizable-object.schema.json');
|
|
15
|
-
const localizableSchema = require('../../schemas/pub-manifest/module/localizable.schema.json');
|
|
16
|
-
const resourceCategorizationSchema = require('../../schemas/pub-manifest/module/resource.categorization.schema.json');
|
|
17
|
-
const stringsSchema = require('../../schemas/pub-manifest/module/strings.schema.json');
|
|
18
|
-
const urlSchema = require('../../schemas/pub-manifest/module/url.schema.json');
|
|
19
|
-
const urlsSchema = require('../../schemas/pub-manifest/module/urls.schema.json');
|
|
20
|
-
const publicationSchema = require('../../schemas/pub-manifest/publication.schema.json');
|
|
21
|
-
export const publicationSchemas = [
|
|
22
|
-
bcpSchema,
|
|
23
|
-
contextSchema,
|
|
24
|
-
contributorObjectSchema,
|
|
25
|
-
contributorSchema,
|
|
26
|
-
dateSchema,
|
|
27
|
-
durationSchema,
|
|
28
|
-
itemListsSchema,
|
|
29
|
-
itemListSchema,
|
|
30
|
-
languageSchema,
|
|
31
|
-
linkSchema,
|
|
32
|
-
localizableObjectSchema,
|
|
33
|
-
localizableSchema,
|
|
34
|
-
resourceCategorizationSchema,
|
|
35
|
-
stringsSchema,
|
|
36
|
-
urlSchema,
|
|
37
|
-
urlsSchema,
|
|
38
|
-
publicationSchema,
|
|
39
|
-
];
|
|
40
|
-
export { publicationSchema };
|
|
41
|
-
//# sourceMappingURL=pub-manifest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pub-manifest.js","sourceRoot":"","sources":["../../src/schema/pub-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,iEAAiE;AACjE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,SAAS,GAAG,OAAO,CAAC,mDAAmD,CAAC,CAAC;AAC/E,MAAM,aAAa,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAC;AACvF,MAAM,uBAAuB,GAAG,OAAO,CAAC,kEAAkE,CAAC,CAAC;AAC5G,MAAM,iBAAiB,GAAG,OAAO,CAAC,2DAA2D,CAAC,CAAC;AAC/F,MAAM,UAAU,GAAG,OAAO,CAAC,oDAAoD,CAAC,CAAC;AACjF,MAAM,cAAc,GAAG,OAAO,CAAC,wDAAwD,CAAC,CAAC;AACzF,MAAM,eAAe,GAAG,OAAO,CAAC,0DAA0D,CAAC,CAAC;AAC5F,MAAM,cAAc,GAAG,OAAO,CAAC,wDAAwD,CAAC,CAAC;AACzF,MAAM,cAAc,GAAG,OAAO,CAAC,wDAAwD,CAAC,CAAC;AACzF,MAAM,UAAU,GAAG,OAAO,CAAC,oDAAoD,CAAC,CAAC;AACjF,MAAM,uBAAuB,GAAG,OAAO,CAAC,kEAAkE,CAAC,CAAC;AAC5G,MAAM,iBAAiB,GAAG,OAAO,CAAC,2DAA2D,CAAC,CAAC;AAC/F,MAAM,4BAA4B,GAAG,OAAO,CAAC,uEAAuE,CAAC,CAAC;AACtH,MAAM,aAAa,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAC;AACvF,MAAM,SAAS,GAAG,OAAO,CAAC,mDAAmD,CAAC,CAAC;AAC/E,MAAM,UAAU,GAAG,OAAO,CAAC,oDAAoD,CAAC,CAAC;AACjF,MAAM,iBAAiB,GAAG,OAAO,CAAC,oDAAoD,CAAC,CAAC;AAExF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,SAAS;IACT,aAAa;IACb,uBAAuB;IACvB,iBAAiB;IACjB,UAAU;IACV,cAAc;IACd,eAAe;IACf,cAAc;IACd,cAAc;IACd,UAAU;IACV,uBAAuB;IACvB,iBAAiB;IACjB,4BAA4B;IAC5B,aAAa;IACb,SAAS;IACT,UAAU;IACV,iBAAiB;CACT,CAAC;AAEX,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was automatically generated by json-schema-to-typescript.
|
|
3
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
4
|
-
* and run json-schema-to-typescript to regenerate this file.
|
|
5
|
-
*/
|
|
6
|
-
export type PublicationContexts = [] | ['https://schema.org'] | [
|
|
7
|
-
'https://schema.org',
|
|
8
|
-
'https://www.w3.org/ns/pub-context',
|
|
9
|
-
...(string | {
|
|
10
|
-
language: BCP47LanguageTag;
|
|
11
|
-
direction?: never;
|
|
12
|
-
[k: string]: unknown;
|
|
13
|
-
} | {
|
|
14
|
-
direction: 'ltr' | 'rtl';
|
|
15
|
-
language?: never;
|
|
16
|
-
[k: string]: unknown;
|
|
17
|
-
} | {
|
|
18
|
-
language: BCP47LanguageTag;
|
|
19
|
-
direction: 'ltr' | 'rtl';
|
|
20
|
-
[k: string]: unknown;
|
|
21
|
-
} | {
|
|
22
|
-
language?: never;
|
|
23
|
-
direction?: never;
|
|
24
|
-
[k: string]: unknown;
|
|
25
|
-
})[]
|
|
26
|
-
];
|
|
27
|
-
export type BCP47LanguageTag = string;
|
|
28
|
-
export type URL = string;
|
|
29
|
-
export type UniqueStrings = string | string[];
|
|
30
|
-
export type ListsOfItemList = SchemaOrgItemListObject | SchemaOrgItemListObject[];
|
|
31
|
-
export type LocalizableStringOrObject = string | (string | LocalizableStringObject)[] | LocalizableStringObject;
|
|
32
|
-
export type Contributor = string | (string | ContributorObject)[] | ContributorObject;
|
|
33
|
-
export type URLs = string | string[];
|
|
34
|
-
export type Duration = string;
|
|
35
|
-
export type Languages = BCP47LanguageTag | BCP47LanguageTag[];
|
|
36
|
-
export type Dates = string;
|
|
37
|
-
export type ResourceCategorization = (URL | PublicationLinks) | (URL | PublicationLinks)[];
|
|
38
|
-
export interface PublicationManifest {
|
|
39
|
-
'@context': PublicationContexts;
|
|
40
|
-
type?: string | string[];
|
|
41
|
-
conformsTo: URL | URL[];
|
|
42
|
-
id?: string;
|
|
43
|
-
abridged?: boolean;
|
|
44
|
-
accessMode?: UniqueStrings;
|
|
45
|
-
accessModeSufficient?: ListsOfItemList;
|
|
46
|
-
accessibilityFeature?: UniqueStrings;
|
|
47
|
-
accessibilityHazard?: UniqueStrings;
|
|
48
|
-
accessibilitySummary?: LocalizableStringOrObject;
|
|
49
|
-
artist?: Contributor;
|
|
50
|
-
author?: Contributor;
|
|
51
|
-
colorist?: Contributor;
|
|
52
|
-
contributor?: Contributor;
|
|
53
|
-
creator?: Contributor;
|
|
54
|
-
editor?: Contributor;
|
|
55
|
-
illustrator?: Contributor;
|
|
56
|
-
inker?: Contributor;
|
|
57
|
-
letterer?: Contributor;
|
|
58
|
-
penciler?: Contributor;
|
|
59
|
-
publisher?: Contributor;
|
|
60
|
-
readBy?: Contributor;
|
|
61
|
-
translator?: Contributor;
|
|
62
|
-
url?: URLs;
|
|
63
|
-
duration?: Duration;
|
|
64
|
-
inLanguage?: Languages;
|
|
65
|
-
dateModified?: Dates;
|
|
66
|
-
datePublished?: Dates;
|
|
67
|
-
name?: LocalizableStringOrObject;
|
|
68
|
-
readingOrder?: ResourceCategorization;
|
|
69
|
-
resources?: ResourceCategorization;
|
|
70
|
-
links?: ResourceCategorization;
|
|
71
|
-
readingProgression?: 'ltr' | 'rtl';
|
|
72
|
-
[k: string]: unknown;
|
|
73
|
-
}
|
|
74
|
-
export interface SchemaOrgItemListObject {
|
|
75
|
-
type: 'ItemList' | string[];
|
|
76
|
-
itemListElement: string[];
|
|
77
|
-
[k: string]: unknown;
|
|
78
|
-
}
|
|
79
|
-
export interface LocalizableStringObject {
|
|
80
|
-
value: string;
|
|
81
|
-
language?: BCP47LanguageTag;
|
|
82
|
-
[k: string]: unknown;
|
|
83
|
-
}
|
|
84
|
-
export interface ContributorObject {
|
|
85
|
-
name: LocalizableStringOrObject;
|
|
86
|
-
id?: URL;
|
|
87
|
-
type?: ('Person' | 'Organization') | string[];
|
|
88
|
-
url?: URL;
|
|
89
|
-
identifier?: string[];
|
|
90
|
-
[k: string]: unknown;
|
|
91
|
-
}
|
|
92
|
-
export interface PublicationLinks {
|
|
93
|
-
type?: 'LinkedResource' | string[];
|
|
94
|
-
url: URL;
|
|
95
|
-
encodingFormat?: string;
|
|
96
|
-
name?: LocalizableStringOrObject;
|
|
97
|
-
description?: string | LocalizableStringObject;
|
|
98
|
-
rel?: string | string[];
|
|
99
|
-
integrity?: string;
|
|
100
|
-
duration?: Duration;
|
|
101
|
-
alternate?: ResourceCategorization;
|
|
102
|
-
[k: string]: unknown;
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=publication.schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"publication.schema.d.ts","sourceRoot":"","sources":["../../src/schema/publication.schema.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH,MAAM,MAAM,mBAAmB,GAC3B,EAAE,GACF,CAAC,oBAAoB,CAAC,GACtB;IACE,oBAAoB;IACpB,mCAAmC;IACnC,GAAG,CACC,MAAM,GACN;QACE,QAAQ,EAAE,gBAAgB,CAAC;QAC3B,SAAS,CAAC,EAAE,KAAK,CAAC;QAClB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACtB,GACD;QACE,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;QACzB,QAAQ,CAAC,EAAE,KAAK,CAAC;QACjB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACtB,GACD;QACE,QAAQ,EAAE,gBAAgB,CAAC;QAC3B,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;QACzB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACtB,GACD;QACE,QAAQ,CAAC,EAAE,KAAK,CAAC;QACjB,SAAS,CAAC,EAAE,KAAK,CAAC;QAClB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACtB,CACJ,EAAE;CACJ,CAAC;AACN,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC;AACtC,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AACzB,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAC9C,MAAM,MAAM,eAAe,GACvB,uBAAuB,GACvB,uBAAuB,EAAE,CAAC;AAC9B,MAAM,MAAM,yBAAyB,GACjC,MAAM,GACN,CAAC,MAAM,GAAG,uBAAuB,CAAC,EAAE,GACpC,uBAAuB,CAAC;AAC5B,MAAM,MAAM,WAAW,GACnB,MA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E,GAAG,CAAC;IACT,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,yBAAyB,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,GAAG,uBAAuB,CAAC;IAC/C,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**
|
|
3
|
-
* This file was automatically generated by json-schema-to-typescript.
|
|
4
|
-
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
5
|
-
* and run json-schema-to-typescript to regenerate this file.
|
|
6
|
-
*/
|
|
7
|
-
export {};
|
|
8
|
-
//# sourceMappingURL=publication.schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"publication.schema.js","sourceRoot":"","sources":["../../src/schema/publication.schema.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB;;;;GAIG"}
|
package/dist/server.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { PreviewServer, ResolvedConfig as ResolvedViteConfig, ViteDevServer } from 'vite';
|
|
2
|
-
import { ResolvedTaskConfig } from './config/resolve.js';
|
|
3
|
-
import { ParsedVivliostyleInlineConfig } from './config/schema.js';
|
|
4
|
-
export type ViewerUrlOption = Pick<ResolvedTaskConfig, 'size' | 'cropMarks' | 'bleed' | 'cropOffset' | 'css' | 'customStyle' | 'customUserStyle' | 'singleDoc' | 'quick' | 'viewerParam'>;
|
|
5
|
-
export declare function getViewerParams(src: string | undefined, { size, cropMarks, bleed, cropOffset, css, customStyle, customUserStyle, singleDoc, quick, viewerParam, }: ViewerUrlOption): string;
|
|
6
|
-
export declare function getSourceUrl({ viewerInput, base, workspaceDir, rootUrl, }: Pick<ResolvedTaskConfig, 'viewerInput' | 'base' | 'workspaceDir' | 'rootUrl'>): Promise<string>;
|
|
7
|
-
export declare function getViewerFullUrl({ viewerInput, base, workspaceDir, rootUrl, viewer, ...config }: ViewerUrlOption & Pick<ResolvedTaskConfig, 'viewerInput' | 'base' | 'workspaceDir' | 'rootUrl' | 'viewer'>): Promise<string>;
|
|
8
|
-
export declare function createViteServer(args: {
|
|
9
|
-
config: ResolvedTaskConfig;
|
|
10
|
-
viteConfig: ResolvedViteConfig;
|
|
11
|
-
inlineConfig: ParsedVivliostyleInlineConfig;
|
|
12
|
-
mode: 'preview';
|
|
13
|
-
}): Promise<ViteDevServer>;
|
|
14
|
-
export declare function createViteServer(args: {
|
|
15
|
-
config: ResolvedTaskConfig;
|
|
16
|
-
viteConfig: ResolvedViteConfig;
|
|
17
|
-
inlineConfig: ParsedVivliostyleInlineConfig;
|
|
18
|
-
mode: 'build';
|
|
19
|
-
}): Promise<PreviewServer>;
|
|
20
|
-
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,aAAa,EACb,cAAc,IAAI,kBAAkB,EACpC,aAAa,EACd,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAcnE,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,kBAAkB,EAChB,MAAM,GACN,WAAW,GACX,OAAO,GACP,YAAY,GACZ,KAAK,GACL,aAAa,GACb,iBAAiB,GACjB,WAAW,GACX,OAAO,GACP,aAAa,CAChB,CAAC;AAEF,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,EACE,IAAI,EACJ,SAAS,EACT,KAAK,EACL,UAAU,EACV,GAAG,EACH,WAAW,EACX,eAAe,EACf,SAAS,EACT,KAAK,EACL,WAAW,GACZ,EAAE,eAAe,GACjB,MAAM,CAkDR;AAED,wBAAsB,YAAY,CAAC,EACjC,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,OAAO,GACR,EAAE,IAAI,CACL,kBAAkB,EAClB,aAAa,GAAG,MAAM,GAAG,cAAc,GAAG,SAAS,CACpD,mBA8BA;AAED,wBAAsB,gBAAgB,CAAC,EACrC,WAAW,EACX,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,MAAM,EACN,GAAG,MAAM,EACV,EAAE,eAAe,GAChB,IAAI,CACF,kBAAkB,EAClB,aAAa,GAAG,MAAM,GAAG,cAAc,GAAG,SAAS,GAAG,QAAQ,CAC/D,mBAkBF;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,kBAAkB,CAAC;IAC3B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,YAAY,EAAE,6BAA6B,CAAC;IAC5C,IAAI,EAAE,SAAS,CAAC;CACjB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC3B,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,MAAM,EAAE,kBAAkB,CAAC;IAC3B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,YAAY,EAAE,6BAA6B,CAAC;IAC5C,IAAI,EAAE,OAAO,CAAC;CACf,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC"}
|
package/dist/server.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { URL } from 'node:url';
|
|
3
|
-
import upath from 'upath';
|
|
4
|
-
import { createServer, preview, } from 'vite';
|
|
5
|
-
import { EMPTY_DATA_URI, VIEWER_ROOT_PATH } from './const.js';
|
|
6
|
-
import { Logger } from './logger.js';
|
|
7
|
-
import { getDefaultEpubOpfPath, isValidUri, openEpub, registerExitHandler, } from './util.js';
|
|
8
|
-
import { vsBrowserPlugin } from './vite/vite-plugin-browser.js';
|
|
9
|
-
import { vsDevServerPlugin } from './vite/vite-plugin-dev-server.js';
|
|
10
|
-
import { vsStaticServePlugin } from './vite/vite-plugin-static-serve.js';
|
|
11
|
-
import { vsViewerPlugin } from './vite/vite-plugin-viewer.js';
|
|
12
|
-
export function getViewerParams(src, { size, cropMarks, bleed, cropOffset, css, customStyle, customUserStyle, singleDoc, quick, viewerParam, }) {
|
|
13
|
-
const pageSizeValue = size && ('format' in size ? size.format : `${size.width} ${size.height}`);
|
|
14
|
-
function escapeParam(url) {
|
|
15
|
-
return url.replace(/&/g, '%26');
|
|
16
|
-
}
|
|
17
|
-
let viewerParams = src ? `src=${escapeParam(src)}` : '';
|
|
18
|
-
viewerParams += `&bookMode=${!singleDoc}&renderAllPages=${!quick}`;
|
|
19
|
-
if (customStyle) {
|
|
20
|
-
viewerParams += `&style=${escapeParam(customStyle)}`;
|
|
21
|
-
}
|
|
22
|
-
if (customUserStyle) {
|
|
23
|
-
viewerParams += `&userStyle=${escapeParam(customUserStyle)}`;
|
|
24
|
-
}
|
|
25
|
-
if (pageSizeValue || cropMarks || bleed || cropOffset || css) {
|
|
26
|
-
let pageStyle = '@page{';
|
|
27
|
-
if (pageSizeValue) {
|
|
28
|
-
pageStyle += `size:${pageSizeValue};`;
|
|
29
|
-
}
|
|
30
|
-
if (cropMarks) {
|
|
31
|
-
pageStyle += `marks:crop cross;`;
|
|
32
|
-
}
|
|
33
|
-
if (bleed || cropMarks) {
|
|
34
|
-
pageStyle += `bleed:${bleed ?? '3mm'};`;
|
|
35
|
-
}
|
|
36
|
-
if (cropOffset) {
|
|
37
|
-
pageStyle += `crop-offset:${cropOffset};`;
|
|
38
|
-
}
|
|
39
|
-
pageStyle += '}';
|
|
40
|
-
// The pageStyle settings are put between the `/*<viewer>*/` and `/*</viewer>*/`
|
|
41
|
-
// in the `&style=data:,…` viewer parameter so that they are reflected in the
|
|
42
|
-
// Settings menu of the Viewer. Also the custom CSS code is appended after the
|
|
43
|
-
// `/*</viewer>*/` so that it is shown in the Edit CSS box in the Settings menu.
|
|
44
|
-
viewerParams += `&style=data:,/*<viewer>*/${encodeURIComponent(pageStyle)}/*</viewer>*/${encodeURIComponent(css ?? '')}`;
|
|
45
|
-
}
|
|
46
|
-
if (viewerParam) {
|
|
47
|
-
// append additional viewer parameters
|
|
48
|
-
viewerParams += `&${viewerParam}`;
|
|
49
|
-
}
|
|
50
|
-
return viewerParams;
|
|
51
|
-
}
|
|
52
|
-
export async function getSourceUrl({ viewerInput, base, workspaceDir, rootUrl, }) {
|
|
53
|
-
let input;
|
|
54
|
-
switch (viewerInput.type) {
|
|
55
|
-
case 'webpub':
|
|
56
|
-
input = viewerInput.manifestPath;
|
|
57
|
-
break;
|
|
58
|
-
case 'webbook':
|
|
59
|
-
input = viewerInput.webbookEntryUrl;
|
|
60
|
-
break;
|
|
61
|
-
case 'epub-opf':
|
|
62
|
-
input = viewerInput.epubOpfPath;
|
|
63
|
-
break;
|
|
64
|
-
case 'epub': {
|
|
65
|
-
if (!fs.existsSync(viewerInput.epubTmpOutputDir)) {
|
|
66
|
-
await openEpub(viewerInput.epubPath, viewerInput.epubTmpOutputDir);
|
|
67
|
-
}
|
|
68
|
-
input = getDefaultEpubOpfPath(viewerInput.epubTmpOutputDir);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
default:
|
|
72
|
-
input = viewerInput;
|
|
73
|
-
}
|
|
74
|
-
return (isValidUri(input)
|
|
75
|
-
? new URL(input)
|
|
76
|
-
: new URL(upath.posix.join(base, upath.relative(workspaceDir, input)), rootUrl)).href;
|
|
77
|
-
}
|
|
78
|
-
export async function getViewerFullUrl({ viewerInput, base, workspaceDir, rootUrl, viewer, ...config }) {
|
|
79
|
-
const viewerUrl = viewer
|
|
80
|
-
? new URL(viewer)
|
|
81
|
-
: new URL(`${VIEWER_ROOT_PATH}/index.html`, rootUrl);
|
|
82
|
-
const sourceUrl = await getSourceUrl({
|
|
83
|
-
viewerInput,
|
|
84
|
-
base,
|
|
85
|
-
workspaceDir,
|
|
86
|
-
rootUrl,
|
|
87
|
-
});
|
|
88
|
-
const viewerParams = getViewerParams(sourceUrl === EMPTY_DATA_URI
|
|
89
|
-
? undefined // open Viewer start page
|
|
90
|
-
: sourceUrl, config);
|
|
91
|
-
viewerUrl.hash = '';
|
|
92
|
-
return `${viewerUrl.href}#${viewerParams}`;
|
|
93
|
-
}
|
|
94
|
-
export async function createViteServer({ config, viteConfig, inlineConfig, mode, }) {
|
|
95
|
-
const viteInlineConfig = {
|
|
96
|
-
clearScreen: false,
|
|
97
|
-
configFile: false,
|
|
98
|
-
appType: 'custom',
|
|
99
|
-
plugins: [
|
|
100
|
-
vsDevServerPlugin({ config, inlineConfig }),
|
|
101
|
-
vsViewerPlugin({ config, inlineConfig }),
|
|
102
|
-
vsBrowserPlugin({ config, inlineConfig }),
|
|
103
|
-
vsStaticServePlugin({ config, inlineConfig }),
|
|
104
|
-
],
|
|
105
|
-
server: viteConfig.server,
|
|
106
|
-
preview: viteConfig.preview,
|
|
107
|
-
customLogger: viteConfig.customLogger,
|
|
108
|
-
cacheDir: viteConfig.cacheDir,
|
|
109
|
-
};
|
|
110
|
-
Logger.debug('createViteServer > viteInlineConfig %O', viteInlineConfig);
|
|
111
|
-
if (config.context === config.workspaceDir) {
|
|
112
|
-
const { cacheDir } = viteInlineConfig;
|
|
113
|
-
registerExitHandler('Removing the Vite cacheDir', () => {
|
|
114
|
-
if (fs.existsSync(cacheDir)) {
|
|
115
|
-
fs.rmSync(cacheDir, { recursive: true });
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
if (mode === 'preview') {
|
|
120
|
-
return await createServer(viteInlineConfig);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
return await preview(viteInlineConfig);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,YAAY,EAEZ,OAAO,GAIR,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,QAAQ,EACR,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAgB9D,MAAM,UAAU,eAAe,CAC7B,GAAuB,EACvB,EACE,IAAI,EACJ,SAAS,EACT,KAAK,EACL,UAAU,EACV,GAAG,EACH,WAAW,EACX,eAAe,EACf,SAAS,EACT,KAAK,EACL,WAAW,GACK;IAElB,MAAM,aAAa,GACjB,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAE5E,SAAS,WAAW,CAAC,GAAW;QAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,YAAY,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,WAAW,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AC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,MAAM,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAC9C,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACzC,CAAC;AACH,CAAC"}
|
package/dist/util.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { BaseIssue } from 'valibot';
|
|
3
|
-
import type { PublicationManifest } from './schema/publication.schema.js';
|
|
4
|
-
export declare const cwd: string;
|
|
5
|
-
export declare const registerExitHandler: (debugMessage: string, handler: () => void) => void;
|
|
6
|
-
export declare function runExitHandlers(): void;
|
|
7
|
-
export declare class DetailError extends Error {
|
|
8
|
-
detail: string | undefined;
|
|
9
|
-
constructor(message: string | undefined, detail: string | undefined);
|
|
10
|
-
}
|
|
11
|
-
export declare function getFormattedError(err: Error): string;
|
|
12
|
-
export declare function gracefulError(err: Error): void;
|
|
13
|
-
export declare function readJSON(path: string): any;
|
|
14
|
-
export declare function statFileSync(filePath: string, { errorMessage, }?: {
|
|
15
|
-
errorMessage?: string;
|
|
16
|
-
}): fs.Stats;
|
|
17
|
-
export declare function inflateZip(filePath: string, dest: string): Promise<void>;
|
|
18
|
-
export declare function useTmpDirectory(): Promise<[string, () => void]>;
|
|
19
|
-
export declare function touchTmpFile(path: string): () => void;
|
|
20
|
-
export declare function pathEquals(path1: string, path2: string): boolean;
|
|
21
|
-
export declare function pathContains(parentPath: string, childPath: string): boolean;
|
|
22
|
-
export declare function isValidUri(str: string): boolean;
|
|
23
|
-
export declare function isInContainer(): boolean;
|
|
24
|
-
export declare function openEpub(epubPath: string, tmpDir: string): Promise<() => void>;
|
|
25
|
-
export declare function getDefaultEpubOpfPath(epubDir: string): string;
|
|
26
|
-
export declare function getEpubRootDir(epubOpfPath: string): string | undefined;
|
|
27
|
-
export declare const assertPubManifestSchema: (obj: unknown) => obj is PublicationManifest;
|
|
28
|
-
export declare function parseJsonc(rawJsonc: string): string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | any | {
|
|
29
|
-
[property: string]: string | number | boolean | any | any | null;
|
|
30
|
-
} | null)[] | {
|
|
31
|
-
[property: string]: string | number | boolean | any | any | null;
|
|
32
|
-
} | null)[] | {
|
|
33
|
-
[property: string]: string | number | boolean | any | any | null;
|
|
34
|
-
} | null)[] | {
|
|
35
|
-
[property: string]: string | number | boolean | any | any | null;
|
|
36
|
-
} | null)[] | {
|
|
37
|
-
[property: string]: string | number | boolean | any | any | null;
|
|
38
|
-
} | null)[] | {
|
|
39
|
-
[property: string]: string | number | boolean | any | any | null;
|
|
40
|
-
} | null)[] | {
|
|
41
|
-
[property: string]: string | number | boolean | any | any | null;
|
|
42
|
-
} | null)[] | {
|
|
43
|
-
[property: string]: string | number | boolean | any | any | null;
|
|
44
|
-
} | null)[] | {
|
|
45
|
-
[property: string]: string | number | boolean | any | any | null;
|
|
46
|
-
} | null)[] | {
|
|
47
|
-
[property: string]: string | number | boolean | any | any | null;
|
|
48
|
-
} | null)[] | {
|
|
49
|
-
[property: string]: string | number | boolean | any | any | null;
|
|
50
|
-
} | null)[] | {
|
|
51
|
-
[property: string]: string | number | boolean | any | any | null;
|
|
52
|
-
} | null;
|
|
53
|
-
export declare function prettifySchemaError(rawJsonc: string, issues: BaseIssue<unknown>[]): string;
|
|
54
|
-
export declare function writeFileIfChanged(filePath: string, content: Buffer): void;
|
|
55
|
-
//# sourceMappingURL=util.d.ts.map
|
package/dist/util.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":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AAI,OAAO,CAEvC;AAED,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAW9D;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,UAWpD;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,sBAgBjD;AAsBD,eAAO,MAAM,uBAAuB,QAd5B,OAAO,KAAG,GAAG,uBAkBlB,CAAC;AAEJ,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;SAO1C;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,UAoD7B;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAKnE"}
|
package/dist/util.js
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import { codeFrameColumns } from '@babel/code-frame';
|
|
2
|
-
import { evaluate, parse, } from '@humanwhocodes/momoa';
|
|
3
|
-
import AjvModule from 'ajv';
|
|
4
|
-
import AjvFormatsModule from 'ajv-formats';
|
|
5
|
-
import { XMLParser } from 'fast-xml-parser';
|
|
6
|
-
import { removeSync } from 'fs-extra/esm';
|
|
7
|
-
import StreamZip from 'node-stream-zip';
|
|
8
|
-
import fs from 'node:fs';
|
|
9
|
-
import readline from 'node:readline';
|
|
10
|
-
import util from 'node:util';
|
|
11
|
-
import tmp from 'tmp';
|
|
12
|
-
import upath from 'upath';
|
|
13
|
-
import { gray, red, redBright } from 'yoctocolors';
|
|
14
|
-
import { Logger } from './logger.js';
|
|
15
|
-
import { publicationSchema, publicationSchemas, } from './schema/pub-manifest.js';
|
|
16
|
-
export const cwd = upath.normalize(process.cwd());
|
|
17
|
-
const beforeExitHandlers = [];
|
|
18
|
-
export const registerExitHandler = (debugMessage, handler) => {
|
|
19
|
-
beforeExitHandlers.push(() => {
|
|
20
|
-
Logger.debug(debugMessage);
|
|
21
|
-
handler();
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
export function runExitHandlers() {
|
|
25
|
-
while (beforeExitHandlers.length) {
|
|
26
|
-
try {
|
|
27
|
-
beforeExitHandlers.shift()?.();
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
// NOOP
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const exitSignals = ['exit', 'SIGINT', 'SIGTERM'];
|
|
35
|
-
exitSignals.forEach((sig) => {
|
|
36
|
-
process.once(sig, (signal, exitCode) => {
|
|
37
|
-
runExitHandlers();
|
|
38
|
-
if (process.exitCode === undefined) {
|
|
39
|
-
process.exitCode =
|
|
40
|
-
exitCode !== undefined ? 128 + exitCode : Number(signal);
|
|
41
|
-
}
|
|
42
|
-
process.exit();
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
if (process.platform === 'win32') {
|
|
46
|
-
// Windows does not support signals, so use readline interface
|
|
47
|
-
const rl = readline.createInterface({
|
|
48
|
-
input: process.stdin,
|
|
49
|
-
output: process.stdout,
|
|
50
|
-
});
|
|
51
|
-
rl.on('SIGINT', () => {
|
|
52
|
-
runExitHandlers();
|
|
53
|
-
process.exit(1);
|
|
54
|
-
});
|
|
55
|
-
registerExitHandler('Closing readline interface', () => {
|
|
56
|
-
rl.close();
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
export class DetailError extends Error {
|
|
60
|
-
detail;
|
|
61
|
-
constructor(message, detail) {
|
|
62
|
-
super(message);
|
|
63
|
-
this.detail = detail;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
export function getFormattedError(err) {
|
|
67
|
-
return err instanceof DetailError
|
|
68
|
-
? `${err.message}\n${err.detail}`
|
|
69
|
-
: err.stack || `${err.message}`;
|
|
70
|
-
}
|
|
71
|
-
export function gracefulError(err) {
|
|
72
|
-
console.log(`${redBright('ERROR')} ${getFormattedError(err)}
|
|
73
|
-
|
|
74
|
-
${gray('If you think this is a bug, please report at https://github.com/vivliostyle/vivliostyle-cli/issues')}`);
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
export function readJSON(path) {
|
|
78
|
-
try {
|
|
79
|
-
return JSON.parse(fs.readFileSync(path, 'utf8'));
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
export function statFileSync(filePath, { errorMessage = 'Specified input does not exist', } = {}) {
|
|
86
|
-
try {
|
|
87
|
-
return fs.statSync(filePath);
|
|
88
|
-
}
|
|
89
|
-
catch (err) {
|
|
90
|
-
if (err.code === 'ENOENT') {
|
|
91
|
-
throw new Error(`${errorMessage}: ${filePath}`);
|
|
92
|
-
}
|
|
93
|
-
throw err;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
export async function inflateZip(filePath, dest) {
|
|
97
|
-
return await new Promise((res, rej) => {
|
|
98
|
-
try {
|
|
99
|
-
const zip = new StreamZip({
|
|
100
|
-
file: filePath,
|
|
101
|
-
storeEntries: true,
|
|
102
|
-
});
|
|
103
|
-
zip.on('error', (err) => {
|
|
104
|
-
rej(err);
|
|
105
|
-
});
|
|
106
|
-
zip.on('ready', async () => {
|
|
107
|
-
await util.promisify(zip.extract)(null, dest);
|
|
108
|
-
await util.promisify(zip.close)();
|
|
109
|
-
Logger.debug(`Unzipped ${filePath} to ${dest}`);
|
|
110
|
-
res();
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
catch (err) {
|
|
114
|
-
rej(err);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
export function useTmpDirectory() {
|
|
119
|
-
return new Promise((res, rej) => {
|
|
120
|
-
tmp.dir({ unsafeCleanup: true }, (err, path, clear) => {
|
|
121
|
-
if (err) {
|
|
122
|
-
return rej(err);
|
|
123
|
-
}
|
|
124
|
-
Logger.debug(`Created the temporary directory: ${path}`);
|
|
125
|
-
if (import.meta.env?.VITEST) {
|
|
126
|
-
return res([path, () => { }]);
|
|
127
|
-
}
|
|
128
|
-
const callback = () => {
|
|
129
|
-
// clear function doesn't work well?
|
|
130
|
-
// clear();
|
|
131
|
-
removeSync(path);
|
|
132
|
-
};
|
|
133
|
-
registerExitHandler(`Removing the temporary directory: ${path}`, callback);
|
|
134
|
-
res([path, callback]);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
export function touchTmpFile(path) {
|
|
139
|
-
fs.mkdirSync(upath.dirname(path), { recursive: true });
|
|
140
|
-
// Create file if not exist
|
|
141
|
-
fs.closeSync(fs.openSync(path, 'a'));
|
|
142
|
-
Logger.debug(`Created the temporary file: ${path}`);
|
|
143
|
-
const callback = () => {
|
|
144
|
-
removeSync(path);
|
|
145
|
-
};
|
|
146
|
-
registerExitHandler(`Removing the temporary file: ${path}`, callback);
|
|
147
|
-
return callback;
|
|
148
|
-
}
|
|
149
|
-
export function pathEquals(path1, path2) {
|
|
150
|
-
return upath.relative(path1, path2) === '';
|
|
151
|
-
}
|
|
152
|
-
export function pathContains(parentPath, childPath) {
|
|
153
|
-
const rel = upath.relative(parentPath, childPath);
|
|
154
|
-
return rel !== '' && !rel.startsWith('..');
|
|
155
|
-
}
|
|
156
|
-
export function isValidUri(str) {
|
|
157
|
-
return /^(https?|file|data):/i.test(str);
|
|
158
|
-
}
|
|
159
|
-
export function isInContainer() {
|
|
160
|
-
return fs.existsSync('/opt/vivliostyle-cli/.vs-cli-version');
|
|
161
|
-
}
|
|
162
|
-
export async function openEpub(epubPath, tmpDir) {
|
|
163
|
-
await inflateZip(epubPath, tmpDir);
|
|
164
|
-
Logger.debug(`Created the temporary EPUB directory: ${tmpDir}`);
|
|
165
|
-
const deleteEpub = () => {
|
|
166
|
-
fs.rmSync(tmpDir, { recursive: true });
|
|
167
|
-
};
|
|
168
|
-
registerExitHandler(`Removing the temporary EPUB directory: ${tmpDir}`, deleteEpub);
|
|
169
|
-
return deleteEpub;
|
|
170
|
-
}
|
|
171
|
-
export function getDefaultEpubOpfPath(epubDir) {
|
|
172
|
-
const containerXmlPath = upath.join(epubDir, 'META-INF/container.xml');
|
|
173
|
-
const xmlParser = new XMLParser({
|
|
174
|
-
ignoreAttributes: false,
|
|
175
|
-
});
|
|
176
|
-
const { container } = xmlParser.parse(fs.readFileSync(containerXmlPath, 'utf8'));
|
|
177
|
-
const rootfile = [container.rootfiles.rootfile].flat()[0]; // Only supports a default rendition
|
|
178
|
-
const epubOpfPath = upath.join(epubDir, rootfile['@_full-path']);
|
|
179
|
-
return epubOpfPath;
|
|
180
|
-
}
|
|
181
|
-
export function getEpubRootDir(epubOpfPath) {
|
|
182
|
-
function traverse(dir) {
|
|
183
|
-
const files = fs.readdirSync(dir);
|
|
184
|
-
if (files.includes('META-INF') &&
|
|
185
|
-
pathEquals(epubOpfPath, getDefaultEpubOpfPath(dir))) {
|
|
186
|
-
return dir;
|
|
187
|
-
}
|
|
188
|
-
const next = upath.dirname(dir);
|
|
189
|
-
if (pathEquals(dir, next)) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
return traverse(next);
|
|
193
|
-
}
|
|
194
|
-
return traverse(upath.dirname(epubOpfPath));
|
|
195
|
-
}
|
|
196
|
-
// FIXME: https://github.com/ajv-validator/ajv/issues/2047
|
|
197
|
-
const Ajv = AjvModule.default;
|
|
198
|
-
const addFormats = AjvFormatsModule.default;
|
|
199
|
-
const getAjvValidatorFunction = (schema, refSchemas) => (obj) => {
|
|
200
|
-
const ajv = new Ajv({ strict: false });
|
|
201
|
-
addFormats(ajv);
|
|
202
|
-
if (refSchemas) {
|
|
203
|
-
ajv.addSchema(refSchemas);
|
|
204
|
-
}
|
|
205
|
-
const validate = ajv.compile(schema);
|
|
206
|
-
const valid = validate(obj);
|
|
207
|
-
if (!valid) {
|
|
208
|
-
throw validate.errors?.[0] || new Error();
|
|
209
|
-
}
|
|
210
|
-
return true;
|
|
211
|
-
};
|
|
212
|
-
export const assertPubManifestSchema = getAjvValidatorFunction(publicationSchema, publicationSchemas);
|
|
213
|
-
export function parseJsonc(rawJsonc) {
|
|
214
|
-
const ast = parse(rawJsonc, {
|
|
215
|
-
mode: 'jsonc',
|
|
216
|
-
ranges: false,
|
|
217
|
-
tokens: false,
|
|
218
|
-
});
|
|
219
|
-
return evaluate(ast);
|
|
220
|
-
}
|
|
221
|
-
export function prettifySchemaError(rawJsonc, issues) {
|
|
222
|
-
const parsed = parse(rawJsonc, {
|
|
223
|
-
mode: 'jsonc',
|
|
224
|
-
ranges: false,
|
|
225
|
-
tokens: false,
|
|
226
|
-
});
|
|
227
|
-
// Traverse to the deepest issue
|
|
228
|
-
function traverse(issues, depth) {
|
|
229
|
-
return issues.flatMap((issue) => {
|
|
230
|
-
const p = issue.path?.length || 0;
|
|
231
|
-
if (!issue.issues) {
|
|
232
|
-
return [[[issue], depth + p]];
|
|
233
|
-
}
|
|
234
|
-
return traverse(issue.issues, depth + p).map(([i, d]) => [
|
|
235
|
-
[issue, ...i],
|
|
236
|
-
d,
|
|
237
|
-
]);
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
const all = traverse(issues, 0);
|
|
241
|
-
const maxDepth = Math.max(...all.map(([, d]) => d));
|
|
242
|
-
const issuesTraversed = all.find(([, d]) => d === maxDepth)[0];
|
|
243
|
-
let jsonValue = parsed.body;
|
|
244
|
-
for (const p of issuesTraversed.flatMap((v) => v.path ?? [])) {
|
|
245
|
-
let childValue;
|
|
246
|
-
if (p.type === 'object' && jsonValue.type === 'Object') {
|
|
247
|
-
childValue = jsonValue.members.find((m) => (m.name.type === 'Identifier' && m.name.name === p.key) ||
|
|
248
|
-
(m.name.type === 'String' && m.name.value === p.key))?.value;
|
|
249
|
-
}
|
|
250
|
-
if (p.type === 'array' && jsonValue.type === 'Array') {
|
|
251
|
-
childValue = jsonValue.elements[p.key]?.value;
|
|
252
|
-
}
|
|
253
|
-
if (childValue) {
|
|
254
|
-
jsonValue = childValue;
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
break;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
let message = `${red(issuesTraversed.at(-1).message)}`;
|
|
261
|
-
if (jsonValue) {
|
|
262
|
-
message += `\n${codeFrameColumns(rawJsonc, jsonValue.loc, {
|
|
263
|
-
highlightCode: true,
|
|
264
|
-
})}`;
|
|
265
|
-
}
|
|
266
|
-
return message;
|
|
267
|
-
}
|
|
268
|
-
export function writeFileIfChanged(filePath, content) {
|
|
269
|
-
if (!fs.existsSync(filePath) || !fs.readFileSync(filePath).equals(content)) {
|
|
270
|
-
fs.mkdirSync(upath.dirname(filePath), { recursive: true });
|
|
271
|
-
fs.writeFileSync(filePath, content);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
//# sourceMappingURL=util.js.map
|