@panomc/plugin-kit 0.0.0-stage → 1.0.0-dev.62

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 (89) hide show
  1. package/assets/pano-bootstrap.css +17903 -0
  2. package/bin/__tests__/new/e2e.test.js +111 -0
  3. package/bin/__tests__/new/helpers.js +76 -0
  4. package/bin/__tests__/new/new.test.js +472 -0
  5. package/bin/new.js +530 -0
  6. package/bin/pano-plugin.js +162 -0
  7. package/bin/templates/plugin/README.md +30 -0
  8. package/bin/templates/plugin/_gitignore +15 -0
  9. package/bin/templates/plugin/build.gradle.kts +389 -0
  10. package/bin/templates/plugin/gradle/wrapper/gradle-wrapper.jar +0 -0
  11. package/bin/templates/plugin/gradle/wrapper/gradle-wrapper.properties +7 -0
  12. package/bin/templates/plugin/gradle.properties +55 -0
  13. package/bin/templates/plugin/gradlew +249 -0
  14. package/bin/templates/plugin/gradlew.bat +92 -0
  15. package/bin/templates/plugin/package.json.tpl +14 -0
  16. package/bin/templates/plugin/rollup.config.js +2 -0
  17. package/bin/templates/plugin/settings.gradle.kts +5 -0
  18. package/bin/templates/plugin/src/main/kotlin/__PKGPATH__/__CLASS__Plugin.kt +50 -0
  19. package/bin/templates/plugin/src/main/kotlin/__PKGPATH__/frontend/ExampleFallbackPage.kt +28 -0
  20. package/bin/templates/plugin/src/main/kotlin/__PKGPATH__/routes/GetHelloAPI.kt +19 -0
  21. package/bin/templates/plugin/src/main/kotlin/com/panomc/plugins/license/LicenseGuard.kt +30 -0
  22. package/bin/templates/plugin/src/main/kotlin/com/panomc/plugins/license/PluginLicenseClient.kt +144 -0
  23. package/bin/templates/plugin/src/main/resources/config.conf +1 -0
  24. package/bin/templates/plugin/src/main/resources/frontend-targets.json +1 -0
  25. package/bin/templates/plugin/src/main/resources/locales/en-US.json +3 -0
  26. package/bin/templates/plugin/src/main/resources/logo.png +0 -0
  27. package/bin/templates/plugin/src/theme/views/HelloPage.svelte +26 -0
  28. package/bin/ui.js +96 -0
  29. package/package.json +48 -4
  30. package/src/config.js +191 -0
  31. package/src/controller/__tests__/controller.test.js +647 -0
  32. package/src/controller/index.js +604 -0
  33. package/src/dev.js +208 -0
  34. package/src/index.js +22 -0
  35. package/src/rollup/__tests__/controllers/controllers.test.js +418 -0
  36. package/src/rollup/__tests__/controllers/fixture.js +143 -0
  37. package/src/rollup/__tests__/controllers/golden/controllers.json +34 -0
  38. package/src/rollup/__tests__/controllers/golden/controllers.types.js +69 -0
  39. package/src/rollup/__tests__/controllers/golden/pano-plugin.json +16 -0
  40. package/src/rollup/__tests__/controllers/golden/pano-plugin.lock.json +27 -0
  41. package/src/rollup/__tests__/controllers/golden/pano-plugin.with-views.json +54 -0
  42. package/src/rollup/__tests__/preset/preset.test.js +418 -0
  43. package/src/rollup/__tests__/rules/_build.js +39 -0
  44. package/src/rollup/__tests__/rules/_fixture.js +83 -0
  45. package/src/rollup/__tests__/rules/helpers.test.js +148 -0
  46. package/src/rollup/__tests__/rules/rules.test.js +259 -0
  47. package/src/rollup/__tests__/rules/stamp.test.js +113 -0
  48. package/src/rollup/__tests__/samples/samples.test.js +481 -0
  49. package/src/rollup/__tests__/seams/config.test.js +78 -0
  50. package/src/rollup/__tests__/seams/lock.test.js +124 -0
  51. package/src/rollup/__tests__/seams/sdk-seams.test.js +93 -0
  52. package/src/rollup/__tests__/seams/stubs.test.js +52 -0
  53. package/src/rollup/__tests__/views/helpers.js +82 -0
  54. package/src/rollup/__tests__/views/views.test.js +522 -0
  55. package/src/rollup/__tests__/widgets/helpers.js +117 -0
  56. package/src/rollup/__tests__/widgets/widgets.test.js +422 -0
  57. package/src/rollup/cli-build.js +90 -0
  58. package/src/rollup/cli-check.js +280 -0
  59. package/src/rollup/cli-classes.js +75 -0
  60. package/src/rollup/client-gen.js +67 -0
  61. package/src/rollup/controllers.js +434 -0
  62. package/src/rollup/entry.js +250 -0
  63. package/src/rollup/helpers.js +193 -0
  64. package/src/rollup/index.js +601 -0
  65. package/src/rollup/integrate.js +205 -0
  66. package/src/rollup/lock.js +230 -0
  67. package/src/rollup/meta.js +479 -0
  68. package/src/rollup/rules.js +950 -0
  69. package/src/rollup/samples.js +667 -0
  70. package/src/rollup/stamp.js +410 -0
  71. package/src/rollup/types.js +248 -0
  72. package/src/rollup/views.js +1205 -0
  73. package/src/rollup/widgets.js +1000 -0
  74. package/src/styles/__tests__/fallback/__snapshots__/build-fallback-css.test.js.snap +173 -0
  75. package/src/styles/__tests__/fallback/build-fallback-css.test.js +526 -0
  76. package/src/styles/__tests__/fallback/fixtures/base.css +247 -0
  77. package/src/styles/__tests__/fallback/plugins.test.js +301 -0
  78. package/src/styles/__tests__/lint/check-styles.test.js +423 -0
  79. package/src/styles/__tests__/lint/fixtures/ProductCard.golden.svelte +13 -0
  80. package/src/styles/__tests__/lint/fixtures/ProductCard.in.svelte +13 -0
  81. package/src/styles/__tests__/lint/semantic-classes.test.js +364 -0
  82. package/src/styles/bootstrap-classes.js +155 -0
  83. package/src/styles/check-styles.js +626 -0
  84. package/src/styles/fallback-css.js +1182 -0
  85. package/src/styles/plugin-css.js +237 -0
  86. package/src/styles/scan.js +206 -0
  87. package/src/styles/semantic-classes.js +436 -0
  88. package/src/styles/tokens.map.js +53 -0
  89. package/README.md +0 -3
