dcp-client 5.0.4 → 5.1.1

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/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ dist/dcp-client-bundle.js* binary
2
+ libexec/sandbox/pyodide-core.js binary
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file dcp-client.css Styles for dcp-client. These impact the appearance of DOM elements
3
+ * generated by DCP-Client; eg. the modal dialogs which pop up when the
4
+ * wallet API is used.
5
+ *
6
+ * This stylesheet is loaded automatically by dcp-client when the load-css attribute is
7
+ * undefined or has the value true. Any other value will be interpreted as a URL from
8
+ * which to load the css.
9
+ *
10
+ * @author Wes Garland, wes@distributive.network
11
+ * @date Nov 2024
12
+ */
13
+
14
+ @layer dcp-style dcp-client;
15
+ @import https://cdn.distributed.computerl
16
+
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bug"><path d="m8 2 1.88 1.88"/><path d="M14.12 3.88 16 2"/><path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1"/><path d="M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6"/><path d="M12 20v-9"/><path d="M6.53 9C4.6 8.8 3 7.1 3 5"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="M22 13h-4"/><path d="M17.2 17c2.1.1 3.8 1.9 3.8 4"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-alert"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-hard-drive-upload"><path d="m16 6-4-4-4 4"/><path d="M12 2v8"/><rect width="20" height="8" x="2" y="14" rx="2"/><path d="M6 18h.01"/><path d="M10 18h.01"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-triangle-alert"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>
package/assets/x.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
@@ -27,7 +27,7 @@ ${progName} - Query values from dcpConfig
27
27
  Copyright (c) 2018-2025 Distributive Corp., All Rights Reserved.
28
28
 
29
29
  Usage: ${progName} [--keys] [--to-string] [--json]
30
- [--programName=string]
30
+ [--program-name=string]
31
31
  [--scheduler=URL] [--bundle-location[=URL]]
32
32
  [--no-remote-config] [--remote-config=URL]
33
33
  <--all | path.to.config.variable [path.to.config.variable...]>
@@ -109,7 +109,7 @@ for (let i=2; i < process.argv.length; i++)
109
109
  mods.push(JSON.stringify);
110
110
  mods.push(stringModFn);
111
111
  break;
112
- case '--programName':
112
+ case '--program-name':
113
113
  dcpClientOptions.programName = optarg;
114
114
  break;
115
115
  case '--scheduler':
@@ -0,0 +1,149 @@
1
+ #! /usr/bin/env node
2
+ /**
3
+ * @file dcp-client/bin/dcp-module-bundler.js
4
+ *
5
+ * Run webpack using dynamic in-memory input.
6
+ * Uses unionfs to layer memfs on top of fs,
7
+ * in order to resolve modules in the local filesystem.
8
+ *
9
+ * @author Paul, paul@distributive.network
10
+ * @date June 2025
11
+ */
12
+ // @ts-check
13
+ 'use strict';
14
+
15
+ const webpack = require('webpack');
16
+ const process = require('process');
17
+ const debug = require('debug')('webpack');
18
+ const fs = require('fs');
19
+ const { Union } = require('unionfs');
20
+ const { createFsFromVolume, Volume } = require('memfs');
21
+ const debugDetails = debug.extend('details');
22
+
23
+ //
24
+ // Tracing Note:
25
+ //
26
+ // DEBUG=webpack -- turns on debug(...)
27
+ // DEBUG=webpack:details -- turns on debugDetails(...)
28
+ // Debug=webpack* -- turns on debug(...) and debugDetails(...)
29
+ //
30
+
31
+ function compile (compiler)
32
+ {
33
+ try
34
+ {
35
+ return new Promise((resolve, reject) => {
36
+ compiler.run((err, stats) => {
37
+ (err) ? reject(err) : resolve(stats);
38
+ });
39
+ });
40
+ }
41
+ catch (error)
42
+ {
43
+ debug('Webpack compilation failure:', error);
44
+ throw error;
45
+ }
46
+ }
47
+
48
+ function showDiags (stats)
49
+ {
50
+ const statsConfig = {
51
+ colors: true,
52
+ errors: true,
53
+ errorCause: true,
54
+ errorDetails: true,
55
+ errorErrors: true,
56
+ errorStack: true,
57
+ warnings: true,
58
+ assets: false, // Include information about generated assets
59
+ chunks: false, // Include information about chunks
60
+ entrypoints: false, // Include information about entrypoints
61
+ modules: false, // Include information about modules
62
+ // You can add more options here based on what you need:
63
+ // https://webpack.js.org/api/stats/#stats-options
64
+ };
65
+
66
+ // Convert stats to a JSON object for easier access and filtering
67
+ const info = stats.toJson(statsConfig);
68
+
69
+ if (stats.hasErrors())
70
+ {
71
+ debug('Webpack compilation errors:');
72
+ info.errors.forEach(error => debug(error.message));
73
+ throw new Error('Webpack compilation failed with errors.', { cause: info.errors });
74
+ }
75
+
76
+ if (stats.hasWarnings())
77
+ {
78
+ debug('Webpack compilation warnings:');
79
+ info.warnings.forEach(warning => debug(warning.message));
80
+ }
81
+
82
+ debugDetails('webpack compilation stats:', JSON.stringify(info, null, 2));
83
+
84
+ return info;
85
+ }
86
+
87
+ async function inMemWebpack (config)
88
+ {
89
+ // Create a memory filesystem
90
+ let memVolume = new Volume();
91
+ let memfs = createFsFromVolume(memVolume);
92
+
93
+ // Create a union filesystem that combines memory fs and normal node fs.
94
+ let ufs = new Union();
95
+ // @ts-ignore
96
+ ufs.use(memfs).use(fs);
97
+
98
+ // Place the input in memfs and update config.entry.
99
+ const buf = fs.readFileSync(config.entry);
100
+ config.entry = '/inMemoryinput.js';
101
+ memfs.writeFileSync(config.entry, buf);
102
+ if (debug.enabled)
103
+ {
104
+ const _buf = memfs.readFileSync(config.entry);
105
+ if (!Buffer.isBuffer(_buf))
106
+ throw new Error("Webpack: Buffer.isBuffer has failed");
107
+ }
108
+
109
+ const compiler = webpack(config);
110
+ try
111
+ {
112
+ // @ts-ignore
113
+ compiler.inputFileSystem = ufs;
114
+ const stats = await compile(compiler);
115
+ showDiags(stats);
116
+ }
117
+ finally
118
+ {
119
+ compiler.close((closeErr) => {
120
+ if (debug.enabled && closeErr)
121
+ debug('Failure closing webpack compiler', { cause: closeErr });
122
+ });
123
+ }
124
+ }
125
+
126
+ async function main ()
127
+ {
128
+ const success = 0;
129
+ const failure = 1;
130
+
131
+ debug('Webpack command-line args', process.argv);
132
+ try
133
+ {
134
+ // node dcp-module-bundler.js configFile.json
135
+ const configuration = require(process.argv[2]);
136
+ debug('Webpack configuration:', configuration);
137
+
138
+ await inMemWebpack(configuration);
139
+ }
140
+ catch (error)
141
+ {
142
+ process.exitCode = failure;
143
+ debug('Failure compiling webpack', { cause: error });
144
+ throw error;
145
+ }
146
+ process.exitCode = success;
147
+ }
148
+
149
+ ( async () => { await main(); } )();
package/build/bundle CHANGED
@@ -174,7 +174,7 @@ fi
174
174
  NO_LOG=1 \
