@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,436 @@
1
+ /**
2
+ * Semantic classes (doc 03 section 1): the root class `<ns>-<view-kebab>` is added by the build,
3
+ * the part classes `<ns>-<view-kebab>__<part>` by the `pano-plugin classes --fix` codemod.
4
+ *
5
+ * Parser: `parse(source, { modern: true })` from `svelte/compiler`; edits with `magic-string`.
6
+ * Classes carry no styling; Bootstrap classes stay beside them.
7
+ */
8
+ import MagicString from 'magic-string';
9
+ import { parse } from 'svelte/compiler';
10
+ import { isAllowedThemeClass } from './bootstrap-classes.js';
11
+
12
+ /**
13
+ * The Bootstrap table of doc 03 section 1.2, in priority order: the first entry whose class the
14
+ * element carries names the part.
15
+ *
16
+ * @type {ReadonlyArray<readonly [string, string]>}
17
+ */
18
+ export const PART_TABLE = Object.freeze([
19
+ ['card-body', 'body'],
20
+ ['card-title', 'title'],
21
+ ['card-header', 'header'],
22
+ ['card-footer', 'footer'],
23
+ ['card-img-top', 'image'],
24
+ ['badge', 'badge'],
25
+ ['alert', 'alert'],
26
+ ['list-group', 'list'],
27
+ ['list-group-item', 'item'],
28
+ ['table', 'table'],
29
+ ['form-control', 'input'],
30
+ ['form-select', 'select'],
31
+ ['form-label', 'label'],
32
+ ['form-check-input', 'check'],
33
+ ['nav-link', 'link'],
34
+ ['modal-header', 'header'],
35
+ ['modal-body', 'body'],
36
+ ['modal-footer', 'footer'],
37
+ ['offcanvas-header', 'header'],
38
+ ['offcanvas-body', 'body'],
39
+ ['dropdown-menu', 'menu'],
40
+ ['dropdown-item', 'menu-item'],
41
+ ['pagination', 'pager'],
42
+ ['btn', 'action'],
43
+ ]);
44
+
45
+ /** The tag table, used after the Bootstrap table. @type {Readonly<Record<string, string>>} */
46
+ export const TAG_TABLE = Object.freeze({
47
+ img: 'image',
48
+ h1: 'title',
49
+ h2: 'title',
50
+ h3: 'title',
51
+ h4: 'title',
52
+ h5: 'title',
53
+ h6: 'title',
54
+ });
55
+
56
+ /** Block types a root element may sit in, with the fragments to descend into. */
57
+ const ROOT_BLOCKS = {
58
+ IfBlock: ['consequent', 'alternate'],
59
+ EachBlock: ['body', 'fallback'],
60
+ AwaitBlock: ['pending', 'then', 'catch'],
61
+ KeyBlock: ['fragment'],
62
+ };
63
+
64
+ /**
65
+ * `ProductCard` -> `product-card`, `HTMLView` -> `html-view`, `add_to_cart` -> `add-to-cart`.
66
+ *
67
+ * @param {string} name
68
+ * @returns {string}
69
+ */
70
+ export function kebab(name) {
71
+ return String(name)
72
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
73
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
74
+ .replace(/[^A-Za-z0-9]+/g, '-')
75
+ .replace(/^-+|-+$/g, '')
76
+ .toLowerCase();
77
+ }
78
+
79
+ /**
80
+ * The root class of a view.
81
+ *
82
+ * @param {string} ns
83
+ * @param {string} view
84
+ * @returns {string}
85
+ */
86
+ export function rootClassOf(ns, view) {
87
+ return `${ns}-${kebab(view)}`;
88
+ }
89
+
90
+ /** A generated root class collides with a Bootstrap / FontAwesome class: the build must fail. */
91
+ export class SemanticClassCollisionError extends Error {
92
+ constructor(message) {
93
+ super(message);
94
+ this.name = 'SemanticClassCollisionError';
95
+ }
96
+ }
97
+
98
+ /** @param {string} source @param {number} index @returns {number} 1-based line */
99
+ function lineOf(source, index) {
100
+ let line = 1;
101
+ for (let i = 0; i < index && i < source.length; i++) if (source.charCodeAt(i) === 10) line++;
102
+ return line;
103
+ }
104
+
105
+ function parseModern(source) {
106
+ return parse(source, { modern: true });
107
+ }
108
+
109
+ /**
110
+ * Class tokens an expression names literally: string literals, template quasis and the keys of an
111
+ * object (`{ 'is-sold-out': cond }`).
112
+ *
113
+ * @param {any} node ESTree node
114
+ * @param {string[]} out
115
+ */
116
+ function literalTokens(node, out) {
117
+ if (!node || typeof node !== 'object') return;
118
+ if (Array.isArray(node)) {
119
+ for (const n of node) literalTokens(n, out);
120
+ return;
121
+ }
122
+ if (node.type === 'Literal' && typeof node.value === 'string') {
123
+ out.push(...node.value.split(/\s+/).filter(Boolean));
124
+ return;
125
+ }
126
+ if (node.type === 'TemplateElement') {
127
+ out.push(...String(node.value?.cooked ?? node.value?.raw ?? '').split(/\s+/).filter(Boolean));
128
+ return;
129
+ }
130
+ if (node.type === 'Property' && !node.computed) {
131
+ if (node.key?.type === 'Identifier') out.push(node.key.name);
132
+ else literalTokens(node.key, out);
133
+ literalTokens(node.value, out);
134
+ return;
135
+ }
136
+ for (const key of Object.keys(node)) {
137
+ if (key === 'loc' || key === 'start' || key === 'end' || key === 'type') continue;
138
+ literalTokens(node[key], out);
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Literal class tokens of one element: the `class` attribute (text and expression literals) and
144
+ * `class:name` directives.
145
+ *
146
+ * @param {any} el RegularElement
147
+ * @returns {string[]}
148
+ */
149
+ function elementTokens(el) {
150
+ /** @type {string[]} */
151
+ const out = [];
152
+ for (const attr of el.attributes ?? []) {
153
+ if (attr.type === 'ClassDirective') out.push(attr.name);
154
+ if (attr.type !== 'Attribute' || attr.name !== 'class' || attr.value === true) continue;
155
+ const parts = Array.isArray(attr.value) ? attr.value : [attr.value];
156
+ for (const part of parts) {
157
+ if (part.type === 'Text') out.push(...part.data.split(/\s+/).filter(Boolean));
158
+ else if (part.type === 'ExpressionTag') literalTokens(part.expression, out);
159
+ }
160
+ }
161
+ return out;
162
+ }
163
+
164
+ /**
165
+ * Root elements: RegularElement nodes reached from the top fragment, descending only through
166
+ * IfBlock, EachBlock, AwaitBlock and KeyBlock (every branch).
167
+ *
168
+ * @param {any} fragment
169
+ * @returns {any[]}
170
+ */
171
+ function rootElements(fragment) {
172
+ const found = [];
173
+ const visit = (nodes) => {
174
+ for (const node of nodes ?? []) {
175
+ if (node.type === 'RegularElement') found.push(node);
176
+ else if (ROOT_BLOCKS[node.type])
177
+ for (const key of ROOT_BLOCKS[node.type]) visit(node[key]?.nodes);
178
+ }
179
+ };
180
+ visit(fragment?.nodes);
181
+ return found;
182
+ }
183
+
184
+ /**
185
+ * Root elements of a view with their literal class tokens, for the lint.
186
+ *
187
+ * @param {string} source
188
+ * @returns {{ tag: string, tokens: string[], line: number }[]}
189
+ */
190
+ export function inspectRoots(source) {
191
+ const ast = parseModern(source);
192
+ return rootElements(ast.fragment).map((el) => ({
193
+ tag: el.name,
194
+ tokens: elementTokens(el),
195
+ line: lineOf(source, el.start),
196
+ }));
197
+ }
198
+
199
+ /** Every RegularElement in the template, in source order. */
200
+ function allElements(root) {
201
+ const found = [];
202
+ const seen = new WeakSet();
203
+ const visit = (node) => {
204
+ if (!node || typeof node !== 'object' || seen.has(node)) return;
205
+ seen.add(node);
206
+ if (Array.isArray(node)) {
207
+ for (const n of node) visit(n);
208
+ return;
209
+ }
210
+ if (node.type === 'RegularElement') found.push(node);
211
+ for (const key of Object.keys(node)) {
212
+ if (key === 'loc' || key === 'name_loc' || key === 'metadata') continue;
213
+ visit(node[key]);
214
+ }
215
+ };
216
+ visit(root.fragment);
217
+ return found.sort((a, b) => a.start - b.start);
218
+ }
219
+
220
+ /**
221
+ * Adds `cls` to an element with the three class forms of doc 03 section 1.2. Returns false when the
222
+ * element already carries it.
223
+ *
224
+ * - no `class` attribute: `class="x"`
225
+ * - text value: `x` is prepended (also inside a quoted value that holds `{expr}` parts)
226
+ * - expression value: `class={['x', <expr>]}`; an array literal gets the entry inserted
227
+ *
228
+ * @param {MagicString} ms
229
+ * @param {any} el RegularElement
230
+ * @param {string} cls
231
+ * @returns {boolean}
232
+ */
233
+ function mergeClass(ms, el, cls) {
234
+ if (elementTokens(el).includes(cls)) return false;
235
+ const attr = (el.attributes ?? []).find((a) => a.type === 'Attribute' && a.name === 'class');
236
+ if (!attr) {
237
+ ms.appendLeft(el.start + 1 + el.name.length, ` class="${cls}"`);
238
+ return true;
239
+ }
240
+ const original = ms.original;
241
+ if (attr.value === true) {
242
+ ms.overwrite(attr.start, attr.end, `class="${cls}"`);
243
+ return true;
244
+ }
245
+ if (Array.isArray(attr.value)) {
246
+ const first = attr.value[0];
247
+ const last = attr.value[attr.value.length - 1];
248
+ if (!first) {
249
+ ms.overwrite(attr.start, attr.end, `class="${cls}"`);
250
+ return true;
251
+ }
252
+ const quoted = /["']/.test(original[first.start - 1] ?? '');
253
+ if (quoted) ms.appendLeft(first.start, `${cls} `);
254
+ else {
255
+ ms.appendLeft(first.start, `"${cls} `);
256
+ ms.appendRight(last.end, '"');
257
+ }
258
+ return true;
259
+ }
260
+ const expr = attr.value.expression;
261
+ if (expr.type === 'ArrayExpression') {
262
+ ms.appendLeft(expr.start + 1, `'${cls}'${expr.elements.length ? ', ' : ''}`);
263
+ } else {
264
+ ms.appendLeft(expr.start, `['${cls}', `);
265
+ ms.appendRight(expr.end, ']');
266
+ }
267
+ return true;
268
+ }
269
+
270
+ /**
271
+ * Adds the root class `<ns>-<view-kebab>` to every root element. Idempotent.
272
+ *
273
+ * - No element root (a component, `{@render}` or text at the top level): no class, `roots` is
274
+ * empty and `warnings` carries the build message.
275
+ * - A generated class that is a Bootstrap / FontAwesome class throws an Error naming `namespace`.
276
+ *
277
+ * @param {string} source
278
+ * @param {{ ns: string, view: string }} ctx
279
+ * @returns {{ code: string, added: string[], roots: string[], warnings: string[] }}
280
+ * roots = tag names found
281
+ */
282
+ export function addRootClass(source, ctx) {
283
+ const cls = rootClassOf(ctx.ns, ctx.view);
284
+ if (isAllowedThemeClass(cls)) {
285
+ throw new SemanticClassCollisionError(
286
+ `${ctx.view}: the generated root class "${cls}" is a Bootstrap / FontAwesome class. ` +
287
+ `Set "namespace" in pano.plugin.js to a short name that does not start like one.`,
288
+ );
289
+ }
290
+ const ast = parseModern(source);
291
+ const elements = rootElements(ast.fragment);
292
+ if (!elements.length) {
293
+ return {
294
+ code: source,
295
+ added: [],
296
+ roots: [],
297
+ warnings: [
298
+ `${ctx.view} has no root element; wrap it in an element so themes can target it`,
299
+ ],
300
+ };
301
+ }
302
+ const ms = new MagicString(source);
303
+ let changed = false;
304
+ for (const el of elements) if (mergeClass(ms, el, cls)) changed = true;
305
+ return {
306
+ code: changed ? ms.toString() : source,
307
+ added: changed ? [cls] : [],
308
+ roots: [...new Set(elements.map((e) => e.name))],
309
+ warnings: [],
310
+ };
311
+ }
312
+
313
+ /** The part name an element's classes ask for, or null. */
314
+ function partNameOf(el, tokens) {
315
+ for (const [bootstrapClass, part] of PART_TABLE) if (tokens.includes(bootstrapClass)) return part;
316
+ const tagPart = TAG_TABLE[el.name];
317
+ if (tagPart && tokens.some((t) => isAllowedThemeClass(t))) return tagPart;
318
+ return null;
319
+ }
320
+
321
+ /**
322
+ * Part name of the Bootstrap table or the tag table for an element, or null when it has none.
323
+ * Used by the lint to name the part a missing class would get.
324
+ *
325
+ * @param {string} tag
326
+ * @param {string[]} tokens
327
+ * @returns {string | null}
328
+ */
329
+ export function partNameFor(tag, tokens) {
330
+ return partNameOf({ name: tag }, tokens);
331
+ }
332
+
333
+ /** Last segment of the first literal `$_('…')` key inside the element, as a kebab part name. */
334
+ function keyPartOf(source, el) {
335
+ const m = /\$_\(\s*(['"`])([^'"`]+)\1/.exec(source.slice(el.start, el.end));
336
+ if (!m) return null;
337
+ const segment = m[2].split('.').pop() ?? '';
338
+ return kebab(segment) || null;
339
+ }
340
+
341
+ /**
342
+ * Adds part classes to elements with a Bootstrap component class and no `<ns>-` class. Idempotent.
343
+ * Name: first match of the Bootstrap table, then the tag table. On a clash inside one file: the
344
+ * last segment of the first `$_('…')` key inside the element, else `<name>-2`, `-3`.
345
+ *
346
+ * @param {string} source
347
+ * @param {{ ns: string, view: string }} ctx
348
+ * @returns {{ code: string, added: { line: number, class: string }[] }}
349
+ */
350
+ export function addPartClasses(source, ctx) {
351
+ const root = rootClassOf(ctx.ns, ctx.view);
352
+ const ast = parseModern(source);
353
+ const ms = new MagicString(source);
354
+ const used = new Set();
355
+ for (const m of source.matchAll(new RegExp(`${escapeRe(root)}__([a-z0-9-]+)`, 'g')))
356
+ used.add(m[1]);
357
+
358
+ const added = [];
359
+ for (const el of allElements(ast)) {
360
+ const tokens = elementTokens(el);
361
+ if (tokens.some((t) => t.startsWith(`${ctx.ns}-`))) continue;
362
+ const base = partNameOf(el, tokens);
363
+ if (!base) continue;
364
+ let name = base;
365
+ if (used.has(name)) {
366
+ const fromKey = keyPartOf(source, el);
367
+ if (fromKey && !used.has(fromKey)) name = fromKey;
368
+ else {
369
+ let n = 2;
370
+ while (used.has(`${base}-${n}`)) n++;
371
+ name = `${base}-${n}`;
372
+ }
373
+ }
374
+ used.add(name);
375
+ const cls = `${root}__${name}`;
376
+ if (mergeClass(ms, el, cls)) added.push({ line: lineOf(source, el.start), class: cls });
377
+ }
378
+ return { code: added.length ? ms.toString() : source, added };
379
+ }
380
+
381
+ function escapeRe(s) {
382
+ return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
383
+ }
384
+
385
+ /**
386
+ * Views a preprocessor instance handles.
387
+ *
388
+ * @typedef {(filename: string) => (string | null | undefined)} ViewResolver
389
+ * returns the view name for a file, or null when the file is not a view
390
+ */
391
+
392
+ /**
393
+ * rollup-plugin-svelte `preprocess` entry (inside `panoPlugin()`): addRootClass on every view.
394
+ *
395
+ * `views` decides which files are views (name = file name without `.svelte`): a function
396
+ * `(filename) => name | null`, or a list of directories / files. Default: every `.svelte` file
397
+ * outside `node_modules`. A file with no element root is left alone and `warn` (default
398
+ * `console.warn`) prints the message. A Bootstrap collision throws, which fails the build.
399
+ *
400
+ * @param {{ ns: string, views?: ViewResolver | string[], warn?: (message: string) => void }} options
401
+ * @returns {{ name: string, markup: (input: { content: string, filename?: string }) => { code: string } | undefined }}
402
+ */
403
+ export function panoSemanticClasses({ ns, views, warn = (m) => console.warn(m) }) {
404
+ const resolve = viewResolver(views);
405
+ return {
406
+ name: 'pano-semantic-classes',
407
+ markup({ content, filename }) {
408
+ if (!filename || !filename.endsWith('.svelte')) return undefined;
409
+ const view = resolve(filename.replace(/\\/g, '/'));
410
+ if (!view) return undefined;
411
+ let result;
412
+ try {
413
+ result = addRootClass(content, { ns, view });
414
+ } catch (error) {
415
+ // A Svelte syntax error is reported by the compiler with better positions; a collision
416
+ // is ours and must fail the build.
417
+ if (error instanceof SemanticClassCollisionError) throw error;
418
+ return undefined;
419
+ }
420
+ for (const message of result.warnings) warn(`${filename}: ${message}`);
421
+ return result.code === content ? undefined : { code: result.code };
422
+ },
423
+ };
424
+ }
425
+
426
+ /** @param {ViewResolver | string[] | undefined} views @returns {ViewResolver} */
427
+ function viewResolver(views) {
428
+ const nameOf = (file) => file.slice(file.lastIndexOf('/') + 1).replace(/\.svelte$/, '');
429
+ if (typeof views === 'function') return views;
430
+ if (Array.isArray(views)) {
431
+ const entries = views.map((v) => v.replace(/\\/g, '/').replace(/\/+$/, ''));
432
+ return (file) =>
433
+ entries.some((e) => file === e || file.startsWith(`${e}/`)) ? nameOf(file) : null;
434
+ }
435
+ return (file) => (file.includes('/node_modules/') ? null : nameOf(file));
436
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The 34 `--pano-*` design tokens (doc 03 section 2). Single source of truth: the Sass bridge, the
3
+ * literal-defaults sheet and the fallback stylesheet are all generated from this table by
4
+ * `scripts/build-tokens.js`.
5
+ *
6
+ * @typedef {object} PanoToken
7
+ * @property {string} token the CSS custom property, e.g. `--pano-color-bg`
8
+ * @property {string|null} bs the Bootstrap CSS variable it mirrors, or null when Bootstrap has none
9
+ * @property {string} [sass] Sass expression used when `bs` is null
10
+ * @property {boolean} [low] declare with zero specificity (`:where()`), so a palette block that sets
11
+ * the same token (the `on-*` pair in `define-theme`) wins over the bridge
12
+ */
13
+
14
+ /** @type {PanoToken[]} */
15
+ export const TOKENS = [
16
+ { token: "--pano-color-bg", bs: "--bs-body-bg" },
17
+ { token: "--pano-color-surface", bs: "--bs-secondary-bg" },
18
+ { token: "--pano-color-surface-raised", bs: "--bs-tertiary-bg" },
19
+ { token: "--pano-color-text", bs: "--bs-body-color" },
20
+ { token: "--pano-color-text-muted", bs: "--bs-secondary-color" },
21
+ { token: "--pano-color-text-subtle", bs: "--bs-tertiary-color" },
22
+ { token: "--pano-color-heading", bs: "--bs-emphasis-color" },
23
+ { token: "--pano-color-border", bs: "--bs-border-color" },
24
+ { token: "--pano-color-primary", bs: "--bs-primary" },
25
+ { token: "--pano-color-secondary", bs: "--bs-secondary" },
26
+ { token: "--pano-color-success", bs: "--bs-success" },
27
+ { token: "--pano-color-danger", bs: "--bs-danger" },
28
+ { token: "--pano-color-warning", bs: "--bs-warning" },
29
+ { token: "--pano-color-info", bs: "--bs-info" },
30
+ { token: "--pano-color-link", bs: "--bs-link-color" },
31
+ { token: "--pano-color-link-hover", bs: "--bs-link-hover-color" },
32
+ { token: "--pano-color-on-primary", bs: null, sass: "color-contrast($primary)", low: true },
33
+ { token: "--pano-color-on-secondary", bs: null, sass: "color-contrast($secondary)", low: true },
34
+ { token: "--pano-radius", bs: "--bs-border-radius" },
35
+ { token: "--pano-radius-sm", bs: "--bs-border-radius-sm" },
36
+ { token: "--pano-radius-lg", bs: "--bs-border-radius-lg" },
37
+ { token: "--pano-radius-pill", bs: "--bs-border-radius-pill" },
38
+ { token: "--pano-border-width", bs: "--bs-border-width" },
39
+ { token: "--pano-shadow-sm", bs: "--bs-box-shadow-sm" },
40
+ { token: "--pano-shadow", bs: "--bs-box-shadow" },
41
+ { token: "--pano-shadow-lg", bs: "--bs-box-shadow-lg" },
42
+ { token: "--pano-font-body", bs: "--bs-body-font-family" },
43
+ { token: "--pano-font-heading", bs: null, sass: "if($headings-font-family, $headings-font-family, inherit)" },
44
+ { token: "--pano-font-mono", bs: "--bs-font-monospace" },
45
+ { token: "--pano-font-size", bs: "--bs-body-font-size" },
46
+ { token: "--pano-font-weight", bs: "--bs-body-font-weight" },
47
+ { token: "--pano-font-weight-bold", bs: null, sass: "$font-weight-bold" },
48
+ { token: "--pano-line-height", bs: "--bs-body-line-height" },
49
+ { token: "--pano-space", bs: null, sass: "$spacer" },
50
+ ];
51
+
52
+ /** The six palettes, in output order. `light` also owns `:root`. */
53
+ export const PALETTES = ["light", "dark", "copper", "emerald", "midnight", "crimson"];
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.