rebuildjs 0.32.0 → 0.34.2

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/browser/index.js CHANGED
@@ -19,51 +19,52 @@ export const [
19
19
  ] = /** @type {be_lock_memosig_triple_T<rebuildjs_metafile_T>} */
20
20
  be_lock_memosig_triple_(
21
21
  ()=>undefined,
22
- async (ctx, browser__metafile$)=>{
23
- browser__metafile__waitfor_promise?.cancel?.()
24
- if (browser__metafile$.lock) return
25
- nullish__none_([browser__metafile_path_(ctx)],
26
- async browser__metafile_path=>{
27
- try {
28
- if (await cmd(
29
- browser__metafile__waitfor_promise =
30
- file_exists__waitfor(
31
- browser__metafile_path,
32
- 1000,
33
- ()=>cmd(sleep(0))))
34
- ) {
35
- browser__metafile$._ = await cmd(
36
- waitfor(async ()=>{
37
- const buf = await cmd(readFile(browser__metafile_path))
38
- const json = buf + ''
39
- try {
40
- return JSON.parse(json)
41
- } catch {
42
- return undefined
43
- }
44
- }, 1000))
45
- }
46
- } catch (err) {
47
- if (err instanceof Cancel) return
48
- throw err
22
+ { ns: 'app', id: 'browser__metafile' }
23
+ ).add(async (ctx, browser__metafile$)=>{
24
+ browser__metafile__waitfor_promise?.cancel?.()
25
+ if (browser__metafile$.lock) return
26
+ nullish__none_([browser__metafile_path_(ctx)],
27
+ async browser__metafile_path=>{
28
+ try {
29
+ if (await cmd(
30
+ browser__metafile__waitfor_promise =
31
+ file_exists__waitfor(
32
+ browser__metafile_path,
33
+ 1000,
34
+ ()=>cmd(sleep(0))))
35
+ ) {
36
+ browser__metafile$._ = await cmd(
37
+ waitfor(async ()=>{
38
+ const buf = await cmd(readFile(browser__metafile_path))
39
+ const json = buf + ''
40
+ try {
41
+ return JSON.parse(json)
42
+ } catch {
43
+ return undefined
44
+ }
45
+ }, 1000))
49
46
  }
50
- async function cmd(promise) {
51
- if (cancel_()) throw new Cancel()
52
- const rv = await promise
53
- if (cancel_()) {
54
- promise.cancel?.()
55
- throw new Cancel()
56
- }
57
- return rv
58
- }
59
- function cancel_() {
60
- return (
61
- browser__metafile$.lock
62
- || browser__metafile_path !== browser__metafile_path_(ctx)
63
- )
47
+ } catch (err) {
48
+ if (err instanceof Cancel) return
49
+ throw err
50
+ }
51
+ async function cmd(promise) {
52
+ if (cancel_()) throw new Cancel()
53
+ const rv = await promise
54
+ if (cancel_()) {
55
+ promise.cancel?.()
56
+ throw new Cancel()
64
57
  }
65
- })
66
- }, { ns: 'app', id: 'browser__metafile' })
58
+ return rv
59
+ }
60
+ function cancel_() {
61
+ return (
62
+ browser__metafile$.lock
63
+ || browser__metafile_path !== browser__metafile_path_(ctx)
64
+ )
65
+ }
66
+ })
67
+ })
67
68
  export function browser__metafile__persist() {
68
69
  return nullish__none_([
69
70
  browser__metafile_path_(app_ctx),
package/build/index.js CHANGED
@@ -53,58 +53,59 @@ export function build_id__refresh() {
53
53
  export const [
54
54
  persist__metafile__build_id$_,
55
55
  persist__metafile__build_id_,
56
- ] = be_memo_pair_(()=>undefined,
57
- (ctx, persist__metafile__build_id$)=>{
58
- const build_id = build_id_(ctx)
59
- const metafile__build_id = metafile__build_id_(ctx)
60
- const server__metafile_path = server__metafile_path_(ctx)
61
- const browser__metafile_path = browser__metafile_path_(ctx)
62
- if (metafile__build_id) {
63
- const cancel__period = cancel__period_(0, cancel_)
64
- run(async ()=>{
65
- try {
66
- await cmd(
67
- file_exists__waitfor(server__metafile_path, 1000, cancel__period))
68
- await cmd(
69
- waitfor(()=>
70
- readFile(server__metafile_path).then(buf=>
71
- JSON.parse('' + buf)?.build_id === build_id),
72
- 1000,
73
- cancel__period))
74
- await cmd(
75
- file_exists__waitfor(browser__metafile_path, 1000, cancel__period))
76
- await cmd(
77
- waitfor(()=>
78
- readFile(browser__metafile_path).then(buf=>
79
- JSON.parse('' + buf)?.build_id === build_id),
80
- 1000,
81
- cancel__period))
82
- persist__metafile__build_id$._ = build_id
83
- } catch (err) {
84
- if (err instanceof Cancel) return
85
- throw err
86
- }
87
- })
88
- }
89
- async function cmd(promise) {
90
- if (cancel_()) throw new Cancel
91
- const rv = await promise
92
- if (cancel_()) {
93
- promise.cancel?.()
94
- throw new Cancel
56
+ ] = be_memo_pair_(
57
+ ()=>undefined,
58
+ { id: 'persist__metafile__build_id', ns: 'app' }
59
+ ).add((ctx, persist__metafile__build_id$)=>{
60
+ const build_id = build_id_(ctx)
61
+ const metafile__build_id = metafile__build_id_(ctx)
62
+ const server__metafile_path = server__metafile_path_(ctx)
63
+ const browser__metafile_path = browser__metafile_path_(ctx)
64
+ if (metafile__build_id) {
65
+ const cancel__period = cancel__period_(0, cancel_)
66
+ run(async ()=>{
67
+ try {
68
+ await cmd(
69
+ file_exists__waitfor(server__metafile_path, 1000, cancel__period))
70
+ await cmd(
71
+ waitfor(()=>
72
+ readFile(server__metafile_path).then(buf=>
73
+ JSON.parse('' + buf)?.build_id === build_id),
74
+ 1000,
75
+ cancel__period))
76
+ await cmd(
77
+ file_exists__waitfor(browser__metafile_path, 1000, cancel__period))
78
+ await cmd(
79
+ waitfor(()=>
80
+ readFile(browser__metafile_path).then(buf=>
81
+ JSON.parse('' + buf)?.build_id === build_id),
82
+ 1000,
83
+ cancel__period))
84
+ persist__metafile__build_id$._ = build_id
85
+ } catch (err) {
86
+ if (err instanceof Cancel) return
87
+ throw err
95
88
  }
96
- return rv
97
- }
98
- function cancel_() {
99
- return (
100
- build_id_(ctx) !== build_id
101
- || metafile__build_id_(ctx) !== metafile__build_id
102
- || server__metafile_path_(ctx) !== server__metafile_path
103
- || browser__metafile_path_(ctx) !== browser__metafile_path
104
- )
89
+ })
90
+ }
91
+ async function cmd(promise) {
92
+ if (cancel_()) throw new Cancel
93
+ const rv = await promise
94
+ if (cancel_()) {
95
+ promise.cancel?.()
96
+ throw new Cancel
105
97
  }
106
- },
107
- { id: 'persist__metafile__build_id', ns: 'app' })
98
+ return rv
99
+ }
100
+ function cancel_() {
101
+ return (
102
+ build_id_(ctx) !== build_id
103
+ || metafile__build_id_(ctx) !== metafile__build_id
104
+ || server__metafile_path_(ctx) !== server__metafile_path
105
+ || browser__metafile_path_(ctx) !== browser__metafile_path
106
+ )
107
+ }
108
+ })
108
109
  export const [
109
110
  persist__metafile__ready$_,
110
111
  persist__metafile__ready_,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rebuildjs",
3
- "version": "0.32.0",
3
+ "version": "0.34.2",
4
4
  "description": "Reactive esbuild...simple hackable alternative to vite for Multi Page Apps",
5
5
  "keywords": [
6
6
  "reactive",
@@ -53,15 +53,15 @@
53
53
  "./package.json": "./package.json"
54
54
  },
55
55
  "dependencies": {
56
- "ctx-core": "^5.14.0",
56
+ "ctx-core": "^5.16.1",
57
57
  "elysia": "^0.8.8",
58
58
  "esbuild": "^0.19.11",
59
59
  "fdir": "^6.1.1",
60
60
  "picomatch": "^3.0.1"
61
61
  },
62
62
  "devDependencies": {
63
- "@typescript-eslint/eslint-plugin": "^6.18.0",
64
- "@typescript-eslint/parser": "^6.18.0",
63
+ "@typescript-eslint/eslint-plugin": "^6.18.1",
64
+ "@typescript-eslint/parser": "^6.18.1",
65
65
  "c8": "^9.0.0",
66
66
  "check-dts": "^0.7.2",
67
67
  "eslint": "^8.56.0",
package/server/index.js CHANGED
@@ -27,50 +27,51 @@ export const [
27
27
  ] = /** @type {be_lock_memosig_triple_T<rebuildjs_metafile_T>} */
28
28
  be_lock_memosig_triple_(
29
29
  ()=>undefined,
30
- async (ctx, server__metafile$)=>{
31
- server__metafile__waitfor_promise?.cancel?.()
32
- if (server__metafile$.lock) return
33
- nullish__none_([server__metafile_path_(ctx)],
34
- async server__metafile_path=>{
35
- try {
36
- if (await cmd(
37
- server__metafile__waitfor_promise =
38
- file_exists__waitfor(
39
- server__metafile_path,
40
- 1000,
41
- ()=>cmd(sleep(0))))
42
- ) {
43
- server__metafile$._ = await cmd(
44
- waitfor(async ()=>{
45
- const buf = await cmd(readFile(server__metafile_path))
46
- const json = buf + ''
47
- try {
48
- return JSON.parse(json)
49
- } catch {
50
- return undefined
51
- }
52
- }, 1000))
53
- }
54
- } catch (err) {
55
- if (err instanceof Cancel) return
56
- throw err
30
+ { ns: 'app', id: 'server__metafile' }
31
+ ).add(async (ctx, server__metafile$)=>{
32
+ server__metafile__waitfor_promise?.cancel?.()
33
+ if (server__metafile$.lock) return
34
+ nullish__none_([server__metafile_path_(ctx)],
35
+ async server__metafile_path=>{
36
+ try {
37
+ if (await cmd(
38
+ server__metafile__waitfor_promise =
39
+ file_exists__waitfor(
40
+ server__metafile_path,
41
+ 1000,
42
+ ()=>cmd(sleep(0))))
43
+ ) {
44
+ server__metafile$._ = await cmd(
45
+ waitfor(async ()=>{
46
+ const buf = await cmd(readFile(server__metafile_path))
47
+ const json = buf + ''
48
+ try {
49
+ return JSON.parse(json)
50
+ } catch {
51
+ return undefined
52
+ }
53
+ }, 1000))
57
54
  }
58
- async function cmd(promise) {
59
- if (cancel_()) throw new Cancel()
60
- const rv = await promise
61
- if (cancel_()) {
62
- promise.cancel?.()
63
- throw new Cancel()
64
- }
65
- return rv
55
+ } catch (err) {
56
+ if (err instanceof Cancel) return
57
+ throw err
58
+ }
59
+ async function cmd(promise) {
60
+ if (cancel_()) throw new Cancel()
61
+ const rv = await promise
62
+ if (cancel_()) {
63
+ promise.cancel?.()
64
+ throw new Cancel()
66
65
  }
67
- function cancel_() {
68
- return (
69
- server__metafile$.lock
70
- || server__metafile_path !== server__metafile_path_(ctx))
71
- }
72
- })
73
- }, { ns: 'app', id: 'server__metafile' })
66
+ return rv
67
+ }
68
+ function cancel_() {
69
+ return (
70
+ server__metafile$.lock
71
+ || server__metafile_path !== server__metafile_path_(ctx))
72
+ }
73
+ })
74
+ })
74
75
  export function server__metafile__persist() {
75
76
  return nullish__none_([
76
77
  server__metafile_path_(app_ctx),
@@ -103,13 +103,19 @@ test('server__metafile', async ()=>{
103
103
  equal(_server__metafile$_(app_ctx)._, server__metafile0)
104
104
  equal(_server__metafile_(app_ctx), server__metafile0)
105
105
  dist_path__set(app_ctx, '/cwd/dist1')
106
- await rmemo__wait(_server__metafile$_(app_ctx), m=>deep_equal(m, server__metafile1), 100)
106
+ await rmemo__wait(
107
+ _server__metafile$_(app_ctx),
108
+ m=>deep_equal(m, server__metafile1),
109
+ 100)
107
110
  equal(_server__metafile$_(app_ctx)._, server__metafile1)
108
111
  equal(_server__metafile_(app_ctx), server__metafile1)
109
112
  equal(file_exists__waitfor__path, '/cwd/dist1/server/metafile.json')
110
113
  equal(readFile_path, '/cwd/dist1/server/metafile.json')
111
114
  dist_path__set(app_ctx, '/cwd/dist0')
112
- await rmemo__wait(_server__metafile$_(app_ctx), m=>deep_equal(m, server__metafile0), 100)
115
+ await rmemo__wait(
116
+ _server__metafile$_(app_ctx),
117
+ m=>deep_equal(m, server__metafile0),
118
+ 100)
113
119
  equal(_server__metafile$_(app_ctx)._, server__metafile0)
114
120
  equal(_server__metafile_(app_ctx), server__metafile0)
115
121
  equal(file_exists__waitfor__path, '/cwd/dist0/server/metafile.json')
@@ -120,7 +126,10 @@ test('server__metafile', async ()=>{
120
126
  dist_path__set(app_ctx, '/cwd/dist1')
121
127
  let error_msg:string|undefined = undefined
122
128
  try {
123
- await rmemo__wait(_server__metafile$_(app_ctx), m=>deep_equal(m, server__metafile1), 100)
129
+ await rmemo__wait(
130
+ _server__metafile$_(app_ctx),
131
+ m=>deep_equal(m, server__metafile1),
132
+ 100)
124
133
  } catch (e) {
125
134
  error_msg = (e as Error).message
126
135
  }