Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antora/site-generator-default

Package Overview
Dependencies
Maintainers
2
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antora/site-generator-default - npm Package Compare versions

Comparing version 3.0.0-beta.1 to 3.0.0-beta.2

9

lib/generate-site.js

@@ -7,5 +7,5 @@ 'use strict'

async function generateSite (playbook) {
const context = new GeneratorContext(module)
try {
const context = new GeneratorContext(playbook, module)
const { fxns, vars } = context
const { fxns, vars } = await GeneratorContext.start(context, playbook)
await context.notify('playbookBuilt')

@@ -59,3 +59,6 @@ playbook = vars.lock('playbook')

} catch (err) {
if (!GeneratorContext.isHaltSignal(err)) throw err
if (!GeneratorContext.isStopSignal(err)) throw err
await err.notify()
} finally {
await GeneratorContext.close(context)
}

@@ -62,0 +65,0 @@ }

@@ -23,4 +23,7 @@ 'use strict'

class HaltSignal extends Error {}
const FUNCTION_WITH_POSITIONAL_PARAMETER_RX = /^(?:function *)?(?:\w+ *)?\( *\w|^\w+(?: *, *\w+)* *=>/
const NEWLINES_RX = /\r?\n/g
class StopSignal extends Error {}
class GeneratorContext extends EventEmitter {

@@ -30,8 +33,7 @@ #fxns

constructor (playbook, module_) {
constructor (module_) {
super()
// deprecated method aliases - remove for Antora 3.0.0
Object.defineProperties(this, { halt: { value: this.stop }, updateVars: { value: this.updateVariables } })
if (!('path' in (this.module = module_))) module_.path = require('path').dirname(module_.filename)
this._registerFunctions(module_)
this._registerExtensions(playbook, this._initVariables(playbook), module_)
Object.defineProperties(this, { _initVariables: {}, _registerExtensions: {}, _registerFunctions: {} })
}

@@ -51,6 +53,2 @@

halt () {
throw new HaltSignal()
}
async notify (eventName) {

@@ -66,3 +64,3 @@ if (!this.listenerCount(eventName)) return

const fxns = this.#fxns
Object.entries(updates).map(([name, fxn]) => {
Object.entries(updates).forEach(([name, fxn]) => {
if (name in fxns) fxns[name] = fxn.bind(this)

@@ -76,2 +74,7 @@ })

stop (code) {
if (code != null) process.exitCode = code
throw Object.assign(new StopSignal(), { notify: this.notify.bind(this, 'contextStopped') })
}
updateVariables (updates) {

@@ -88,35 +91,43 @@ try {

// TODO remove updateVars before Antora 3.0.0
updateVars (updates) {
return this.updateVariables(updates)
static async close (instance) {
await instance.notify('contextClosed').catch(() => undefined)
}
static isHaltSignal (err) {
return err instanceof HaltSignal
static isStopSignal (err) {
return err instanceof StopSignal
}
static async start (instance, playbook) {
const returnValue = instance._init(playbook)
await instance.notify('contextStarted')
return returnValue
}
_init (playbook) {
this._registerFunctions()
this._registerExtensions(playbook, this._initVariables(playbook))
Object.defineProperties(this, { _init: {}, _initVariables: {}, _registerExtensions: {}, _registerFunctions: {} })
return { fxns: this.#fxns, vars: this.#vars }
}
_initVariables (playbook) {
Object.defineProperty(this, 'vars', {
configurable: true,
get: () => {
delete this.vars
return Object.setPrototypeOf(this.#vars, {
lock (name) {
return Object.defineProperty(this, name, { configurable: false, writable: false })[name]
},
remove (name) {
const currentValue = this[name]
delete this[name]
return currentValue
},
})
},
})
return (this.#vars = { playbook })
return (this.#vars = Object.setPrototypeOf(
{ playbook },
{
lock (name) {
return Object.defineProperty(this, name, { configurable: false, writable: false })[name]
},
remove (name) {
const currentValue = this[name]
delete this[name]
return currentValue
},
}
))
}
_registerExtensions (playbook, vars, module_) {
_registerExtensions (playbook, vars) {
const extensions = (playbook.antora || {}).extensions || []
if (extensions.length) {
const requireContext = { dot: playbook.dir, paths: [playbook.dir || '', module_.path] }
const requireContext = { dot: playbook.dir, paths: [playbook.dir || '', this.module.path] }
extensions.forEach((ext) => {

@@ -128,3 +139,3 @@ const { enabled = true, id, require: request, ...config } = ext.constructor === String ? { require: ext } : ext

if (register.length) {
if (/^(?:function *)?(?:\w+ *)?\( *\w|^\w+(?: *, *\w+)* *=>/.test(register.toString().replace(/\r?\n/g, ' '))) {
if (FUNCTION_WITH_POSITIONAL_PARAMETER_RX.test(register.toString().replace(NEWLINES_RX, ' '))) {
register.length === 1 ? register(this) : register(this, Object.assign({ config }, vars))

@@ -139,6 +150,8 @@ } else {

}
this.notify = this.eventNames().length ? this.notify.bind(this) : async () => undefined
if (this.eventNames().length) return
const notify = async () => undefined
Object.defineProperty(this, 'notify', { value: notify })
}
_registerFunctions (module_) {
_registerFunctions () {
this.#fxns = Object.entries(

@@ -150,3 +163,3 @@ Object.entries(FUNCTION_PROVIDERS).reduce((accum, [fxnName, moduleKey]) => {

).reduce((accum, [moduleKey, fxnNames]) => {
const defaultExport = module_.require('@antora/' + moduleKey)
const defaultExport = this.require('@antora/' + moduleKey)
const defaultExportName = defaultExport.name

@@ -159,9 +172,2 @@ fxnNames.forEach((fxnName) => {

}, {})
Object.defineProperty(this, 'fxns', {
configurable: true,
get: () => {
delete this.fxns
return this.#fxns
},
})
}

@@ -168,0 +174,0 @@ }

{
"name": "@antora/site-generator-default",
"version": "3.0.0-beta.1",
"version": "3.0.0-beta.2",
"description": "The default site generator for producing and publishing static documentation sites with Antora.",

@@ -18,17 +18,17 @@ "license": "MPL-2.0",

"dependencies": {
"@antora/asciidoc-loader": "3.0.0-beta.1",
"@antora/content-aggregator": "3.0.0-beta.1",
"@antora/content-classifier": "3.0.0-beta.1",
"@antora/document-converter": "3.0.0-beta.1",
"@antora/logger": "3.0.0-beta.1",
"@antora/navigation-builder": "3.0.0-beta.1",
"@antora/page-composer": "3.0.0-beta.1",
"@antora/redirect-producer": "3.0.0-beta.1",
"@antora/site-mapper": "3.0.0-beta.1",
"@antora/site-publisher": "3.0.0-beta.1",
"@antora/ui-loader": "3.0.0-beta.1",
"@antora/asciidoc-loader": "3.0.0-beta.2",
"@antora/content-aggregator": "3.0.0-beta.2",
"@antora/content-classifier": "3.0.0-beta.2",
"@antora/document-converter": "3.0.0-beta.2",
"@antora/logger": "3.0.0-beta.2",
"@antora/navigation-builder": "3.0.0-beta.2",
"@antora/page-composer": "3.0.0-beta.2",
"@antora/redirect-producer": "3.0.0-beta.2",
"@antora/site-mapper": "3.0.0-beta.2",
"@antora/site-publisher": "3.0.0-beta.2",
"@antora/ui-loader": "3.0.0-beta.2",
"@antora/user-require-helper": "~2.0"
},
"devDependencies": {
"@antora/playbook-builder": "3.0.0-beta.1"
"@antora/playbook-builder": "3.0.0-beta.2"
},

@@ -50,3 +50,3 @@ "engines": {

],
"gitHead": "7c5ef1ea93dd489af533c80a936c736013c41769"
"gitHead": "5cd3f9cc70622e465cb44daf1aa2035ed5a35f54"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc