@voxgig/model 11.1.0 → 12.0.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/dist/watch.js CHANGED
@@ -8,6 +8,7 @@ exports.Watch = void 0;
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const build_1 = require("./build");
10
10
  const chokidar_1 = require("chokidar");
11
+ const node_fs_1 = require("node:fs");
11
12
  const promises_1 = require("fs/promises");
12
13
  class Watch {
13
14
  constructor(bspec, log) {
@@ -60,16 +61,12 @@ class Watch {
60
61
  }
61
62
  // Check if there have been no recent changes, if so, run build.
62
63
  this.intervalId = setInterval(() => {
63
- // const start = this.startTime
64
64
  const now = Date.now();
65
65
  const idleDuration = now - this.lastChange.when;
66
66
  // Only trigger a build if there was an actual change
67
67
  const trigger = this.lastChange.when !== this.lastTrigger.when; // &&
68
68
  // this.lastChange.path !== this.lastTrigger.path
69
69
  if (trigger) {
70
- // Only add to build queue if we've been idle.
71
- // This allows external compilation outputting multiple files to complete fully.
72
- // IMPORTANT: always trigger a new build if there were changes *inside* a build period
73
70
  if (this.idle < idleDuration) {
74
71
  this.lastTrigger.path = this.lastChange.path;
75
72
  this.lastTrigger.when = this.lastChange.when;
@@ -144,9 +141,10 @@ class Watch {
144
141
  for (const target of Object.keys(build.deps)) {
145
142
  files.push(...Object.keys(build.deps[target]));
146
143
  }
147
- // TODO: remove deleted files
148
144
  for (const file of files) {
149
- if ('string' === typeof file && '' !== file && build.opts.base !== file) {
145
+ // A dry run's in-memory config is not on disk to be watched.
146
+ if ('string' === typeof file && '' !== file && build.opts.base !== file &&
147
+ (0, node_fs_1.existsSync)(file)) {
150
148
  await this.add(file);
151
149
  }
152
150
  }
package/dist/watch.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"watch.js","sourceRoot":"","sources":["../src/watch.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;;;;AAEpD,0DAA4B;AAc5B,mCAAmC;AACnC,uCAAo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C;CACF;QAIC,KAAK"}
@@ -8,8 +8,6 @@ sys: shape: type({})
8
8
  # Service base has no defaults.
9
9
  sys: shape: srv: base: {
10
10
  in: {
11
- # TODO: validate leaf?
12
- # &&: => &:, &: &:, &: &: &:, etc
13
11
  }
14
12
  out: {}
15
13
  deps: {
@@ -20,7 +18,7 @@ sys: shape: srv: base: {
20
18
  path: {
21
19
  prefix?: string
22
20
  area?: string
23
- suffix?: string
21
+ suffix?: string
24
22
  }
25
23
  method: string
26
24
  cors: {
@@ -38,7 +36,6 @@ sys: shape: srv: base: {
38
36
  }
39
37
 
40
38
 
41
- # Shared service defaults
42
39
  sys: shape: srv: std: $.sys.shape.srv.base & {
43
40
  api: web: {
44
41
  active: *true | boolean
@@ -91,36 +88,15 @@ sys: shape: ent: {
91
88
  }
92
89
  }
93
90
 
94
- # sys: shape: ent: field: &: {
95
- # active: *true | boolean
96
- # kind: *'Text' | string
97
- # title: string
98
-
99
- # # Developer model (backend)
100
- # dx: {}
101
91
 
102
- # # User inerface model (frontend)
103
- # ux: {
104
- # desc: string
105
- # }
106
- # }
107
92
 
108
93
 
109
94
 
110
- # App Shapes
111
- # --------------
95
+
112
96
 
113
97
  sys: shape: app: {
114
98
  name: string
115
99
  layout: string
116
- # TODO: test
117
- # parts: {
118
- # &: {
119
- # part: string
120
- # active: boolean
121
- # # active: *true | boolean
122
- # }
123
- # }
124
100
  }
125
101
 
126
102
  sys: shape: part: img: {
@@ -128,29 +104,5 @@ sys: shape: part: img: {
128
104
  svg: string
129
105
  }
130
106
 
131
-
132
- # app: web: basic: .sys.shape.app
133
-
134
- # app: web: basic: {
135
- # name: basic
136
- # layout: BasicAdmin
137
- # }
138
-
139
- # app: web: basic: parts: {
140
- # head: {
141
- # part: BasicHead
142
- # }
143
-
144
- # side: {
145
- # part: BasicSide
146
- # }
147
-
148
- # main: {
149
- # part: BasicMain
150
- # }
151
-
152
- # foot: {
153
- # part: BasicFoot
154
- # }
155
- # }
156
107
 
108
+ # app: web: basic: .sys.shape.app
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxgig/model",
3
- "version": "11.1.0",
3
+ "version": "12.0.0",
4
4
  "main": "dist/model.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/model.d.ts",
@@ -19,14 +19,14 @@
19
19
  "url": "git://github.com/voxgig/model.git"
20
20
  },
21
21
  "scripts": {
22
- "test": "node --test --experimental-test-coverage --test-coverage-include='dist/**' --test-coverage-lines=95 --test-coverage-functions=95 --test-coverage-branches=90 \"dist-test/**/*.test.js\"",
22
+ "test": "node ../tools/comment-gate.cjs && node --test --experimental-test-coverage --test-coverage-include='dist/**' --test-coverage-lines=95 --test-coverage-functions=95 --test-coverage-branches=90 \"dist-test/**/*.test.js\"",
23
23
  "test-some": "node --enable-source-maps --test-name-pattern=\"$TEST_PATTERN\" --test dist-test/**/*.test.js",
24
24
  "test-cov": "rm -rf ./coverage && mkdir -p ./coverage && node --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --enable-source-maps --test \"dist-test/*.test.js\"",
25
25
  "watch": "tsc --build src test -w",
26
26
  "build": "tsc --build src test",
27
- "test-model": "voxgig-model test/sys01/model/model.aon",
28
- "model": "voxgig-model -w model/sys.aon",
29
- "model-build": "voxgig-model -g debug model/sys.aon",
27
+ "test-model": "voxgig-model test/sys01/model/model.aontu",
28
+ "model": "voxgig-model -w model/sys.aontu",
29
+ "model-build": "voxgig-model -g debug model/sys.aontu",
30
30
  "clean": "rm -rf node_modules dist dist-test yarn.lock package-lock.json",
31
31
  "reset": "npm run clean && npm i && npm run build && npm test",
32
32
  "repo-bump": "npm version patch --no-git-tag-version && node -e \"console.log('bumped to v' + require('./package.json').version + ' (package.json only - commit via repo-tag / repo-release)')\"",
@@ -55,9 +55,9 @@
55
55
  "LICENSE"
56
56
  ],
57
57
  "dependencies": {
58
- "@tabnas/jsonic": "0.6.2",
59
- "@tabnas/parser": "0.8.7",
60
- "aontu": "0.53.0",
58
+ "@tabnas/jsonic": ">=0.7.1",
59
+ "@tabnas/parser": ">=0.12.2",
60
+ "aontu": ">=0.75.0",
61
61
  "chokidar": "5.0.0",
62
62
  "memfs": "4.64.0",
63
63
  "shape": ">=10"
package/src/build.ts CHANGED
@@ -81,10 +81,6 @@ class BuildImpl implements Build {
81
81
  let hasErr = false
82
82
  let runlog = []
83
83
 
84
- // Reset per-run error state. The BuildImpl is reused across watch
85
- // rebuilds, so without this a single failure would stick to every
86
- // later build. Reassign (don't clear in place) so a previously
87
- // returned BuildResult keeps its own errors.
88
84
  this.errs = []
89
85
 
90
86
  this.ctx = { step: 'pre', state: {}, watch: rspec.watch }
@@ -117,8 +113,6 @@ class BuildImpl implements Build {
117
113
  }
118
114
  }
119
115
 
120
- // Only reload when a pre-producer actually modified model sources
121
- // (signalled via pr.reload). Previously this always ran on success.
122
116
  const reload = forceReload && !hasErr
123
117
 
124
118
  if (reload) {
@@ -150,7 +144,6 @@ class BuildImpl implements Build {
150
144
 
151
145
  const br: BuildResult =
152
146
  {
153
- // TODO: remove need for this
154
147
  build: () => this,
155
148
 
156
149
  ok: !hasErr,
package/src/config.ts CHANGED
@@ -1,19 +1,45 @@
1
1
  /* Copyright © 2021-2025 Voxgig Ltd, MIT License. */
2
2
 
3
3
 
4
+ import Path from 'node:path'
5
+
4
6
  import type { BuildResult, BuildSpec, Log } from './types'
5
7
 
6
8
  import { Watch } from './watch'
7
9
 
8
10
 
11
+ const CONFIG_FILE = 'model-config.aontu'
12
+ const LEGACY_CONFIG_FILE = 'model-config.aon'
13
+
14
+ const DEFAULT_CONFIG = `
15
+ @"@voxgig/model/model/.model-config/model-config.aontu"
16
+
17
+ sys: model: action: {}
18
+ `
19
+
20
+ const QUOTES = '"\'`'
21
+ const SPACE = ' \t\r\n'
22
+
23
+
24
+
25
+ // What the Model prepared before the config build: a failure to report, or,
26
+ // for a dry run, the config text to serve and the legacy file it comes from.
27
+ type ConfigPrep = {
28
+ err?: Error
29
+ text?: () => string
30
+ from?: string
31
+ }
32
+
9
33
 
10
34
  class Config {
11
35
  build: BuildSpec
12
36
  watch: Watch
13
37
  log: Log
38
+ prep: ConfigPrep
14
39
 
15
- constructor(spec: BuildSpec, log: Log) {
40
+ constructor(spec: BuildSpec, log: Log, prep: ConfigPrep = {}) {
16
41
  this.log = log
42
+ this.prep = prep
17
43
 
18
44
  this.build = {
19
45
  path: spec.path,
@@ -30,7 +56,14 @@ class Config {
30
56
  }
31
57
 
32
58
  async run(watch: boolean): Promise<BuildResult> {
33
- return this.watch.run('config', watch, '<config>')
59
+ if (this.prep.err) {
60
+ return { ok: false, errs: [this.prep.err], runlog: [] }
61
+ }
62
+ const br = await this.watch.run('config', watch, '<config>')
63
+ if (watch && this.prep.from) {
64
+ await this.watch.add(this.prep.from)
65
+ }
66
+ return br
34
67
  }
35
68
 
36
69
  async start(initial: boolean = true) {
@@ -43,7 +76,191 @@ class Config {
43
76
  }
44
77
 
45
78
 
46
- export { Config, BuildSpec }
79
+ // Creates the config when there is none, migrating a legacy
80
+ // model-config.aon forward if one is present. A dry run writes nothing: the
81
+ // config text is derived afresh from its source on every read instead.
82
+ function prepareConfig(
83
+ fs: any, cbase: string, log: Log, dryrun?: boolean
84
+ ): ConfigPrep {
85
+ const cpath = cbase + '/' + CONFIG_FILE
86
+ const legacy = cbase + '/' + LEGACY_CONFIG_FILE
87
+
88
+ if (fs.existsSync(cpath)) {
89
+ if (fs.existsSync(legacy)) {
90
+ log.warn({
91
+ point: 'config-legacy-ignored', legacy,
92
+ note: 'ignoring ' + legacy + ': ' + cpath + ' takes precedence'
93
+ })
94
+ }
95
+ return {}
96
+ }
97
+
98
+ let old: string | undefined
99
+ try {
100
+ old = fs.readFileSync(legacy, 'utf8')
101
+ }
102
+ catch (err: any) {
103
+ if ('ENOENT' !== err?.code) {
104
+ return { err: configError('cannot read ' + legacy, err) }
105
+ }
106
+ }
107
+
108
+ if (null != old) {
109
+ log.info({
110
+ point: 'config-migrate', legacy, path: cpath,
111
+ note: 'migrated ' + legacy + ' to ' + cpath +
112
+ (dryrun ? ' (dry run: in memory only)' : '')
113
+ })
114
+ }
115
+
116
+ if (dryrun) {
117
+ return null == old ? { text: () => DEFAULT_CONFIG } : {
118
+ text: () => rewriteAonIncludes(fs.readFileSync(legacy, 'utf8')),
119
+ from: legacy,
120
+ }
121
+ }
122
+
123
+ try {
124
+ fs.mkdirSync(cbase, { recursive: true })
125
+ writeAtomic(fs, cpath, null == old ? DEFAULT_CONFIG : rewriteAonIncludes(old))
126
+ }
127
+ catch (err: any) {
128
+ return { err: configError('cannot write ' + cpath, err) }
129
+ }
130
+
131
+ if (null != old) {
132
+ try { fs.unlinkSync(legacy) } catch (_err: any) { }
133
+ }
134
+
135
+ return {}
136
+ }
137
+
138
+
139
+ function configError(what: string, cause: any): Error {
140
+ return Object.assign(
141
+ new Error('model config: ' + what + ': ' + (cause?.message || cause)),
142
+ { code: cause?.code, cause })
143
+ }
144
+
145
+
146
+ // A reader never sees a partial file: the text lands beside the target and
147
+ // is renamed over it.
148
+ function writeAtomic(fs: any, path: string, src: string) {
149
+ const tmp = path + '.' + process.pid + '.' +
150
+ Math.random().toString(36).slice(2) + '.tmp'
151
+ try {
152
+ fs.writeFileSync(tmp, src)
153
+ fs.renameSync(tmp, path)
154
+ }
155
+ catch (err: any) {
156
+ try { fs.unlinkSync(tmp) } catch (_err: any) { }
157
+ throw err
158
+ }
159
+ }
160
+
161
+
162
+ // A dry run writes nothing, so its config is served from memory, derived on
163
+ // each read; its mtime is that of the legacy source, so an edit there
164
+ // invalidates the build cache. Matched by resolved path: callers join with
165
+ // '/', which a Windows path does not spell the same way.
166
+ function readBack(fs: any, path: string, text: () => string, from?: string) {
167
+ const at = Path.resolve(path)
168
+ const mtimeMs = Date.now()
169
+ const mine = (p: any) => Path.resolve(String(p)) === at
170
+
171
+ return {
172
+ ...fs,
173
+ readFileSync: (p: any, opts?: any) => {
174
+ if (!mine(p)) {
175
+ return fs.readFileSync(p, opts)
176
+ }
177
+ const enc = 'string' === typeof opts ? opts : opts?.encoding
178
+ const src = text()
179
+ return null == enc ? Buffer.from(src) : src
180
+ },
181
+ statSync: (p: any, ...rest: any[]) => !mine(p) ? fs.statSync(p, ...rest) :
182
+ from ? fs.statSync(from, ...rest) :
183
+ { mtimeMs, isFile: () => true, isDirectory: () => false },
184
+ }
185
+ }
186
+
187
+
188
+ // Points each include of a .aon file at its .aontu successor. Strings and
189
+ // comments are skipped, so a path held as data or commented out is kept.
190
+ function rewriteAonIncludes(src: string): string {
191
+ let out = ''
192
+ let i = 0
193
+
194
+ while (i < src.length) {
195
+ const c = src[i]
196
+ let end = i + 1
197
+ let retarget = false
198
+
199
+ if ('#' === c) {
200
+ end = src.indexOf('\n', i)
201
+ end = -1 === end ? src.length : end
202
+ }
203
+ else if (QUOTES.includes(c)) {
204
+ end = stringEnd(src, i).end
205
+ }
206
+ else if ('@' === c) {
207
+ let q = end
208
+ while (q < src.length && SPACE.includes(src[q])) {
209
+ q++
210
+ }
211
+ if (q < src.length && QUOTES.includes(src[q])) {
212
+ const str = stringEnd(src, q)
213
+ end = str.end
214
+ retarget = str.closed && src.slice(q + 1, end - 1).endsWith('.aon')
215
+ }
216
+ }
217
+
218
+ out += retarget ?
219
+ src.slice(i, end - 1) + 'tu' + src[end - 1] : src.slice(i, end)
220
+ i = end
221
+ }
222
+
223
+ return out
224
+ }
225
+
226
+
227
+ // A string ends at its unescaped closing quote, or, unterminated, at its
228
+ // line; a backtick string may span lines.
229
+ function stringEnd(src: string, start: number): { end: number, closed: boolean } {
230
+ const quote = src[start]
231
+ let i = start + 1
232
+ while (i < src.length) {
233
+ const c = src[i]
234
+ if ('\\' === c) {
235
+ i += 2
236
+ }
237
+ else if (quote === c) {
238
+ return { end: i + 1, closed: true }
239
+ }
240
+ else if ('\n' === c && '`' !== quote) {
241
+ return { end: i, closed: false }
242
+ }
243
+ else {
244
+ i++
245
+ }
246
+ }
247
+ return { end: src.length, closed: false }
248
+ }
249
+
250
+
251
+ export {
252
+ Config,
253
+ BuildSpec,
254
+ CONFIG_FILE,
255
+ LEGACY_CONFIG_FILE,
256
+ prepareConfig,
257
+ readBack,
258
+ rewriteAonIncludes,
259
+ }
260
+
261
+ export type {
262
+ ConfigPrep,
263
+ }
47
264
 
48
265
 
49
266
 
package/src/init.ts CHANGED
@@ -4,9 +4,9 @@ import Path from 'node:path'
4
4
 
5
5
 
6
6
  const STARTER_MODEL = `# Voxgig model. Edit this file, then build it:
7
- # voxgig-model model/model.aon
7
+ # voxgig-model model/model.aontu
8
8
  #
9
- # Models are unified .aon - add types, defaults, references, imports.
9
+ # Models are unified .aontu - add types, defaults, references, imports.
10
10
  # Tutorial: https://github.com/voxgig/model/blob/main/docs/tutorial.md
11
11
 
12
12
  name: 'my-model'
@@ -35,8 +35,8 @@ type InitResult = {
35
35
  function initModel(dir: string, fs: any): InitResult {
36
36
  const d = dir || '.'
37
37
  const files: [string, string][] = [
38
- [Path.join(d, 'model', 'model.aon'), STARTER_MODEL],
39
- [Path.join(d, 'model', '.model-config', 'model-config.aon'), STARTER_CONFIG],
38
+ [Path.join(d, 'model', 'model.aontu'), STARTER_MODEL],
39
+ [Path.join(d, 'model', '.model-config', 'model-config.aontu'), STARTER_CONFIG],
40
40
  ]
41
41
 
42
42
  const created: string[] = []
package/src/model.ts CHANGED
@@ -20,7 +20,7 @@ import type {
20
20
  } from './types'
21
21
 
22
22
 
23
- import { Config } from './config'
23
+ import { Config, CONFIG_FILE, prepareConfig, readBack } from './config'
24
24
  import { Watch } from './watch'
25
25
 
26
26
  import { model_producer } from './producer/model'
@@ -83,10 +83,6 @@ class Model {
83
83
 
84
84
  if (self.trigger_model) {
85
85
 
86
- // TODO: better design
87
- // Point the config's last result at the current build so the model
88
- // producer reads fresh config state. It must be a thunk to satisfy
89
- // BuildResult.build's `() => Build` contract (consumers call it).
90
86
  const lastConfig = self.build.use?.config?.watch?.last
91
87
  if (lastConfig) {
92
88
  lastConfig.build = () => build
@@ -191,50 +187,11 @@ class Model {
191
187
 
192
188
 
193
189
  function makeConfig(mspec: ModelSpec, log: Log, fs: any, trigger_model_build: ProducerDef) {
194
- let cbase = mspec.base + '/.model-config'
195
- let cpath = cbase + '/model-config.aon'
196
-
197
- // MIGRATE A LEGACY .aontu CONFIG RATHER THAN WRITING OVER IT. This block
198
- // CREATES the config when it finds none, so looking only for `.aon` in a
199
- // project that has a `model-config.aontu` would not read the old file — it
200
- // would decide there is no config and write a fresh default beside it,
201
- // silently discarding whatever the project had declared there.
202
- const legacycpath = cbase + '/model-config.aontu'
203
- if (!fs.existsSync(cpath) && fs.existsSync(legacycpath)) {
204
- // NOT A VERBATIM COPY. This package's OWN config moved to .aon in v10, so
205
- // a legacy config's import of it names a file that no longer ships and the
206
- // migrated config fails to resolve - `aontu/multisource_not_found:
207
- // @voxgig/model/model/.model-config/model-config.aontu` - on the first
208
- // build after upgrading. Renaming the file without retargeting that import
209
- // just moves the breakage.
210
- //
211
- // Only THIS package's import is retargeted, and only where it is an
212
- // IMPORT. Two things are deliberately left alone:
213
- //
214
- // - a project's own `.aontu` imports, which still name real files on
215
- // its disk that nothing here renamed;
216
- // - this same pathname held as ordinary string DATA (a note, a
217
- // compatibility path in action metadata).
218
- //
219
- // Hence the match is anchored to aontu's `@"..."` import syntax, closing
220
- // quote included, rather than to the bare pathname. Both are declarations
221
- // the migration exists to preserve, and silently editing one during a
222
- // one-time migration is precisely the failure this whole block guards
223
- // against.
224
- const legacy = fs.readFileSync(legacycpath, 'utf8')
225
- fs.writeFileSync(cpath, legacy.replace(
226
- /@(\s*)"(@voxgig\/model\/[^"]*model-config)\.aontu"/g, '@$1"$2.aon"'))
227
- try { fs.unlinkSync(legacycpath) } catch (_err: any) { }
228
- }
229
-
230
- if (!fs.existsSync(cpath)) {
231
- fs.mkdirSync(cbase, { recursive: true })
232
- fs.writeFileSync(cpath, `
233
- @"@voxgig/model/model/.model-config/model-config.aon"
190
+ const cbase = mspec.base + '/.model-config'
191
+ const cpath = cbase + '/' + CONFIG_FILE
234
192
 
235
- sys: model: action: {}
236
- `)
237
- }
193
+ const prep = prepareConfig(fs, cbase, log, mspec.dryrun)
194
+ const cfs = null == prep.text ? fs : readBack(fs, cpath, prep.text, prep.from)
238
195
 
239
196
  let cspec: BuildSpec = {
240
197
  name: 'config',
@@ -254,10 +211,10 @@ sys: model: action: {}
254
211
  ],
255
212
  require: mspec.require,
256
213
  log,
257
- fs,
214
+ fs: cfs,
258
215
  }
259
216
 
260
- return new Config(cspec, log)
217
+ return new Config(cspec, log, prep)
261
218
  }
262
219
 
263
220
 
@@ -14,12 +14,8 @@ const local_producer: Producer = async (build: Build, ctx: BuildContext) => {
14
14
  if (null == actionDefs) {
15
15
  actionDefs = ctx.state.local.actionDefs = []
16
16
 
17
- // TODO: need to provide project root via build
18
17
  let root = Path.resolve(build.path, '..', '..')
19
18
 
20
- // TODO: build should do this
21
- // Config is optional: with no .model-config build linked in, there are no
22
- // declared actions and the model runs on its own.
23
19
  let configBuildResult = build.use.config?.watch?.last
24
20
  let configBuild = configBuildResult?.build()
25
21
  let config = configBuild?.model || {}
@@ -75,7 +71,6 @@ const local_producer: Producer = async (build: Build, ctx: BuildContext) => {
75
71
 
76
72
  for (let actionDef of runActionDefs) {
77
73
  try {
78
- // TODO: this call signature needs to be well-defined as it is an external interface
79
74
  let ares = await actionDef.action(build.model, build, ctx)
80
75
  ok = ok && (null == ares || !!ares.ok)
81
76
  reload = reload || ares?.reload
@@ -4,17 +4,6 @@ import Path from 'path'
4
4
  import type { Build, Producer, BuildContext, ProducerResult } from '../types'
5
5
 
6
6
 
7
- // Serialize the model to two-space-indented JSON with object keys in strictly
8
- // lexical (UTF-8 byte) order, byte-for-byte identical to the Go
9
- // implementation's encoding/json. JSON.stringify cannot express this: JS
10
- // objects iterate integer-like keys ("9", "10") in numeric order ahead of the
11
- // other keys regardless of insertion order, so the order must be imposed
12
- // during serialization, and the default JS string sort compares UTF-16 code
13
- // units, which disagrees with Go's byte order for astral-plane keys. Arrays
14
- // keep their order. Values only producer mutation can introduce mirror
15
- // JSON.stringify: undefined, functions, and symbols are dropped from objects
16
- // and become null in arrays (sparse holes too), and toJSON results are fed
17
- // back through the canonical serializer.
18
7
  function jsonify(value: any, indent: string): string {
19
8
  if (Array.isArray(value)) {
20
9
  if (0 === value.length) {
@@ -54,9 +43,6 @@ function jsonify(value: any, indent: string): string {
54
43
  }
55
44
 
56
45
 
57
- // JSON.stringify, plus the U+2028/U+2029 escapes Go's encoding/json always
58
- // applies even with HTML escaping off. JSON.stringify emits the separators
59
- // literally (both forms are valid JSON), so escape them here for byte parity.
60
46
  function jstr(value: any): string | undefined {
61
47
  const out = JSON.stringify(value)
62
48
  return undefined === out ? undefined :