175
175
  SKIP_SUDO_CHECK=1 \
176
176
  DCP_LOCAL_CONFIG_EXTRAS="${BUNDLE_TMP}/local-config.incl" \
177
- "${DCP_SRC}/install.sh" -NI ${DCP_INSTALL_FLAGS} build-dcp-client
177
+ "${DCP_SRC}/install.sh" -NI ${DCP_INSTALL_FLAGS} autogen-schemas build-dcp-client
178
178
 
179
179
  EXIT_CODE="$?"
180
180
  if [ "$EXIT_CODE" != "0" ]; then
package/dcp-client.js CHANGED
@@ -258,22 +258,35 @@ https://distributive.network/`, "font-weight: bold; font-size: 1.2em; color: #00
258
258
  };
259
259
  }
260
260
 
261
- /* Load the modal stylesheet
262
- * Add our favicon (unless they've already got one)
261
+ /* Load the default appearance CSS. This lets us style trivial DCP programs so that the modals use
262
+ * e.g. so that popups in wallet API look right.
263
263
  */
264
- function loadLinks () {
264
+ function loadCSS () {
265
+ // Best-effort to find cdn location
266
+ // 1. use dcpConfig.cdn.location
267
+ // 2. use dcpConfigHref to infer where cdn is (when dcpConfigHref is loading through some service)
268
+ // 3. use thisScriptURL to infer where cdn is
269
+ var cdnOrigin;
270
+ if (typeof dcpConfig === 'object' && dcpConfig.cdn?.location?.href)
271
+ cdnOrigin = dcpConfig.cdn.location.origin
272
+ else if (typeof dcpConfigHref === 'string' && dcpConfigHref.match(/(portal|auth|cdn|scheduler)\.?/))
273
+ {
274
+ cdnOrigin = new URL(dcpConfigHref).origin;
275
+ cdnOrigin = cdnOrigin.replace(/(portal|auth|cdn|scheduler)\.?/, 'cdn.');
276
+ }
277
+ else
278
+ {
279
+ cdnOrigin = thisScriptURL.origin.replace(/(portal|auth|cdn|scheduler)\.?/, 'cdn.');
280
+ if (!cdnOrigin.match(/^(http|https):\/\/cdn/)) // Loaded directly
281
+ cdnOrigin = cdnOrigin.replace(/^(http:\/\/|https:\/\/)/, '$1cdn.');
282
+ }
283
+
265
284
  const head = document.getElementsByTagName('head')[0];
266
285
  let styleLink = document.createElement('link');
267
286
  styleLink.rel = 'stylesheet';
268
- styleLink.href = thisScript.src.replace('/dcp-client.js', '/templates/dcp-modal.css');
269
- head.prepend(styleLink);
270
-
271
- if (document.querySelector("link[rel*='icon']")) return
272
- let faviconLink = document.createElement('link');
273
- faviconLink.type = 'image/x-icon';
274
- faviconLink.rel = 'shortcut icon';
275
- faviconLink.href = thisScript.src.replace('/dcp-client.js', '/favicon.ico');
276
- head.appendChild(faviconLink);
287
+ styleLink.href = cdnOrigin + '/css/dcp-modals.css';
288
+ styleLink.id = 'dcp-modal-styles'
289
+ head.appendChild(styleLink);
277
290
  }
278
291
 
279
292
  let shimCallback;
@@ -281,8 +294,8 @@ https://distributive.network/`, "font-weight: bold; font-size: 1.2em; color: #00
281
294
  shimCallback = loadCJS2Shim(); /* BravoJS, NobleJS, etc - set up for requireNative */
282
295
 
283
296
  loadConfig();
297
+ loadCSS();
284
298
  loadBundle(shimCallback);
285
- loadLinks();
286
299
  }
287
300
  })();
288
301