@ubox-tools/deploy-xperience 1.1.22 → 1.1.24

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.
Files changed (3) hide show
  1. package/README.md +16 -4
  2. package/deploy.js +22 -27
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -106,15 +106,25 @@ When `--ubox-id` is provided, the search/create step is skipped entirely and the
106
106
 
107
107
  ## Proxy / Source Transformation
108
108
 
109
- Before injecting source files, `generateProxy()` applies three transforms to each file:
109
+ Before injecting source files, `generateProxy()` applies transforms to each file:
110
110
 
111
111
  | Transform | Applies to | What it does |
112
112
  |---|---|---|
113
- | Parameter substitution | JS | Replaces `const KEY = "value"` with `const KEY = "{parameter:KEY}"` for every key in `parameters.json` |
114
- | Asset path substitution | JS, CSS | Replaces `../assets/file.ext` references with `{resources:type/file.ext}` tokens |
113
+ | Asset path substitution | JS, CSS, HTML | Replaces `assets/file.ext` references with `{resources:type/file.ext}` tokens |
115
114
  | Emoji escaping | JS | Converts non-ASCII characters to `\uXXXX` Unicode escape sequences |
116
115
  | Local tag stripping | HTML | Removes local `<link href>` and `<script src>` tags (CDN URLs are kept) |
117
116
 
117
+ Asset references are resolved by their actual relative path, so both a root-level shared folder and a per-app folder work:
118
+
119
+ | Reference in source | Resolved from |
120
+ |---|---|
121
+ | `../../assets/logo.png` | `<project-root>/assets/logo.png` |
122
+ | `assets/logo.png` | `apps/<appName>/assets/logo.png` |
123
+
124
+ Files inside subdirectories (e.g. `assets/img/logo.png`) are supported — the token uses only the filename: `{resources:images/logo.png}`.
125
+
126
+ > **Parameter tokens are embedded at authoring time** — `data.js` uses inline `{parameter:key}` tokens with local fallbacks. No deploy-time regex substitution is performed.
127
+
118
128
  ## Project Layout Expected
119
129
 
120
130
  ```
@@ -130,7 +140,9 @@ Before injecting source files, `generateProxy()` applies three transforms to eac
130
140
  parameters.json (optional)
131
141
  main/
132
142
  ...same files...
133
- assets/
143
+ assets/ (optional, app-specific assets)
144
+ *.jpg / *.png / ...
145
+ assets/ (shared across all apps)
134
146
  *.jpg / *.png / *.woff2 / ...
135
147
  deploy.js
136
148
  ```
package/deploy.js CHANGED
@@ -238,33 +238,27 @@ function generateProxy(appName) {
238
238
  const isHTML = ext === 'html';
239
239
 
240
240
  if (isJS || isCSS) {
241
- // 1. Parameter token substitution (JS only — parameters live in JS files)
242
- if (isJS) {
243
- for (const key of Object.keys(params)) {
244
- const re = new RegExp(`((?:const|let|var)\\s+${key}\\s*=\\s*)(?:"[^"]*"|'[^']*')`, 'g');
245
- content = content.replace(re, `$1"{parameter:${key}}"`);
246
- }
247
- }
248
-
249
- // 2. Asset path substitution: "...assets/file.ext" → "{resources:type/file.ext}"
250
- const assetInStringRe = /(['"])(?:\.\.\/)*assets\/([^'"]+)\1/g;
251
- content = content.replace(assetInStringRe, (match, quote, assetFile) => {
252
- const assetExt = path.extname(assetFile).slice(1).toLowerCase();
241
+ // 1. Asset path substitution: "...assets/file.ext" "{resources:type/file.ext}"
242
+ const assetInStringRe = /(['"])((?:\.\.\/)*assets\/([^'"]+))\1/g;
243
+ content = content.replace(assetInStringRe, (match, quote, relativePath, assetFile) => {
244
+ const fileName = path.basename(assetFile);
245
+ const assetExt = path.extname(fileName).slice(1).toLowerCase();
253
246
  const type = assetResourceType(assetExt);
254
- const absPath = path.join(ASSETS_DIR, assetFile);
255
- if (fs.existsSync(absPath)) assets[assetFile] = { type, absPath };
256
- return `"{resources:${type}/${assetFile}}"`;
247
+ const absPath = path.resolve(appDir, relativePath);
248
+ if (fs.existsSync(absPath)) assets[fileName] = { type, absPath };
249
+ return `"{resources:${type}/${fileName}}"`;
257
250
  });
258
251
 
259
252
  // CSS url() pattern
260
253
  if (isCSS) {
261
- const assetUrlRe = /url\((['"]?)(?:\.\.\/)*assets\/([^'")\s]+)\1\)/g;
262
- content = content.replace(assetUrlRe, (match, quote, assetFile) => {
263
- const assetExt = path.extname(assetFile).slice(1).toLowerCase();
254
+ const assetUrlRe = /url\((['"]?)((?:\.\.\/)*assets\/([^'")\s]+))\1\)/g;
255
+ content = content.replace(assetUrlRe, (match, quote, relativePath, assetFile) => {
256
+ const fileName = path.basename(assetFile);
257
+ const assetExt = path.extname(fileName).slice(1).toLowerCase();
264
258
  const type = assetResourceType(assetExt);
265
- const absPath = path.join(ASSETS_DIR, assetFile);
266
- if (fs.existsSync(absPath)) assets[assetFile] = { type, absPath };
267
- return `url("{resources:${type}/${assetFile}}")`;
259
+ const absPath = path.resolve(appDir, relativePath);
260
+ if (fs.existsSync(absPath)) assets[fileName] = { type, absPath };
261
+ return `url("{resources:${type}/${fileName}}")`;
268
262
  });
269
263
  }
270
264
 
@@ -274,13 +268,14 @@ function generateProxy(appName) {
274
268
 
275
269
  if (isHTML) {
276
270
  // Asset path substitution for HTML src/href attributes
277
- const assetInStringRe = /(['"])(?:\.\.\/)*assets\/([^'"]+)\1/g;
278
- content = content.replace(assetInStringRe, (match, quote, assetFile) => {
279
- const assetExt = path.extname(assetFile).slice(1).toLowerCase();
271
+ const assetInStringRe = /(['"])((?:\.\.\/)*assets\/([^'"]+))\1/g;
272
+ content = content.replace(assetInStringRe, (match, quote, relativePath, assetFile) => {
273
+ const fileName = path.basename(assetFile);
274
+ const assetExt = path.extname(fileName).slice(1).toLowerCase();
280
275
  const type = assetResourceType(assetExt);
281
- const absPath = path.join(ASSETS_DIR, assetFile);
282
- if (fs.existsSync(absPath)) assets[assetFile] = { type, absPath };
283
- return `"{resources:${type}/${assetFile}}"`;
276
+ const absPath = path.resolve(appDir, relativePath);
277
+ if (fs.existsSync(absPath)) assets[fileName] = { type, absPath };
278
+ return `"{resources:${type}/${fileName}}"`;
284
279
  });
285
280
 
286
281
  // Strip local <link> tags (keep CDN ones with https://)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubox-tools/deploy-xperience",
3
- "version": "1.1.22",
3
+ "version": "1.1.24",
4
4
  "description": "Deploy a Ubox experience to studio.ubox.world",
5
5
  "bin": { "deploy-xperience": "./deploy.js" },
6
6
  "dependencies": { "puppeteer": "*" },