@mayson-org/inject-script 1.0.30 → 1.0.32

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EAEf,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EACL,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAChF,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,0BAA0B,GAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,WAAW,EACX,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,8BAA8B,EAC9B,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,sCAAsC,EACtC,8BAA8B,EAC9B,mBAAmB,EAC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AmB,EACnB,+BAA+B,GAChC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,0BAA0B,GAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,WAAW,EACX,sBAAsB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,8BAA8B,EAC9B,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,sCAAsC,EACtC,8BAA8B,EAC9B,mBAAmB,EACnB,eAAe,EACf,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,aAAa,EACb,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AAKzB,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mFAAmF;IACnF,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AA2EF;;;GAGG;AACH,wBAAsB,aAAa,CACjC,WAAW,GAAE,MAAsB,EACnC,cAAc,GAAE,aAAa,EAAE,GAAG,oBAAoC,EACtE,SAAS,GAAE,OAAe,GACzB,OAAO,CAAC,cAAc,CAAC,CAmHzB"}
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ function normalizeArgs(typesOrOptions, dryRunArg) {
36
36
  pwaEnabled: typesOrOptions.pwa !== false,
37
37
  };
38
38
  }
39
- function filterTypesForConfig(types, showRemixPill, pwaEnabled) {
39
+ function filterTypesForConfig(types, pwaEnabled) {
40
40
  const messages = [];
41
41
  let selected = types.includes('all') ? [...ALL_TYPES] : [...types];
42
42
  if (!pwaEnabled) {
@@ -45,14 +45,16 @@ function filterTypesForConfig(types, showRemixPill, pwaEnabled) {
45
45
  }
46
46
  selected = selected.filter((t) => t !== 'pwa');
47
47
  }
48
- if (selected.includes('watermark') && !showRemixPill) {
49
- messages.push('watermark disabled — show_remix_pill is false (removing pill if present)');
50
- return {
51
- types: selected.filter((t) => t !== 'watermark'),
52
- messages,
53
- removeWatermark: true,
54
- };
55
- }
48
+ // if (selected.includes('watermark')) {
49
+ // messages.push(
50
+ // 'watermark disabled — show_remix_pill is false (removing pill if present)',
51
+ // );
52
+ // return {
53
+ // types: selected.filter((t) => t !== 'watermark'),
54
+ // messages,
55
+ // removeWatermark: true,
56
+ // };
57
+ // }
56
58
  return { types: selected, messages, removeWatermark: false };
57
59
  }
58
60
  function stripWatermark(layoutPath, dryRun, messages) {
@@ -82,7 +84,7 @@ export async function runAutoInject(projectRoot = process.cwd(), typesOrOptions
82
84
  }
83
85
  const config = await resolveMaysonConfig();
84
86
  console.log(`[mayson] resolved show_remix_pill=${config.showRemixPill} enable_remix=${config.enableRemix}`);
85
- const { types: effectiveTypes, messages, removeWatermark } = filterTypesForConfig(types, config.showRemixPill, pwaEnabled);
87
+ const { types: effectiveTypes, messages, removeWatermark } = filterTypesForConfig(types, pwaEnabled);
86
88
  if (removeWatermark) {
87
89
  stripWatermark(layoutPath, dryRun, messages);
88
90
  }
@@ -112,8 +114,6 @@ export async function runAutoInject(projectRoot = process.cwd(), typesOrOptions
112
114
  metadata: {
113
115
  apiRoutePath: `/api/${apiSubpath}`,
114
116
  appBaseUrl: config.appBaseUrl,
115
- workspaceId: config.workspaceId,
116
- collectionId: config.collectionId,
117
117
  },
118
118
  };
119
119
  const isTypeScript = layoutPath.endsWith('.tsx') || layoutPath.endsWith('.ts');
@@ -54,12 +54,10 @@ describe('Metadata API Route & Cookie Caching', () => {
54
54
  assert.ok(!subpath1.startsWith('mayson-'));
55
55
  assert.notEqual(subpath1, subpath2);
56
56
  });
57
- it('patches next.config with rewrites for /~muxt-app.js and /~api/analytics including workspace_id and collection_id', () => {
57
+ it('patches next.config with rewrites for /~muxt-app.js and /~api/analytics', () => {
58
58
  const res = patchNextConfig({
59
59
  projectRoot: process.cwd(),
60
60
  appBaseUrl: 'https://mayson.dev',
61
- workspaceId: 'work_123',
62
- collectionId: 'coll_456',
63
61
  dryRun: true,
64
62
  });
65
63
  assert.ok(res.messages.length > 0);
@@ -1 +1 @@
1
- {"version":3,"file":"inject-api-route.d.ts","sourceRoot":"","sources":["../../../src/plugins/metadata/inject-api-route.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAIrF;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAOjD;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ3E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,MAAM,GACvB,MAAM,CAKR;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,oBAAoB,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GACxD,mBAAmB,CAqErB"}
1
+ {"version":3,"file":"inject-api-route.d.ts","sourceRoot":"","sources":["../../../src/plugins/metadata/inject-api-route.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAIrF;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CAOjD;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ3E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,MAAM,GACvB,MAAM,CAKR;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,oBAAoB,GAAG;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GACxD,mBAAmB,CA4DrB"}
@@ -40,17 +40,10 @@ export function injectMetadataApiRoute(context) {
40
40
  const injectedComponents = [];
41
41
  const skippedComponents = [];
42
42
  const appBaseUrl = context.context?.metadata?.appBaseUrl || context.context?.watermark?.appBaseUrl;
43
- const workspaceId = context.context?.metadata?.workspaceId || process.env.MAYSON_WORKSPACE_ID;
44
- const collectionId = context.context?.metadata?.collectionId ||
45
- context.context?.watermark?.collectionId ||
46
- process.env.MAYSON_COLLECTION_ID ||
47
- process.env.NEXT_PUBLIC_MAYSON_COLLECTION_ID;
48
43
  // Patch next.config rewrites for /~muxt-app.js and /~api/analytics
49
44
  const nextConfigResult = patchNextConfig({
50
45
  projectRoot,
51
46
  appBaseUrl,
52
- workspaceId,
53
- collectionId,
54
47
  dryRun,
55
48
  });
56
49
  messages.push(...nextConfigResult.messages);
@@ -1,8 +1,6 @@
1
1
  export declare function patchNextConfig(options: {
2
2
  projectRoot: string;
3
3
  appBaseUrl?: string;
4
- workspaceId?: string;
5
- collectionId?: string;
6
4
  dryRun?: boolean;
7
5
  }): {
8
6
  changed: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"patch-next-config.d.ts","sourceRoot":"","sources":["../../../src/plugins/metadata/patch-next-config.ts"],"names":[],"mappings":"AAOA,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAgH3C"}
1
+ {"version":3,"file":"patch-next-config.d.ts","sourceRoot":"","sources":["../../../src/plugins/metadata/patch-next-config.ts"],"names":[],"mappings":"AASA,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CA0F3C"}
@@ -5,22 +5,8 @@ function readEnv(key) {
5
5
  }
6
6
  export function patchNextConfig(options) {
7
7
  const { projectRoot, dryRun = false } = options;
8
- const rawBase = (options.appBaseUrl || readEnv('MAYSON_APP_BASE_URL') || 'https://mayson.dev').replace(/\/$/, '');
8
+ const rawBase = (options.appBaseUrl || 'https://mayson.dev').replace(/\/$/, '');
9
9
  const messages = [];
10
- const workspaceId = (options.workspaceId ||
11
- readEnv('MAYSON_WORKSPACE_ID')).trim();
12
- const collectionId = (options.collectionId ||
13
- readEnv('MAYSON_COLLECTION_ID') ||
14
- readEnv('NEXT_PUBLIC_MAYSON_COLLECTION_ID')).trim();
15
- const queryParts = [];
16
- if (workspaceId) {
17
- queryParts.push(`workspace_id=${encodeURIComponent(workspaceId)}`);
18
- }
19
- if (collectionId) {
20
- queryParts.push(`collection_id=${encodeURIComponent(collectionId)}`);
21
- }
22
- const queryString = queryParts.length > 0 ? `?${queryParts.join('&')}` : '';
23
- const analyticsDestination = `${rawBase}/api/analytics${queryString}`;
24
10
  const rewritesSnippet = `
25
11
  async rewrites() {
26
12
  return [
@@ -30,7 +16,7 @@ export function patchNextConfig(options) {
30
16
  },
31
17
  {
32
18
  source: '/~api/analytics',
33
- destination: '${analyticsDestination}',
19
+ destination: '${rawBase}/api/analytics?workspace_id=${readEnv('MAYSON_WORKSPACE_ID')}&collection_id=${readEnv('MAYSON_COLLECTION_ID')}',
34
20
  },
35
21
  ];
36
22
  },`;
@@ -68,7 +54,7 @@ module.exports = nextConfig;
68
54
  },
69
55
  {
70
56
  source: '/~api/analytics',
71
- destination: '${analyticsDestination}',
57
+ destination: '${rawBase}/api/analytics',
72
58
  },`;
73
59
  updated = updated.replace(/return\s*\[/, `return [${rewriteItems}`);
74
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mayson-org/inject-script",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "CLI and library to inject Mayson watermark, ascii, and PWA into Next.js App Router layouts.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",