@vectoriox/iox-ui 5.173.0 → 5.175.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.
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +15 -3
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +870 -77
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +171 -143
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/generation-core/index.d.ts +306 -17
- package/harness-core/index.d.ts +86 -82
- package/package.json +1 -1
- package/src/design-core/header-behaviour.ts +14 -4
- package/src/generation-core/audit-site.ts +71 -2
- package/src/generation-core/audit-words.ts +20 -0
- package/src/generation-core/check-layout.ts +1 -1
- package/src/generation-core/check-list.ts +8 -0
- package/src/generation-core/compose-site.ts +50 -9
- package/src/generation-core/fallback-memory.ts +1 -1
- package/src/generation-core/import-plan.ts +400 -0
- package/src/generation-core/layout-fingerprint.ts +10 -2
- package/src/generation-core/list-words.ts +6 -0
- package/src/generation-core/patterns.ts +3 -1
- package/src/generation-core/plan-wire.ts +37 -8
- package/src/generation-core/plan-words.ts +7 -3
- package/src/generation-core/popup-plan.ts +232 -0
- package/src/generation-core/public-api.ts +2 -0
- package/src/generation-core/showcase.ts +17 -2
- package/src/generation-core/site-build-run.ts +3 -0
- package/src/generation-core/site-plan.model.ts +35 -3
- package/src/generation-core/site-spec.generated.ts +74 -6
- package/src/generation-core/validate-site-plan.ts +46 -6
- package/src/harness-core/harness-spec.generated.ts +1 -0
- package/src/harness-core/site-analysis.ts +34 -9
- package/styles/iox-design.css +4 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MOOD_IDS, MOOD_LABELS, STYLE_PRESETS, SPEC_FLAVORS, flavorPackById, parseFontFamilies, SPEC_AXES, motionWordTier, MotionWordTier, parseHexColor, rgbToOklab, presetChoices, toHexColor, stylePresetById, resolveTokenValues, designTokenRows, wcagContrastRatio, auditDesignContrast, PRELOADER_LEVELS, SCRUB_LEVELS } from '@vectoriox/iox-ui/design-core';
|
|
2
|
-
import { shapeKeys, requiredShapeKeys, PathIssueCollector, isPlainObject, pathAt, FACT_KEYS, jsonText, jsonOneOf, jsonListOf, jsonShapedObject, describeShapeKey, SPEC_SITE_LIBRARY, patternById, SITE_FACT_LABELS,
|
|
2
|
+
import { HEBREW_PREFIXES, shapeKeys, requiredShapeKeys, PathIssueCollector, isPlainObject, pathAt, FACT_KEYS, jsonText, jsonOneOf, jsonListOf, jsonShapedObject, describeShapeKey, SPEC_SITE_LIBRARY, patternById, SITE_FACT_LABELS, SITE_TEMPLATES, STUDIO_TEMPLATE, jsonInteger } from '@vectoriox/iox-ui/generation-core';
|
|
3
3
|
|
|
4
4
|
// GENERATED from iox-ai-guidance flavor-spec.v1.json — do not edit; re-run scripts/gen-flavor-spec.mjs
|
|
5
5
|
// (npm run gen:flavor-spec). The JSON is itself generated by iox-ai-guidance
|
|
@@ -4710,6 +4710,7 @@ const SPEC_ANALYSIS_SHAPE = {
|
|
|
4710
4710
|
"business": "business",
|
|
4711
4711
|
"needs": "need[] — what the site needs: the owner's (from: you) and the type's (from: type)",
|
|
4712
4712
|
"facts": "{ [fact]: factRead } — site.facts keys, only what the prompt states; every quote is words of the prompt",
|
|
4713
|
+
"statedFacts?": "{ [statedFact]: factRead } — harness.statedFacts keys (news), only what the prompt states; never a placeholder and never in missingFacts. On the wire a stated fact is a fact line of the facts list",
|
|
4713
4714
|
"missingFacts": "string[] — site.facts keys the prompt does not state",
|
|
4714
4715
|
"voice": "voice",
|
|
4715
4716
|
"moods": "string[] — ≤ 3 moods",
|
|
@@ -5415,6 +5416,139 @@ function needsSell(needs) {
|
|
|
5415
5416
|
return needs.some(n => n.id === PRODUCTS_NEED);
|
|
5416
5417
|
}
|
|
5417
5418
|
|
|
5419
|
+
/**
|
|
5420
|
+
* What Start reads from the owner's words BEFORE any model runs (AI plan rev 3 §3d step 0, N-D3): the kind of
|
|
5421
|
+
* business by the contract's own keywords (`BusinessType.match` — "the no-model fallback"), and the addresses
|
|
5422
|
+
* typed into the box (each becomes a "style only" reference chip, R1). Pure; the template path uses it today and
|
|
5423
|
+
* the reading stage (M1-1) checks the model against the same match.
|
|
5424
|
+
*/
|
|
5425
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
5426
|
+
const KEYWORD_RES = new Map();
|
|
5427
|
+
/** A keyword matches at the START of a word (so a stem — "סדנ", "consult" — matches its forms). */
|
|
5428
|
+
function keywordRe(keyword) {
|
|
5429
|
+
let re = KEYWORD_RES.get(keyword);
|
|
5430
|
+
if (!re) {
|
|
5431
|
+
re = new RegExp(`(^|[^\\p{L}\\p{N}])${HEBREW_PREFIXES}${escapeRe(keyword.toLocaleLowerCase())}`, 'u');
|
|
5432
|
+
KEYWORD_RES.set(keyword, re);
|
|
5433
|
+
}
|
|
5434
|
+
return re;
|
|
5435
|
+
}
|
|
5436
|
+
/** The keywords that appear in the words, in the list's order — each at the START of a word, Hebrew prefixes allowed (the
|
|
5437
|
+
* ONE word rule of the no-model reading: the type match and the film's raise / lower words, award §0b.7). */
|
|
5438
|
+
function keywordsIn(text, keywords) {
|
|
5439
|
+
const words = (text ?? '').toLocaleLowerCase();
|
|
5440
|
+
return words.trim() ? keywords.filter(k => keywordRe(k).test(words)) : [];
|
|
5441
|
+
}
|
|
5442
|
+
/** The kind of business the words name, best first; empty when none of the keywords appears. Ties keep the board's order. */
|
|
5443
|
+
function matchBusinessTypes(text, types = BUSINESS_TYPES) {
|
|
5444
|
+
const words = (text ?? '').toLocaleLowerCase();
|
|
5445
|
+
if (!words.trim())
|
|
5446
|
+
return [];
|
|
5447
|
+
return types
|
|
5448
|
+
.map((type, order) => {
|
|
5449
|
+
const keywords = keywordsIn(words, type.match);
|
|
5450
|
+
return { id: type.id, keywords, score: keywords.reduce((n, k) => n + k.length, 0), order };
|
|
5451
|
+
})
|
|
5452
|
+
.filter(m => m.score > 0)
|
|
5453
|
+
.sort((a, b) => b.score - a.score || a.order - b.order)
|
|
5454
|
+
.map(({ order, ...m }) => m);
|
|
5455
|
+
}
|
|
5456
|
+
/** The single best kind of business the words name, or null. */
|
|
5457
|
+
function matchBusinessType(text, types = BUSINESS_TYPES) {
|
|
5458
|
+
return matchBusinessTypes(text, types)[0]?.id ?? null;
|
|
5459
|
+
}
|
|
5460
|
+
// A port stays with its host ("staging.example:8080"): dropping it would read a DIFFERENT site.
|
|
5461
|
+
const ADDRESS_RE = /(?:https?:\/\/)?(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}(?::\d{1,5})?(?:\/[^\s<>"']*)?/gi;
|
|
5462
|
+
const TRAILING = /[.,;:!?)\]}'"״׳]+$/;
|
|
5463
|
+
/** An address as a chip shows it: no scheme, no `www.`, no trailing punctuation or slash, lower-case host. */
|
|
5464
|
+
function normalizeAddress(raw) {
|
|
5465
|
+
const bare = raw.replace(TRAILING, '').replace(/^https?:\/\//i, '').replace(/^www\./i, '').replace(/\/+$/, '');
|
|
5466
|
+
const slash = bare.indexOf('/');
|
|
5467
|
+
return slash < 0 ? bare.toLowerCase() : bare.slice(0, slash).toLowerCase() + bare.slice(slash);
|
|
5468
|
+
}
|
|
5469
|
+
/** Every website address typed or pasted in the words (an http(s) address or a bare domain), once each, in
|
|
5470
|
+
* order. An email address is not a website. */
|
|
5471
|
+
function addressesIn(text) {
|
|
5472
|
+
const found = [];
|
|
5473
|
+
for (const m of (text ?? '').matchAll(ADDRESS_RE)) {
|
|
5474
|
+
const before = m.index ? text[m.index - 1] : '';
|
|
5475
|
+
if (before === '@' || /[\p{L}\p{N}_-]/u.test(before))
|
|
5476
|
+
continue;
|
|
5477
|
+
const address = normalizeAddress(m[0]);
|
|
5478
|
+
if (address && !found.includes(address))
|
|
5479
|
+
found.push(address);
|
|
5480
|
+
}
|
|
5481
|
+
return found;
|
|
5482
|
+
}
|
|
5483
|
+
/** The words without one address (removing its chip): every spelling of it, and the space it leaves. */
|
|
5484
|
+
function withoutAddress(text, address) {
|
|
5485
|
+
const out = (text ?? '').replace(ADDRESS_RE, (m, offset, whole) => {
|
|
5486
|
+
const before = offset ? whole[offset - 1] : '';
|
|
5487
|
+
if (before === '@' || /[\p{L}\p{N}_-]/u.test(before))
|
|
5488
|
+
return m;
|
|
5489
|
+
return normalizeAddress(m) === address ? '' : m;
|
|
5490
|
+
});
|
|
5491
|
+
return out.replace(/[ \t]{2,}/g, ' ').replace(/ +([.,;:!?])/g, '$1').trim();
|
|
5492
|
+
}
|
|
5493
|
+
|
|
5494
|
+
/**
|
|
5495
|
+
* A popup, SUGGESTED (popups-plan.md §10, PU-D11 / PU-D12). The harness's answer, never the model's:
|
|
5496
|
+
* - the STANCE — `offer` (hospitality, food, shops, events, studios), `ifAsked` (trust and care types), `never` — the
|
|
5497
|
+
* type's default (contract `POPUP_STANCES`, on each type as `popup`) moved ONE step by the owner's words, as for the film;
|
|
5498
|
+
* an owner who says "no popup" (`refusedBy`) makes it `never` whatever else they wrote.
|
|
5499
|
+
* - the Plan step's two LINES — "Show your news in a popup" exists only when the owner STATED news (`news`, a stated fact:
|
|
5500
|
+
* never inferred, never a placeholder) and the stance is offer, and starts ticked; "Invite visitors to your newsletter
|
|
5501
|
+
* in a popup" is offered when the site has a newsletter form and the stance is not never, and is never ticked by itself.
|
|
5502
|
+
* A generated site gets a popup only from one of these two lines. Pure: no transport, no clock.
|
|
5503
|
+
*/
|
|
5504
|
+
/** How a popup is suggested. */
|
|
5505
|
+
var PopupStance;
|
|
5506
|
+
(function (PopupStance) {
|
|
5507
|
+
PopupStance["Offer"] = "offer";
|
|
5508
|
+
PopupStance["IfAsked"] = "ifAsked";
|
|
5509
|
+
PopupStance["Never"] = "never";
|
|
5510
|
+
})(PopupStance || (PopupStance = {}));
|
|
5511
|
+
/** The words that move the stance (contract `POPUP_STANCES`). */
|
|
5512
|
+
const POPUP_WORDS = {
|
|
5513
|
+
raise: SPEC_POPUP_STANCES.raise,
|
|
5514
|
+
lower: SPEC_POPUP_STANCES.lower,
|
|
5515
|
+
refusedBy: SPEC_POPUP_STANCES.refusedBy,
|
|
5516
|
+
};
|
|
5517
|
+
/** The stated facts, keyed (`news`). Kept apart from site.facts on purpose: a site.facts key is a placeholder. */
|
|
5518
|
+
const STATED_FACTS = SPEC_STATED_FACTS;
|
|
5519
|
+
const STATED_FACT_KEYS = Object.keys(SPEC_STATED_FACTS);
|
|
5520
|
+
/** What the owner's words say about a popup (the ONE no-model word rule, `keywordsIn`). A refusal ("no popup") holds a
|
|
5521
|
+
* raise word ("popup"); it is read first and the raise words it holds do not count. */
|
|
5522
|
+
function popupWordsIn(prompt) {
|
|
5523
|
+
const text = prompt ?? '';
|
|
5524
|
+
const refused = keywordsIn(text, POPUP_WORDS.refusedBy);
|
|
5525
|
+
const raised = refused.length ? [] : keywordsIn(text, POPUP_WORDS.raise);
|
|
5526
|
+
return { raised, lowered: keywordsIn(text, POPUP_WORDS.lower), refused };
|
|
5527
|
+
}
|
|
5528
|
+
/** The stance for a business and the owner's words: the type's default moved ONE step (raise ifAsked → offer, lower
|
|
5529
|
+
* offer → ifAsked, both cancel); `never` moves for no word; a refusal is never; an unknown type is never. */
|
|
5530
|
+
function popupStanceFor(type, words) {
|
|
5531
|
+
const base = (type?.popup ?? PopupStance.Never);
|
|
5532
|
+
if (base === PopupStance.Never || words.refused.length)
|
|
5533
|
+
return PopupStance.Never;
|
|
5534
|
+
const raise = words.raised.length > 0, lower = words.lowered.length > 0;
|
|
5535
|
+
if (raise && !lower)
|
|
5536
|
+
return PopupStance.Offer;
|
|
5537
|
+
if (lower && !raise)
|
|
5538
|
+
return PopupStance.IfAsked;
|
|
5539
|
+
return base;
|
|
5540
|
+
}
|
|
5541
|
+
const HIDDEN = { shown: false, ticked: false };
|
|
5542
|
+
/** The Plan step's popup lines for a site (PU-D12). */
|
|
5543
|
+
function popupSuggestion(input) {
|
|
5544
|
+
const words = popupWordsIn(input.prompt);
|
|
5545
|
+
const stance = popupStanceFor(businessTypeById(input.businessType), words);
|
|
5546
|
+
const stated = !!(input.news?.value?.trim() && input.news?.quote?.trim());
|
|
5547
|
+
const news = stated && stance === PopupStance.Offer ? { shown: true, ticked: true } : HIDDEN;
|
|
5548
|
+
const newsletter = input.newsletterForm && stance !== PopupStance.Never ? { shown: true, ticked: false } : HIDDEN;
|
|
5549
|
+
return { stance, news, newsletter, words };
|
|
5550
|
+
}
|
|
5551
|
+
|
|
5418
5552
|
/**
|
|
5419
5553
|
* What the reading of a prompt returns (AI plan rev 3 §3d): one of the 30 kinds of business (and the two
|
|
5420
5554
|
* nearest), who it is for, what the site needs, the facts the prompt STATES (each with the words it came from)
|
|
@@ -5542,6 +5676,25 @@ function validateSiteAnalysis(value, ctx) {
|
|
|
5542
5676
|
c.add(AnalysisIssueCode.QuoteNotInPrompt, pathAt(path, 'quote'), 'is not words of the prompt — a fact the prompt does not state is missing, never filled');
|
|
5543
5677
|
found.add(key);
|
|
5544
5678
|
}
|
|
5679
|
+
if (a['statedFacts'] !== undefined) {
|
|
5680
|
+
if (!isPlainObject(a['statedFacts']))
|
|
5681
|
+
c.add(AnalysisIssueCode.Shape, 'statedFacts', 'must be an object');
|
|
5682
|
+
else
|
|
5683
|
+
for (const [key, raw] of Object.entries(a['statedFacts'])) {
|
|
5684
|
+
const path = `statedFacts.${key}`;
|
|
5685
|
+
if (!STATED_FACT_KEYS.includes(key)) {
|
|
5686
|
+
c.add(AnalysisIssueCode.UnknownFact, path, `"${key}" is not a stated fact (${STATED_FACT_KEYS.join(', ')})`);
|
|
5687
|
+
continue;
|
|
5688
|
+
}
|
|
5689
|
+
const fact = c.object(raw, 'factRead', path);
|
|
5690
|
+
if (!fact)
|
|
5691
|
+
continue;
|
|
5692
|
+
c.string(fact, 'value', path);
|
|
5693
|
+
const quote = c.string(fact, 'quote', path);
|
|
5694
|
+
if (quote && !promptWords.includes(normalise(quote)))
|
|
5695
|
+
c.add(AnalysisIssueCode.QuoteNotInPrompt, pathAt(path, 'quote'), 'is not words of the prompt — news the prompt does not state does not exist');
|
|
5696
|
+
}
|
|
5697
|
+
}
|
|
5545
5698
|
c.strings(a, 'missingFacts', '').forEach((key, i) => {
|
|
5546
5699
|
if (!FACT_KEYS.includes(key))
|
|
5547
5700
|
c.add(AnalysisIssueCode.UnknownFact, `missingFacts[${i}]`, `"${key}" is not a fact`);
|
|
@@ -5579,18 +5732,22 @@ const oneOf = jsonOneOf;
|
|
|
5579
5732
|
const listOf = jsonListOf;
|
|
5580
5733
|
/** An object of `shape`: exactly its keys, its required ones required, each described by the table. */
|
|
5581
5734
|
const shaped = (shape, properties) => jsonShapedObject(SHAPE[shape], properties, shape);
|
|
5735
|
+
/** Every fact a line may state: the site's facts, then the stated ones (PU3: `news` — only as stated, never missing). */
|
|
5736
|
+
const WIRE_FACT_KEYS = [...FACT_KEYS, ...STATED_FACT_KEYS];
|
|
5737
|
+
const STATED_KEY = 'statedFacts';
|
|
5582
5738
|
/** A stated fact on the wire: which fact, then the document's `factRead` keys in the table's own words. */
|
|
5583
5739
|
const FACT_LINE_SHAPE = {
|
|
5584
|
-
fact: `${
|
|
5740
|
+
fact: `${WIRE_FACT_KEYS.map(k => `'${k}'`).join(' | ')} — which fact (site.facts), each at most once; `
|
|
5741
|
+
+ STATED_FACT_KEYS.map(k => `'${k}': ${STATED_FACTS[k].how}`).join('; '),
|
|
5585
5742
|
...SHAPE['factRead'],
|
|
5586
5743
|
};
|
|
5587
|
-
/** The analysis as the wire carries it: `facts` a list of fact lines, described in the table's words. */
|
|
5588
|
-
const ANALYSIS_WIRE_SHAPE = {
|
|
5744
|
+
/** The analysis as the wire carries it: `facts` a list of fact lines (the stated facts among them), described in the table's words. */
|
|
5745
|
+
const ANALYSIS_WIRE_SHAPE = Object.fromEntries(Object.entries({
|
|
5589
5746
|
...SHAPE['analysis'],
|
|
5590
5747
|
facts: `factLine[] — ${describeShapeKey(SHAPE['analysis'], 'facts').replace(/^\{ \[fact\]: factRead \} — /, '')}`,
|
|
5591
|
-
};
|
|
5748
|
+
}).filter(([k]) => k.replace(/\?$/, '') !== STATED_KEY));
|
|
5592
5749
|
function siteAnalysisJsonSchema() {
|
|
5593
|
-
const factLine = jsonShapedObject(FACT_LINE_SHAPE, { fact: oneOf(
|
|
5750
|
+
const factLine = jsonShapedObject(FACT_LINE_SHAPE, { fact: oneOf(WIRE_FACT_KEYS), value: text(), quote: text() }, 'factLine');
|
|
5594
5751
|
return jsonShapedObject(ANALYSIS_WIRE_SHAPE, {
|
|
5595
5752
|
businessType: oneOf(BUSINESS_TYPE_IDS),
|
|
5596
5753
|
alternatives: listOf(oneOf(BUSINESS_TYPE_IDS)),
|
|
@@ -5617,6 +5774,7 @@ function analysisFromWire(wire) {
|
|
|
5617
5774
|
if (!Array.isArray(wire['facts']))
|
|
5618
5775
|
return { analysis: wire, issues: [{ code: AnalysisIssueCode.Shape, path: 'facts', message: 'must be a list of { fact, value, quote }' }] };
|
|
5619
5776
|
const facts = {};
|
|
5777
|
+
const stated = {};
|
|
5620
5778
|
const issues = [];
|
|
5621
5779
|
wire['facts'].forEach((line, i) => {
|
|
5622
5780
|
if (!isPlainObject(line) || typeof line['fact'] !== 'string') {
|
|
@@ -5624,16 +5782,19 @@ function analysisFromWire(wire) {
|
|
|
5624
5782
|
return;
|
|
5625
5783
|
}
|
|
5626
5784
|
const { fact, ...read } = line;
|
|
5627
|
-
|
|
5785
|
+
// PU3: a stated fact (news) is the document's `statedFacts`, never a site fact.
|
|
5786
|
+
const into = STATED_FACT_KEYS.includes(fact) ? stated : facts;
|
|
5787
|
+
if (fact in into)
|
|
5628
5788
|
issues.push({ code: AnalysisIssueCode.Duplicate, path: `facts[${i}].fact`, message: `"${fact}" is stated twice` });
|
|
5629
5789
|
else
|
|
5630
|
-
|
|
5790
|
+
into[fact] = read;
|
|
5631
5791
|
});
|
|
5632
|
-
return { analysis: { ...wire, facts }, issues };
|
|
5792
|
+
return { analysis: { ...wire, facts, ...(Object.keys(stated).length ? { [STATED_KEY]: stated } : {}) }, issues };
|
|
5633
5793
|
}
|
|
5634
5794
|
/** The document → the wire (what a model writes). */
|
|
5635
5795
|
function analysisToWire(analysis) {
|
|
5636
|
-
|
|
5796
|
+
const { statedFacts, ...rest } = analysis;
|
|
5797
|
+
return { ...rest, facts: [...Object.entries(analysis.facts), ...Object.entries(statedFacts ?? {})].map(([fact, read]) => ({ fact, ...read })) };
|
|
5637
5798
|
}
|
|
5638
5799
|
|
|
5639
5800
|
var PresetFit;
|
|
@@ -6004,81 +6165,6 @@ function analysisPromptContext(analysis, opts = {}) {
|
|
|
6004
6165
|
};
|
|
6005
6166
|
}
|
|
6006
6167
|
|
|
6007
|
-
/**
|
|
6008
|
-
* What Start reads from the owner's words BEFORE any model runs (AI plan rev 3 §3d step 0, N-D3): the kind of
|
|
6009
|
-
* business by the contract's own keywords (`BusinessType.match` — "the no-model fallback"), and the addresses
|
|
6010
|
-
* typed into the box (each becomes a "style only" reference chip, R1). Pure; the template path uses it today and
|
|
6011
|
-
* the reading stage (M1-1) checks the model against the same match.
|
|
6012
|
-
*/
|
|
6013
|
-
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
6014
|
-
const KEYWORD_RES = new Map();
|
|
6015
|
-
/** A keyword matches at the START of a word (so a stem — "סדנ", "consult" — matches its forms). */
|
|
6016
|
-
function keywordRe(keyword) {
|
|
6017
|
-
let re = KEYWORD_RES.get(keyword);
|
|
6018
|
-
if (!re) {
|
|
6019
|
-
re = new RegExp(`(^|[^\\p{L}\\p{N}])${HEBREW_PREFIXES}${escapeRe(keyword.toLocaleLowerCase())}`, 'u');
|
|
6020
|
-
KEYWORD_RES.set(keyword, re);
|
|
6021
|
-
}
|
|
6022
|
-
return re;
|
|
6023
|
-
}
|
|
6024
|
-
/** The keywords that appear in the words, in the list's order — each at the START of a word, Hebrew prefixes allowed (the
|
|
6025
|
-
* ONE word rule of the no-model reading: the type match and the film's raise / lower words, award §0b.7). */
|
|
6026
|
-
function keywordsIn(text, keywords) {
|
|
6027
|
-
const words = (text ?? '').toLocaleLowerCase();
|
|
6028
|
-
return words.trim() ? keywords.filter(k => keywordRe(k).test(words)) : [];
|
|
6029
|
-
}
|
|
6030
|
-
/** The kind of business the words name, best first; empty when none of the keywords appears. Ties keep the board's order. */
|
|
6031
|
-
function matchBusinessTypes(text, types = BUSINESS_TYPES) {
|
|
6032
|
-
const words = (text ?? '').toLocaleLowerCase();
|
|
6033
|
-
if (!words.trim())
|
|
6034
|
-
return [];
|
|
6035
|
-
return types
|
|
6036
|
-
.map((type, order) => {
|
|
6037
|
-
const keywords = keywordsIn(words, type.match);
|
|
6038
|
-
return { id: type.id, keywords, score: keywords.reduce((n, k) => n + k.length, 0), order };
|
|
6039
|
-
})
|
|
6040
|
-
.filter(m => m.score > 0)
|
|
6041
|
-
.sort((a, b) => b.score - a.score || a.order - b.order)
|
|
6042
|
-
.map(({ order, ...m }) => m);
|
|
6043
|
-
}
|
|
6044
|
-
/** The single best kind of business the words name, or null. */
|
|
6045
|
-
function matchBusinessType(text, types = BUSINESS_TYPES) {
|
|
6046
|
-
return matchBusinessTypes(text, types)[0]?.id ?? null;
|
|
6047
|
-
}
|
|
6048
|
-
// A port stays with its host ("staging.example:8080"): dropping it would read a DIFFERENT site.
|
|
6049
|
-
const ADDRESS_RE = /(?:https?:\/\/)?(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}(?::\d{1,5})?(?:\/[^\s<>"']*)?/gi;
|
|
6050
|
-
const TRAILING = /[.,;:!?)\]}'"״׳]+$/;
|
|
6051
|
-
/** An address as a chip shows it: no scheme, no `www.`, no trailing punctuation or slash, lower-case host. */
|
|
6052
|
-
function normalizeAddress(raw) {
|
|
6053
|
-
const bare = raw.replace(TRAILING, '').replace(/^https?:\/\//i, '').replace(/^www\./i, '').replace(/\/+$/, '');
|
|
6054
|
-
const slash = bare.indexOf('/');
|
|
6055
|
-
return slash < 0 ? bare.toLowerCase() : bare.slice(0, slash).toLowerCase() + bare.slice(slash);
|
|
6056
|
-
}
|
|
6057
|
-
/** Every website address typed or pasted in the words (an http(s) address or a bare domain), once each, in
|
|
6058
|
-
* order. An email address is not a website. */
|
|
6059
|
-
function addressesIn(text) {
|
|
6060
|
-
const found = [];
|
|
6061
|
-
for (const m of (text ?? '').matchAll(ADDRESS_RE)) {
|
|
6062
|
-
const before = m.index ? text[m.index - 1] : '';
|
|
6063
|
-
if (before === '@' || /[\p{L}\p{N}_-]/u.test(before))
|
|
6064
|
-
continue;
|
|
6065
|
-
const address = normalizeAddress(m[0]);
|
|
6066
|
-
if (address && !found.includes(address))
|
|
6067
|
-
found.push(address);
|
|
6068
|
-
}
|
|
6069
|
-
return found;
|
|
6070
|
-
}
|
|
6071
|
-
/** The words without one address (removing its chip): every spelling of it, and the space it leaves. */
|
|
6072
|
-
function withoutAddress(text, address) {
|
|
6073
|
-
const out = (text ?? '').replace(ADDRESS_RE, (m, offset, whole) => {
|
|
6074
|
-
const before = offset ? whole[offset - 1] : '';
|
|
6075
|
-
if (before === '@' || /[\p{L}\p{N}_-]/u.test(before))
|
|
6076
|
-
return m;
|
|
6077
|
-
return normalizeAddress(m) === address ? '' : m;
|
|
6078
|
-
});
|
|
6079
|
-
return out.replace(/[ \t]{2,}/g, ' ').replace(/ +([.,;:!?])/g, '$1').trim();
|
|
6080
|
-
}
|
|
6081
|
-
|
|
6082
6168
|
/**
|
|
6083
6169
|
* Which template the template path (and the plan stage) builds a kind of business from (AI plan rev 3 §3d,
|
|
6084
6170
|
* N-D3): its structure's template when that one has shipped, else Studio — said, never silent. No type → Studio.
|
|
@@ -6729,64 +6815,6 @@ function filmIdeaFor(input) {
|
|
|
6729
6815
|
return none(skipped[skipped.length - 1]?.reason ?? FilmIdeaReason.Never, skipped);
|
|
6730
6816
|
}
|
|
6731
6817
|
|
|
6732
|
-
/**
|
|
6733
|
-
* A popup, SUGGESTED (popups-plan.md §10, PU-D11 / PU-D12). The harness's answer, never the model's:
|
|
6734
|
-
* - the STANCE — `offer` (hospitality, food, shops, events, studios), `ifAsked` (trust and care types), `never` — the
|
|
6735
|
-
* type's default (contract `POPUP_STANCES`, on each type as `popup`) moved ONE step by the owner's words, as for the film;
|
|
6736
|
-
* an owner who says "no popup" (`refusedBy`) makes it `never` whatever else they wrote.
|
|
6737
|
-
* - the Plan step's two LINES — "Show your news in a popup" exists only when the owner STATED news (`news`, a stated fact:
|
|
6738
|
-
* never inferred, never a placeholder) and the stance is offer, and starts ticked; "Invite visitors to your newsletter
|
|
6739
|
-
* in a popup" is offered when the site has a newsletter form and the stance is not never, and is never ticked by itself.
|
|
6740
|
-
* A generated site gets a popup only from one of these two lines. Pure: no transport, no clock.
|
|
6741
|
-
*/
|
|
6742
|
-
/** How a popup is suggested. */
|
|
6743
|
-
var PopupStance;
|
|
6744
|
-
(function (PopupStance) {
|
|
6745
|
-
PopupStance["Offer"] = "offer";
|
|
6746
|
-
PopupStance["IfAsked"] = "ifAsked";
|
|
6747
|
-
PopupStance["Never"] = "never";
|
|
6748
|
-
})(PopupStance || (PopupStance = {}));
|
|
6749
|
-
/** The words that move the stance (contract `POPUP_STANCES`). */
|
|
6750
|
-
const POPUP_WORDS = {
|
|
6751
|
-
raise: SPEC_POPUP_STANCES.raise,
|
|
6752
|
-
lower: SPEC_POPUP_STANCES.lower,
|
|
6753
|
-
refusedBy: SPEC_POPUP_STANCES.refusedBy,
|
|
6754
|
-
};
|
|
6755
|
-
/** The stated facts, keyed (`news`). Kept apart from site.facts on purpose: a site.facts key is a placeholder. */
|
|
6756
|
-
const STATED_FACTS = SPEC_STATED_FACTS;
|
|
6757
|
-
const STATED_FACT_KEYS = Object.keys(SPEC_STATED_FACTS);
|
|
6758
|
-
/** What the owner's words say about a popup (the ONE no-model word rule, `keywordsIn`). A refusal ("no popup") holds a
|
|
6759
|
-
* raise word ("popup"); it is read first and the raise words it holds do not count. */
|
|
6760
|
-
function popupWordsIn(prompt) {
|
|
6761
|
-
const text = prompt ?? '';
|
|
6762
|
-
const refused = keywordsIn(text, POPUP_WORDS.refusedBy);
|
|
6763
|
-
const raised = refused.length ? [] : keywordsIn(text, POPUP_WORDS.raise);
|
|
6764
|
-
return { raised, lowered: keywordsIn(text, POPUP_WORDS.lower), refused };
|
|
6765
|
-
}
|
|
6766
|
-
/** The stance for a business and the owner's words: the type's default moved ONE step (raise ifAsked → offer, lower
|
|
6767
|
-
* offer → ifAsked, both cancel); `never` moves for no word; a refusal is never; an unknown type is never. */
|
|
6768
|
-
function popupStanceFor(type, words) {
|
|
6769
|
-
const base = (type?.popup ?? PopupStance.Never);
|
|
6770
|
-
if (base === PopupStance.Never || words.refused.length)
|
|
6771
|
-
return PopupStance.Never;
|
|
6772
|
-
const raise = words.raised.length > 0, lower = words.lowered.length > 0;
|
|
6773
|
-
if (raise && !lower)
|
|
6774
|
-
return PopupStance.Offer;
|
|
6775
|
-
if (lower && !raise)
|
|
6776
|
-
return PopupStance.IfAsked;
|
|
6777
|
-
return base;
|
|
6778
|
-
}
|
|
6779
|
-
const HIDDEN = { shown: false, ticked: false };
|
|
6780
|
-
/** The Plan step's popup lines for a site (PU-D12). */
|
|
6781
|
-
function popupSuggestion(input) {
|
|
6782
|
-
const words = popupWordsIn(input.prompt);
|
|
6783
|
-
const stance = popupStanceFor(businessTypeById(input.businessType), words);
|
|
6784
|
-
const stated = !!(input.news?.value?.trim() && input.news?.quote?.trim());
|
|
6785
|
-
const news = stated && stance === PopupStance.Offer ? { shown: true, ticked: true } : HIDDEN;
|
|
6786
|
-
const newsletter = input.newsletterForm && stance !== PopupStance.Never ? { shown: true, ticked: false } : HIDDEN;
|
|
6787
|
-
return { stance, news, newsletter, words };
|
|
6788
|
-
}
|
|
6789
|
-
|
|
6790
6818
|
/**
|
|
6791
6819
|
* @vectoriox/iox-ui/harness-core — the design HARNESS (AI plan rev 3 §3f, decision N18), FRAMEWORK-FREE: the 30
|
|
6792
6820
|
* kinds of business and their rules (generated 1:1 from iox-ai-guidance `flavor-spec.v1.json` `harness`), the
|