bajo 2.13.1 → 2.14.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/class/bajo.js CHANGED
@@ -850,7 +850,7 @@ class Bajo extends Plugin {
850
850
  const { parseObject } = this.app.lib
851
851
  const { defaultsDeep } = this.app.lib.aneka
852
852
  const { uniq, isString, isArray, findIndex, isPlainObject, merge } = this.app.lib._
853
- let { ns, baseNs, extend, checkOverride, merge: merged, pattern, ignoreError = true, defValue = {}, parserOpts = {}, globOpts = {} } = options
853
+ let { ns, baseNs, extend, checkOverride, merge: merged, pattern, ignoreError = true, defValue = {}, parserOpts = {}, globOpts = {}, handler } = options
854
854
 
855
855
  const getParseOptsArgs = (opts, orig) => {
856
856
  opts.parserOpts = opts.parserOpts ?? {}
@@ -864,7 +864,10 @@ class Bajo extends Plugin {
864
864
 
865
865
  const output = async (obj) => {
866
866
  let orig = parseObject(obj)
867
- if (!baseNs || extend === false) return orig
867
+ if (!baseNs || extend === false) {
868
+ await this.runHook('bajo:afterReadConfig', file, orig, options)
869
+ return orig
870
+ }
868
871
  const { suffix = '', keys = [] } = options
869
872
  let bases = this.app.getAllNs()
870
873
  if (isString(extend)) extend = extend.split(',').map(i => i.trim)
@@ -882,24 +885,32 @@ class Bajo extends Plugin {
882
885
  if (checkOverride) {
883
886
  getParseOptsArgs(opts, orig)
884
887
  const fileExt = `${this.app.main.dir.pkg}/extend/${baseNs}/override/${ns}${suffix}/${_path}`
888
+ await this.runHook('bajo.override:beforeReadConfig', fileExt, options)
885
889
  const result = parseObject(await this.readConfig(fileExt, { ...opts, extend: false, checkOverride: false, merge: false }))
890
+ await this.runHook('bajo.override:afterReadConfig', fileExt, result, options)
886
891
  if (!isEmpty(result)) orig = result
887
892
  }
888
893
  getParseOptsArgs(opts, orig)
889
894
  const binder = merged ? merge : defaultsDeep
890
895
  for (const base of bases) {
891
896
  if (!this.app[base]) continue
897
+ options.sourceNs = base
892
898
  const fileExt = `${this.app[base].dir.pkg}/extend/${baseNs}/extend/${ns}${suffix}/${_path}`
899
+ await this.runHook('bajo.extend:beforeReadConfig', fileExt, options)
893
900
  const result = parseObject(await this.readConfig(fileExt, { ...opts, extend: false, merge: false }))
901
+ await this.runHook('bajo.extend:afterReadConfig', fileExt, result, options)
894
902
  if (isEmpty(result)) continue
895
903
  if (isArray(result)) ext = [...result, ...ext]
896
904
  else ext = binder({}, result, ext)
897
905
  }
898
- if (isArray(orig)) return [...orig, ...ext]
899
- const item = keys.length > 0 ? pick(ext, keys) : ext
900
- return binder({}, item, orig)
906
+ delete options.sourceNs
907
+ let result = isArray(orig) ? [...orig, ...ext] : binder({}, keys.length > 0 ? pick(ext, keys) : ext, orig)
908
+ if (handler) result = await this.callHandler(this.app[ns], handler, result)
909
+ await this.runHook('bajo:afterReadConfig', file, result, options)
910
+ return result
901
911
  }
902
912
 
913
+ await this.runHook('bajo:beforeReadConfig', file, options)
903
914
  parserOpts.readFromFile = true
904
915
  if (!ns) ns = this.ns
905
916
  file = resolvePath(this.getPluginFile(file))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "2.13.1",
3
+ "version": "2.14.0",
4
4
  "description": "The ultimate framework for whipping up massive apps in no time",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-05-16
4
+
5
+ - [2.14.0] Add ```bajo:beforeReadConfig()``` hook
6
+ - [2.14.0] Add ```bajo.override:beforeReadConfig()``` hook
7
+ - [2.14.0] Add ```bajo.extend:beforeReadConfig()``` hook
8
+ - [2.14.0] Add ```bajo:afterReadConfig()``` hook
9
+ - [2.14.0] Add ```bajo.override:afterReadConfig()``` hook
10
+ - [2.14.0] Add ```bajo.extend:afterReadConfig()``` hook
11
+
3
12
  ## 2026-05-02
4
13
 
5
14
  - [2.13.1] Bug fix in ```app.t()```