rebuildjs 0.15.1 → 0.17.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/asset/index.d.ts CHANGED
@@ -4,3 +4,8 @@ export declare function asset_path_a_<
4
4
  >(...mod_promise_a:Tuple):Promise<{
5
5
  [Index in keyof Tuple]: string
6
6
  }>
7
+ export declare function assets_(..._assets_a:assets_T[]):assets_T
8
+ export type assets_T = {
9
+ css_a?:string[]
10
+ script_a?:string[]
11
+ }
package/asset/index.js CHANGED
@@ -1,6 +1,25 @@
1
+ /// <reference types="./index.d.ts" />
1
2
  export async function asset_path_(mod_promise) {
2
3
  return (await mod_promise.then(mod=>mod.default)).replace(/^\.\//, '/')
3
4
  }
4
5
  export async function asset_path_a_(...mod_promise_a) {
5
6
  return Promise.all(mod_promise_a.map(asset_path_))
6
7
  }
8
+ /**
9
+ * @param {assets_T[]}_assets_a
10
+ * @returns {{script_a: *[], css_a: *[]}}
11
+ * @private
12
+ */
13
+ export function assets_(..._assets_a) {
14
+ /** @type {assets_T} */
15
+ const assets = { css_a: [], script_a: [] }
16
+ for (const _assets of _assets_a) {
17
+ for (const css of _assets?.css_a || []) {
18
+ if (!~assets.css_a.indexOf(css)) assets.css_a.push(css)
19
+ }
20
+ for (const script of _assets?.script_a || []) {
21
+ if (!~assets.script_a.indexOf(script)) assets.script_a.push(script)
22
+ }
23
+ }
24
+ return assets
25
+ }
@@ -1,14 +1,36 @@
1
1
  import { test } from 'uvu'
2
2
  import { equal } from 'uvu/assert'
3
- import { asset_path_ } from './index.js'
3
+ import { asset_path_, asset_path_a_, assets_ } from './index.js'
4
4
  test('asset_path_', async ()=>{
5
- let in_path:string|undefined
6
- const mod_ = async (path:string)=>{
7
- in_path = path
8
- return { default: './path.png' }
9
- }
10
- equal(in_path, undefined)
11
5
  equal(await asset_path_(mod_('./path.png')), '/path.png')
12
- equal(in_path, './path.png')
6
+ })
7
+ test('asset_path_a_', async ()=>{
8
+ equal(await asset_path_a_(
9
+ mod_('./path0.png'),
10
+ mod_('./path1.png'),
11
+ mod_('./path2.png'),
12
+ mod_('./path3.png'),
13
+ ), [
14
+ '/path0.png',
15
+ '/path1.png',
16
+ '/path2.png',
17
+ '/path3.png',
18
+ ])
19
+ })
20
+ test('assets_', async ()=>{
21
+ equal(assets_(
22
+ { script_a: ['/foo.js' ] },
23
+ { css_a: ['/foo.css'] },
24
+ { script_a: ['/bar.js'], css_a: ['/bar.css'] },
25
+ { },
26
+ { script_a: [], css_a: [] },
27
+ { script_a: undefined, css_a: undefined }),
28
+ {
29
+ css_a: ['/foo.css', '/bar.css'],
30
+ script_a: ['/foo.js', '/bar.js']
31
+ })
13
32
  })
14
33
  test.run()
34
+ async function mod_ (out_path:string){
35
+ return { default:out_path }
36
+ }
package/css/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import type { Plugin } from 'esbuild'
2
2
  export declare function cssjs_esbuild_plugin_():Plugin
3
+ export declare function var__css__replace(css:string, ..._var_R_a:Record<string, string>[]):string
package/css/index.js CHANGED
@@ -18,3 +18,18 @@ export function cssjs_esbuild_plugin_() {
18
18
  },
19
19
  }
20
20
  }
21
+ /**
22
+ * @param {string}css
23
+ * @param {Record<string, string>}_var_R_a
24
+ * @returns {string}
25
+ */
26
+ export function var__css__replace(css, ..._var_R_a) {
27
+ const var_R = _var_R_a.reduce((
28
+ var_R,
29
+ _var_R
30
+ )=>({
31
+ ...var_R,
32
+ ..._var_R,
33
+ }), {})
34
+ return css.replaceAll(/var\(([^)]*)\)/g, (_, $)=>var_R[$])
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rebuildjs",
3
- "version": "0.15.1",
3
+ "version": "0.17.0",
4
4
  "description": "Reactive esbuild...simple hackable alternative to vite for Multi Page Apps",
5
5
  "keywords": [
6
6
  "reactive",