bajo 1.0.8 → 1.0.10

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.
@@ -144,8 +144,9 @@
144
144
  "stop": "Stop",
145
145
  "supportDisabled%s": "%s support is disabled",
146
146
  "collect%s": "Collect %s",
147
- "andL": "and",
148
- "orL": "or",
149
- "noneL": "none",
150
- "isRequired%s": "'%s' is required"
147
+ "and": "and",
148
+ "or": "or",
149
+ "none": "none",
150
+ "isRequired%s": "'%s' is required",
151
+ "isDisabled%s": "'%s' is disabled"
151
152
  }
package/bajo/intl/id.json CHANGED
@@ -144,7 +144,9 @@
144
144
  "stop": "Berhentikan",
145
145
  "supportDisabled%s": "Dukungan %s dimatikan",
146
146
  "collect%s": "Koleksi %s",
147
- "andL": "dan",
148
- "orL": "atau",
149
- "noneL": "kosong"
147
+ "and": "dan",
148
+ "or": "atau",
149
+ "none": "kosong",
150
+ "isRequired%s": "'%s' disyaratkan",
151
+ "isDisabled%s": "'%s' dimatikan"
150
152
  }
package/boot/class/app.js CHANGED
@@ -60,9 +60,9 @@ class App {
60
60
  await bootPlugins.call(bajo)
61
61
  await exitHandler.call(bajo)
62
62
  // boot complete
63
- await bajo.runHook('bajo:bootComplete')
64
63
  const elapsed = new Date() - bajo.runAt
65
64
  bajo.log.info('bootCompleted%s', bajo.secToHms(elapsed, true))
65
+ await bajo.runHook('bajo:bootComplete')
66
66
  if (bajo.applet) await runAsApplet.call(bajo)
67
67
  }
68
68
  }
@@ -0,0 +1,15 @@
1
+ function extractText (text, patternStart, patternEnd) {
2
+ let result = ''
3
+ const open = text.indexOf(patternStart)
4
+ if (open > -1) {
5
+ text = text.slice(open + patternStart.length)
6
+ const close = text.indexOf(patternEnd)
7
+ if (close > -1) {
8
+ result = text.slice(0, close)
9
+ }
10
+ }
11
+ const pattern = `${patternStart}${result}${patternEnd}`
12
+ return { result, pattern }
13
+ }
14
+
15
+ export default extractText
@@ -5,6 +5,7 @@ import lodash from 'lodash'
5
5
  const { trim } = lodash
6
6
 
7
7
  function getPluginFile (file) {
8
+ if (!this) return file
8
9
  if (file[0] === '.') file = `${currentLoc(import.meta).dir}/${trim(file.slice(1), '/')}`
9
10
  if (!this) return file
10
11
  if (file.includes(':')) {
@@ -5,13 +5,13 @@ const { isPlainObject } = lodash
5
5
 
6
6
  function join (array, sep) {
7
7
  const translate = val => {
8
- if (this && this.print) return this.print.write(val)
8
+ if (this && this.print) return this.print.write(val).toLowerCase()
9
9
  return val
10
10
  }
11
- if (array.length === 0) return translate('noneL')
11
+ if (array.length === 0) return translate('none')
12
12
  if (array.length === 1) return array[0]
13
13
  if (isSet(sep) && !isPlainObject(sep)) return array.join(sep)
14
- let { separator = ', ', joiner = 'andL' } = sep ?? {}
14
+ let { separator = ', ', joiner = 'and' } = sep ?? {}
15
15
  joiner = translate(joiner)
16
16
  const last = (array.pop() ?? '').trim()
17
17
  return array.map(a => (a + '').trim()).join(separator) + ` ${joiner} ${last}`
@@ -3,7 +3,6 @@ import dotenvParseVariables from 'dotenv-parse-variables'
3
3
  import ms from 'ms'
4
4
  import dayjs from '../../../lib/dayjs.js'
5
5
  import isSet from './is-set.js'
6
- // import translate from '../../../lib/translate.js'
7
6
 
8
7
  const { isPlainObject, isArray, isNumber, set, cloneDeep, isString, omit } = lodash
9
8
  const statics = ['*']
@@ -40,12 +39,8 @@ function parseObject (input, { silent = true, parseValue = false, lang, ns } = {
40
39
  const newK = k.slice(2)
41
40
  if (lang) {
42
41
  const scope = ns ? me.app[ns] : me
43
- let [text, ...args] = v.split('|')
44
- args = args.map(a => {
45
- if (a.slice(0, 2) === 't:') a = scope.print.write(lang, a.slice(2))
46
- return a
47
- })
48
- obj[newK] = scope.print.write(text, lang, ...args)
42
+ const [text, ...args] = v.split('|')
43
+ obj[newK] = scope.print.write(text, ...args, { lang })
49
44
  } else obj[newK] = v
50
45
  mutated.push(k)
51
46
  } else if (parseValue) {
@@ -48,7 +48,7 @@ class BajoError {
48
48
  const val = get(v, 'context.value')
49
49
  value[i] = {
50
50
  field,
51
- error: print.write(`validation.${v.type}`, v.context),
51
+ error: print.write(`validation.${v.type}`, v.context ?? {}, {}),
52
52
  value: val,
53
53
  ext: { type: v.type, context: v.context }
54
54
  }
@@ -35,7 +35,7 @@ class Print {
35
35
  let lang = this.plugin.app.bajo.config.lang
36
36
  if (isPlainObject(opts)) {
37
37
  args.pop()
38
- lang = opts.lang
38
+ if (opts.lang) lang = opts.lang
39
39
  }
40
40
  const { fallback, supported } = this.plugin.app.bajo.config.intl
41
41
  if (!unknownLangWarning && !supported.includes(lang)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {