@jsenv/core 28.2.3 → 28.3.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/main.js CHANGED
@@ -29611,6 +29611,25 @@ const createBuildFilesService = ({
29611
29611
 
29612
29612
  const SECONDS_IN_30_DAYS = 60 * 60 * 24 * 30;
29613
29613
 
29614
+ const replacePlaceholders = (content, replacements) => {
29615
+ const magicSource = createMagicSource(content);
29616
+ Object.keys(replacements).forEach(key => {
29617
+ let index = content.indexOf(key);
29618
+
29619
+ while (index !== -1) {
29620
+ const start = index;
29621
+ const end = index + key.length;
29622
+ magicSource.replace({
29623
+ start,
29624
+ end,
29625
+ replacement: replacements[key]
29626
+ });
29627
+ index = content.indexOf(key, end);
29628
+ }
29629
+ });
29630
+ return magicSource.toContentAndSourcemap();
29631
+ };
29632
+
29614
29633
  const execute = async ({
29615
29634
  signal = new AbortController().signal,
29616
29635
  handleSIGINT = true,
@@ -29783,4 +29802,4 @@ const jsenvPluginInjectGlobals = urlAssociations => {
29783
29802
  };
29784
29803
  };
29785
29804
 
29786
- export { build, chromium, chromiumIsolatedTab, execute, executeTestPlan, firefox, firefoxIsolatedTab, jsenvPluginInjectGlobals, nodeChildProcess, nodeWorkerThread, pingServer, startBuildServer, startDevServer, webkit, webkitIsolatedTab };
29805
+ export { build, chromium, chromiumIsolatedTab, execute, executeTestPlan, firefox, firefoxIsolatedTab, jsenvPluginInjectGlobals, nodeChildProcess, nodeWorkerThread, pingServer, replacePlaceholders, startBuildServer, startDevServer, webkit, webkitIsolatedTab };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "28.2.3",
3
+ "version": "28.3.0",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -0,0 +1,15 @@
1
+ import { createMagicSource } from "@jsenv/sourcemap"
2
+
3
+ export const replacePlaceholders = (content, replacements) => {
4
+ const magicSource = createMagicSource(content)
5
+ Object.keys(replacements).forEach((key) => {
6
+ let index = content.indexOf(key)
7
+ while (index !== -1) {
8
+ const start = index
9
+ const end = index + key.length
10
+ magicSource.replace({ start, end, replacement: replacements[key] })
11
+ index = content.indexOf(key, end)
12
+ }
13
+ })
14
+ return magicSource.toContentAndSourcemap()
15
+ }
package/src/main.js CHANGED
@@ -23,6 +23,7 @@ export { startBuildServer } from "./build/start_build_server.js"
23
23
 
24
24
  // helpers
25
25
  export { pingServer } from "./ping_server.js"
26
+ export { replacePlaceholders } from "./helpers/replace_placeholders.js"
26
27
 
27
28
  // advanced
28
29
  export { execute } from "./execute/execute.js"