resuxjs 0.4.0-beta.8 → 0.4.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.
@@ -77,15 +77,19 @@ function resolveTemplateContentBounds(source, content, reportedOffset) {
77
77
  end: fallbackStart + content.length
78
78
  };
79
79
  }
80
+ function previousNonSpaceChar(source, index) {
81
+ for (let cursor = index - 1; cursor >= 0; cursor--) if (!/\s/.test(source[cursor])) return source[cursor];
82
+ return "";
83
+ }
80
84
  function findTagEnd(source, start) {
81
85
  let quote = null;
82
86
  for (let index = start; index < source.length; index++) {
83
87
  const char = source[index];
84
88
  if (quote) {
85
- if (char === quote && source[index - 1] !== "\\") quote = null;
89
+ if (char === quote) quote = null;
86
90
  continue;
87
91
  }
88
- if (char === "\"" || char === "'") {
92
+ if ((char === "\"" || char === "'") && previousNonSpaceChar(source, index) === "=") {
89
93
  quote = char;
90
94
  continue;
91
95
  }
@@ -106,7 +110,7 @@ function normalizeOpeningTag(tag) {
106
110
  const valueStart = cursor;
107
111
  cursor++;
108
112
  while (cursor < tag.length) {
109
- if (tag[cursor] === quote && tag[cursor - 1] !== "\\") {
113
+ if (tag[cursor] === quote) {
110
114
  cursor++;
111
115
  break;
112
116
  }
@@ -1 +1 @@
1
- {"version":3,"file":"directives.js","names":["parseSfc"],"sources":["../../src/compiler/directives.ts"],"sourcesContent":["import { parse as parseSfc } from \"@vue/compiler-sfc\";\n\nconst RX_DIRECTIVE_PREFIX = \"rx-\";\nconst VUE_DIRECTIVE_PREFIX = \"v-\";\n\n/**\n * Converts Resux-branded directive attributes (`rx-*`) to the directive names\n * understood by Vue's template parser. Only attribute names inside opening\n * template tags are changed; text, comments and attribute values are preserved.\n */\nexport function normalizeResuxDirectiveSyntax(template: string): string {\n let output = \"\";\n let cursor = 0;\n\n while (cursor < template.length) {\n const tagStart = template.indexOf(\"<\", cursor);\n if (tagStart === -1) {\n output += template.slice(cursor);\n break;\n }\n\n output += template.slice(cursor, tagStart);\n\n if (template.startsWith(\"<!--\", tagStart)) {\n const commentEnd = template.indexOf(\"-->\", tagStart + 4);\n if (commentEnd === -1) {\n output += template.slice(tagStart);\n break;\n }\n output += template.slice(tagStart, commentEnd + 3);\n cursor = commentEnd + 3;\n continue;\n }\n\n const tagEnd = findTagEnd(template, tagStart + 1);\n if (tagEnd === -1) {\n output += template.slice(tagStart);\n break;\n }\n\n output += normalizeOpeningTag(template.slice(tagStart, tagEnd + 1));\n cursor = tagEnd + 1;\n }\n\n return output;\n}\n\n/**\n * Normalizes only the `<template>` block of a Vue SFC. Script and style blocks\n * are intentionally untouched, so strings such as `\"rx-if\"` keep their value.\n */\nexport function normalizeResuxSfcSource(source: string, filename = \"component.vue\"): string {\n if (!source.includes(RX_DIRECTIVE_PREFIX)) {\n return source;\n }\n\n const parsed = parseSfc(source, { filename });\n const template = parsed.descriptor.template;\n if (!template || !template.content.includes(RX_DIRECTIVE_PREFIX)) {\n return source;\n }\n\n const normalizedTemplate = normalizeResuxDirectiveSyntax(template.content);\n if (normalizedTemplate === template.content) {\n return source;\n }\n\n const bounds = resolveTemplateContentBounds(source, template.content, template.loc.start.offset);\n if (!bounds) {\n return source;\n }\n\n return `${source.slice(0, bounds.start)}${normalizedTemplate}${source.slice(bounds.end)}`;\n}\n\n/** Rewords compiler diagnostics so the public API always speaks Resux syntax. */\nexport function rethrowWithResuxDirectiveBrand(error: unknown): never {\n if (error instanceof Error) {\n error.message = brandDirectiveText(error.message);\n if (error.stack) {\n error.stack = brandDirectiveText(error.stack);\n }\n }\n throw error;\n}\n\nfunction brandDirectiveText(value: string): string {\n return value.replace(/\\bv-(?=[a-z][\\w-]*)/gi, RX_DIRECTIVE_PREFIX);\n}\n\nfunction resolveTemplateContentBounds(\n source: string,\n content: string,\n reportedOffset: number,\n): { start: number; end: number } | null {\n if (source.slice(reportedOffset, reportedOffset + content.length) === content) {\n return { start: reportedOffset, end: reportedOffset + content.length };\n }\n\n const templateOpen = /<template(?:\\s[^>]*)?>/i.exec(source);\n if (!templateOpen || templateOpen.index === undefined) {\n return null;\n }\n\n const openingEnd = templateOpen.index + templateOpen[0].length;\n const fallbackStart = source.indexOf(content, openingEnd);\n if (fallbackStart === -1) {\n return null;\n }\n\n return { start: fallbackStart, end: fallbackStart + content.length };\n}\n\nfunction findTagEnd(source: string, start: number): number {\n let quote: '\"' | \"'\" | null = null;\n\n for (let index = start; index < source.length; index++) {\n const char = source[index];\n if (quote) {\n if (char === quote && source[index - 1] !== \"\\\\\") {\n quote = null;\n }\n continue;\n }\n\n if (char === '\"' || char === \"'\") {\n quote = char;\n continue;\n }\n\n if (char === \">\") {\n return index;\n }\n }\n\n return -1;\n}\n\nfunction normalizeOpeningTag(tag: string): string {\n if (/^<\\s*(?:\\/|!|\\?)/.test(tag)) {\n return tag;\n }\n\n let output = \"\";\n let cursor = 0;\n let expectsUnquotedValue = false;\n\n // Copy the opening bracket, whitespace and element name unchanged.\n while (cursor < tag.length && !/\\s/.test(tag[cursor]) && tag[cursor] !== \">\") {\n output += tag[cursor++];\n }\n\n while (cursor < tag.length) {\n const char = tag[cursor];\n\n if (char === '\"' || char === \"'\") {\n const quote = char;\n const valueStart = cursor;\n cursor++;\n while (cursor < tag.length) {\n if (tag[cursor] === quote && tag[cursor - 1] !== \"\\\\\") {\n cursor++;\n break;\n }\n cursor++;\n }\n output += tag.slice(valueStart, cursor);\n expectsUnquotedValue = false;\n continue;\n }\n\n if (/\\s/.test(char) || char === \"/\" || char === \">\") {\n output += char;\n cursor++;\n continue;\n }\n\n if (char === \"=\") {\n output += char;\n cursor++;\n expectsUnquotedValue = true;\n continue;\n }\n\n const tokenStart = cursor;\n while (\n cursor < tag.length\n && !/\\s/.test(tag[cursor])\n && tag[cursor] !== \"=\"\n && tag[cursor] !== \"/\"\n && tag[cursor] !== \">\"\n ) {\n cursor++;\n }\n\n const token = tag.slice(tokenStart, cursor);\n output += !expectsUnquotedValue\n && token.startsWith(RX_DIRECTIVE_PREFIX)\n && token.length > RX_D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AC7B,OAAO;CAGT,IAAI,SAAS;CACb,IAAI,SAAS;CACb,IAAI,uBAAuB;CAG3B,OAAO,SAAS,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,OAAO,KAAK,IAAI,YAAY,KACvE,UAAU,IAAI;CAGhB,OAAO,SAAS,IAAI,QAAQ;EAC1B,MAAM,OAAO,IAAI;EAEjB,IAAI,SAAS,QAAO,SAAS,KAAK;GAChC,MAAM,QAAQ;GACd,MAAM,aAAa;GACnB;GACA,OAAO,SAAS,IAAI,QAAQ;IAC1B,IAAI,IAAI,YAAY,SAAS,IAAI,SAAS,OAAO,MAAM;KACrD;KACA;IACF;IACA;GACF;GACA,UAAU,IAAI,MAAM,YAAY,MAAM;GACtC,uBAAuB;GACvB;EACF;EAEA,IAAI,KAAK,KAAK,IAAI,KAAK,SAAS,OAAO,SAAS,KAAK;GACnD,UAAU;GACV;GACA;EACF;EAEA,IAAI,SAAS,KAAK;GAChB,UAAU;GACV;GACA,uBAAuB;GACvB;EACF;EAEA,MAAM,aAAa;EACnB,OACE,SAAS,IAAI,UACV,CAAC,KAAK,KAAK,IAAI,OAAO,KACtB,IAAI,YAAY,OAChB,IAAI,YAAY,OAChB,IAAI,YAAY,KAEnB;EAGF,MAAM,QAAQ,IAAI,MAAM,YAAY,MAAM;EAC1C,UAAU,CAAC,wBACN,MAAM,WAAW,mBAAmB,KACpC,MAAM,SAAS,IACd,GAAG,uBAAuB,MAAM,MAAM,CAA0B,MAChE;EACN,uBAAuB;CACzB;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"directives.js","names":["parseSfc"],"sources":["../../src/compiler/directives.ts"],"sourcesContent":["import { parse as parseSfc } from \"@vue/compiler-sfc\";\n\nconst RX_DIRECTIVE_PREFIX = \"rx-\";\nconst VUE_DIRECTIVE_PREFIX = \"v-\";\n\n/**\n * Converts Resux-branded directive attributes (`rx-*`) to the directive names\n * understood by Vue's template parser. Only attribute names inside opening\n * template tags are changed; text, comments and attribute values are preserved.\n */\nexport function normalizeResuxDirectiveSyntax(template: string): string {\n let output = \"\";\n let cursor = 0;\n\n while (cursor < template.length) {\n const tagStart = template.indexOf(\"<\", cursor);\n if (tagStart === -1) {\n output += template.slice(cursor);\n break;\n }\n\n output += template.slice(cursor, tagStart);\n\n if (template.startsWith(\"<!--\", tagStart)) {\n const commentEnd = template.indexOf(\"-->\", tagStart + 4);\n if (commentEnd === -1) {\n output += template.slice(tagStart);\n break;\n }\n output += template.slice(tagStart, commentEnd + 3);\n cursor = commentEnd + 3;\n continue;\n }\n\n const tagEnd = findTagEnd(template, tagStart + 1);\n if (tagEnd === -1) {\n output += template.slice(tagStart);\n break;\n }\n\n output += normalizeOpeningTag(template.slice(tagStart, tagEnd + 1));\n cursor = tagEnd + 1;\n }\n\n return output;\n}\n\n/**\n * Normalizes only the `<template>` block of a Vue SFC. Script and style blocks\n * are intentionally untouched, so strings such as `\"rx-if\"` keep their value.\n */\nexport function normalizeResuxSfcSource(source: string, filename = \"component.vue\"): string {\n if (!source.includes(RX_DIRECTIVE_PREFIX)) {\n return source;\n }\n\n const parsed = parseSfc(source, { filename });\n const template = parsed.descriptor.template;\n if (!template || !template.content.includes(RX_DIRECTIVE_PREFIX)) {\n return source;\n }\n\n const normalizedTemplate = normalizeResuxDirectiveSyntax(template.content);\n if (normalizedTemplate === template.content) {\n return source;\n }\n\n const bounds = resolveTemplateContentBounds(source, template.content, template.loc.start.offset);\n if (!bounds) {\n return source;\n }\n\n return `${source.slice(0, bounds.start)}${normalizedTemplate}${source.slice(bounds.end)}`;\n}\n\n/** Rewords compiler diagnostics so the public API always speaks Resux syntax. */\nexport function rethrowWithResuxDirectiveBrand(error: unknown): never {\n if (error instanceof Error) {\n error.message = brandDirectiveText(error.message);\n if (error.stack) {\n error.stack = brandDirectiveText(error.stack);\n }\n }\n throw error;\n}\n\nfunction brandDirectiveText(value: string): string {\n return value.replace(/\\bv-(?=[a-z][\\w-]*)/gi, RX_DIRECTIVE_PREFIX);\n}\n\nfunction resolveTemplateContentBounds(\n source: string,\n content: string,\n reportedOffset: number,\n): { start: number; end: number } | null {\n if (source.slice(reportedOffset, reportedOffset + content.length) === content) {\n return { start: reportedOffset, end: reportedOffset + content.length };\n }\n\n const templateOpen = /<template(?:\\s[^>]*)?>/i.exec(source);\n if (!templateOpen || templateOpen.index === undefined) {\n return null;\n }\n\n const openingEnd = templateOpen.index + templateOpen[0].length;\n const fallbackStart = source.indexOf(content, openingEnd);\n if (fallbackStart === -1) {\n return null;\n }\n\n return { start: fallbackStart, end: fallbackStart + content.length };\n}\n\nfunction previousNonSpaceChar(source: string, index: number): string {\n for (let cursor = index - 1; cursor >= 0; cursor--) {\n if (!/\\s/.test(source[cursor])) {\n return source[cursor];\n }\n }\n return \"\";\n}\n\nfunction findTagEnd(source: string, start: number): number {\n let quote: '\"' | \"'\" | null = null;\n\n for (let index = start; index < source.length; index++) {\n const char = source[index];\n if (quote) {\n // HTML attribute values have no backslash escapes, so a value such as\n // title=\"C:\\\" ends at its closing quote.\n if (char === quote) {\n quote = null;\n }\n continue;\n }\n\n // Only a quote that starts an attribute value (right after `=`) opens a\n // quoted region. Quotes inside dynamic argument names such as\n // `:['a\\'b']` are part of an expression, not an attribute value.\n if ((char === '\"' || char === \"'\") && previousNonSpaceChar(source, index) === \"=\") {\n quote = char;\n continue;\n }\n\n if (char === \">\") {\n return index;\n }\n }\n\n return -1;\n}\n\nfunction normalizeOpeningTag(tag: string): string {\n if (/^<\\s*(?:\\/|!|\\?)/.test(tag)) {\n return tag;\n }\n\n let output = \"\";\n let cursor = 0;\n let expectsUnquotedValue = false;\n\n // Copy the opening bracket, whitespace and element name unchanged.\n while (cursor < tag.length && !/\\s/.test(tag[cursor]) && tag[cursor] !== \">\") {\n output += tag[cursor++];\n }\n\n while (cursor < tag.length) {\n const char = tag[cursor];\n\n if (char === '\"' || char === \"'\") {\n const quote = char;\n const valueStart = cursor;\n cursor++;\n while (cursor < tag.length) {\n if (tag[cursor] === quote) {\n cursor++;\n break;\n }\n cursor++;\n }\n output += tag.slice(valueStart, cursor);\n expectsUnquotedValue = false;\n continue;\n }\n\n if (/\\s/.test(char) || char === \"/\" || char === \">\") {\n output += char;\n cursor++;\n continue;\n }\n\n if (char === \"=\") {\n output += char;\n cursor++;\n expectsUnquotedValue = true;\n continue;\n }\n\n const tokenStart = cursor;\n while (\n cursor < tag.length\n && !/\\s/.test(tag[cursor])\n && tag[cursor] !== \"=\"\n && tag[cursor] !== \"/\"\n && tag[cursor] !== \">\"\n ) {\n cursor++;\n }\n\n const token = tag.slice(tokenStart, cursor);\n output += !expectsUnquotedValue\n && token.startsWith(RX_DIRECTIVE_PREFIX)\n && token.length > RX_DIRECTIVE_PREFIX.length\n ? `${VUE_DIRECTIVE_PREFIX}${token.slice(RX_DIRECTIVE_PREFIX.length)}`\n : token;\n expectsUnquotedValue = false;\n }\n\n return output;\n}\n"],"mappings":";;AAEA,MAAM,sBAAsB;AAC5B,MAAM,uBAAuB;;;;;;AAO7B,SAAgB,8BAA8B,UAA0B;CACtE,IAAI,SAAS;CACb,IAAI,SAAS;CAEb,OAAO,SAAS,SAAS,QAAQ;EAC/B,MAAM,WAAW,SAAS,QAAQ,KAAK,MAAM;EAC7C,IAAI,aAAa,IAAI;GACnB,UAAU,SAAS,MAAM,MAAM;GAC/B;EACF;EAEA,UAAU,SAAS,MAAM,QAAQ,QAAQ;EAEzC,IAAI,SAAS,WAAW,QAAQ,QAAQ,GAAG;GACzC,MAAM,aAAa,SAAS,QAAQ,OAAO,WAAW,CAAC;GACvD,IAAI,eAAe,IAAI;IACrB,UAAU,SAAS,MAAM,QAAQ;IACjC;GACF;GACA,UAAU,SAAS,MAAM,UAAU,aAAa,CAAC;GACjD,SAAS,aAAa;GACtB;EACF;EAEA,MAAM,SAAS,WAAW,UAAU,WAAW,CAAC;EAChD,IAAI,WAAW,IAAI;GACjB,UAAU,SAAS,MAAM,QAAQ;GACjC;EACF;EAEA,UAAU,oBAAoB,SAAS,MAAM,UAAU,SAAS,CAA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CAAC,KAAK,KAAK,IAAI,OAAO,KACtB,IAAI,YAAY,OAChB,IAAI,YAAY,OAChB,IAAI,YAAY,KAEnB;EAGF,MAAM,QAAQ,IAAI,MAAM,YAAY,MAAM;EAC1C,UAAU,CAAC,wBACN,MAAM,WAAW,mBAAmB,KACpC,MAAM,SAAS,IACd,GAAG,uBAAuB,MAAM,MAAM,CAA0B,MAChE;EACN,uBAAuB;CACzB;CAEA,OAAO;AACT"}
@@ -1327,7 +1327,7 @@ function transformTemplateExpressionCode(expression, templateRefBindings, file,
1327
1327
  const identifiers = /* @__PURE__ */ new Set();
1328
1328
  const visit = (current) => {
1329
1329
  if (ts.isIdentifier(current)) {
1330
- if (shouldAutoUnwrapTemplateIdentifier(current)) {
1330
+ if (shouldAutoUnwrapTemplateIdentifier(current) && !isShadowedByFunctionParameter(current)) {
1331
1331
  if (templateRefBindings.has(current.text)) {
1332
1332
  const position = current.end - 1;
1333
1333
  if (position >= 0 && position <= expression.length) insertions.push(position);
@@ -1360,6 +1360,13 @@ function transformTemplateExpressionCode(expression, templateRefBindings, file,
1360
1360
  identifiers: [...identifiers]
1361
1361
  };
1362
1362
  }
1363
+ function isShadowedByFunctionParameter(node) {
1364
+ for (let current = node; current; current = current.parent) {
1365
+ if (!ts.isArrowFunction(current) && !ts.isFunctionExpression(current)) continue;
1366
+ for (const parameter of current.parameters) if (collectBindingNames(parameter.name).includes(node.text)) return true;
1367
+ }
1368
+ return false;
1369
+ }
1363
1370
  function shouldAutoUnwrapTemplateIdentifier(node) {
1364
1371
  const parent = node.parent;
1365
1372
  if (!parent) return true;
@@ -2351,21 +2358,31 @@ function scanRuntimeConfigForSecrets(config, halalConfig) {
2351
2358
  /amzn\.mws\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}/i,
2352
2359
  /https?:\/\/[^/]+:[^/]+@/
2353
2360
  ];
2354
- for (const [key, value] of Object.entries(publicConfig)) {
2355
- const upperKey = key.toUpperCase();
2356
- if (unsafeKeys.some((unsafe) => upperKey.includes(unsafe))) {
2357
- const msg = `[resux-safety] Unsafe key name "${key}" found in public runtimeConfig. Do not expose secrets to the client.`;
2358
- if (isStrict) throw new Error(msg);
2359
- else console.warn(`\x1b[33m${msg}\x1b[0m`);
2361
+ const report = (msg) => {
2362
+ if (isStrict) throw new Error(msg);
2363
+ console.warn(`\x1b[33m${msg}\x1b[0m`);
2364
+ };
2365
+ const seen = /* @__PURE__ */ new WeakSet();
2366
+ const scan = (value, pathLabel, keyName) => {
2367
+ if (keyName !== null) {
2368
+ const upperKey = keyName.toUpperCase();
2369
+ if (unsafeKeys.some((unsafe) => upperKey.includes(unsafe))) report(`[resux-safety] Unsafe key name "${pathLabel}" found in public runtimeConfig. Do not expose secrets to the client.`);
2360
2370
  }
2361
2371
  if (typeof value === "string") {
2362
- if (secretValuePatterns.some((pattern) => pattern.test(value))) {
2363
- const msg = `[resux-safety] Value of public runtimeConfig key "${key}" looks like a private credential or API secret. Do not expose secrets to the client.`;
2364
- if (isStrict) throw new Error(msg);
2365
- else console.warn(`\x1b[33m${msg}\x1b[0m`);
2372
+ if (secretValuePatterns.some((pattern) => pattern.test(value))) report(`[resux-safety] Value of public runtimeConfig key "${pathLabel}" looks like a private credential or API secret. Do not expose secrets to the client.`);
2373
+ return;
2374
+ }
2375
+ if (value && typeof value === "object") {
2376
+ if (seen.has(value)) return;
2377
+ seen.add(value);
2378
+ if (Array.isArray(value)) {
2379
+ value.forEach((item, index) => scan(item, `${pathLabel}[${index}]`, null));
2380
+ return;
2366
2381
  }
2382
+ for (const [childKey, childValue] of Object.entries(value)) scan(childValue, `${pathLabel}.${childKey}`, childKey);
2367
2383
  }
2368
- }
2384
+ };
2385
+ for (const [key, value] of Object.entries(publicConfig)) scan(value, key, key);
2369
2386
  }
2370
2387
  function createRuntimeConfig(config) {
2371
2388
  const runtimeConfig = config.runtimeConfig;
@@ -2383,7 +2400,10 @@ function createRuntimeConfig(config) {
2383
2400
  }
2384
2401
  };
2385
2402
  const halalConfig = config.halalAI;
2386
- scanRuntimeConfigForSecrets(appRuntimeConfig, halalConfig);
2403
+ scanRuntimeConfigForSecrets({
2404
+ ...appRuntimeConfig,
2405
+ public: publicConfig
2406
+ }, halalConfig);
2387
2407
  return appRuntimeConfig;
2388
2408
  }
2389
2409
  function createRouteRules(config) {