@@ -0,0 +1,259 @@
1
+ import { afterAll, afterEach, describe, expect, test } from "bun:test";
2
+ import { analyzeProject, panoRules, resolveProject } from "../../rules.js";
3
+ import { GOOD_FILES, cleanup, makePlugin, runBuildStart } from "./_fixture.js";
4
+
5
+ afterAll(cleanup);
6
+
7
+ /** @param {Record<string, string>} files */
8
+ async function analyze(files) {
9
+ const root = makePlugin(files);
10
+ const project = await resolveProject({ root });
11
+ return { root, project, analysis: await analyzeProject(project) };
12
+ }
13
+
14
+ /** @param {Record<string, string>} files */
15
+ async function start(files, options = {}) {
16
+ const root = makePlugin(files);
17
+ return runBuildStart(panoRules({ root, ...options }));
18
+ }
19
+
20
+ describe("panoRules: a plugin that follows every rule", () => {
21
+ test("has no violations and reports the helper closure", async () => {
22
+ const { analysis, project } = await analyze(GOOD_FILES);
23
+
24
+ expect(analysis.violations).toEqual([]);
25
+ expect(analysis.views.size).toBe(2);
26
+ expect(analysis.helpers.get("ProductCard")?.map((file) => file.replace(project.themeDir, ""))).toEqual([
27
+ "/lib/round.js",
28
+ "/lib/sale.js",
29
+ ]);
30
+ expect(analysis.helpers.get("Child")).toEqual([]);
31
+ });
32
+
33
+ test("buildStart passes", async () => {
34
+ const { error, warnings } = await start(GOOD_FILES);
35
+ expect(error).toBeNull();
36
+ expect(warnings).toEqual([]);
37
+ });
38
+ });
39
+
40
+ describe("V1 view imports", () => {
41
+ test("a view importing a controller names file, line and the require() replacement", async () => {
42
+ const { error } = await start({
43
+ ...GOOD_FILES,
44
+ "src/theme/controllers/pricing.js": "export default {};\n",
45
+ "src/theme/views/ProductCard.svelte":
46
+ '<script>\n import { x } from "svelte";\n import pricing from "../controllers/pricing.js";\n</script>\n<div />\n',
47
+ });
48
+
49
+ expect(error?.message).toBe(
50
+ "ProductCard.svelte:3 imports ../controllers/pricing.js — controllers are compiled and closed; read it with plugin('market').require('pricing')",
51
+ );
52
+ });
53
+
54
+ test("a helper importing a package says which view uses it", async () => {
55
+ const { error } = await start({
56
+ ...GOOD_FILES,
57
+ "src/theme/lib/sale.js": 'import dayjs from "dayjs";\nexport const sale = () => dayjs();\n',
58
+ });
59
+
60
+ expect(error?.message).toBe(
61
+ "lib/sale.js:1 (used by ProductCard.svelte) imports dayjs — view helpers ship as readable source and cannot import packages; move that code to src/theme/controllers/ (packages are bundled there)",
62
+ );
63
+ });
64
+
65
+ test("a view importing a package gets the same fix", async () => {
66
+ const { error } = await start({
67
+ ...GOOD_FILES,
68
+ "src/theme/views/Child.svelte": '<script>\n import dayjs from "dayjs";\n</script>\n<p />\n',
69
+ });
70
+
71
+ expect(error?.message).toContain("Child.svelte:2 imports dayjs — view helpers ship as readable source and cannot import packages");
72
+ expect(error?.message).toContain("move that code to src/theme/controllers/ (packages are bundled there)");
73
+ });
74
+
75
+ test("a helper that imports a controller is refused", async () => {
76
+ const { error } = await start({
77
+ ...GOOD_FILES,
78
+ "src/theme/controllers/pricing.js": "export default {};\n",
79
+ "src/theme/lib/round.js": 'import p from "../controllers/pricing.js";\nexport const round = (n) => n;\n',
80
+ });
81
+
82
+ expect(error?.message).toContain("lib/round.js:1 (used by ProductCard.svelte) imports ../controllers/pricing.js — controllers are compiled and closed");
83
+ });
84
+
85
+ test("a helper outside src/theme and a non-js import are refused", async () => {
86
+ const { analysis } = await analyze({
87
+ ...GOOD_FILES,
88
+ "src/shared.js": "export const shared = 1;\n",
89
+ "src/theme/views/Child.svelte":
90
+ '<script>\n import { shared } from "../../shared.js";\n import data from "../data.json";\n</script>\n<p />\n',
91
+ "src/theme/data.json": "{}",
92
+ });
93
+
94
+ const messages = analysis.violations.map((violation) => violation.message);
95
+ expect(messages).toContain(
96
+ "Child.svelte:2 imports ../../shared.js — view helpers must live under src/theme/ so they ship with the views",
97
+ );
98
+ expect(messages).toContain("Child.svelte:3 imports ../data.json — views import only .svelte files and relative .js view helpers");
99
+ });
100
+
101
+ test("a helper may not import svelte or the sdk (only other helpers)", async () => {
102
+ const { analysis } = await analyze({
103
+ ...GOOD_FILES,
104
+ "src/theme/lib/round.js": 'import { get } from "svelte/store";\nexport const round = (n) => n;\n',
105
+ });
106
+
107
+ expect(analysis.violations.map((violation) => violation.message)).toEqual([
108
+ expect.stringContaining("lib/round.js:1 (used by ProductCard.svelte) imports svelte/store"),
109
+ ]);
110
+ });
111
+ });
112
+
113
+ describe("V2 controller purity", () => {
114
+ const files = {
115
+ ...GOOD_FILES,
116
+ "src/theme/controllers/cart.js": 'import { session } from "../stores/session.js";\nexport default {};\n',
117
+ "src/theme/stores/session.js": 'import { writable } from "svelte/store";\nexport const session = writable(null);\n',
118
+ };
119
+
120
+ test("the error shows the import chain", async () => {
121
+ const { error } = await start(files);
122
+
123
+ expect(error?.message).toBe(
124
+ "controllers/cart.js -> stores/session.js:1 imports svelte/store — controllers are framework-free; use host.session().",
125
+ );
126
+ });
127
+
128
+ test("the sdk, $app and a .svelte file are refused too; packages and helpers are fine", async () => {
129
+ const { analysis } = await analyze({
130
+ ...GOOD_FILES,
131
+ "src/theme/controllers/a.js": 'import x from "@panomc/sdk/controllers";\nimport y from "$app/navigation";\nimport V from "../views/Child.svelte";\nimport dayjs from "dayjs";\nimport { sale } from "../lib/sale.js";\nexport default {};\n',
132
+ });
133
+
134
+ expect(analysis.violations.map((violation) => violation.rule)).toEqual(["V2", "V2", "V2"]);
135
+ expect(analysis.violations.map((violation) => violation.message)).toEqual([
136
+ expect.stringContaining("controllers/a.js:1 imports @panomc/sdk/controllers"),
137
+ expect.stringContaining("controllers/a.js:2 imports $app/navigation"),
138
+ expect.stringContaining("controllers/a.js:3 imports ../views/Child.svelte"),
139
+ ]);
140
+ });
141
+
142
+ test("V2 stays an error in migration mode", async () => {
143
+ const { error } = await start(files, { viewImports: "warn" });
144
+ expect(error?.message).toContain("controllers/cart.js -> stores/session.js:1 imports svelte/store");
145
+ });
146
+ });
147
+
148
+ describe("V3 sample purity", () => {
149
+ test("a samples file importing a package fails", async () => {
150
+ const { error } = await start({
151
+ ...GOOD_FILES,
152
+ "src/theme/views/ProductCard.samples.js": 'import dayjs from "dayjs";\nexport const filled = {};\n',
153
+ });
154
+
155
+ expect(error?.message).toBe(
156
+ "views/ProductCard.samples.js:1 imports dayjs — sample files are pure data: import only view helpers and other relative .js fixtures (no packages, no Svelte, no @panomc/sdk)",
157
+ );
158
+ });
159
+
160
+ test("the chain through a fixture file is shown; relative .js fixtures pass", async () => {
161
+ const { analysis } = await analyze({
162
+ ...GOOD_FILES,
163
+ "src/theme/views/ProductCard.samples.js": 'import { product } from "../fixtures/product.js";\nimport { sale } from "../lib/sale.js";\nexport const filled = { product };\n',
164
+ "src/theme/fixtures/product.js": 'import { get } from "svelte/store";\nexport const product = {};\n',
165
+ });
166
+
167
+ expect(analysis.violations.map((violation) => violation.message)).toEqual([
168
+ "views/ProductCard.samples.js -> fixtures/product.js:1 imports svelte/store — sample files are pure data: import only view helpers and other relative .js fixtures (no packages, no Svelte, no @panomc/sdk)",
169
+ ]);
170
+ });
171
+ });
172
+
173
+ describe("V5 no context between views", () => {
174
+ const files = {
175
+ ...GOOD_FILES,
176
+ "src/theme/views/Child.svelte":
177
+ '<script>\n import { getContext } from "svelte";\n\n const session = getContext("session");\n</script>\n<p />\n',
178
+ };
179
+
180
+ test("getContext in a view names file, line and the replacement", async () => {
181
+ const { error } = await start(files);
182
+
183
+ expect(error?.message).toBe(
184
+ 'Child.svelte:4 getContext("session"): views run in two Svelte copies on the server; take it as a prop or read host data through @panomc/sdk',
185
+ );
186
+ });
187
+
188
+ test("setContext, hasContext, aliases and a namespace import are found", async () => {
189
+ const { analysis } = await analyze({
190
+ ...GOOD_FILES,
191
+ "src/theme/views/Child.svelte":
192
+ '<script>\n import { setContext as put, hasContext } from "svelte";\n import * as S from "svelte";\n put("a", 1);\n const h = hasContext("b");\n S.getContext("c");\n</script>\n<p />\n',
193
+ });
194
+
195
+ expect(analysis.violations.map((violation) => violation.message)).toEqual([
196
+ expect.stringContaining('Child.svelte:4 setContext("a")'),
197
+ expect.stringContaining('Child.svelte:5 hasContext("b")'),
198
+ expect.stringContaining('Child.svelte:6 getContext("c")'),
199
+ ]);
200
+ });
201
+
202
+ test("a module-script call is found as well, and the same name from elsewhere is not", async () => {
203
+ const { analysis } = await analyze({
204
+ ...GOOD_FILES,
205
+ "src/theme/views/Child.svelte":
206
+ '<script module>\n import { getContext } from "svelte";\n export const view = {};\n</script>\n<script>\n const getContext2 = () => 1;\n const x = getContext("k");\n</script>\n<p />\n',
207
+ "src/theme/views/Other.svelte": '<script>\n const getContext = () => 1;\n getContext("k");\n</script>\n<p />\n',
208
+ });
209
+
210
+ expect(analysis.violations.map((violation) => violation.message)).toEqual([
211
+ expect.stringContaining('Child.svelte:7 getContext("k")'),
212
+ ]);
213
+ });
214
+ });
215
+
216
+ describe("PANO_VIEW_IMPORTS=warn (migration mode)", () => {
217
+ const files = {
218
+ ...GOOD_FILES,
219
+ "src/theme/controllers/pricing.js": "export default {};\n",
220
+ "src/theme/views/ProductCard.svelte":
221
+ '<script>\n import pricing from "../controllers/pricing.js";\n import { getContext } from "svelte";\n getContext("x");\n</script>\n<div />\n',
222
+ };
223
+
224
+ afterEach(() => {
225
+ delete process.env.PANO_VIEW_IMPORTS;
226
+ });
227
+
228
+ test("turns V1 and V5 into warnings and sets the manifest flag", async () => {
229
+ process.env.PANO_VIEW_IMPORTS = "warn";
230
+
231
+ const root = makePlugin(files);
232
+ const plugin = panoRules({ root });
233
+ const { error, warnings } = await runBuildStart(plugin);
234
+
235
+ expect(error).toBeNull();
236
+ expect(warnings).toHaveLength(2);
237
+ expect(warnings[0]).toContain("ProductCard.svelte:2 imports ../controllers/pricing.js");
238
+ expect(warnings[1]).toContain('ProductCard.svelte:4 getContext("x")');
239
+ expect(plugin.api.viewImports).toBe("warn");
240
+ expect(plugin.api.manifestFlags()).toEqual({ viewImports: "warn" });
241
+ });
242
+
243
+ test("without the variable the same plugin fails and sets no flag", async () => {
244
+ const root = makePlugin(files);
245
+ const plugin = panoRules({ root });
246
+ const { error } = await runBuildStart(plugin);
247
+
248
+ expect(error?.message).toContain("2 build rule violations");
249
+ expect(plugin.api.viewImports).toBe("error");
250
+ expect(plugin.api.manifestFlags()).toEqual({});
251
+ });
252
+
253
+ test("the shared context gets the mode", async () => {
254
+ const context = /** @type {Record<string, any>} */ ({});
255
+ await runBuildStart(panoRules({ root: makePlugin(files), viewImports: "warn", context }));
256
+ expect(context.viewImports).toBe("warn");
257
+ expect(context.violations).toHaveLength(2);
258
+ });
259
+ });
@@ -0,0 +1,113 @@
1
+ import { afterAll, describe, expect, test } from "bun:test";
2
+ import { panoStamp, readControllerVersions } from "../../stamp.js";
3
+ import { resolveProject } from "../../rules.js";
4
+ import { buildViews } from "./_build.js";
5
+ import { cleanup, makePlugin } from "./_fixture.js";
6
+
7
+ afterAll(cleanup);
8
+
9
+ const CART = `import { defineController } from "@panomc/plugin-kit/controller";
10
+ export default defineController({ name: "cart", version: 3, state: () => ({}), actions: () => ({}) });
11
+ `;
12
+ const FORMAT = `import { defineController } from "@panomc/plugin-kit/controller";
13
+ export default defineController({ name: "format", version: 2, state: () => ({}), actions: () => ({}) });
14
+ `;
15
+
16
+ /** @param {string} body */
17
+ const view = (body) => `<script>\n import { plugin } from "@panomc/sdk/controllers";\n${body}\n</script>\n<p />\n`;
18
+
19
+ describe("stamping", () => {
20
+ test("reads the versions from defineController calls", async () => {
21
+ const root = makePlugin({ "src/theme/controllers/cart.js": CART, "src/theme/controllers/format.js": FORMAT, "src/theme/controllers/_private.js": "export const x = 1;\n" });
22
+ expect(await readControllerVersions(await resolveProject({ root }))).toEqual({ cart: 3, format: 2 });
23
+ });
24
+
25
+ test("require / use / load get { version }, readable copy stays as written", async () => {
26
+ const source = view(` const market = plugin("market");
27
+ const cart = market.require("cart");
28
+ const fmt = plugin("market").use("format");
29
+ const later = market.load("cart", { params: { a: 1 } });
30
+ const kept = market.use("cart", { version: 9 });`);
31
+ const root = makePlugin({
32
+ "src/theme/controllers/cart.js": CART,
33
+ "src/theme/controllers/format.js": FORMAT,
34
+ "src/theme/views/A.svelte": source,
35
+ });
36
+ const stamp = panoStamp({ root });
37
+ const { code } = await buildViews(root, ["src/theme/views/A.svelte"], [stamp]);
38
+
39
+ expect(code).toContain('market.require("cart", { version: 3 })');
40
+ expect(code).toContain('plugin("market").use("format", { version: 2 })');
41
+ expect(code).toMatch(/market\.load\("cart", \{ params: \{ a: 1 \}, version: 3 \}\)/);
42
+ expect(code).toContain('market.use("cart", { version: 9 })');
43
+ expect(stamp.api.usage.get("A")).toEqual({ "market/cart": 3, "market/format": 2 });
44
+
45
+ // the readable copy is the author's source: the plugin never writes to it
46
+ const { default: fs } = await import("node:fs");
47
+ expect(fs.readFileSync(`${root}/src/theme/views/A.svelte`, "utf8")).toBe(source);
48
+ expect(source).not.toContain("version: 3");
49
+ });
50
+
51
+ test("destructured methods, a variable options object and useController", async () => {
52
+ const root = makePlugin({
53
+ "src/theme/controllers/cart.js": CART,
54
+ "src/theme/views/A.svelte": `<script>
55
+ import { plugin, useController as uc } from "@panomc/sdk/controllers";
56
+ const { require: need } = plugin("market");
57
+ const a = need("cart");
58
+ const opts = { params: {} };
59
+ const b = plugin("market").use("cart", opts);
60
+ const c = uc("market/cart");
61
+ const d = uc("other/cart");
62
+ const e = plugin("other").require("cart");
63
+ </script>
64
+ <p />
65
+ `,
66
+ });
67
+ const { code } = await buildViews(root, ["src/theme/views/A.svelte"], [panoStamp({ root })]);
68
+
69
+ expect(code).toContain('need("cart", { version: 3 })');
70
+ expect(code).toContain('.use("cart", { ...(opts), version: 3 })');
71
+ expect(code).toContain('useController("market/cart", { version: 3 })');
72
+ expect(code).toContain('useController("other/cart")');
73
+ expect(code).toContain('plugin("other").require("cart")');
74
+ });
75
+
76
+ test("a non-literal controller name is a build error with the author's line", async () => {
77
+ const root = makePlugin({
78
+ "src/theme/controllers/cart.js": CART,
79
+ "src/theme/views/A.svelte": view(` const name = "cart";\n\n const cart = plugin("market").require(name);`),
80
+ });
81
+
82
+ await expect(buildViews(root, ["src/theme/views/A.svelte"], [panoStamp({ root })])).rejects.toThrow(
83
+ "A.svelte:5 require(name) — controller names must be string literals so the build can stamp their version",
84
+ );
85
+ });
86
+
87
+ test("an unknown controller name warns and is left alone", async () => {
88
+ const root = makePlugin({
89
+ "src/theme/controllers/cart.js": CART,
90
+ "src/theme/views/A.svelte": view(` const x = plugin("market").require("missing");`),
91
+ });
92
+ const warnings = /** @type {string[]} */ ([]);
93
+ const { code } = await buildViews(root, ["src/theme/views/A.svelte"], [panoStamp({ root })], {
94
+ onwarn: (message) => warnings.push(message),
95
+ });
96
+
97
+ expect(code).toContain('require("missing")');
98
+ expect(warnings.join("\n")).toContain("A.svelte:3 require('missing') — no controller named missing");
99
+ });
100
+
101
+ test("an explicit controllers option replaces reading the files", async () => {
102
+ const root = makePlugin({ "src/theme/views/A.svelte": view(` const x = plugin("market").require("cart");`) });
103
+ const { code } = await buildViews(root, ["src/theme/views/A.svelte"], [panoStamp({ root, controllers: { "market/cart": 7 } })]);
104
+ expect(code).toContain('require("cart", { version: 7 })');
105
+ });
106
+
107
+ test("a view without controller calls is left untouched", async () => {
108
+ const root = makePlugin({ "src/theme/views/A.svelte": "<p>hi</p>\n" });
109
+ const stamp = panoStamp({ root });
110
+ await buildViews(root, ["src/theme/views/A.svelte"], [stamp]);
111
+ expect(stamp.api.usage.get("A")).toEqual({});
112
+ });
113
+ });