create-dalila 1.2.21 → 1.2.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-dalila",
3
- "version": "1.2.21",
3
+ "version": "1.2.22",
4
4
  "description": "Create Dalila apps with one command",
5
5
  "bin": {
6
6
  "create-dalila": "index.js"
@@ -35,6 +35,6 @@
35
35
  },
36
36
  "homepage": "https://github.com/evertondsvieira/dalila/blob/main/README.md",
37
37
  "dependencies": {
38
- "dalila": "^1.10.3"
38
+ "dalila": "^1.10.4"
39
39
  }
40
40
  }
@@ -72,6 +72,10 @@ function stringifyInlineScriptPayload(value, indent = 0) {
72
72
  .join('\n');
73
73
  }
74
74
 
75
+ function stringifyInlineScriptLiteral(value) {
76
+ return escapeInlineScriptContent(JSON.stringify(value));
77
+ }
78
+
75
79
  function normalizePreloadStorageType(storageType) {
76
80
  return storageType === 'sessionStorage' ? 'sessionStorage' : 'localStorage';
77
81
  }
@@ -424,15 +428,15 @@ export function detectPreloadScripts(baseDir) {
424
428
 
425
429
  export function generatePreloadScript(name, defaultValue, storageType = 'localStorage') {
426
430
  const safeStorageType = normalizePreloadStorageType(storageType);
427
- const payload = JSON.stringify({
431
+ const payload = stringifyInlineScriptLiteral({
428
432
  key: name,
429
433
  defaultValue,
430
434
  storageType: safeStorageType,
431
435
  });
432
- const fallbackValue = JSON.stringify(defaultValue);
436
+ const fallbackValue = stringifyInlineScriptLiteral(defaultValue);
433
437
  const script = `(function(){try{var p=${payload};var s=window[p.storageType];var v=s.getItem(p.key);document.documentElement.setAttribute('data-theme',v==null?p.defaultValue:JSON.parse(v))}catch(e){document.documentElement.setAttribute('data-theme',${fallbackValue})}})();`;
434
438
 
435
- return escapeInlineScriptContent(script);
439
+ return script;
436
440
  }
437
441
 
438
442
  function renderPreloadScriptTags(baseDir) {